Revert "[jit] Allow NEW_AOTCONST () to work in JIT mode too, use this to simplify...
authorZoltan Varga <vargaz@gmail.com>
Sat, 25 Jul 2015 02:12:13 +0000 (22:12 -0400)
committerZoltan Varga <vargaz@gmail.com>
Sat, 25 Jul 2015 02:12:13 +0000 (22:12 -0400)
This reverts commit bf736f6c5938641a77da1941f28c96513c42df38.

Revert this as it seems to break the build.

mono/mini/ir-emit.h
mono/mini/method-to-ir.c
mono/mini/mini.c
mono/mini/mini.h

index 9b0c7b00ec8a8eb459bf91943ad89fd09912ba17..59654ee902875458b9aa814f6dc22c194f449b49 100644 (file)
@@ -187,8 +187,6 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
         (dest)->inst_imm = (imm); \
        } while (0)
 
-/* NEW_AOTCONST works in JIT mode too by calling mono_resolve_patch_target () */
-
 #ifdef MONO_ARCH_NEED_GOT_VAR
 
 #define NEW_PATCH_INFO(cfg,dest,el1,el2) do {  \
@@ -207,8 +205,8 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
                        (dest)->inst_basereg = got_loc->dreg;                   \
                        (dest)->inst_p1 = group;                        \
                } else {                                                \
-                       gpointer _data = mini_resolve_patch_info ((cfg), (patch_type), (cons)); \
-                       (dest)->inst_p0 = (_data); \
+                       (dest)->inst_p0 = (cons);                       \
+                       (dest)->inst_i1 = (gpointer)(patch_type);       \
                }                                                       \
                (dest)->type = STACK_PTR;                               \
                (dest)->dreg = alloc_dreg ((cfg), STACK_PTR);   \
@@ -231,13 +229,8 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
 
 #define NEW_AOTCONST(cfg,dest,patch_type,cons) do {    \
         MONO_INST_NEW ((cfg), (dest), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \
-               if (cfg->compile_aot) {                                                                                         \
-                       (dest)->inst_p0 = (cons);                         \
-                       (dest)->inst_i1 = (gpointer)(patch_type);       \
-               } else { \
-                       gpointer _data = mini_resolve_patch_info ((cfg), (patch_type), (cons)); \
-                       (dest)->inst_p0 = (_data); \
-               } \
+               (dest)->inst_p0 = (cons);       \
+               (dest)->inst_i1 = (gpointer)(patch_type); \
                (dest)->type = STACK_PTR;       \
                (dest)->dreg = alloc_dreg ((cfg), STACK_PTR);   \
     } while (0)
@@ -261,7 +254,7 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
 
 #define NEW_METHODCONST(cfg,dest,val) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_METHODCONST, (val))
 
-#define NEW_VTABLECONST(cfg,dest,vtable) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_VTABLE, (vtable)->klass)
+#define NEW_VTABLECONST(cfg,dest,vtable) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_VTABLE, cfg->compile_aot ? (gpointer)((vtable)->klass) : (vtable))
 
 #define NEW_SFLDACONST(cfg,dest,val) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_SFLDA, (val))
 
@@ -447,7 +440,7 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg)
 
 #define EMIT_NEW_METHODCONST(cfg,dest,val) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_METHODCONST, (val)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
 
-#define EMIT_NEW_VTABLECONST(cfg,dest,vtable) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_VTABLE, (vtable)->klass); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
+#define EMIT_NEW_VTABLECONST(cfg,dest,vtable) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_VTABLE, cfg->compile_aot ? (gpointer)((vtable)->klass) : (vtable)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
 
 #define EMIT_NEW_SFLDACONST(cfg,dest,val) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_SFLDA, (val)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
 
@@ -630,15 +623,17 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg)
 
 #define        MONO_EMIT_NEW_AOTCONST(cfg,dr,imm,type) do { \
         MonoInst *inst; \
-        NEW_AOTCONST ((cfg), (inst), (type), (imm)); \
+        MONO_INST_NEW ((cfg), (inst), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \
         inst->dreg = dr; \
+        inst->inst_p0 = imm; \
+        inst->inst_c1 = type; \
                MONO_ADD_INS ((cfg)->cbb, inst); \
        } while (0)
 
 #endif
 
 #define        MONO_EMIT_NEW_CLASSCONST(cfg,dr,imm) MONO_EMIT_NEW_AOTCONST(cfg,dr,imm,MONO_PATCH_INFO_CLASS)
-#define MONO_EMIT_NEW_VTABLECONST(cfg,dest,vtable) MONO_EMIT_NEW_AOTCONST ((cfg), (dest), (vtable)->klass, MONO_PATCH_INFO_VTABLE)
+#define MONO_EMIT_NEW_VTABLECONST(cfg,dest,vtable) MONO_EMIT_NEW_AOTCONST ((cfg), (dest), (cfg)->compile_aot ? (gpointer)((vtable)->klass) : (vtable), MONO_PATCH_INFO_VTABLE)
 #define MONO_EMIT_NEW_SIGNATURECONST(cfg,dr,sig) MONO_EMIT_NEW_AOTCONST ((cfg), (dr), (sig), MONO_PATCH_INFO_SIGNATURE)
 
 #define MONO_EMIT_NEW_VZERO(cfg,dr,kl) do {    \
