* ProtectedConfigurationProvider.cs:
[mono.git] / mono / mini / mini.c
index e9c9f676ce470b960e3bf22dfac3f5c048607f4c..353268e25e44155a22ab07fb6de8ecbf93411eae 100644 (file)
@@ -1711,13 +1711,11 @@ handle_stack_args (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst **sp, int coun
 static int
 ret_type_to_call_opcode (MonoType *type, int calli, int virt)
 {
-       int t = type->type;
-
        if (type->byref)
                return calli? OP_CALL_REG: virt? CEE_CALLVIRT: CEE_CALL;
 
 handle_enum:
-       switch (t) {
+       switch (type->type) {
        case MONO_TYPE_VOID:
                return calli? OP_VOIDCALL_REG: virt? OP_VOIDCALLVIRT: OP_VOIDCALL;
        case MONO_TYPE_I1:
@@ -1747,14 +1745,14 @@ handle_enum:
                return calli? OP_FCALL_REG: virt? OP_FCALLVIRT: OP_FCALL;
        case MONO_TYPE_VALUETYPE:
                if (type->data.klass->enumtype) {
-                       t = type->data.klass->enum_basetype->type;
+                       type = type->data.klass->enum_basetype;
                        goto handle_enum;
                } else
                        return calli? OP_VCALL_REG: virt? OP_VCALLVIRT: OP_VCALL;
        case MONO_TYPE_TYPEDBYREF:
                return calli? OP_VCALL_REG: virt? OP_VCALLVIRT: OP_VCALL;
        case MONO_TYPE_GENERICINST:
-               t = type->data.generic_inst->generic_type->type;
+               type = type->data.generic_inst->generic_type;
                goto handle_enum;
        default:
                g_error ("unknown type 0x%02x in ret_type_to_call_opcode", type->type);
@@ -1818,7 +1816,8 @@ handle_loaded_temps (MonoCompile *cfg, MonoBasicBlock *bblock, MonoInst **stack,
 static int
 check_call_signature (MonoCompile *cfg, MonoMethodSignature *sig, MonoInst **args)
 {
-       int i, simple_type;
+       MonoType *simple_type;
+       int i;
 
        if (sig->hasthis) {
                if (args [0]->type != STACK_OBJ && args [0]->type != STACK_MP && args [0]->type != STACK_PTR)
@@ -1850,9 +1849,9 @@ check_call_signature (MonoCompile *cfg, MonoMethodSignature *sig, MonoInst **arg
                                return 1;
                        continue;
                }
-               simple_type = sig->params [i]->type;
+               simple_type = sig->params [i];
 handle_enum:
-               switch (simple_type) {
+               switch (simple_type->type) {
                case MONO_TYPE_VOID:
                        return 1;
                        continue;
@@ -1892,8 +1891,8 @@ handle_enum:
                                return 1;
                        continue;
                case MONO_TYPE_VALUETYPE:
-                       if (sig->params [i]->data.klass->enumtype) {
-                               simple_type = sig->params [i]->data.klass->enum_basetype->type;
+                       if (simple_type->data.klass->enumtype) {
+                               simple_type = simple_type->data.klass->enum_basetype;
                                goto handle_enum;
                        }
                        if (args [i]->type != STACK_VTYPE)
@@ -1904,11 +1903,12 @@ handle_enum:
                                return 1;
                        continue;
                case MONO_TYPE_GENERICINST:
-                       simple_type = sig->params [i]->data.generic_inst->generic_type->type;
+                       simple_type = sig->params [i]->data.generic_inst->generic_type;
                        goto handle_enum;
 
                default:
-                       g_error ("unknown type 0x%02x in check_call_signature", simple_type);
+                       g_error ("unknown type 0x%02x in check_call_signature",
+                                simple_type->type);
                }
        }
        return 0;
@@ -2140,6 +2140,10 @@ mono_get_element_address_signature (int arity)
        res = mono_metadata_signature_alloc (mono_defaults.corlib, arity + 1);
 
        res->pinvoke = 1;
+#ifdef MONO_ARCH_VARARG_ICALLS
+       /* Only set this only some archs since not all backends can handle varargs+pinvoke */
+       res->call_convention = MONO_CALL_VARARG;
+#endif
        res->params [0] = &mono_defaults.array_class->byval_arg; 
        
        for (i = 1; i <= arity; i++)
@@ -2172,6 +2176,10 @@ mono_get_array_new_va_signature (int arity)
        res = mono_metadata_signature_alloc (mono_defaults.corlib, arity + 1);
 
        res->pinvoke = 1;
+#ifdef MONO_ARCH_VARARG_ICALLS
+       /* Only set this only some archs since not all backends can handle varargs+pinvoke */
+       res->call_convention = MONO_CALL_VARARG;
+#endif
 
        res->params [0] = &mono_defaults.int_class->byval_arg;  
        for (i = 0; i < arity; i++)
@@ -2287,7 +2295,7 @@ handle_box (MonoCompile *cfg, MonoBasicBlock *bblock, MonoInst *val, const gucha
        }
        NEW_TEMPLOAD (cfg, dest, temp);
        NEW_ICONST (cfg, vtoffset, sizeof (MonoObject));
-       MONO_INST_NEW (cfg, add, CEE_ADD);
+       MONO_INST_NEW (cfg, add, OP_PADD);
        add->inst_left = dest;
        add->inst_right = vtoffset;
        add->cil_code = ip;
@@ -4227,7 +4235,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        ins->inst_newa_class = klass;
                        ins->cil_code = ip;
 
-                       MONO_INST_NEW (cfg, add, CEE_ADD);
+                       MONO_INST_NEW (cfg, add, OP_PADD);
                        NEW_ICONST (cfg, vtoffset, sizeof (MonoObject));
                        add->inst_left = ins;
                        add->inst_right = vtoffset;
@@ -4278,7 +4286,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        ins->inst_newa_class = klass;
                        ins->cil_code = ip;
 
-                       MONO_INST_NEW (cfg, add, CEE_ADD);
+                       MONO_INST_NEW (cfg, add, OP_PADD);
                        NEW_ICONST (cfg, vtoffset, sizeof (MonoObject));
                        add->inst_left = ins;
                        add->inst_right = vtoffset;
@@ -4408,7 +4416,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                } else {
                                        MonoInst *store;
                                        NEW_ICONST (cfg, offset_ins, foffset);
-                                       MONO_INST_NEW (cfg, ins, CEE_ADD);
+                                       MONO_INST_NEW (cfg, ins, OP_PADD);
                                        ins->cil_code = ip;
                                        ins->inst_left = *sp;
                                        ins->inst_right = offset_ins;
@@ -4478,7 +4486,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        }
                                } else {
                                        NEW_ICONST (cfg, offset_ins, foffset);
-                                       MONO_INST_NEW (cfg, ins, CEE_ADD);
+                                       MONO_INST_NEW (cfg, ins, OP_PADD);
                                        ins->cil_code = ip;
                                        ins->inst_left = *sp;
                                        ins->inst_right = offset_ins;
@@ -4778,7 +4786,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        *sp++ = ins;
                        ip += 5;
                        break;
-               case CEE_LDELEM: {
+               case CEE_LDELEM_ANY: {
                        MonoInst *load;
                        CHECK_STACK (2);
                        sp -= 2;
@@ -4854,7 +4862,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        inline_costs += 1;
                        break;
                }
-               case CEE_STELEM: {
+               case CEE_STELEM_ANY: {
                        MonoInst *load;
                        /*
                         * translate to:
@@ -5518,6 +5526,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                MONO_INST_NEW (cfg, ins, OP_LOCALLOC);
                                ins->inst_left = *sp;
                                ins->cil_code = ip;
+                               ins->type = STACK_MP;
 
                                cfg->flags |= MONO_CFG_HAS_ALLOCA;
                                if (header->init_locals)
@@ -5568,7 +5577,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                ip += 2;
                                break;
                        case CEE_TAIL_:
-                               ins_flag |= MONO_INST_TAILCALL;
+                               ins_flag   |= MONO_INST_TAILCALL;
+                               cfg->flags |= MONO_CFG_HAS_TAIL;
                                /* Can't inline tail calls at this time */
                                inline_costs += 100000;
                                ip += 2;
@@ -8209,7 +8219,7 @@ mini_init (const char *filename)
 #endif
        mono_install_stack_walk (mono_jit_walk_stack);
 
-       domain = mono_init (filename);
+       domain = mono_init_from_assembly (filename, filename);
        mono_init_icall ();
 
        mono_add_internal_call ("System.Diagnostics.StackFrame::get_frame_info",