[runtime] Refactor and unify tls access
[mono.git] / mono / mini / mini-x86.c
index 288af652434bf9ffc25e4ad0893d5087409de286..d1245cbee2e8492042c627df5b451c4cfcab0459 100644 (file)
@@ -2380,21 +2380,6 @@ emit_tls_set_reg (guint8* code, int sreg, int offset_reg)
        return code;
 }
  
- /*
- * mono_arch_translate_tls_offset:
- *
- *   Translate the TLS offset OFFSET computed by MONO_THREAD_VAR_OFFSET () into a format usable by OP_TLS_GET_REG/OP_TLS_SET_REG.
- */
-int
-mono_arch_translate_tls_offset (int offset)
-{
-#ifdef __APPLE__
-       return tls_gs_offset + (offset * 4);
-#else
-       return offset;
-#endif
-}
-
 /*
  * emit_setup_lmf:
  *
@@ -4872,6 +4857,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_XZERO:
                        x86_sse_alu_pd_reg_reg (code, X86_SSE_PXOR, ins->dreg, ins->dreg);
                        break;
+               case OP_XONES:
+                       x86_sse_alu_pd_reg_reg (code, X86_SSE_PCMPEQB, ins->dreg, ins->dreg);
+                       break;
 
                case OP_FCONV_TO_R8_X:
                        x86_fst_membase (code, ins->backend.spill_var->inst_basereg, ins->backend.spill_var->inst_offset, TRUE, TRUE);
@@ -5325,17 +5313,10 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        if (method->save_lmf) {
                gint32 lmf_offset = cfg->lmf_var->inst_offset;
                guint8 *patch;
-               gboolean supported = FALSE;
-
-               if (cfg->compile_aot) {
-#if defined(MONO_HAVE_FAST_TLS)
-                       supported = TRUE;
-#endif
-               } else if (mono_get_jit_tls_offset () != -1) {
-                       supported = TRUE;
-               }
 
                /* check if we need to restore protection of the stack after a stack overflow */
+               /* FIXME */
+#if 0
                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));
@@ -5358,6 +5339,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
                } else {
                        /* FIXME: maybe save the jit tls in the prolog */
                }
+#endif
 
                /* restore caller saved regs */
                if (cfg->used_int_regs & (1 << X86_EBX)) {
@@ -5613,7 +5595,7 @@ imt_branch_distance (MonoIMTCheckItem **imt_entries, int start, int target)
  * LOCKING: called with the domain lock held
  */
 gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
        gpointer fail_tramp)
 {
        int i;
@@ -5645,7 +5627,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                size += item->chunk_size;
        }
        if (fail_tramp)
-               code = mono_method_alloc_generic_virtual_thunk (domain, size);
+               code = mono_method_alloc_generic_virtual_trampoline (domain, size);
        else
                code = mono_domain_code_reserve (domain, size);
        start = code;
@@ -5715,7 +5697,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        }
 
        if (!fail_tramp)
-               mono_stats.imt_thunks_size += code - start;
+               mono_stats.imt_trampolines_size += code - start;
        g_assert (code - start <= size);
 
 #if DEBUG_IMT
@@ -5730,7 +5712,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                if (vtable)
                        buff = g_strdup_printf ("imt_%s_%s_entries_%d", vtable->klass->name_space, vtable->klass->name, count);
                else
-                       buff = g_strdup_printf ("imt_thunk_entries_%d", count);
+                       buff = g_strdup_printf ("imt_trampoline_entries_%d", count);
                mono_emit_jit_tramp (start, code - start, buff);
                g_free (buff);
        }