Initialize LLVM's ARM target when compiling for it.
[mono.git] / mono / mini / mini-amd64.c
index 7785ba034543d734ecf0a947ca1edc0f455bb220..f4945b9459f1c78a2db5ee1fcdbcc8bbb693437a 100644 (file)
@@ -171,36 +171,11 @@ mono_arch_xregname (int reg)
                return "unknown";
 }
 
-G_GNUC_UNUSED static void
-break_count (void)
-{
-}
-
-G_GNUC_UNUSED static gboolean
-debug_count (void)
-{
-       static int count = 0;
-       count ++;
-
-       if (!getenv ("COUNT"))
-               return TRUE;
-
-       if (count == atoi (getenv ("COUNT"))) {
-               break_count ();
-       }
-
-       if (count > atoi (getenv ("COUNT"))) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 static gboolean
 debug_omit_fp (void)
 {
 #if 0
-       return debug_count ();
+       return mono_debug_count ();
 #else
        return TRUE;
 #endif
@@ -1202,7 +1177,7 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign
  * Returns the size of the argument area on the stack.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k;
        CallInfo *cinfo = get_call_info (NULL, NULL, csig);
@@ -1345,7 +1320,7 @@ mono_arch_cleanup (void)
  * This function returns the optimizations supported on this cpu.
  */
 guint32
-mono_arch_cpu_optimizazions (guint32 *exclude_mask)
+mono_arch_cpu_optimizations (guint32 *exclude_mask)
 {
        int eax, ebx, ecx, edx;
        guint32 opts = 0;
@@ -1784,7 +1759,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        } else {
                if (cfg->arch.omit_fp)
                        cfg->arch.reg_save_area_offset = offset;
-               /* Reserve space for caller saved registers */
+               /* Reserve space for callee saved registers */
                for (i = 0; i < AMD64_NREG; ++i)
                        if (AMD64_IS_CALLEE_SAVED_REG (i) && (cfg->used_int_regs & (1 << i))) {
                                offset += sizeof(mgreg_t);
@@ -3613,11 +3588,12 @@ mono_amd64_have_tls_get (void)
 #ifdef __APPLE__
        static gboolean have_tls_get = FALSE;
        static gboolean inited = FALSE;
+       guint8 *ins;
 
        if (inited)
                return have_tls_get;
 
-       guint8 *ins = (guint8*)pthread_getspecific;
+       ins = (guint8*)pthread_getspecific;
 
        /*
         * We're looking for these two instructions:
@@ -7006,61 +6982,6 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                }
        }
 
-       /* Might need to attach the thread to the JIT  or change the domain for the callback */
-       if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) {
-               guint64 domain = (guint64)cfg->domain;
-
-               args_clobbered = TRUE;
-
-               /* 
-                * The call might clobber argument registers, but they are already
-                * saved to the stack/global regs.
-                */
-               if (appdomain_tls_offset != -1 && lmf_tls_offset != -1) {
-                       guint8 *buf, *no_domain_branch;
-
-                       code = mono_amd64_emit_tls_get (code, AMD64_RAX, appdomain_tls_offset);
-                       if (cfg->compile_aot) {
-                               /* AOT code is only used in the root domain */
-                               amd64_mov_reg_imm (code, AMD64_ARG_REG1, 0);
-                       } else {
-                               if ((domain >> 32) == 0)
-                                       amd64_mov_reg_imm_size (code, AMD64_ARG_REG1, domain, 4);
-                               else
-                                       amd64_mov_reg_imm_size (code, AMD64_ARG_REG1, domain, 8);
-                       }
-                       amd64_alu_reg_reg (code, X86_CMP, AMD64_RAX, AMD64_ARG_REG1);
-                       no_domain_branch = code;
-                       x86_branch8 (code, X86_CC_NE, 0, 0);
-                       code = mono_amd64_emit_tls_get ( code, AMD64_RAX, lmf_addr_tls_offset);
-                       amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
-                       buf = code;
-                       x86_branch8 (code, X86_CC_NE, 0, 0);
-                       amd64_patch (no_domain_branch, code);
-                       code = emit_call (cfg, code, MONO_PATCH_INFO_INTERNAL_METHOD, 
-                                         (gpointer)"mono_jit_thread_attach", TRUE);
-                       amd64_patch (buf, code);
-#ifdef HOST_WIN32
-                       /* The TLS key actually contains a pointer to the MonoJitTlsData structure */
-                       /* FIXME: Add a separate key for LMF to avoid this */
-                       amd64_alu_reg_imm (code, X86_ADD, AMD64_RAX, G_STRUCT_OFFSET (MonoJitTlsData, lmf));
-#endif
-               } else {
-                       g_assert (!cfg->compile_aot);
-                       if (cfg->compile_aot) {
-                               /* AOT code is only used in the root domain */
-                               amd64_mov_reg_imm (code, AMD64_ARG_REG1, 0);
-                       } else {
-                               if ((domain >> 32) == 0)
-                                       amd64_mov_reg_imm_size (code, AMD64_ARG_REG1, domain, 4);
-                               else
-                                       amd64_mov_reg_imm_size (code, AMD64_ARG_REG1, domain, 8);
-                       }
-                       code = emit_call (cfg, code, MONO_PATCH_INFO_INTERNAL_METHOD,
-                                         (gpointer)"mono_jit_thread_attach", TRUE);
-               }
-       }
-
        if (method->save_lmf) {
                code = emit_save_lmf (cfg, code, lmf_var->inst_offset, &args_clobbered);
        }
@@ -8067,6 +7988,8 @@ mono_arch_finish_init (void)
                appdomain_tls_offset = -1;
        if (lmf_tls_offset >= 64)
                lmf_tls_offset = -1;
+       if (lmf_addr_tls_offset >= 64)
+               lmf_addr_tls_offset = -1;
 #else
 #ifdef MONO_XEN_OPT
        optimize_for_xen = access ("/proc/xen", F_OK) == 0;