static MonoMethod *compare_exchange_method;
int obj_null_branch, true_locktaken_branch = 0, syncp_null_branch, has_owner_branch, other_owner_branch, tid_branch, thin_hash_branch;
int tid_loc, syncp_loc, owner_loc;
- int thread_tls_offset;
gboolean is_v4 = mono_method_signature (monitor_enter_method)->param_count == 2;
int fast_path_idx = is_v4 ? FASTPATH_ENTERV4 : FASTPATH_ENTER;
WrapperInfo *info;
/* The !is_v4 version is not used/tested */
g_assert (is_v4);
- thread_tls_offset = mono_thread_get_tls_offset ();
- if (thread_tls_offset == -1)
- return NULL;
-
if (monitor_il_fastpaths [fast_path_idx])
return monitor_il_fastpaths [fast_path_idx];
+ if (!mono_get_runtime_callbacks ()->tls_key_supported (TLS_KEY_THREAD))
+ return NULL;
+
if (!compare_exchange_method) {
MonoMethodDesc *desc;
MonoClass *class;
MonoMethodBuilder *mb;
MonoMethod *res;
int obj_null_branch, has_waiting_branch, has_syncp_branch, owned_branch, nested_branch, thin_hash_branch;
- int thread_tls_offset;
int syncp_loc;
WrapperInfo *info;
- thread_tls_offset = mono_thread_get_tls_offset ();
- if (thread_tls_offset == -1)
- return NULL;
-
if (monitor_il_fastpaths [FASTPATH_EXIT])
return monitor_il_fastpaths [FASTPATH_EXIT];
+ if (!mono_get_runtime_callbacks ()->tls_key_supported (TLS_KEY_THREAD))
+ return NULL;
+
mb = mono_mb_new (mono_defaults.monitor_class, "FastMonitorExit", MONO_WRAPPER_UNKNOWN);
mb->method->slot = -1;
void (*set_cast_details) (MonoClass *from, MonoClass *to);
void (*debug_log) (int level, MonoString *category, MonoString *message);
gboolean (*debug_log_is_enabled) (void);
+ gboolean (*tls_key_supported) (MonoTlsKey key);
} MonoRuntimeCallbacks;
typedef gboolean (*MonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data);
return mini_get_tls_offset (key) != -1;
}
+static gboolean
+mini_tls_key_supported (MonoTlsKey key)
+{
+ if (!MONO_ARCH_HAVE_TLS_GET)
+ return FALSE;
+
+ return mini_get_tls_offset (key) != -1;
+}
+
MonoInst*
mono_create_tls_get (MonoCompile *cfg, MonoTlsKey key)
{
callbacks.set_cast_details = mono_set_cast_details;
callbacks.debug_log = mono_debugger_agent_debug_log;
callbacks.debug_log_is_enabled = mono_debugger_agent_debug_log_is_enabled;
+ callbacks.tls_key_supported = mini_tls_key_supported;
if (mono_use_imt) {
callbacks.get_vtable_trampoline = mini_get_vtable_trampoline;