index d9b02641f02e201b5cf6f40234ed7fa2dfe474c1..9798cd745f223b7064f8a5df12cddcaf7a6f8d19 100644 (file)
@@ -1548,7 +1548,10 @@ mini_emit_interface_bitmap_check (MonoCompile *cfg, int intf_bit_reg, int base_r
        NEW_LOAD_MEMBASE (cfg, ins, OP_LOAD_MEMBASE, ibitmap_reg, base_reg, offset);
        MONO_ADD_INS (cfg->cbb, ins);
        args [0] = ins;
-       EMIT_NEW_AOTCONST (cfg, args [1], MONO_PATCH_INFO_IID, klass);
+       if (cfg->compile_aot)
+               EMIT_NEW_AOTCONST (cfg, args [1], MONO_PATCH_INFO_IID, klass);
+       else
+               EMIT_NEW_ICONST (cfg, args [1], klass->interface_id);
        res = mono_emit_jit_icall (cfg, mono_class_interface_match, args);
        MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, intf_bit_reg, res->dreg);
 #else
@@ -2025,7 +2028,10 @@ emit_push_lmf (MonoCompile *cfg)
                        /* jit_tls = pthread_getspecific (mono_jit_tls_id); lmf_addr = &jit_tls->lmf; */
 
                        /* Load mono_jit_tls_id */
-                       EMIT_NEW_AOTCONST (cfg, args [0], MONO_PATCH_INFO_JIT_TLS_ID, NULL);
+                       if (cfg->compile_aot)
+                               EMIT_NEW_AOTCONST (cfg, args [0], MONO_PATCH_INFO_JIT_TLS_ID, NULL);
+                       else
+                               EMIT_NEW_ICONST (cfg, args [0], mono_jit_tls_id);
                        /* call pthread_getspecific () */
                        jit_tls_ins = mono_emit_jit_icall (cfg, pthread_getspecific, args);
                        /* lmf_addr = &jit_tls->lmf */
@@ -2418,14 +2424,20 @@ emit_imt_argument (MonoCompile *cfg, MonoCallInst *call, MonoMethod *method, Mon
 
                if (imt_arg) {
                        MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, method_reg, imt_arg->dreg);
-               } else {
+               } else if (cfg->compile_aot) {
                        MONO_EMIT_NEW_AOTCONST (cfg, method_reg, method, MONO_PATCH_INFO_METHODCONST);
+               } else {
+                       MonoInst *ins;
+                       MONO_INST_NEW (cfg, ins, OP_PCONST);
+                       ins->inst_p0 = method;
+                       ins->dreg = method_reg;
+                       MONO_ADD_INS (cfg->cbb, ins);
                }
 
 #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;
        }
 
@@ -2433,8 +2445,14 @@ emit_imt_argument (MonoCompile *cfg, MonoCallInst *call, MonoMethod *method, Mon
 
        if (imt_arg) {
                MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, method_reg, imt_arg->dreg);
-       } else {
+       } else if (cfg->compile_aot) {
                MONO_EMIT_NEW_AOTCONST (cfg, method_reg, method, MONO_PATCH_INFO_METHODCONST);
+       } else {
+               MonoInst *ins;
+               MONO_INST_NEW (cfg, ins, OP_PCONST);
+               ins->inst_p0 = method;
+               ins->dreg = method_reg;
+               MONO_ADD_INS (cfg->cbb, ins);
        }
 
        mono_call_inst_add_outarg_reg (cfg, call, method_reg, MONO_ARCH_IMT_REG, FALSE);
@@ -3082,6 +3100,7 @@ emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
        } else if (card_table && !cfg->compile_aot && !mono_gc_card_table_nursery_check ()) {
                int offset_reg = alloc_preg (cfg);
                int card_reg  = alloc_preg (cfg);
+               MonoInst *ins;
 
                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_UN_IMM, offset_reg, ptr->dreg, card_table_shift_bits);
                if (card_table_mask)
@@ -3090,7 +3109,15 @@ emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
                /*We can't use PADD_IMM since the cardtable might end up in high addresses and amd64 doesn't support
                 * IMM's larger than 32bits.
                 */
