Revert "[jit] Add a new mono_arch_init_compile () backend function which is used...
authorZoltan Varga <vargaz@gmail.com>
Sun, 27 Sep 2015 18:42:56 +0000 (14:42 -0400)
committerZoltan Varga <vargaz@gmail.com>
Sun, 27 Sep 2015 18:42:56 +0000 (14:42 -0400)
This reverts commit bc50c6630337e2a6b40c653d1a0f73c89b519a82.

Revert this as it seems to break the build.

mono/mini/arch-stubs.c
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini.h

index 92baf99643680057a4b970262f24e035acd1f677..d67b677dd871f5d7e4f84a56951926ba585a7dd3 100644 (file)
@@ -71,53 +71,3 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
 {
 }
 #endif
-
-#ifndef MONO_ARCH_HAVE_OP_TAIL_CALL
-gboolean
-mono_arch_tail_call_supported (MonoCompile *cfg, MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig)
-{
-       return mono_metadata_signature_equal (caller_sig, callee_sig) && !MONO_TYPE_ISSTRUCT (callee_sig->ret);
-}
-#endif
-
-#ifndef MONO_ARCH_HAVE_INIT_COMPILE
-void
-mono_arch_init_compile (MonoCompile *cfg)
-{
-#ifdef MONO_ARCH_NEED_GOT_VAR
-       if (cfg->compile_aot)
-               cfg->need_got_var = 1;
-#endif
-#ifdef MONO_ARCH_HAVE_CARD_TABLE_WBARRIER
-       cfg->have_card_table_wb = 1;
-#endif
-#ifdef MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT
-       cfg->have_op_generic_class_init = 1;
-#endif
-#ifdef MONO_ARCH_EMULATE_MUL_DIV
-       cfg->emulate_mul_div = 1;
-#endif
-#ifdef MONO_ARCH_EMULATE_DIV
-       cfg->emulate_div = 1;
-#endif
-#if !defined(MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS)
-       cfg->emulate_long_shift_opts = 1;
-#endif
-#ifdef MONO_ARCH_HAVE_OBJC_GET_SELECTOR
-       cfg->have_objc_get_selector = 1;
-#endif
-#ifdef MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK
-       cfg->have_generalized_imt_thunk = 1;
-#endif
-#ifdef MONO_ARCH_GSHARED_SUPPORTED
-       cfg->gshared_supported = 1;
-#endif
-       if (MONO_ARCH_HAVE_TLS_GET)
-               cfg->have_tls_get = 1;
-       if (MONO_ARCH_USE_FPSTACK)
-               cfg->use_fpstack = 1;
-#ifdef MONO_ARCH_HAVE_LIVERANGE_OPS
-       cfg->have_liverange_ops = 1;
-#endif
-}
-#endif
index 590ffc95bd2bbbae06809909a02f4eb616fa4a0f..e5cd02291b0f5d10da83c9779fda373ba294fb37 100644 (file)
@@ -138,7 +138,7 @@ static int ldind_to_load_membase (int opcode);
 static int stind_to_store_membase (int opcode);
 
 int mono_op_to_op_imm (int opcode);
-int mono_op_to_op_imm_noemul (MonoCompile *cfg, int opcode);
+int mono_op_to_op_imm_noemul (int opcode);
 
 MONO_API MonoInst* mono_emit_native_call (MonoCompile *cfg, gconstpointer func, MonoMethodSignature *sig, MonoInst **args);
 
@@ -1227,12 +1227,16 @@ mono_get_domainvar (MonoCompile *cfg)
 MonoInst *
 mono_get_got_var (MonoCompile *cfg)
 {
-       if (!cfg->need_got_var)
+#ifdef MONO_ARCH_NEED_GOT_VAR
+       if (!cfg->compile_aot)
                return NULL;
        if (!cfg->got_var) {
                cfg->got_var = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
        }
        return cfg->got_var;
+#else
+       return NULL;
+#endif
 }
 
 static MonoInst *
@@ -2427,7 +2431,7 @@ emit_imt_argument (MonoCompile *cfg, MonoCallInst *call, MonoMethod *method, Mon
 #ifdef ENABLE_LLVM
                call->imt_arg_reg = method_reg;
 #endif
-               mono_call_inst_add_outarg_reg (cfg, call, method_reg, MONO_ARCH_IMT_REG, FALSE);
+       mono_call_inst_add_outarg_reg (cfg, call, method_reg, MONO_ARCH_IMT_REG, FALSE);
                return;
        }
 
