Author: mprobst
Date: 2007-10-11 08:19:00 -0400 (Thu, 11 Oct 2007)
New Revision: 87331
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/metadata-internals.h
trunk/mono/mono/metadata/metadata.c
trunk/mono/mono/mini/ChangeLog
trunk/mono/mono/mini/generic-sharing.c
trunk/mono/mono/mini/mini-alpha.c
trunk/mono/mono/mini/mini-amd64.c
trunk/mono/mono/mini/mini-arm.c
trunk/mono/mono/mini/mini-hppa.c
trunk/mono/mono/mini/mini-ia64.c
trunk/mono/mono/mini/mini-mips.c
trunk/mono/mono/mini/mini-ppc.c
trunk/mono/mono/mini/mini-s390.c
trunk/mono/mono/mini/mini-s390x.c
trunk/mono/mono/mini/mini-sparc.c
trunk/mono/mono/mini/mini-x86.c
trunk/mono/mono/mini/mini.c
trunk/mono/mono/mini/mini.h
Log:
2007-10-11 Mark Probst <[EMAIL PROTECTED]>
* metadata.c, metadata-internals.h: Generalized
mono_type_stack_size() to mono_type_stack_size_internal() which
takes an additional argument specifying whether it allows open
types.
2007-10-11 Mark Probst <[EMAIL PROTECTED]>
* mini.h, mini.c: Introduced the MonoGenericSharingContext, which
replaces the generic_shared flag and will carry more information
in the future.
* generic-sharing.c: Added mini_type_stack_size() which allows
allows open types if given a generic sharing context.
mini_get_basic_type_from_generic() takes a
MonoGenericSharingContext* instead of a MonoCompile* now.
* mini-alpha.c, mini-amd64.c, mini-arm.c, mini-hppa.c,
mini-ia64.c, mini-mips.c, mini-ppc.c, mini-s390.c, mini-s390x.c,
mini-sparc.c, mini-x86.c: Trivial changes required by the two
changes above. Just passing arguments through to the right
places.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/metadata/ChangeLog 2007-10-11 12:19:00 UTC (rev 87331)
@@ -1,3 +1,10 @@
+2007-10-11 Mark Probst <[EMAIL PROTECTED]>
+
+ * metadata.c, metadata-internals.h: Generalized
+ mono_type_stack_size() to mono_type_stack_size_internal() which
+ takes an additional argument specifying whether it allows open
+ types.
+
2007-10-10 Rodrigo Kumpera <[EMAIL PROTECTED]>
* verify.c (do_invoke_method): handle typedbyref params
Modified: trunk/mono/mono/metadata/metadata-internals.h
===================================================================
--- trunk/mono/mono/metadata/metadata-internals.h 2007-10-11 11:41:44 UTC
(rev 87330)
+++ trunk/mono/mono/metadata/metadata-internals.h 2007-10-11 12:19:00 UTC
(rev 87331)
@@ -420,5 +420,8 @@
MonoGenericInst *
mono_get_shared_generic_inst (MonoGenericContainer *container) MONO_INTERNAL;
+int
+mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open)
MONO_INTERNAL;
+
#endif /* __MONO_METADATA_INTERNALS_H__ */
Modified: trunk/mono/mono/metadata/metadata.c
===================================================================
--- trunk/mono/mono/metadata/metadata.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/metadata/metadata.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -3640,6 +3640,12 @@
int
mono_type_stack_size (MonoType *t, int *align)
{
+ return mono_type_stack_size_internal (t, align, FALSE);
+}
+
+int
+mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open)
+{
int tmp;
g_assert (t != NULL);
@@ -3689,7 +3695,7 @@
guint32 size;
if (t->data.klass->enumtype)
- return mono_type_stack_size
(t->data.klass->enum_basetype, align);
+ return mono_type_stack_size_internal
(t->data.klass->enum_basetype, align, allow_open);
else {
size = mono_class_value_size (t->data.klass,
(guint32*)align);
@@ -3706,11 +3712,12 @@
MonoGenericClass *gclass = t->data.generic_class;
MonoClass *container_class = gclass->container_class;
- g_assert (!gclass->context.class_inst->is_open);
+ if (!allow_open)
+ g_assert (!gclass->context.class_inst->is_open);
if (container_class->valuetype) {
if (container_class->enumtype)
- return mono_type_stack_size
(container_class->enum_basetype, align);
+ return mono_type_stack_size_internal
(container_class->enum_basetype, align, allow_open);
else {
guint32 size = mono_class_value_size
(mono_class_from_mono_type (t), (guint32*)align);
Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/ChangeLog 2007-10-11 12:19:00 UTC (rev 87331)
@@ -1,4 +1,20 @@
+2007-10-11 Mark Probst <[EMAIL PROTECTED]>
+ * mini.h, mini.c: Introduced the MonoGenericSharingContext, which
+ replaces the generic_shared flag and will carry more information
+ in the future.
+
+ * generic-sharing.c: Added mini_type_stack_size() which allows
+ allows open types if given a generic sharing context.
+ mini_get_basic_type_from_generic() takes a
+ MonoGenericSharingContext* instead of a MonoCompile* now.
+
+ * mini-alpha.c, mini-amd64.c, mini-arm.c, mini-hppa.c,
+ mini-ia64.c, mini-mips.c, mini-ppc.c, mini-s390.c, mini-s390x.c,
+ mini-sparc.c, mini-x86.c: Trivial changes required by the two
+ changes above. Just passing arguments through to the right
+ places.
+
Wed Oct 10 19:44:42 CEST 2007 Paolo Molaro <[EMAIL PROTECTED]>
* mini-arm.c: unify the call emission to emit_code_seq().
Modified: trunk/mono/mono/mini/generic-sharing.c
===================================================================
--- trunk/mono/mono/mini/generic-sharing.c 2007-10-11 11:41:44 UTC (rev
87330)
+++ trunk/mono/mono/mini/generic-sharing.c 2007-10-11 12:19:00 UTC (rev
87331)
@@ -209,12 +209,18 @@
}
MonoType*
-mini_get_basic_type_from_generic (MonoCompile *cfg, MonoType *type)
+mini_get_basic_type_from_generic (MonoGenericSharingContext *gsctx, MonoType
*type)
{
if (!type->byref && (type->type == MONO_TYPE_VAR || type->type ==
MONO_TYPE_MVAR)) {
/* FIXME: we support sharing only of reference types */
- g_assert (cfg->generic_shared);
+ g_assert (gsctx);
return &mono_defaults.object_class->byval_arg;
}
return type;
}
+
+int
+mini_type_stack_size (MonoGenericSharingContext *gsctx, MonoType *t, int
*align)
+{
+ return mono_type_stack_size_internal (t, align, gsctx != NULL);
+}
Modified: trunk/mono/mono/mini/mini-alpha.c
===================================================================
--- trunk/mono/mono/mini/mini-alpha.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-alpha.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -134,7 +134,7 @@
ArgInfo args [1];
} CallInfo;
-static CallInfo* get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke);
+static CallInfo* get_call_info (MonoGenericSharingContext *gsctx,
MonoMethodSignature *sig, gboolean is_pinvoke);
static unsigned int *emit_call(MonoCompile *cfg, unsigned int *code,
guint32 patch_type, gconstpointer data);
@@ -195,7 +195,7 @@
}
static void
-add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
+add_valuetype (MonoGenericSharingContext *ctx, MonoMethodSignature *sig,
ArgInfo *ainfo, MonoType *type,
gboolean is_return,
guint32 *gr, guint32 *fr, guint32 *stack_size)
{
@@ -211,7 +211,7 @@
else if (sig->pinvoke)
size = mono_type_native_stack_size (&klass->byval_arg, NULL);
else
- size = mono_type_stack_size (&klass->byval_arg, NULL);
+ size = mini_type_stack_size (gsctx, &klass->byval_arg, NULL);
if (!sig->pinvoke || (size == 0) || is_return) {
/* Allways pass in memory */
@@ -394,7 +394,7 @@
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
if (cinfo->ret.storage == ArgValuetypeInReg)
cfg->ret_var_is_local = TRUE;
@@ -1341,7 +1341,7 @@
sig = mono_method_signature (method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
if (sig->ret->type != MONO_TYPE_VOID) {
if ((cinfo->ret.storage == ArgInIReg) &&
@@ -1500,7 +1500,7 @@
offset = cfg->arch.args_save_area_offset;
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
if (sig->ret->type != MONO_TYPE_VOID)
{
@@ -1742,7 +1742,7 @@
MonoJitArgumentInfo *arg_info)
{
int k;
- CallInfo *cinfo = get_call_info (csig, FALSE);
+ CallInfo *cinfo = get_call_info (NULL, csig, FALSE);
guint32 args_size = cinfo->stack_usage;
ALPHA_DEBUG("mono_arch_get_argument_info");
@@ -4312,7 +4312,7 @@
int this_reg, int this_type, int vt_reg)
{
MonoCallInst *call = (MonoCallInst*)inst;
- CallInfo * cinfo = get_call_info (inst->signature, FALSE);
+ CallInfo * cinfo = get_call_info (cfg->generic_sharing_context,
inst->signature, FALSE);
CFG_DEBUG(2) ALPHA_DEBUG("mono_arch_emit_this_vret_args");
@@ -4465,7 +4465,7 @@
* For x86 win32, see ???.
*/
static CallInfo*
-get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
+get_call_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig,
gboolean is_pinvoke)
{
guint32 i, gr, fr, *pgr, *pfr;
MonoType *ret_type;
@@ -4535,7 +4535,7 @@
{
guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0;
- add_valuetype (sig, &cinfo->ret, sig->ret, TRUE,
+ add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
if (cinfo->ret.storage == ArgOnStack)
@@ -4636,7 +4636,7 @@
case MONO_TYPE_VALUETYPE:
/* FIXME: */
/* We allways pass valuetypes on the stack */
- add_valuetype (sig, ainfo, sig->params [i],
+ add_valuetype (gsctx, sig, ainfo, sig->params [i],
FALSE, pgr, pfr, &stack_size);
break;
case MONO_TYPE_TYPEDBYREF:
@@ -4794,7 +4794,7 @@
n = sig->param_count + sig->hasthis;
// Collect info about method we age going to call
- cinfo = get_call_info (sig, sig->pinvoke);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, sig->pinvoke);
CFG_DEBUG(3) g_print("ALPHA: Will call %s method with %d(%d) params.
RetType: %s(0x%X)\n",
sig->pinvoke ? "PInvoke" : "Managed",
@@ -4887,7 +4887,7 @@
size = mono_type_native_stack_size (&in->klass->byval_arg,
&align);
else
- size = mono_type_stack_size (&in->klass->byval_arg, &align);
+ size = mini_type_stack_size (cfg->generic_sharing_context,
&in->klass->byval_arg, &align);
if (ainfo->storage == ArgAggregate)
{
@@ -5173,7 +5173,7 @@
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
for (i = 0; i < sig->param_count + sig->hasthis; ++i)
{
@@ -5355,7 +5355,7 @@
/* Allocate a new area on the stack and save arguments there */
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
n = sig->param_count + sig->hasthis;
@@ -5604,7 +5604,7 @@
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
/* if (cfg->arch.omit_fp) {
cfg->flags |= MONO_CFG_HAS_SPILLUP;
Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-amd64.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -360,7 +360,7 @@
}
static void
-add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
+add_valuetype (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig,
ArgInfo *ainfo, MonoType *type,
gboolean is_return,
guint32 *gr, guint32 *fr, guint32 *stack_size)
{
@@ -373,7 +373,7 @@
if (sig->pinvoke)
size = mono_type_native_stack_size (&klass->byval_arg, NULL);
else
- size = mono_type_stack_size (&klass->byval_arg, NULL);
+ size = mini_type_stack_size (gsctx, &klass->byval_arg, NULL);
if (!sig->pinvoke || (size == 0) || (size > 16)) {
/* Allways pass in memory */
@@ -505,6 +505,7 @@
int n = sig->hasthis + sig->param_count;
guint32 stack_size = 0;
CallInfo *cinfo;
+ MonoGenericSharingContext *gsctx = cfg ? cfg->generic_sharing_context :
NULL;
if (mp)
cinfo = mono_mempool_alloc0 (mp, sizeof (CallInfo) + (sizeof
(ArgInfo) * n));
@@ -517,7 +518,7 @@
/* return value */
{
ret_type = mono_type_get_underlying_type (sig->ret);
- ret_type = mini_get_basic_type_from_generic (cfg, ret_type);
+ ret_type = mini_get_basic_type_from_generic (gsctx, ret_type);
switch (ret_type->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I1:
@@ -562,7 +563,7 @@
case MONO_TYPE_VALUETYPE: {
guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0;
- add_valuetype (sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
+ add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
if (cinfo->ret.storage == ArgOnStack)
/* The caller passes the address where the
value is stored */
add_general (&gr, &stack_size, &cinfo->ret);
@@ -614,7 +615,7 @@
continue;
}
ptype = mono_type_get_underlying_type (sig->params [i]);
- ptype = mini_get_basic_type_from_generic (cfg, ptype);
+ ptype = mini_get_basic_type_from_generic (gsctx, ptype);
switch (ptype->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I1:
@@ -648,7 +649,7 @@
}
/* fall through */
case MONO_TYPE_VALUETYPE:
- add_valuetype (sig, ainfo, sig->params [i], FALSE, &gr,
&fr, &stack_size);
+ add_valuetype (gsctx, sig, ainfo, sig->params [i],
FALSE, &gr, &fr, &stack_size);
break;
case MONO_TYPE_TYPEDBYREF:
stack_size += sizeof (MonoTypedRef);
@@ -1288,7 +1289,7 @@
size = mono_type_native_stack_size
(&in->klass->byval_arg, &align);
else {
/*
- * Other backends use
mono_type_stack_size (), but that
+ * Other backends use
mini_type_stack_size (), but that
* aligns the size to 8, which is
larger than the size of
* the source, leading to reads of
invalid memory if the
* source is at the end of address
space.
Modified: trunk/mono/mono/mini/mini-arm.c
===================================================================
--- trunk/mono/mono/mini/mini-arm.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-arm.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -206,7 +206,7 @@
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k],
&align);
else
- size = mono_type_stack_size (csig->params [k], &align);
+ size = mini_type_stack_size (NULL, csig->params [k],
&align);
/* ignore alignment for now */
align = 1;
Modified: trunk/mono/mono/mini/mini-hppa.c
===================================================================
--- trunk/mono/mono/mini/mini-hppa.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-hppa.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -591,7 +591,7 @@
if (inst->backend.is_pinvoke && MONO_TYPE_ISSTRUCT
(inst->inst_vtype) && inst->inst_vtype->type != MONO_TYPE_TYPEDBYREF)
size = mono_class_native_size
(inst->inst_vtype->data.klass, &align);
else
- size = mono_type_stack_size (inst->inst_vtype, &align);
+ size = mini_type_stack_size
(cfg->generic_sharing_context, inst->inst_vtype, &align);
/*
* This is needed since structures containing doubles must be
doubleword
Modified: trunk/mono/mono/mini/mini-ia64.c
===================================================================
--- trunk/mono/mono/mini/mini-ia64.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-ia64.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -243,7 +243,7 @@
}
static void
-add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
+add_valuetype (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig,
ArgInfo *ainfo, MonoType *type,
gboolean is_return,
guint32 *gr, guint32 *fr, guint32 *stack_size)
{
@@ -259,7 +259,7 @@
else if (sig->pinvoke)
size = mono_type_native_stack_size (&klass->byval_arg, NULL);
else
- size = mono_type_stack_size (&klass->byval_arg, NULL);
+ size = mini_type_stack_size (gsctx, &klass->byval_arg, NULL);
if (!sig->pinvoke || (size == 0)) {
/* Allways pass in memory */
@@ -349,7 +349,7 @@
* Gude" document for more information.
*/
static CallInfo*
-get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
+get_call_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig,
gboolean is_pinvoke)
{
guint32 i, gr, fr;
MonoType *ret_type;
@@ -407,7 +407,7 @@
case MONO_TYPE_TYPEDBYREF: {
guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0;
- add_valuetype (sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
+ add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
if (cinfo->ret.storage == ArgOnStack)
/* The caller passes the address where the
value is stored */
add_general (&gr, &stack_size, &cinfo->ret);
@@ -493,7 +493,7 @@
case MONO_TYPE_TYPEDBYREF:
/* FIXME: */
/* We allways pass valuetypes on the stack */
- add_valuetype (sig, ainfo, sig->params [i], FALSE, &gr,
&fr, &stack_size);
+ add_valuetype (gsctx, sig, ainfo, sig->params [i],
FALSE, &gr, &fr, &stack_size);
break;
case MONO_TYPE_U8:
case MONO_TYPE_I8:
@@ -539,7 +539,7 @@
mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count,
MonoJitArgumentInfo *arg_info)
{
int k;
- CallInfo *cinfo = get_call_info (csig, FALSE);
+ CallInfo *cinfo = get_call_info (NULL, csig, FALSE);
guint32 args_size = cinfo->stack_usage;
/* The arguments are saved to a stack area in
mono_arch_instrument_prolog */
@@ -611,7 +611,7 @@
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
MonoInst *ins = cfg->args [i];
@@ -663,7 +663,7 @@
/* Already done */
return;
- cinfo = get_call_info (mono_method_signature (cfg->method), FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context,
mono_method_signature (cfg->method), FALSE);
header = mono_method_get_header (cfg->method);
@@ -757,7 +757,7 @@
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
/*
* Determine whenever the frame pointer can be eliminated.
@@ -947,7 +947,7 @@
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
if (cinfo->ret.storage == ArgAggregate)
cfg->ret_var_is_local = TRUE;
@@ -1036,7 +1036,7 @@
sig = call->signature;
n = sig->param_count + sig->hasthis;
- cinfo = get_call_info (sig, sig->pinvoke);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, sig->pinvoke);
if (cinfo->ret.storage == ArgAggregate) {
/* The code in emit_this_vret_arg needs a local */
@@ -1086,7 +1086,7 @@
size = mono_type_native_stack_size
(&in->klass->byval_arg, &align);
else {
/*
- * Other backends use
mono_type_stack_size (), but that
+ * Other backends use
mini_type_stack_size (), but that
* aligns the size to 8, which is
larger than the size of
* the source, leading to reads of
invalid memory if the
* source is at the end of address
space.
@@ -1926,7 +1926,7 @@
sig = mono_method_signature (method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
/* This is the opposite of the code in emit_prolog */
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
@@ -2027,7 +2027,7 @@
case OP_VCALL_MEMBASE: {
ArgStorage storage;
- cinfo = get_call_info (((MonoCallInst*)ins)->signature, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context,
((MonoCallInst*)ins)->signature, FALSE);
storage = cinfo->ret.storage;
if (storage == ArgAggregate) {
@@ -3790,7 +3790,7 @@
sig = mono_method_signature (method);
pos = 0;
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
cfg->code_size = MAX (((MonoMethodNormal *)method)->header->code_size
* 4, 512);
@@ -4028,7 +4028,7 @@
}
/* Load returned vtypes into registers if needed */
- cinfo = get_call_info (mono_method_signature (method), FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context,
mono_method_signature (method), FALSE);
ainfo = &cinfo->ret;
switch (ainfo->storage) {
case ArgAggregate:
@@ -4252,7 +4252,7 @@
/* Allocate a new area on the stack and save arguments there */
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig,
FALSE);
n = sig->param_count + sig->hasthis;
@@ -4328,7 +4328,7 @@
ia64_codegen_init (code, p);
- cinfo = get_call_info (sig, FALSE);
+ cinfo = get_call_info (cfg->generic_sharing_context, sig, FALSE);
/* Save return value + pass it to func */
switch (cinfo->ret.storage) {
@@ -4567,7 +4567,7 @@
int out_reg = cfg->arch.reg_out0;
if (vt_reg != -1) {
- CallInfo * cinfo = get_call_info (inst->signature, FALSE);
+ CallInfo * cinfo = get_call_info (cfg->generic_sharing_context,
inst->signature, FALSE);
MonoInst *vtarg;
if (cinfo->ret.storage == ArgAggregate) {
Modified: trunk/mono/mono/mini/mini-mips.c
===================================================================
--- trunk/mono/mono/mini/mini-mips.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-mips.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -397,7 +397,7 @@
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k],
&align);
else
- size = mono_type_stack_size (csig->params [k], &align);
+ size = mini_type_stack_size (NULL, csig->params [k],
&align);
/* ignore alignment for now */
align = 1;
Modified: trunk/mono/mono/mini/mini-ppc.c
===================================================================
--- trunk/mono/mono/mini/mini-ppc.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-ppc.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -201,7 +201,7 @@
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k],
&align);
else
- size = mono_type_stack_size (csig->params [k], &align);
+ size = mini_type_stack_size (NULL, csig->params [k],
&align);
/* ignore alignment for now */
align = 1;
Modified: trunk/mono/mono/mini/mini-s390.c
===================================================================
--- trunk/mono/mono/mini/mini-s390.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-s390.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -383,7 +383,7 @@
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k],
&align);
else
- size = mono_type_stack_size (csig->params [k], &align);
+ size = mini_type_stack_size (NULL, csig->params [k],
&align);
frame_size += pad = (align - (frame_size & (align - 1))) &
(align - 1);
arg_info [k].pad = pad;
Modified: trunk/mono/mono/mini/mini-s390x.c
===================================================================
--- trunk/mono/mono/mini/mini-s390x.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-s390x.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -409,7 +409,7 @@
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k],
&align);
else
- size = mono_type_stack_size (csig->params [k], &align);
+ size = mini_type_stack_size (NULL, csig->params [k],
&align);
frame_size += pad = (align - (frame_size & (align - 1))) &
(align - 1);
arg_info [k].pad = pad;
Modified: trunk/mono/mono/mini/mini-sparc.c
===================================================================
--- trunk/mono/mono/mini/mini-sparc.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-sparc.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -860,7 +860,7 @@
if (inst->backend.is_pinvoke && MONO_TYPE_ISSTRUCT
(inst->inst_vtype) && inst->inst_vtype->type != MONO_TYPE_TYPEDBYREF)
size = mono_class_native_size
(inst->inst_vtype->data.klass, &align);
else
- size = mono_type_stack_size (inst->inst_vtype, &align);
+ size = mini_type_stack_size
(m->generic_sharing_context, inst->inst_vtype, &align);
/*
* This is needed since structures containing doubles must be
doubleword
@@ -1105,7 +1105,7 @@
size = mono_type_native_stack_size
(&in->klass->byval_arg, &align);
else {
/*
- * Can't use mono_type_stack_size (),
but that
+ * Can't use mini_type_stack_size (),
but that
* aligns the size to sizeof
(gpointer), which is larger
* than the size of the source, leading
to reads of invalid
* memory if the source is at the end
of address space or
@@ -1931,7 +1931,7 @@
}
static guint32*
-emit_vret_token (MonoInst *ins, guint32 *code)
+emit_vret_token (MonoGenericSharingContext *gsctx, MonoInst *ins, guint32
*code)
{
MonoCallInst *call = (MonoCallInst*)ins;
guint32 size;
@@ -1942,7 +1942,7 @@
*/
if (call->signature->pinvoke &&
MONO_TYPE_ISSTRUCT(call->signature->ret)) {
if (call->signature->ret->type == MONO_TYPE_TYPEDBYREF)
- size = mono_type_stack_size (call->signature->ret,
NULL);
+ size = mini_type_stack_size (gsctx,
call->signature->ret, NULL);
else
size = mono_class_native_size
(call->signature->ret->data.klass, NULL);
sparc_unimp (code, size & 0xfff);
@@ -2889,7 +2889,7 @@
else
code = emit_call (cfg, code, MONO_PATCH_INFO_ABS,
call->fptr);
- code = emit_vret_token (ins, code);
+ code = emit_vret_token (cfg->generic_sharing_context,
ins, code);
code = emit_move_return_value (ins, code);
break;
case OP_FCALL_REG:
@@ -2910,7 +2910,7 @@
else
sparc_nop (code);
- code = emit_vret_token (ins, code);
+ code = emit_vret_token (cfg->generic_sharing_context,
ins, code);
code = emit_move_return_value (ins, code);
break;
case OP_FCALL_MEMBASE:
@@ -2932,7 +2932,7 @@
else
sparc_nop (code);
- code = emit_vret_token (ins, code);
+ code = emit_vret_token (cfg->generic_sharing_context,
ins, code);
code = emit_move_return_value (ins, code);
break;
case OP_SETFRET:
Modified: trunk/mono/mono/mini/mini-x86.c
===================================================================
--- trunk/mono/mono/mini/mini-x86.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini-x86.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -174,7 +174,7 @@
static void
-add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
+add_valuetype (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig,
ArgInfo *ainfo, MonoType *type,
gboolean is_return,
guint32 *gr, guint32 *fr, guint32 *stack_size)
{
@@ -185,7 +185,7 @@
if (sig->pinvoke)
size = mono_type_native_stack_size (&klass->byval_arg, NULL);
else
- size = mono_type_stack_size (&klass->byval_arg, NULL);
+ size = mini_type_stack_size (gsctx, &klass->byval_arg, NULL);
#ifdef SMALL_STRUCTS_IN_REGS
if (sig->pinvoke && is_return) {
@@ -246,6 +246,7 @@
int n = sig->hasthis + sig->param_count;
guint32 stack_size = 0;
CallInfo *cinfo;
+ MonoGenericSharingContext *gsctx = cfg ? cfg->generic_sharing_context :
NULL;
if (mp)
cinfo = mono_mempool_alloc0 (mp, sizeof (CallInfo) + (sizeof
(ArgInfo) * n));
@@ -258,7 +259,7 @@
/* return value */
{
ret_type = mono_type_get_underlying_type (sig->ret);
- ret_type = mini_get_basic_type_from_generic (cfg, ret_type);
+ ret_type = mini_get_basic_type_from_generic (gsctx, ret_type);
switch (ret_type->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I1:
@@ -301,7 +302,7 @@
case MONO_TYPE_VALUETYPE: {
guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0;
- add_valuetype (sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
+ add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE,
&tmp_gr, &tmp_fr, &tmp_stacksize);
if (cinfo->ret.storage == ArgOnStack)
/* The caller passes the address where the
value is stored */
add_general (&gr, &stack_size, &cinfo->ret);
@@ -354,7 +355,7 @@
continue;
}
ptype = mono_type_get_underlying_type (sig->params [i]);
- ptype = mini_get_basic_type_from_generic (cfg, ptype);
+ ptype = mini_get_basic_type_from_generic (gsctx, ptype);
switch (ptype->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I1:
@@ -388,7 +389,7 @@
}
/* Fall through */
case MONO_TYPE_VALUETYPE:
- add_valuetype (sig, ainfo, sig->params [i], FALSE, &gr,
&fr, &stack_size);
+ add_valuetype (gsctx, sig, ainfo, sig->params [i],
FALSE, &gr, &fr, &stack_size);
break;
case MONO_TYPE_TYPEDBYREF:
stack_size += sizeof (MonoTypedRef);
@@ -473,7 +474,7 @@
size = mono_type_native_stack_size (csig->params [k],
&align);
else {
int ialign;
- size = mono_type_stack_size (csig->params [k], &ialign);
+ size = mini_type_stack_size (NULL, csig->params [k],
&ialign);
align = ialign;
}
@@ -1018,7 +1019,7 @@
size =
mono_type_native_stack_size (&in->klass->byval_arg, &align);
else {
int ialign;
- size = mono_type_stack_size
(&in->klass->byval_arg, &ialign);
+ size = mini_type_stack_size
(cfg->generic_sharing_context, &in->klass->byval_arg, &ialign);
align = ialign;
}
arg->opcode = OP_OUTARG_VT;
Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini.c 2007-10-11 12:19:00 UTC (rev 87331)
@@ -109,7 +109,7 @@
goto exception_exit; \
} while (0)
#define GENERIC_SHARING_FAILURE do { \
- if (cfg->generic_shared) { \
+ if (cfg->generic_sharing_context) { \
/* g_print ("sharing failed for method %s.%s in
%s:%d\n", method->klass->name, method->name, __FILE__, __LINE__); */ \
cfg->exception_type =
MONO_EXCEPTION_GENERIC_SHARING_FAILED; \
goto exception_exit; \
@@ -1261,7 +1261,7 @@
* later look inside cfg and see if the arg num is
* really a reference
*/
- g_assert (cfg->generic_shared);
+ g_assert (cfg->generic_sharing_context);
inst->type = STACK_OBJ;
return;
default:
@@ -1643,7 +1643,7 @@
static guint
mini_type_to_ldind (MonoCompile* cfg, MonoType *type)
{
- if (cfg->generic_shared && !type->byref) {
+ if (cfg->generic_sharing_context && !type->byref) {
/* FIXME: all the arguments must be references for now,
* later look inside cfg and see if the arg num is
* really a reference
@@ -1657,7 +1657,7 @@
static guint
mini_type_to_stind (MonoCompile* cfg, MonoType *type)
{
- if (cfg->generic_shared && !type->byref) {
+ if (cfg->generic_sharing_context && !type->byref) {
/* FIXME: all the arguments must be references for now,
* later look inside cfg and see if the arg num is
* really a reference
@@ -2384,7 +2384,7 @@
* later look inside cfg and see if the arg num is
* really a reference
*/
- g_assert (cfg->generic_shared);
+ g_assert (cfg->generic_sharing_context);
if (arg->type != STACK_OBJ)
return 1;
return 0;
@@ -4097,7 +4097,7 @@
end = ip + header->code_size;
mono_jit_stats.cil_code_size += header->code_size;
- if (cfg->generic_shared) {
+ if (cfg->generic_sharing_context) {
g_assert (shared_context);
generic_context = shared_context;
} else if (sig->is_inflated)
@@ -4740,7 +4740,7 @@
if (!cmethod)
goto load_error;
- if (cfg->generic_shared &&
mono_method_check_context_used (cmethod, generic_context))
+ if (cfg->generic_sharing_context &&
mono_method_check_context_used (cmethod, generic_context))
GENERIC_SHARING_FAILURE;
if (mono_security_get_mode () ==
MONO_SECURITY_MODE_CAS) {
@@ -4839,7 +4839,7 @@
if (cmethod && cmethod->klass->generic_container)
UNVERIFIED;
- if (cfg->generic_shared && cmethod &&
mono_method_check_context_used (cmethod, generic_context))
+ if (cfg->generic_sharing_context && cmethod &&
mono_method_check_context_used (cmethod, generic_context))
GENERIC_SHARING_FAILURE;
CHECK_STACK (n);
@@ -5818,7 +5818,7 @@
if (!mono_class_init (cmethod->klass))
goto load_error;
- if (cfg->generic_shared &&
mono_method_check_context_used (cmethod, generic_context))
+ if (cfg->generic_sharing_context &&
mono_method_check_context_used (cmethod, generic_context))
GENERIC_SHARING_FAILURE;
if (mono_security_get_mode () ==
MONO_SECURITY_MODE_CAS) {
@@ -5930,7 +5930,7 @@
if (sp [0]->type != STACK_OBJ)
UNVERIFIED;
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
/* Needed by the code generated in inssel.brg */
@@ -5988,7 +5988,7 @@
klass = mini_get_class (method, token, generic_context);
CHECK_TYPELOAD (klass);
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
@@ -6088,7 +6088,7 @@
klass = mini_get_class (method, token, generic_context);
CHECK_TYPELOAD (klass);
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
if (mono_class_is_nullable (klass)) {
@@ -6130,7 +6130,7 @@
if (sp [0]->type != STACK_OBJ)
UNVERIFIED;
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
/* Needed by the code generated in inssel.brg */
@@ -6404,7 +6404,7 @@
if (!dont_verify && !cfg->skip_visibility &&
!mono_method_can_access_field (method, field))
FIELD_ACCESS_FAILURE;
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
g_assert (!(field->type->attrs &
FIELD_ATTRIBUTE_LITERAL));
@@ -6621,7 +6621,7 @@
klass = mini_get_class (method, token, generic_context);
CHECK_TYPELOAD (klass);
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
@@ -6699,7 +6699,7 @@
klass = mini_get_class (method, token, generic_context);
CHECK_TYPELOAD (klass);
- if (cfg->generic_shared)
+ if (cfg->generic_sharing_context)
context_used = mono_class_check_context_used
(klass, generic_context);
else
context_used = 0;
@@ -7052,7 +7052,7 @@
mono_class_init (klass);
ins->cil_code = ip;
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
loc = mono_compile_create_var (cfg,
&mono_defaults.typed_reference_class->byval_arg, OP_LOCAL);
@@ -7085,7 +7085,7 @@
}
else {
handle = mono_ldtoken (image, n, &handle_class,
generic_context);
- if (cfg->generic_shared &&
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used
(handle_class, generic_context))
GENERIC_SHARING_FAILURE;
}
@@ -7538,7 +7538,7 @@
goto load_error;
mono_class_init (cmethod->klass);
- if (cfg->generic_shared &&
mono_method_check_context_used (cmethod, generic_context))
+ if (cfg->generic_sharing_context &&
mono_method_check_context_used (cmethod, generic_context))
GENERIC_SHARING_FAILURE;
cil_method = cmethod;
@@ -7578,7 +7578,7 @@
goto load_error;
mono_class_init (cmethod->klass);
- if (cfg->generic_shared &&
mono_method_check_context_used (cmethod, generic_context))
+ if (cfg->generic_sharing_context &&
mono_method_check_context_used (cmethod, generic_context))
GENERIC_SHARING_FAILURE;
if (mono_security_get_mode () ==
MONO_SECURITY_MODE_CAS) {
@@ -7765,7 +7765,7 @@
klass = mini_get_class (method, token,
generic_context);
CHECK_TYPELOAD (klass);
- if (cfg->generic_shared &&
mono_class_check_context_used (klass, generic_context))
+ if (cfg->generic_sharing_context &&
mono_class_check_context_used (klass, generic_context))
GENERIC_SHARING_FAILURE;
if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg))
{
@@ -10675,7 +10675,8 @@
cfg->verbose_level = mini_verbose;
cfg->compile_aot = compile_aot;
cfg->skip_visibility = method->skip_visibility;
- cfg->generic_shared = try_generic_shared;
+ if (try_generic_shared)
+ cfg->generic_sharing_context =
(MonoGenericSharingContext*)&cfg->generic_sharing_context;
cfg->token_info_hash = g_hash_table_new (NULL, NULL);
if (!header) {
cfg->exception_type = MONO_EXCEPTION_INVALID_PROGRAM;
@@ -10941,7 +10942,7 @@
jinfo->used_regs = cfg->used_int_regs;
jinfo->domain_neutral = (cfg->opt & MONO_OPT_SHARED) != 0;
jinfo->cas_inited = FALSE; /* initialization delayed at the first stalk
walk using this method */
- jinfo->generic_shared = cfg->generic_shared;
+ jinfo->generic_shared = cfg->generic_sharing_context ? 1 : 0;
if (header->num_clauses) {
int i;
@@ -11210,7 +11211,7 @@
mono_internal_hash_table_insert (&target_domain->jit_code_hash,
method, cfg->jit_info);
code = cfg->native_code;
- if (cfg->generic_shared && mono_method_is_generic_sharable_impl
(method)) {
+ if (cfg->generic_sharing_context &&
mono_method_is_generic_sharable_impl (method)) {
/* g_print ("inserting method %s.%s.%s\n",
method->klass->name_space, method->klass->name, method->name); */
mono_domain_register_shared_generic (target_domain,
method_get_declaring_generic_method (method),
cfg->jit_info);
Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2007-10-11 11:41:44 UTC (rev 87330)
+++ trunk/mono/mono/mini/mini.h 2007-10-11 12:19:00 UTC (rev 87331)
@@ -533,6 +533,14 @@
#define MONO_BBLOCK_IS_IN_REGION(bblock, regtype) (((bblock)->region & (0xf <<
4)) == (regtype))
/*
+ * Will contain information on the generic type arguments in the
+ * future. For now, all arguments are always reference types.
+ */
+typedef struct {
+ int dummy;
+} MonoGenericSharingContext;
+
+/*
* Control Flow Graph and compilation unit information
*/
typedef struct {
@@ -584,6 +592,8 @@
MonoDomain *domain;
+ MonoGenericSharingContext *generic_sharing_context;
+
unsigned char *cil_start;
unsigned char *native_code;
guint code_size;
@@ -610,7 +620,6 @@
guint dont_verify_stack_merge : 1;
guint unverifiable : 1;
guint skip_visibility : 1;
- guint generic_shared : 1;
gpointer debug_info;
guint32 lmf_offset;
guint16 *intvars;
@@ -1124,6 +1133,8 @@
MonoGenericContext* mono_make_shared_context (MonoCompile *cfg,
MonoGenericContext *context) MONO_INTERNAL;
-MonoType* mini_get_basic_type_from_generic (MonoCompile *cfg, MonoType *type)
MONO_INTERNAL;
+MonoType* mini_get_basic_type_from_generic (MonoGenericSharingContext *gsctx,
MonoType *type) MONO_INTERNAL;
+int mini_type_stack_size (MonoGenericSharingContext *gsctx, MonoType *t, int
*align) MONO_INTERNAL;
+
#endif /* __MONO_MINI_H__ */
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches