- if (supported) {
- if (cfg->compile_aot) {
- code = emit_load_aotconst (NULL, code, cfg, NULL, X86_ECX, MONO_PATCH_INFO_TLS_OFFSET, GINT_TO_POINTER (TLS_KEY_JIT_TLS));
-
- code = emit_tls_get_reg (code, X86_ECX, X86_ECX);
- } else {
- code = mono_x86_emit_tls_get (code, X86_ECX, mono_get_jit_tls_offset ());
- }
-
- /* we load the value in a separate instruction: this mechanism may be
- * used later as a safer way to do thread interruption
- */
- x86_mov_reg_membase (code, X86_ECX, X86_ECX, MONO_STRUCT_OFFSET (MonoJitTlsData, restore_stack_prot), 4);
- x86_alu_reg_imm (code, X86_CMP, X86_ECX, 0);
- patch = code;
- x86_branch8 (code, X86_CC_Z, 0, FALSE);
- /* note that the call trampoline will preserve eax/edx */
- x86_call_reg (code, X86_ECX);
- x86_patch (patch, code);
+ if (!cfg->compile_aot && mono_arch_have_fast_tls () && mono_tls_get_tls_offset (TLS_KEY_JIT_TLS) != -1) {
+ code = mono_x86_emit_tls_get (code, X86_ECX, mono_tls_get_tls_offset (TLS_KEY_JIT_TLS));