-               MONO_EMIT_NEW_AOTCONST (cfg, card_reg, NULL, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR);
+               if (cfg->compile_aot) {
+                       MONO_EMIT_NEW_AOTCONST (cfg, card_reg, NULL, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR);
+               } else {
+                       MONO_INST_NEW (cfg, ins, OP_PCONST);
+                       ins->inst_p0 = card_table;
+                       ins->dreg = card_reg;
+                       MONO_ADD_INS (cfg->cbb, ins);
+               }
+
                MONO_EMIT_NEW_BIALU (cfg, OP_PADD, offset_reg, offset_reg, card_reg);
                MONO_EMIT_NEW_STORE_MEMBASE_IMM (cfg, OP_STOREI1_MEMBASE_IMM, offset_reg, 0, 1);
        } else {
@@ -3847,17 +3874,19 @@ mini_emit_check_array_type (MonoCompile *cfg, MonoInst *obj, MonoClass *array_cl
                vtable_ins = emit_get_rgctx_klass (cfg, context_used, array_class, MONO_RGCTX_INFO_VTABLE);
                MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, vtable_reg, vtable_ins->dreg);
        } else {
-               MonoVTable *vtable;
-
-               if (!(vtable = mono_class_vtable (cfg->domain, array_class)))
-                       return;
                if (cfg->compile_aot) {
                        int vt_reg;
+                       MonoVTable *vtable;
 
+                       if (!(vtable = mono_class_vtable (cfg->domain, array_class)))
+                               return;
                        vt_reg = alloc_preg (cfg);
                        MONO_EMIT_NEW_VTABLECONST (cfg, vt_reg, vtable);
                        MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, vtable_reg, vt_reg);
                } else {
+                       MonoVTable *vtable;
+                       if (!(vtable = mono_class_vtable (cfg->domain, array_class)))
+                               return;
                        MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, vtable_reg, vtable);
                }
        }
@@ -11960,9 +11989,14 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                break;
                        }
                        case CEE_MONO_LDPTR_CARD_TABLE: {
+                               int shift_bits;
+                               gpointer card_mask;
                                CHECK_STACK_OVF (1);
 
-                               EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR, NULL);
+                               if (cfg->compile_aot)
+                                       EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR, NULL);
+                               else
+                                       EMIT_NEW_PCONST (cfg, ins, mono_gc_get_card_table (&shift_bits, &card_mask));
 
                                *sp++ = ins;
                                ip += 2;
@@ -11970,9 +12004,14 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                break;
                        }
                        case CEE_MONO_LDPTR_NURSERY_START: {
+                               int shift_bits;
+                               size_t size;
                                CHECK_STACK_OVF (1);
 
-                               EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_GC_NURSERY_START, NULL);
+                               if (cfg->compile_aot)
+                                       EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_GC_NURSERY_START, NULL);
+                               else
+                                       EMIT_NEW_PCONST (cfg, ins, mono_gc_get_nursery (&shift_bits, &size));
 
                                *sp++ = ins;
                                ip += 2;
@@ -11982,7 +12021,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        case CEE_MONO_LDPTR_INT_REQ_FLAG: {
                                CHECK_STACK_OVF (1);
 
-                               EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG, NULL);
+                               if (cfg->compile_aot)
+                                       EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG, NULL);
+                               else
+                                       EMIT_NEW_PCONST (cfg, ins, mono_thread_interruption_request_flag ());
 
                                *sp++ = ins;
                                ip += 2;
index 91c046fc93d329c32415af661f556a18865ef527..fd7d7c852be4a7545a5c22dfbe9c002f65a03939 100644 (file)
@@ -1803,19 +1803,6 @@ mono_allocate_stack_slots (MonoCompile *cfg, gboolean backward, guint32 *stack_s
 
 #endif /* DISABLE_JIT */
 
-/* Resolve a patch info at compile time */
-gpointer
-mini_resolve_patch_info (MonoCompile *cfg, MonoJumpInfoType type, gpointer data)
-{
-       MonoJumpInfo ji;
-
-       memset (&ji, 0, sizeof (MonoJumpInfo));
-       ji.type = type;
-       ji.data.target = data;
-
-       return mono_resolve_patch_target (cfg->method, cfg->domain, cfg->native_code, &ji, FALSE);
-}
-
 #define EMUL_HIT_SHIFT 3
 #define EMUL_HIT_MASK ((1 << EMUL_HIT_SHIFT) - 1)
 /* small hit bitmap cache */
index 45210fcec14ee673324c10c86c0208f23f556b70..386f80c7e1ac5ce5fdd44f32cf8021b0c0b53644 100644 (file)
@@ -2217,7 +2217,6 @@ MonoInst* mono_emit_jit_icall (MonoCompile *cfg, gconstpointer func, MonoInst **
 MonoInst* mono_emit_jit_icall_by_info (MonoCompile *cfg, MonoJitICallInfo *info, MonoInst **args);
 MonoInst* mono_emit_method_call (MonoCompile *cfg, MonoMethod *method, MonoInst **args, MonoInst *this);
 void      mono_create_helper_signatures (void);
-gpointer  mini_resolve_patch_info (MonoCompile *cfg, MonoJumpInfoType type, gpointer data);
 
 gboolean  mini_class_is_system_array (MonoClass *klass);
 MonoMethodSignature *mono_get_element_address_signature (int arity);