[mono/mono] [3 commits] d994c2ea: [jit] Clean up usage of signature variables.

"Rodrigo Kumpera ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014210e212e1-e297a282-9760-48d9-b80a-2e8512ff19cf-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/363b1864e808...98d59927c633

   Commit: d994c2ea19daf02c058e9d4402e5364b3f8f9ff1
   Author: Rodrigo Kumpera <[email protected]> (kumpera)
     Date: 2013-10-31 22:41:18 GMT
      URL: https://github.com/mono/mono/commit/d994c2ea19daf02c058e9d4402e5364b3f8f9ff1

[jit] Clean up usage of signature variables.

Changed paths:
  M mono/mini/method-to-ir.c
  M mono/mini/mini-amd64.c
  M mono/mini/mini-x86.c
  M mono/mini/mini.c

Modified: mono/mini/method-to-ir.c
===================================================================
@@ -2336,6 +2336,7 @@
 mono_emit_call_args (MonoCompile *cfg, MonoMethodSignature *sig, 
 					 MonoInst **args, int calli, int virtual, int tail, int rgctx, int unbox_trampoline)
 {
+	MonoType *sig_ret;
 	MonoCallInst *call;
 #ifdef MONO_ARCH_SOFT_FLOAT_FALLBACK
 	int i;
@@ -2349,16 +2350,17 @@
 	call->args = args;
 	call->signature = sig;
 	call->rgctx_reg = rgctx;
+	sig_ret = sig->ret;
 
-	type_to_eval_stack_type ((cfg), sig->ret, &call->inst);
+	type_to_eval_stack_type ((cfg), sig_ret, &call->inst);
 
 	if (tail) {
-		if (mini_type_is_vtype (cfg, sig->ret)) {
+		if (mini_type_is_vtype (cfg, sig_ret)) {
 			call->vret_var = cfg->vret_addr;
 			//g_assert_not_reached ();
 		}
-	} else if (mini_type_is_vtype (cfg, sig->ret)) {
-		MonoInst *temp = mono_compile_create_var (cfg, sig->ret, OP_LOCAL);
+	} else if (mini_type_is_vtype (cfg, sig_ret)) {
+		MonoInst *temp = mono_compile_create_var (cfg, sig_ret, OP_LOCAL);
 		MonoInst *loada;
 
 		temp->backend.is_pinvoke = sig->pinvoke;
@@ -2381,7 +2383,7 @@
 		call->inst.dreg = temp->dreg;
 
 		call->vret_var = loada;
-	} else if (!MONO_TYPE_IS_VOID (sig->ret))
+	} else if (!MONO_TYPE_IS_VOID (sig_ret))
 		call->inst.dreg = alloc_dreg (cfg, call->inst.type);
 
 #ifdef MONO_ARCH_SOFT_FLOAT_FALLBACK

Modified: mono/mini/mini-amd64.c
===================================================================
@@ -1004,7 +1004,7 @@
 		case MONO_TYPE_VALUETYPE: {
 			guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0;
 
-			add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE, &tmp_gr, &tmp_fr, &tmp_stacksize);
+			add_valuetype (gsctx, sig, &cinfo->ret, ret_type, TRUE, &tmp_gr, &tmp_fr, &tmp_stacksize);
 			if (cinfo->ret.storage == ArgOnStack) {
 				cinfo->vtype_retaddr = TRUE;
 				/* The caller passes the address where the value is stored */
@@ -1020,7 +1020,7 @@
 		case MONO_TYPE_VOID:
 			break;
 		default:
-			g_error ("Can't handle as return value 0x%x", sig->ret->type);
+			g_error ("Can't handle as return value 0x%x", ret_type->type);
 		}
 	}
 
@@ -1212,7 +1212,8 @@
 	c1 = get_call_info (NULL, NULL, caller_sig);
 	c2 = get_call_info (NULL, NULL, callee_sig);
 	res = c1->stack_usage >= c2->stack_usage;
