2007-10-11 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Thu, 11 Oct 2007 12:19:00 +0000 (12:19 -0000)
committerMark Probst <mark.probst@gmail.com>
Thu, 11 Oct 2007 12:19:00 +0000 (12:19 -0000)
* 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  <mark.probst@gmail.com>

* 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.

svn path=/trunk/mono/; revision=87331

18 files changed:
mono/metadata/ChangeLog
mono/metadata/metadata-internals.h
mono/metadata/metadata.c
mono/mini/ChangeLog
mono/mini/generic-sharing.c
mono/mini/mini-alpha.c
mono/mini/mini-amd64.c
mono/mini/mini-arm.c
mono/mini/mini-hppa.c
mono/mini/mini-ia64.c
mono/mini/mini-mips.c
mono/mini/mini-ppc.c
mono/mini/mini-s390.c
mono/mini/mini-s390x.c
mono/mini/mini-sparc.c
mono/mini/mini-x86.c
mono/mini/mini.c
mono/mini/mini.h

index bc4262c8203521b6a7eb4ee018464e24a25161f4..15b3fea11ba096fd3238263def7a96d48cf91549 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-11  Mark Probst  <mark.probst@gmail.com>
+
+       * 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  <rkumpera@novell.com>
 
        * verify.c (do_invoke_method): handle typedbyref params
index 62896aed5b4f5294e5525c52c73a5e8cbeb592c4..b5e78b437a8fd4d9018322fd319bca36602e1ca6 100644 (file)
@@ -420,5 +420,8 @@ MonoType *mono_metadata_type_dup (MonoMemPool *mp, const MonoType *original) MON
 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__ */
 
index b756bc1cd8f97a7223b88a61eb6ff6c9e059225c..6f26c5f9784cef5485a5a4c4cf7e568780d5fefc 100644 (file)
@@ -3639,6 +3639,12 @@ mono_type_size (MonoType *t, int *align)
  */
 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;
 
@@ -3689,7 +3695,7 @@ mono_type_stack_size (MonoType *t, int *align)
                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 @@ mono_type_stack_size (MonoType *t, int *align)
                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);
 
index 0a18a3b45b6f5317440381d74ce73848082a2f6a..9e1281a4d5a0593ed0568494b67fd2ab3b782f4f 100644 (file)
@@ -1,3 +1,19 @@
+2007-10-11  Mark Probst  <mark.probst@gmail.com>
+
+       * 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 <lupus@ximian.com>
 
index 5034e4307a68b5262fe8b1d86de2a4d31a6705df..adbbdad339fb70825c41b399acef639bf8048864 100644 (file)
@@ -209,12 +209,18 @@ mono_make_shared_context (MonoCompile *cfg, MonoGenericContext *context)
 }
 
 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);
