Make MonoGenericSharingContext store whenever type arguments are valuetypes or not.
authorZoltan Varga <vargaz@gmail.com>
Fri, 24 Aug 2012 17:29:03 +0000 (19:29 +0200)
committerZoltan Varga <vargaz@gmail.com>
Sun, 20 Jan 2013 12:02:11 +0000 (13:02 +0100)
mono/metadata/domain-internals.h
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c

index 92af3d0553c57eb7992a15f4cb2dcd4ce5474ac7..b9fad3052974c39851d4a0b365742be582a41ce5 100644 (file)
@@ -91,11 +91,16 @@ typedef struct {
 } MonoJitExceptionInfo;
 
 /*
- * Will contain information on the generic type arguments in the
- * future.  For now, all arguments are always reference types.
+ * Contains information about the type arguments for generic shared methods.
  */
 typedef struct {
-       int dummy;
+       /*
+        * If not NULL, determines whenever the class type arguments of the gshared method are references or vtypes.
+        * The array length is equal to class_inst->type_argv.
+        */
+       gboolean *var_is_vt;
+       /* Same for method type parameters */
+       gboolean *mvar_is_vt;
 } MonoGenericSharingContext;
 
 /* Simplified DWARF location list entry */
index e8bacb01a214cc72cc6d00c2da8fd121fe85b8fd..3b465ee2785690e5db5ac4cdad2419faa6f2c11d 100644 (file)
@@ -4643,6 +4643,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
 
        if (jinfo->has_generic_jit_info) {
                MonoGenericJitInfo *gi = mono_jit_info_get_generic_jit_info (jinfo);
+               MonoGenericSharingContext* gsctx = gi->generic_sharing_context;
                guint8 *p1;
 
                p1 = p;
@@ -4674,6 +4675,38 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
                 * when using generic sharing.
                 */
                encode_method_ref (acfg, jinfo->method, p, &p);
+
+               if (gsctx && (gsctx->var_is_vt || gsctx->mvar_is_vt)) {
+                       MonoMethodInflated *inflated;
+                       MonoGenericContext *context;
+                       MonoGenericInst *inst;
+
+                       g_assert (jinfo->method->is_inflated);
+                       inflated = (MonoMethodInflated*)jinfo->method;
+                       context = &inflated->context;
+
+                       encode_value (1, p, &p);
+                       if (context->class_inst) {
+                               inst = context->class_inst;
+
+                               encode_value (inst->type_argc, p, &p);
+                               for (i = 0; i < inst->type_argc; ++i)
+                                       encode_value (gsctx->var_is_vt [i], p, &p);
+                       } else {
+                               encode_value (0, p, &p);
+                       }
+                       if (context->method_inst) {
+                               inst = context->method_inst;
+
+                               encode_value (inst->type_argc, p, &p);
+                               for (i = 0; i < inst->type_argc; ++i)
+                                       encode_value (gsctx->mvar_is_vt [i], p, &p);
+                       } else {
+                               encode_value (0, p, &p);
+                       }
+               } else {
+                       encode_value (0, p, &p);
+               }
        }
 
        if (jinfo->has_try_block_holes) {
index 68bde0c18a5f42b6129d4be1f4fb6917e19285e7..196819437ad7282fed49c5d68e139ecf8381444f 100644 (file)
@@ -2364,10 +2364,27 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
                        }
                }
 
-               /* This currently contains no data */
-               gi->generic_sharing_context = g_new0 (MonoGenericSharingContext, 1);
-
                jinfo->method = decode_resolve_method_ref (amodule, p, &p);
+
+               gi->generic_sharing_context = g_new0 (MonoGenericSharingContext, 1);
+               if (decode_value (p, &p)) {
+                       /* gsharedvt */
+                       int i, n;
+                       MonoGenericSharingContext *gsctx = gi->generic_sharing_context;
+
+                       n = decode_value (p, &p);
+                       if (n) {
+                               gsctx->var_is_vt = g_new0 (gboolean, n);
+                               for (i = 0; i < n; ++i)
+                                       gsctx->var_is_vt [i] = decode_value (p, &p);
+                       }
+                       n = decode_value (p, &p);
+                       if (n) {
+                               gsctx->mvar_is_vt = g_new0 (gboolean, n);
+                               for (i = 0; i < n; ++i)
+                                       gsctx->mvar_is_vt [i] = decode_value (p, &p);
+                       }
+               }
        }
 
        if (has_try_block_holes) {