-	if (callee_sig->ret && MONO_TYPE_ISSTRUCT (callee_sig->ret) && c2->ret.storage != ArgValuetypeInReg)
+	MonoType *callee_ret = callee_sig->ret;
+	if (callee_ret && MONO_TYPE_ISSTRUCT (callee_ret) && c2->ret.storage != ArgValuetypeInReg)
 		/* An address on the callee's stack is passed as the first argument */
 		res = FALSE;
 
@@ -1608,6 +1609,7 @@
 void
 mono_arch_fill_argument_info (MonoCompile *cfg)
 {
+	MonoType *sig_ret;
 	MonoMethodSignature *sig;
 	MonoMethodHeader *header;
 	MonoInst *ins;
@@ -1619,19 +1621,19 @@
 	sig = mono_method_signature (cfg->method);
 
 	cinfo = cfg->arch.cinfo;
-
+	sig_ret = sig->ret;
 	/*
 	 * Contrary to mono_arch_allocate_vars (), the information should describe
 	 * where the arguments are at the beginning of the method, not where they can be 
 	 * accessed during the execution of the method. The later makes no sense for the 
 	 * global register allocator, since a variable can be in more than one location.
 	 */
-	if (sig->ret->type != MONO_TYPE_VOID) {
+	if (sig_ret->type != MONO_TYPE_VOID) {
 		switch (cinfo->ret.storage) {
 		case ArgInIReg:
 		case ArgInFloatSSEReg:
 		case ArgInDoubleSSEReg:
-			if ((MONO_TYPE_ISSTRUCT (sig->ret) && !mono_class_from_mono_type (sig->ret)->enumtype) || ((sig->ret->type == MONO_TYPE_TYPEDBYREF) && cinfo->vtype_retaddr)) {
+			if ((MONO_TYPE_ISSTRUCT (sig_ret) && !mono_class_from_mono_type (sig_ret)->enumtype) || ((sig_ret->type == MONO_TYPE_TYPEDBYREF) && cinfo->vtype_retaddr)) {
 				cfg->vret_addr->opcode = OP_REGVAR;
 				cfg->vret_addr->inst_c0 = cinfo->ret.reg;
 			}
@@ -1686,6 +1688,7 @@
 void
 mono_arch_allocate_vars (MonoCompile *cfg)
 {
+	MonoType *sig_ret;
 	MonoMethodSignature *sig;
 	MonoMethodHeader *header;
 	MonoInst *ins;
@@ -1699,6 +1702,7 @@
 	sig = mono_method_signature (cfg->method);
 
 	cinfo = cfg->arch.cinfo;
+	sig_ret = sig->ret;
 
 	mono_arch_compute_omit_fp (cfg);
 
@@ -1740,12 +1744,12 @@
 			}
 	}
 
-	if (sig->ret->type != MONO_TYPE_VOID) {
+	if (sig_ret->type != MONO_TYPE_VOID) {
 		switch (cinfo->ret.storage) {
 		case ArgInIReg:
 		case ArgInFloatSSEReg:
 		case ArgInDoubleSSEReg:
-			if ((MONO_TYPE_ISSTRUCT (sig->ret) && !mono_class_from_mono_type (sig->ret)->enumtype) || ((sig->ret->type == MONO_TYPE_TYPEDBYREF) && cinfo->vtype_retaddr)) {
+			if ((MONO_TYPE_ISSTRUCT (sig_ret) && !mono_class_from_mono_type (sig_ret)->enumtype) || ((sig_ret->type == MONO_TYPE_TYPEDBYREF) && cinfo->vtype_retaddr)) {
 				if (cfg->globalra) {
 					cfg->vret_addr->opcode = OP_REGVAR;
 					cfg->vret_addr->inst_c0 = cinfo->ret.reg;
@@ -2136,10 +2140,10 @@
 	ArgInfo *ainfo;
 	int j;
 	LLVMCallInfo *linfo;
-	MonoType *t;
+	MonoType *t, *sig_ret;
 
 	n = sig->param_count + sig->hasthis;
-
+	sig_ret = sig->ret;
 	cinfo = get_call_info (cfg->generic_sharing_context, cfg->mempool, sig);
 
 	linfo = mono_mempool_alloc0 (cfg->mempool, sizeof (LLVMCallInfo) + (sizeof (LLVMArgInfo) * n));
@@ -2162,7 +2166,7 @@
 			linfo->ret.pair_storage [j] = arg_storage_to_llvm_arg_storage (cfg, cinfo->ret.pair_storage [j]);
 	}
 
-	if (MONO_TYPE_ISSTRUCT (sig->ret) && cinfo->ret.storage == ArgInIReg) {
+	if (MONO_TYPE_ISSTRUCT (sig_ret) && cinfo->ret.storage == ArgInIReg) {
 		/* Vtype returned using a hidden argument */
 		linfo->ret.storage = LLVMArgVtypeRetAddr;
 		linfo->vret_arg_index = cinfo->vret_arg_index;
@@ -2394,7 +2398,7 @@
 	if (!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG) && (n == sig->sentinelpos))
 		emit_sig_cookie (cfg, call, cinfo);
 
-	if (sig->ret && MONO_TYPE_ISSTRUCT (sig->ret)) {
+	if (sig_ret && MONO_TYPE_ISSTRUCT (sig_ret)) {
 		MonoInst *vtarg;
 
 		if (cinfo->ret.storage == ArgValuetypeInReg) {
@@ -2834,8 +2838,9 @@
 	MonoMethodSignature *sig = dinfo->sig;
 	guint8 *ret = ((DynCallArgs*)buf)->ret;
 	mgreg_t res = ((DynCallArgs*)buf)->res;
+	MonoType *sig_ret = sig->ret;
 
-	switch (mono_type_get_underlying_type (sig->ret)->type) {
+	switch (mono_type_get_underlying_type (sig_ret)->type) {
 	case MONO_TYPE_VOID:
 		*(gpointer*)ret = NULL;
 		break;
@@ -2876,7 +2881,7 @@
 		*(guint64*)ret = res;
 		break;
 	case MONO_TYPE_GENERICINST:
-		if (MONO_TYPE_IS_REFERENCE (sig->ret)) {
+		if (MONO_TYPE_IS_REFERENCE (sig_ret)) {
 			*(gpointer*)ret = GREG_TO_PTR(res);
 			break;
 		} else {

Modified: mono/mini/mini-x86.c
===================================================================
@@ -445,7 +445,7 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 		case MONO_TYPE_TYPEDBYREF: {
 			guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0;
 
-			add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE, &tmp_gr, NULL, &tmp_fr, &tmp_stacksize);
+			add_valuetype (gsctx, sig, &cinfo->ret, ret_type, TRUE, &tmp_gr, NULL, &tmp_fr, &tmp_stacksize);
 			if (cinfo->ret.storage == ArgOnStack) {
 				cinfo->vtype_retaddr = TRUE;
 				/* The caller passes the address where the value is stored */
@@ -462,7 +462,7 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 			cinfo->ret.storage = ArgNone;
 			break;
 		default:
-			g_error ("Can't handle as return value 0x%x", sig->ret->type);
+			g_error ("Can't handle as return value 0x%x", ret_type->type);
 		}
 	}
 
@@ -706,13 +706,15 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 gboolean
 mono_x86_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig)
 {
+	MonoType *callee_ret;
 	CallInfo *c1, *c2;
 	gboolean res;
 
 	c1 = get_call_info (NULL, NULL, caller_sig);
 	c2 = get_call_info (NULL, NULL, callee_sig);
 	res = c1->stack_usage >= c2->stack_usage;
-	if (callee_sig->ret && MONO_TYPE_ISSTRUCT (callee_sig->ret) && c2->ret.storage != ArgValuetypeInReg)
+	callee_ret = callee_sig->ret;
+	if (callee_ret && MONO_TYPE_ISSTRUCT (callee_ret) && c2->ret.storage != ArgValuetypeInReg)
 		/* An address on the callee's stack is passed as the first argument */
 		res = FALSE;
 
@@ -1187,16 +1189,18 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 void
 mono_arch_create_vars (MonoCompile *cfg)
 {
+	MonoType *sig_ret;
 	MonoMethodSignature *sig;
 	CallInfo *cinfo;
 
 	sig = mono_method_signature (cfg->method);
 
 	cinfo = get_call_info (cfg->generic_sharing_context, cfg->mempool, sig);
+	sig_ret = sig->ret;
 
 	if (cinfo->ret.storage == ArgValuetypeInReg)
 		cfg->ret_var_is_local = TRUE;
-	if ((cinfo->ret.storage != ArgValuetypeInReg) && (MONO_TYPE_ISSTRUCT (sig->ret) || mini_is_gsharedvt_variable_type (cfg, sig->ret))) {
+	if ((cinfo->ret.storage != ArgValuetypeInReg) && (MONO_TYPE_ISSTRUCT (sig_ret) || mini_is_gsharedvt_variable_type (cfg, sig_ret))) {
 		cfg->vret_addr = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_ARG);
 	}
 
@@ -1264,11 +1268,12 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 	CallInfo *cinfo;
 	ArgInfo *ainfo;
 	LLVMCallInfo *linfo;
-	MonoType *t;
+	MonoType *t, *sig_ret;
 
 	n = sig->param_count + sig->hasthis;
 
 	cinfo = get_call_info (cfg->generic_sharing_context, cfg->mempool, sig);
+	sig_ret = sig->ret;
 
 	linfo = mono_mempool_alloc0 (cfg->mempool, sizeof (LLVMCallInfo) + (sizeof (LLVMArgInfo) * n));
 
@@ -1294,13 +1299,13 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 		*/
 	}
 
-	if (mini_type_is_vtype (cfg, sig->ret) && cinfo->ret.storage == ArgInIReg) {
+	if (mini_type_is_vtype (cfg, sig_ret) && cinfo->ret.storage == ArgInIReg) {
 		/* Vtype returned using a hidden argument */
 		linfo->ret.storage = LLVMArgVtypeRetAddr;
 		linfo->vret_arg_index = cinfo->vret_arg_index;
 	}
 
-	if (mini_type_is_vtype (cfg, sig->ret) && cinfo->ret.storage != ArgInIReg) {
+	if (mini_type_is_vtype (cfg, sig_ret) && cinfo->ret.storage != ArgInIReg) {
 		// FIXME:
 		cfg->exception_message = g_strdup ("vtype ret in call");
 		cfg->disable_llvm = TRUE;
@@ -1386,6 +1391,7 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 void
 mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
 {
+	MonoType *sig_ret;
 	MonoInst *arg, *in;
 	MonoMethodSignature *sig;
 	int i, j, n;
@@ -1394,6 +1400,7 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 
 	sig = call->signature;
 	n = sig->param_count + sig->hasthis;
+	sig_ret = sig->ret;
 
 	cinfo = get_call_info (cfg->generic_sharing_context, cfg->mempool, sig);
 
@@ -1413,7 +1420,7 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 		}
 	}
 
-	if (sig->ret && MONO_TYPE_ISSTRUCT (sig->ret)) {
+	if (sig_ret && MONO_TYPE_ISSTRUCT (sig_ret)) {
 		if (cinfo->ret.storage == ArgValuetypeInReg) {
 			/*
 			 * Tell the JIT to use a more efficient calling convention: call using
@@ -1571,7 +1578,7 @@ static const guint32 *callconv_param_regs(MonoMethodSignature *sig)
 		}
 	}
 
-	if (sig->ret && (MONO_TYPE_ISSTRUCT (sig->ret) || cinfo->vtype_retaddr)) {
+	if (sig_ret && (MONO_TYPE_ISSTRUCT (sig_ret) || cinfo->vtype_retaddr)) {
 		MonoInst *vtarg;
 
 		if (cinfo->ret.storage == ArgValuetypeInReg) {

Modified: mono/mini/mini.c
===================================================================
@@ -6448,6 +6448,7 @@ void *mono_global_codeman_reserve (int size)
 		 */
 #ifdef MONO_ARCH_DYN_CALL_SUPPORTED
 		if (mono_aot_only || debug_options.dyn_runtime_invoke) {
+			MonoType *ret_type;
 			MonoMethodSignature *sig = mono_method_signature (method);
 			gboolean supported = TRUE;
 			int i;
@@ -6468,8 +6469,9 @@ void *mono_global_codeman_reserve (int size)
 			if (supported)
 				info->dyn_call_info = mono_arch_dyn_call_prepare (sig);
 
+			ret_type = sig->ret;
 			if (info->dyn_call_info) {
-				switch (sig->ret->type) {
+				switch (ret_type->type) {
 				case MONO_TYPE_VOID:
 					break;
 				case MONO_TYPE_I1:
@@ -6486,7 +6488,7 @@ void *mono_global_codeman_reserve (int size)
 				case MONO_TYPE_CHAR:
 				case MONO_TYPE_R4:
 				case MONO_TYPE_R8:
-					info->ret_box_class = mono_class_from_mono_type (sig->ret);
+					info->ret_box_class = mono_class_from_mono_type (ret_type);
 					break;
 				case MONO_TYPE_PTR:
 					info->ret_box_class = mono_defaults.int_class;
@@ -6498,11 +6500,11 @@ void *mono_global_codeman_reserve (int size)
 				case MONO_TYPE_OBJECT:
 					break;
 				case MONO_TYPE_GENERICINST:
-					if (!MONO_TYPE_IS_REFERENCE (sig->ret))
-						info->ret_box_class = mono_class_from_mono_type (sig->ret);
+					if (!MONO_TYPE_IS_REFERENCE (ret_type))
+						info->ret_box_class = mono_class_from_mono_type (ret_type);
 					break;
 				case MONO_TYPE_VALUETYPE:
-					info->ret_box_class = mono_class_from_mono_type (sig->ret);
+					info->ret_box_class = mono_class_from_mono_type (ret_type);
 					break;
 				default:
 					g_assert_not_reached ();

   Commit: a85d5e028536350f24bc58d22bebd940074bb54f
   Author: Rodrigo Kumpera <[email protected]> (kumpera)
     Date: 2013-10-31 23:30:09 GMT
      URL: https://github.com/mono/mono/commit/a85d5e028536350f24bc58d22bebd940074bb54f

[jit] Clean up emit_init_rvar and reduce code duplication.

Changed paths:
  M mono/mini/method-to-ir.c

Modified: mono/mini/method-to-ir.c
===================================================================
@@ -5573,35 +5573,34 @@
 #endif
 
 static void
-emit_init_rvar (MonoCompile *cfg, MonoInst *rvar, MonoType *rtype)
+emit_init_rvar (MonoCompile *cfg, int dreg, MonoType *rtype)
 {
 	static double r8_0 = 0.0;
 	MonoInst *ins;
 
-	switch (rvar->type) {
-	case STACK_I4:
-		MONO_EMIT_NEW_ICONST (cfg, rvar->dreg, 0);
-		break;
-	case STACK_I8:
-		MONO_EMIT_NEW_I8CONST (cfg, rvar->dreg, 0);
-		break;
-	case STACK_PTR:
-	case STACK_MP:
-	case STACK_OBJ:
-		MONO_EMIT_NEW_PCONST (cfg, rvar->dreg, 0);
-		break;
-	case STACK_R8:
+	int t = rtype->type;
+
+	if (t == MONO_TYPE_VALUETYPE && rtype->data.klass->enumtype)
+		t = mono_class_enum_basetype (rtype->data.klass)->type;
+	if (rtype->byref) {
+		MONO_EMIT_NEW_PCONST (cfg, dreg, NULL);
+	} else if (t >= MONO_TYPE_BOOLEAN && t <= MONO_TYPE_U4) {
+		MONO_EMIT_NEW_ICONST (cfg, dreg, 0);
+	} else if (t == MONO_TYPE_I8 || t == MONO_TYPE_U8) {
+		MONO_EMIT_NEW_I8CONST (cfg, dreg, 0);
+	} else if (t == MONO_TYPE_R4 || t == MONO_TYPE_R8) {
 		MONO_INST_NEW (cfg, ins, OP_R8CONST);
 		ins->type = STACK_R8;
 		ins->inst_p0 = (void*)&r8_0;
-		ins->dreg = rvar->dreg;
+		ins->dreg = dreg;
 		MONO_ADD_INS (cfg->cbb, ins);
-		break;
-	case STACK_VTYPE:
-		MONO_EMIT_NEW_VZERO (cfg, rvar->dreg, mono_class_from_mono_type (rtype));
-		break;
-	default:
-		g_assert_not_reached ();
+	} else if ((t == MONO_TYPE_VALUETYPE) || (t == MONO_TYPE_TYPEDBYREF) ||
+		   ((t == MONO_TYPE_GENERICINST) && mono_type_generic_inst_is_valuetype (rtype))) {
+		MONO_EMIT_NEW_VZERO (cfg, dreg, mono_class_from_mono_type (rtype));
+	} else if (((t == MONO_TYPE_VAR) || (t == MONO_TYPE_MVAR)) && mini_type_var_is_vt (cfg, rtype)) {
+		MONO_EMIT_NEW_VZERO (cfg, dreg, mono_class_from_mono_type (rtype));
+	} else {
+		MONO_EMIT_NEW_PCONST (cfg, dreg, NULL);
 	}
 }
 
@@ -5766,7 +5765,7 @@
 					if (bb->last_ins && bb->last_ins->opcode == OP_NOT_REACHED) {
 						cfg->cbb = bb;
 
-						emit_init_rvar (cfg, rvar, fsig->ret);
+						emit_init_rvar (cfg, rvar->dreg, fsig->ret);
 					}
 				}
 			}
@@ -5780,7 +5779,7 @@
 			 * set, so set it to a dummy value.
 			 */
 			if (!ret_var_set)
-				emit_init_rvar (cfg, rvar, fsig->ret);
+				emit_init_rvar (cfg, rvar->dreg, fsig->ret);
 
 			EMIT_NEW_TEMPLOAD (cfg, ins, rvar->inst_c0);
 			*sp++ = ins;
@@ -6478,7 +6477,6 @@ gboolean check_linkdemand (MonoCompile *cfg, MonoMethod *caller, MonoMethod *cal
 	MonoClass *klass;
 	MonoClass *constrained_call = NULL;
 	unsigned char *ip, *end, *target, *err_pos;
-	static double r8_0 = 0.0;
 	MonoMethodSignature *sig;
 	MonoGenericContext *generic_context = NULL;
 	MonoGenericContainer *generic_container = NULL;
@@ -9237,7 +9235,7 @@ gboolean check_linkdemand (MonoCompile *cfg, MonoMethod *caller, MonoMethod *cal
 				
 				if (cmethod->klass->valuetype) {
 					iargs [0] = mono_compile_create_var (cfg, &cmethod->klass->byval_arg, OP_LOCAL);
-					MONO_EMIT_NEW_VZERO (cfg, iargs [0]->dreg, cmethod->klass);
+					emit_init_rvar (cfg, iargs [0]->dreg, &cmethod->klass->byval_arg);
 					EMIT_NEW_TEMPLOADA (cfg, *sp, iargs [0]->inst_c0);
 
 					alloc = NULL;
@@ -11777,37 +11775,17 @@ gboolean check_linkdemand (MonoCompile *cfg, MonoMethod *caller, MonoMethod *cal
 		mono_emit_load_got_addr (cfg);
 
 	if (init_locals) {
-		MonoInst *store;
-
 		cfg->cbb = init_localsbb;
 		cfg->ip = NULL;
 		for (i = 0; i < header->num_locals; ++i) {
-			MonoType *ptype = header->locals [i];
-			int t = ptype->type;
-			dreg = cfg->locals [i]->dreg;
-
-			if (t == MONO_TYPE_VALUETYPE && ptype->data.klass->enumtype)
-				t = mono_class_enum_basetype (ptype->data.klass)->type;
-			if (ptype->byref) {
-				MONO_EMIT_NEW_PCONST (cfg, dreg, NULL);
-			} else if (t >= MONO_TYPE_BOOLEAN && t <= MONO_TYPE_U4) {
-				MONO_EMIT_NEW_ICONST (cfg, cfg->locals [i]->dreg, 0);
-			} else if (t == MONO_TYPE_I8 || t == MONO_TYPE_U8) {
-				MONO_EMIT_NEW_I8CONST (cfg, cfg->locals [i]->dreg, 0);
-			} else if (t == MONO_TYPE_R4 || t == MONO_TYPE_R8) {
-				MONO_INST_NEW (cfg, ins, OP_R8CONST);
-				ins->type = STACK_R8;
-				ins->inst_p0 = (void*)&r8_0;
-				ins->dreg = alloc_dreg (cfg, STACK_R8);
-				MONO_ADD_INS (init_localsbb, ins);
-				EMIT_NEW_LOCSTORE (cfg, store, i, ins);
-			} else if ((t == MONO_TYPE_VALUETYPE) || (t == MONO_TYPE_TYPEDBYREF) ||
-				   ((t == MONO_TYPE_GENERICINST) && mono_type_generic_inst_is_valuetype (ptype))) {
-				MONO_EMIT_NEW_VZERO (cfg, dreg, mono_class_from_mono_type (ptype));
-			} else if (((t == MONO_TYPE_VAR) || (t == MONO_TYPE_MVAR)) && mini_type_var_is_vt (cfg, ptype)) {
-				MONO_EMIT_NEW_VZERO (cfg, dreg, mono_class_from_mono_type (ptype));
+			MonoInst *var = cfg->locals [i];
+			if (COMPILE_SOFT_FLOAT (cfg)) {
+				MonoInst *store;
+				int reg = alloc_dreg (cfg, var->type);
+				emit_init_rvar (cfg, reg, header->locals [i]);
+				EMIT_NEW_LOCSTORE (cfg, store, i, cfg->cbb->last_ins);
 			} else {
-				MONO_EMIT_NEW_PCONST (cfg, dreg, NULL);
+				emit_init_rvar (cfg, var->dreg, header->locals [i]);
 			}
 		}
 	}

   Commit: 98d59927c633656d7b6ecba040815f8ad12d2a64
   Author: Rodrigo Kumpera <[email protected]> (kumpera)
     Date: 2013-10-31 23:34:04 GMT
      URL: https://github.com/mono/mono/commit/98d59927c633656d7b6ecba040815f8ad12d2a64

[jit] The AggressiveInlining hint now triggers class initialization so more stuff gets force-inlined.

Changed paths:
  M mono/mini/method-to-ir.c

Modified: mono/mini/method-to-ir.c
===================================================================
@@ -4463,7 +4463,13 @@
 	 * inside the inlined code
 	 */
 	if (!(cfg->opt & MONO_OPT_SHARED)) {
-		if (method->klass->flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) {
+		/* The AggressiveInlining hint is a good excuse to force that cctor to run. */
+		if (method->iflags & METHOD_IMPL_ATTRIBUTE_AGGRESSIVE_INLINING) {
+			vtable = mono_class_vtable (cfg->domain, method->klass);
+			if (!vtable)
+				return FALSE;
+			mono_runtime_class_init (vtable);
+		} if (method->klass->flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) {
 			if (cfg->run_cctors && method->klass->has_cctor) {
 				/*FIXME it would easier and lazier to just use mono_class_try_get_vtable */
 				if (!method->klass->runtime_info)


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.