@@ -3067,6 +3071,7 @@ emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
        MonoInst *dummy_use;
        int nursery_shift_bits;
        size_t nursery_size;
+       gboolean has_card_table_wb = FALSE;
 
        if (!cfg->gen_write_barriers)
                return;
@@ -3075,7 +3080,11 @@ emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
 
        mono_gc_get_nursery (&nursery_shift_bits, &nursery_size);
 
-       if (cfg->have_card_table_wb && !cfg->compile_aot && card_table && nursery_shift_bits > 0 && !COMPILE_LLVM (cfg)) {
+#ifdef MONO_ARCH_HAVE_CARD_TABLE_WBARRIER
+       has_card_table_wb = TRUE;
+#endif
+
+       if (has_card_table_wb && !cfg->compile_aot && card_table && nursery_shift_bits > 0 && !COMPILE_LLVM (cfg)) {
                MonoInst *wbarrier;
 
                MONO_INST_NEW (cfg, wbarrier, OP_CARD_TABLE_WBARRIER);
@@ -3698,6 +3707,7 @@ emit_class_init (MonoCompile *cfg, MonoClass *klass)
 {
        MonoInst *vtable_arg;
        int context_used;
+       gboolean use_op_generic_class_init = FALSE;
 
        context_used = mini_class_check_context_used (cfg, klass);
 
@@ -3712,7 +3722,12 @@ emit_class_init (MonoCompile *cfg, MonoClass *klass)
                EMIT_NEW_VTABLECONST (cfg, vtable_arg, vtable);
        }
 
-       if (!COMPILE_LLVM (cfg) && cfg->have_op_generic_class_init) {
+#ifdef MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT
+       if (!COMPILE_LLVM (cfg))
+               use_op_generic_class_init = TRUE;
+#endif
+
+       if (use_op_generic_class_init) {
                MonoInst *ins;
 
                /*
@@ -5321,7 +5336,8 @@ mini_emit_ldelema_1_ins (MonoCompile *cfg, MonoClass *klass, MonoInst *arr, Mono
        return ins;
 }
 
-static G_GNUC_UNUSED MonoInst*
+#ifndef MONO_ARCH_EMULATE_MUL_DIV
+static MonoInst*
 mini_emit_ldelema_2_ins (MonoCompile *cfg, MonoClass *klass, MonoInst *arr, MonoInst *index_ins1, MonoInst *index_ins2)
 {
        int bounds_reg = alloc_preg (cfg);
@@ -5394,6 +5410,7 @@ mini_emit_ldelema_2_ins (MonoCompile *cfg, MonoClass *klass, MonoInst *arr, Mono
 
        return ins;
 }
+#endif
 
 static MonoInst*
 mini_emit_ldelema_ins (MonoCompile *cfg, MonoMethod *cmethod, MonoInst **sp, unsigned char *ip, gboolean is_set)
@@ -5409,10 +5426,12 @@ mini_emit_ldelema_ins (MonoCompile *cfg, MonoMethod *cmethod, MonoInst **sp, uns
        if (rank == 1)
                return mini_emit_ldelema_1_ins (cfg, eclass, sp [0], sp [1], TRUE);
 
+#ifndef MONO_ARCH_EMULATE_MUL_DIV
        /* emit_ldelema_2 depends on OP_LMUL */
-       if (!cfg->emulate_mul_div && rank == 2 && (cfg->opt & MONO_OPT_INTRINS) && !mini_is_gsharedvt_variable_klass (eclass)) {
+       if (rank == 2 && (cfg->opt & MONO_OPT_INTRINS) && !mini_is_gsharedvt_variable_klass (eclass)) {
                return mini_emit_ldelema_2_ins (cfg, eclass, sp [0], sp [1], sp [2]);
        }
+#endif
 
        if (mini_is_gsharedvt_variable_klass (eclass))
                element_size = 0;
@@ -5781,7 +5800,8 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        type_from_op (cfg, ins, NULL, NULL);
 
                        return ins;
-               } else if (!cfg->emulate_mul_div && strcmp (cmethod->name, "InternalGetHashCode") == 0 && fsig->param_count == 1 && !mono_gc_is_moving ()) {
+#if !defined(MONO_ARCH_EMULATE_MUL_DIV)
+               } else if (strcmp (cmethod->name, "InternalGetHashCode") == 0 && fsig->param_count == 1 && !mono_gc_is_moving ()) {
                        int dreg = alloc_ireg (cfg);
                        int t1 = alloc_ireg (cfg);
        
@@ -5790,6 +5810,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        ins->type = STACK_I4;
 
                        return ins;
+#endif
                } else if (strcmp (cmethod->name, ".ctor") == 0 && fsig->param_count == 0) {
                        MONO_INST_NEW (cfg, ins, OP_NOP);
                        MONO_ADD_INS (cfg->cbb, ins);
@@ -6506,8 +6527,8 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                                !strcmp (cmethod->klass->name_space, "ObjCRuntime") &&
                                !strcmp (cmethod->klass->name, "Selector"))
                           ) {
-               if (cfg->have_objc_get_selector &&
-                       !strcmp (cmethod->name, "GetHandle") && fsig->param_count == 1 &&
+#ifdef MONO_ARCH_HAVE_OBJC_GET_SELECTOR
+               if (!strcmp (cmethod->name, "GetHandle") && fsig->param_count == 1 &&
                    (args [0]->opcode == OP_GOT_ENTRY || args [0]->opcode == OP_AOTCONST) &&
                    cfg->compile_aot) {
                        MonoInst *pi;
@@ -6537,6 +6558,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        MONO_ADD_INS (cfg->cbb, ins);
                        return ins;
                }
+#endif
        }
 
 #ifdef MONO_ARCH_SIMD_INTRINSICS
@@ -7471,7 +7493,11 @@ is_supported_tail_call (MonoCompile *cfg, MonoMethod *method, MonoMethod *cmetho
        gboolean supported_tail_call;
        int i;
 
+#ifdef MONO_ARCH_HAVE_OP_TAIL_CALL
        supported_tail_call = mono_arch_tail_call_supported (cfg, mono_method_signature (method), mono_method_signature (cmethod));
+#else
+       supported_tail_call = mono_metadata_signature_equal (mono_method_signature (method), mono_method_signature (cmethod)) && !MONO_TYPE_ISSTRUCT (mono_method_signature (cmethod)->ret);
+#endif
 
        for (i = 0; i < fsig->param_count; ++i) {
                if (fsig->params [i]->byref || fsig->params [i]->type == MONO_TYPE_PTR || fsig->params [i]->type == MONO_TYPE_FNPTR)
@@ -9027,6 +9053,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                !(cfg->gsharedvt && mini_is_gsharedvt_signature (fsig))) {
                                MonoInst *this_temp, *this_arg_temp, *store;
                                MonoInst *iargs [4];
+                               gboolean use_imt = FALSE;
 
                                g_assert (fsig->is_inflated);
 
@@ -9036,7 +9063,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig))
                                        GSHAREDVT_FAILURE (*ip);
 
-                               if (cfg->have_generalized_imt_thunk && cfg->gshared_supported && cmethod->wrapper_type == MONO_WRAPPER_NONE) {
+#if MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK && defined(MONO_ARCH_GSHARED_SUPPORTED)
+                               if (cmethod->wrapper_type == MONO_WRAPPER_NONE)
+                                       use_imt = TRUE;
+#endif
+
+                               if (use_imt) {
                                        g_assert (!imt_arg);
                                        if (!context_used)
                                                g_assert (cmethod->is_inflated);
@@ -9872,7 +9904,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                        /* Use the immediate opcodes if possible */
                        if ((sp [1]->opcode == OP_ICONST) && mono_arch_is_inst_imm (sp [1]->inst_c0)) {
-                               int imm_opcode = mono_op_to_op_imm_noemul (cfg, ins->opcode);
+                               int imm_opcode = mono_op_to_op_imm_noemul (ins->opcode);
                                if (imm_opcode != -1) {
                                        ins->opcode = imm_opcode;
                                        ins->inst_p1 = (gpointer)(gssize)(sp [1]->inst_c0);
@@ -9916,13 +9948,13 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        if (((sp [1]->opcode == OP_ICONST) || (sp [1]->opcode == OP_I8CONST)) && mono_arch_is_inst_imm (sp [1]->opcode == OP_ICONST ? sp [1]->inst_c0 : sp [1]->inst_l)) {
                                int imm_opcode;
 
-                               imm_opcode = mono_op_to_op_imm_noemul (cfg, ins->opcode);
-                               if (cfg->emulate_mul_div || cfg->emulate_div) {
-                                       /* Keep emulated opcodes which are optimized away later */
-                                       if ((ins->opcode == OP_IREM_UN || ins->opcode == OP_IDIV_UN_IMM) && (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP)) && sp [1]->opcode == OP_ICONST && mono_is_power_of_two (sp [1]->inst_c0) >= 0) {
-                                               imm_opcode = mono_op_to_op_imm (ins->opcode);
-                                       }
+                               imm_opcode = mono_op_to_op_imm_noemul (ins->opcode);
+#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_DIV)
+                               /* Keep emulated opcodes which are optimized away later */
+                               if ((ins->opcode == OP_IREM_UN || ins->opcode == OP_IDIV_UN_IMM) && (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP)) && sp [1]->opcode == OP_ICONST && mono_is_power_of_two (sp [1]->inst_c0) >= 0) {
+                                       imm_opcode = mono_op_to_op_imm (ins->opcode);
                                }
+#endif
                                if (imm_opcode != -1) {
                                        ins->opcode = imm_opcode;
                                        if (sp [1]->opcode == OP_I8CONST) {
@@ -12200,7 +12232,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                ad_ins = mono_get_domain_intrinsic (cfg);
                                jit_tls_ins = mono_get_jit_tls_intrinsic (cfg);
 
-                               if (cfg->have_tls_get && ad_ins && jit_tls_ins) {
+                               if (MONO_ARCH_HAVE_TLS_GET && ad_ins && jit_tls_ins) {
                                        NEW_BBLOCK (cfg, next_bb);
                                        NEW_BBLOCK (cfg, call_bb);
 
@@ -13407,30 +13439,29 @@ op_to_op_src2_membase (int load_opcode, int opcode)
 }
 
 int
-mono_op_to_op_imm_noemul (MonoCompile *cfg, int opcode)
+mono_op_to_op_imm_noemul (int opcode)
 {
        switch (opcode) {
+#if SIZEOF_REGISTER == 4 && !defined(MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS)
        case OP_LSHR:
        case OP_LSHL:
        case OP_LSHR_UN:
-               if (SIZEOF_REGISTER == 4 && cfg->emulate_long_shift_opts)
-                       return -1;
-               break;
+               return -1;
+#endif
+#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_DIV)
        case OP_IDIV:
        case OP_IDIV_UN:
        case OP_IREM:
        case OP_IREM_UN:
-               if (cfg->emulate_mul_div || cfg->emulate_div)
-                       return -1;
-               break;
+               return -1;
+#endif
+#if defined(MONO_ARCH_EMULATE_MUL_DIV)
        case OP_IMUL:
-               if (cfg->emulate_mul_div)
-                       return -1;
-               break;
+               return -1;
+#endif
        default:
-               break;
+               return mono_op_to_op_imm (opcode);
        }
-       return mono_op_to_op_imm (opcode);
 }
 
 /**
@@ -14066,7 +14097,7 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
                                                         * sregs could use it. So set a flag, and do it after
                                                         * the sregs.
                                                         */
-                                                       if ((!cfg->use_fpstack || ((store_opcode != OP_STORER8_MEMBASE_REG) && (store_opcode != OP_STORER4_MEMBASE_REG))) && !((var)->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
+                                                       if ((!MONO_ARCH_USE_FPSTACK || ((store_opcode != OP_STORER8_MEMBASE_REG) && (store_opcode != OP_STORER4_MEMBASE_REG))) && !((var)->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
                                                                dest_has_lvreg = TRUE;
                                                }
                                        }
@@ -14156,7 +14187,7 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
 
                                                        sreg = alloc_dreg (cfg, stacktypes [regtype]);
 
-                                                       if ((!cfg->use_fpstack || ((load_opcode != OP_LOADR8_MEMBASE) && (load_opcode != OP_LOADR4_MEMBASE))) && !((var)->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)) && !no_lvreg) {
+                                                       if ((!MONO_ARCH_USE_FPSTACK || ((load_opcode != OP_LOADR8_MEMBASE) && (load_opcode != OP_LOADR4_MEMBASE))) && !((var)->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)) && !no_lvreg) {
                                                                if (var->dreg == prev_dreg) {
                                                                        /*
                                                                         * sreg refers to the value loaded by the load
@@ -14263,11 +14294,12 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
                }
        }
        
+#ifdef MONO_ARCH_HAVE_LIVERANGE_OPS
        /*
         * Emit LIVERANGE_START/LIVERANGE_END opcodes, the backend will implement them
         * by storing the current native offset into MonoMethodVar->live_range_start/end.
         */
-       if (cfg->have_liverange_ops && cfg->compute_precise_live_ranges && cfg->comp_done & MONO_COMP_LIVENESS) {
+       if (cfg->compute_precise_live_ranges && cfg->comp_done & MONO_COMP_LIVENESS) {
                for (i = 0; i < cfg->num_varinfo; ++i) {
                        int vreg = MONO_VARINFO (cfg, i)->vreg;
                        MonoInst *ins;
@@ -14289,6 +14321,7 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
                        }
                }
        }
+#endif
 
        if (cfg->gsharedvt_locals_var_ins) {
                /* Nullify if unused */
index 60bb24cb886d27a39f9efdb994b4ae684d1830b8..f0ef08925dfd65d388fafe7693236ab479c940f0 100644 (file)
@@ -1729,22 +1729,6 @@ mono_arch_fill_argument_info (MonoCompile *cfg)
                }
        }
 }
-
-/*
- * mono_arch_init_compile:
- *
- *   Set architecture specific flags in CFG.
- */
-void
-mono_arch_init_compile (MonoCompile *cfg)
-{
-       cfg->have_card_table_wb = 1;
-       cfg->have_op_generic_class_init = 1;
-       cfg->have_generalized_imt_thunk = 1;
-       cfg->gshared_supported = 1;
-       cfg->have_tls_get = mono_amd64_have_tls_get ();
-       cfg->have_liverange_ops = 1;
-}
  
 void
 mono_arch_allocate_vars (MonoCompile *cfg)
index 224e0b55b76b911c009c768409e7b4c57fc68c97..54b12dcf6d0f3aed09e584de0e4e045a5ed88780 100644 (file)
@@ -356,7 +356,6 @@ typedef struct {
 #define MONO_ARCH_HAVE_SDB_TRAMPOLINES 1
 #define MONO_ARCH_HAVE_PATCH_CODE_NEW 1
 #define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
-#define MONO_ARCH_HAVE_INIT_COMPILE 1
 
 #if defined(TARGET_OSX) || defined(__linux__)
 #define MONO_ARCH_HAVE_TLS_GET_REG 1
index 68ba7e2b6264fe15a4e0de7bedf917e84d2e5d2f..cf8929516eef1eb8a2a51dfe72bc66518fc20343 100644 (file)
@@ -1563,18 +1563,6 @@ typedef struct {
        guint            gshared : 1;
        guint            gsharedvt : 1;
        guint            r4fp : 1;
-       guint            need_got_var : 1;
-       guint            have_card_table_wb : 1;
-       guint            have_op_generic_class_init : 1;
-       guint            emulate_mul_div : 1;
-       guint            emulate_div : 1;
-       guint            emulate_long_shift_opts : 1;
-       guint            have_objc_get_selector : 1;
-       guint            have_generalized_imt_thunk : 1;
-       guint            have_tls_get : 1;
-       guint            have_liverange_ops: 1;
-       guint            gshared_supported : 1;
-       guint            use_fpstack : 1;
        int              r4_stack_type;
        gpointer         debug_info;
        guint32          lmf_offset;
@@ -2476,7 +2464,6 @@ void      mono_arch_finish_init                 (void);
 void      mono_arch_cleanup                     (void);
 void      mono_arch_cpu_init                    (void);
 guint32   mono_arch_cpu_optimizations           (guint32 *exclude_mask);
-void      mono_arch_init_compile                (MonoCompile *cfg);
 void      mono_arch_instrument_mem_needs        (MonoMethod *method, int *stack, int *code);
 void     *mono_arch_instrument_prolog           (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);
 void     *mono_arch_instrument_epilog           (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);