Use g_assertion_message instead of exit to kill an iOS app.
[mono.git] / mono / mini / mini-codegen.c
index 6563b7ecb53bdddcb2be8b75a843fffb7be19dc9..22d36cf6546b9aa83df0da7b1c4b5af0a139fc2e 100644 (file)
@@ -271,6 +271,17 @@ mono_call_inst_add_outarg_reg (MonoCompile *cfg, MonoCallInst *call, int vreg, i
        }
 }
 
+/*
+ * mono_call_inst_add_outarg_vt:
+ *
+ *   Register OUTARG_VT as belonging to CALL.
+ */
+void
+mono_call_inst_add_outarg_vt (MonoCompile *cfg, MonoCallInst *call, MonoInst *outarg_vt)
+{
+       call->outarg_vts = g_slist_append_mempool (cfg->mempool, call->outarg_vts, outarg_vt);
+}
+
 static void
 resize_spill_info (MonoCompile *cfg, int bank)
 {
@@ -399,6 +410,53 @@ typedef struct {
 } RegTrack;
 
 #ifndef DISABLE_LOGGING
+
+static const char*
+info_type_to_str (MonoRgctxInfoType type)
+{
+       switch (type) {
+       case MONO_RGCTX_INFO_STATIC_DATA: return "STATIC_DATA";
+       case MONO_RGCTX_INFO_KLASS: return "KLASS";
+       case MONO_RGCTX_INFO_VTABLE: return "VTABLE";
+       case MONO_RGCTX_INFO_TYPE: return "TYPE";
+       case MONO_RGCTX_INFO_REFLECTION_TYPE: return "REFLECTION_TYPE";
+       case MONO_RGCTX_INFO_METHOD: return "METHOD";
+       case MONO_RGCTX_INFO_GENERIC_METHOD_CODE: return "GENERIC_METHOD_CODE";
+       case MONO_RGCTX_INFO_CLASS_FIELD: return "CLASS_FIELD";
+       case MONO_RGCTX_INFO_METHOD_RGCTX: return "METHOD_RGCTX";
+       case MONO_RGCTX_INFO_METHOD_CONTEXT: return "METHOD_CONTEXT";
+       case MONO_RGCTX_INFO_REMOTING_INVOKE_WITH_CHECK: return "REMOTING_INVOKE_WITH_CHECK";
+       case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE: return "METHOD_DELEGATE_CODE";
+       case MONO_RGCTX_INFO_CAST_CACHE: return "CAST_CACHE";
+       default:
+               return "<UNKNOWN RGCTX INFO TYPE>";
+       }
+}
+
+static void
+print_ji (MonoJumpInfo *ji)
+{
+       switch (ji->type) {
+       case MONO_PATCH_INFO_RGCTX_FETCH: {
+               MonoJumpInfoRgctxEntry *entry = ji->data.rgctx_entry;
+
+               printf ("[RGCTX_FETCH ");
+               print_ji (entry->data);
+               printf (" - %s]", info_type_to_str (entry->info_type));
+               break;
+       }
+       case MONO_PATCH_INFO_METHODCONST: {
+               char *s = mono_method_full_name (ji->data.method, TRUE);
+               printf ("[METHODCONST - %s]", s);
+               g_free (s);
+               break;
+       }
+       default:
+               printf ("[%d]", ji->type);
+               break;
+       }
+}
+
 void
 mono_print_ins_index (int i, MonoInst *ins)
 {
@@ -521,6 +579,7 @@ mono_print_ins_index (int i, MonoInst *ins)
        case OP_IAND_IMM:
        case OP_IOR_IMM:
        case OP_IXOR_IMM:
+       case OP_SUB_IMM:
                printf (" [%d]", (int)ins->inst_imm);
                break;
        case OP_ADD_IMM:
@@ -552,7 +611,8 @@ mono_print_ins_index (int i, MonoInst *ins)
        case OP_VCALL2_MEMBASE:
        case OP_VOIDCALL:
        case OP_VOIDCALL_MEMBASE:
-       case OP_VOIDCALLVIRT: {
+       case OP_VOIDCALLVIRT:
+       case OP_TAILCALL: {
                MonoCallInst *call = (MonoCallInst*)ins;
                GSList *list;
 
@@ -569,6 +629,11 @@ mono_print_ins_index (int i, MonoInst *ins)
                        char *full_name = mono_method_full_name (call->method, TRUE);
                        printf (" [%s]", full_name);
                        g_free (full_name);
+               } else if (call->fptr_is_patch) {
+                       MonoJumpInfo *ji = (MonoJumpInfo*)call->fptr;
+
+                       printf (" ");
+                       print_ji (ji);
                } else if (call->fptr) {
                        MonoJitICallInfo *info = mono_find_jit_icall_by_addr (call->fptr);
                        if (info)
@@ -625,6 +690,9 @@ mono_print_ins_index (int i, MonoInst *ins)
        case OP_GC_LIVENESS_USE:
                printf (" R%d", (int)ins->inst_c1);
                break;
+       case OP_SEQ_POINT:
+               printf (" il: %x", (int)ins->inst_imm);
+               break;
        default:
                break;
        }
@@ -2159,8 +2227,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
                                        MONO_INST_NEW (cfg, fxch, OP_X86_FXCH);
                                        fxch->inst_imm = sp - 1 - i;
 
-                                       prev->next = fxch;
-                                       fxch->next = ins;
+                                       mono_bblock_insert_after_ins (bb, prev, fxch);
                                        prev = fxch;
 
                                        tmp = fpstack [sp - 1];
@@ -2174,8 +2241,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
                                MONO_INST_NEW (cfg, fxch, OP_X86_FXCH);
                                fxch->inst_imm = 1;
 
-                               prev->next = fxch;
-                               fxch->next = ins;
+                               mono_bblock_insert_after_ins (bb, prev, fxch);
                                prev = fxch;
 
                                tmp = fpstack [sp - 1];
@@ -2199,8 +2265,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
                                        MONO_INST_NEW (cfg, fxch, OP_X86_FXCH);
                                        fxch->inst_imm = sp - 1 - i;
 
-                                       prev->next = fxch;
-                                       fxch->next = ins;
+                                       mono_bblock_insert_after_ins (bb, prev, fxch);
                                        prev = fxch;
 
                                        tmp = fpstack [sp - 1];
@@ -2227,8 +2292,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
                                        MONO_INST_NEW (cfg, fxch, OP_X86_FXCH);
                                        fxch->inst_imm = sp - 1 - i;
 
-                                       prev->next = fxch;
-                                       fxch->next = ins;
+                                       mono_bblock_insert_after_ins (bb, prev, fxch);
                                        prev = fxch;
 
                                        tmp = fpstack [sp - 1];
@@ -2428,7 +2492,6 @@ mono_opcode_to_type (int opcode, int cmp_opcode)
                switch (cmp_opcode) {
                case OP_ICOMPARE:
                case OP_ICOMPARE_IMM:
-               case OP_LCOMPARE_IMM:
                        return CMP_TYPE_I;
                default:
                        return CMP_TYPE_L;
@@ -2477,8 +2540,9 @@ mono_is_regsize_var (MonoType *t)
                return FALSE;
        case MONO_TYPE_VALUETYPE:
                return FALSE;
+       default:
+               return FALSE;
        }
-       return FALSE;
 }
 
 #ifndef DISABLE_JIT