+}
index 068ce7147b3704c3b85ed1c8b98bc26f30bcf995..3707331f9ecdda6a75d2e4e23c62fd49194a3051 100644 (file)
@@ -134,7 +134,7 @@ typedef struct {
    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 @@ add_float (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo,
 }
 
 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 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
   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 @@ mono_arch_create_vars (MonoCompile *cfg)
    
   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 @@ emit_load_volatile_arguments (MonoCompile *cfg, unsigned int *code)
 
   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 @@ mono_arch_emit_prolog (MonoCompile *cfg)
    
    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 @@ mono_arch_get_argument_info (MonoMethodSignature *csig,
                              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 @@ mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst,
        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 @@ mono_arch_cleanup (void)
  * 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 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
        {
         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 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
        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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
    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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
                 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 @@ mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
 
    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 @@ mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p,
       /* 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 @@ mono_arch_allocate_vars (MonoCompile *cfg)
    
    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;
index 8381c2fa1a18ac0bfdf039cb16e021bd914b5a1c..0c3f926253da17aabb417e13e8e50d17812391f8 100644 (file)
@@ -360,7 +360,7 @@ merge_argument_class_from_type (MonoType *type, ArgumentClass class1)
 }
 
 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 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
        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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
        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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
        /* 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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
                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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
                        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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
                        }
                        /* 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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
                                        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.
index 15e08e6ec50c79ea5e0e43eb9e3dc16d39292287..0d8eb532c70d2f33c31a7eef086b9f47a840cecd 100644 (file)
@@ -206,7 +206,7 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit
                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;
index 6f5f9243f2568cd6d3403093256f1d056d070ae2..31266d573841c4bdfd38398d9b2027ba846740da 100644 (file)
@@ -591,7 +591,7 @@ mono_arch_allocate_vars (MonoCompile *m)
                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 
index 4d7706024ae0c0c0d08a273f228ebd0eae7dc1f2..1478aec28edfdb0f394124c9ba7d0f8c4730547f 100644 (file)
@@ -243,7 +243,7 @@ add_float (guint32 *gr, guint32 *fr, guint32 *stack_size, ArgInfo *ainfo, gboole
 }
 
 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 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
        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 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
  * 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 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
                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 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
                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 @@ int
 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 @@ mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
 
        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 @@ mono_ia64_alloc_stacked_registers (MonoCompile *cfg)
                /* 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 @@ mono_arch_allocate_vars (MonoCompile *cfg)
 
        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 @@ mono_arch_create_vars (MonoCompile *cfg)
 
        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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
        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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
                                        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 @@ emit_load_volatile_arguments (MonoCompile *cfg, Ia64CodegenState code)
 
        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 @@ emit_move_return_value (MonoCompile *cfg, MonoInst *ins, Ia64CodegenState code)
        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 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        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 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        }
 
        /* 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 @@ mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p, gboolean ena
                /* 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 @@ mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean ena
 
        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 @@ mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst, int this_re
        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) {
index adfe7e58ab4aea773c318a8de7608bb42bc3f3a3..22ca93ccb2aa74561bff94aae69c7d62e946fb92 100644 (file)
@@ -397,7 +397,7 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit
                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;
index 415907ac4fd64ff4d3c795e39c8c36fc2c89e808..b576e25027b369c3bc24e11ba7c1a8ed4fa7df7d 100644 (file)
@@ -201,7 +201,7 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit
                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;
index 7870c0a11588aed029e05e73e490bd8cc417a321..601de45185b401d3b32e29398d1f48d85cf4798f 100644 (file)
@@ -383,7 +383,7 @@ mono_arch_get_argument_info (MonoMethodSignature *csig,
                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;
index 86f1fd5f9843311dd99f1c15c5f529e91181847c..930bc243d58464adac1e462a1413f58cd3e72b86 100644 (file)
@@ -409,7 +409,7 @@ mono_arch_get_argument_info (MonoMethodSignature *csig,
                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;
index d0e211cd27f5925eaf051fc26a9df0314dc80dc8..07ae9bae1da1adaf5af605cb214ababcf522a4bc 100644 (file)
@@ -860,7 +860,7 @@ mono_arch_allocate_vars (MonoCompile *m)
                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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
                                        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 @@ emit_save_sp_to_lmf (MonoCompile *cfg, guint32 *code)
 }
 
 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 @@ emit_vret_token (MonoInst *ins, guint32 *code)
         */
        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 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        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 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        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 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        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:
index 4934e8a7eeb07f03883b098395c6671939a67a94..edcc73e586feee2928ec5523d55717d4a1d259c5 100644 (file)
@@ -174,7 +174,7 @@ add_float (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo, gboolean is_double)
 
 
 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 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
        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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
        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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
        /* 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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
                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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
                        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 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
                        }
                        /* 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 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit
                        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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call,
                                                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;
index 6272bf4331482d40d8515f020ad6bb2ab670cb1f..f750f956b0449a3a8b1232b3ac2c97603be19eed 100644 (file)
                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 @@ handle_enum:
                 * 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 @@ check_values_to_signature (MonoInst *args, MonoType *this, MonoMethodSignature *
 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 @@ mini_type_to_ldind (MonoCompile* cfg, MonoType *type)
 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 @@ target_type_is_incompatible (MonoCompile *cfg, MonoType *target, MonoInst *arg)
                 * 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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        }
                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        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 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                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 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
        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 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
        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_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                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);
index 15182ffc416d20dd7d7bd9bcc8327d0f9d4cf5b0..ca82cbbec6ff3c184b5a127bb009495def8fcd61 100644 (file)
@@ -532,6 +532,14 @@ enum {
 
 #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
  */
@@ -584,6 +592,8 @@ typedef struct {
        
        MonoDomain      *domain;
 
+       MonoGenericSharingContext *generic_sharing_context;
+
        unsigned char   *cil_start;
        unsigned char   *native_code;
        guint            code_size;
@@ -610,7 +620,6 @@ typedef struct {
        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 @@ gboolean mono_method_is_generic_sharable_impl (MonoMethod *method) MONO_INTERNAL
 
 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__ */