Author: zoltan
Date: 2007-05-10 15:11:06 -0400 (Thu, 10 May 2007)
New Revision: 77154

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/aot-compiler.c
   trunk/mono/mono/mini/aot-runtime.c
Log:
2007-05-10  Zoltan Varga  <[EMAIL PROTECTED]>

        * aot-runtime.c (decode_cached_class_info): Skip generic types.

        * aot-compiler.c: Add minimal support for AOTing generic code by 
skipping 
        everything generic.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-05-10 19:09:08 UTC (rev 77153)
+++ trunk/mono/mono/mini/ChangeLog      2007-05-10 19:11:06 UTC (rev 77154)
@@ -1,5 +1,10 @@
 2007-05-10  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * aot-runtime.c (decode_cached_class_info): Skip generic types.
+
+       * aot-compiler.c: Add minimal support for AOTing generic code by 
skipping 
+       everything generic.
+
        * mini.c (mono_method_to_ir): Disable AOT when calling 
helper_compile_generic_method.
 
 2007-05-09  Zoltan Varga  <[EMAIL PROTECTED]>

Modified: trunk/mono/mono/mini/aot-compiler.c
===================================================================
--- trunk/mono/mono/mini/aot-compiler.c 2007-05-10 19:09:08 UTC (rev 77153)
+++ trunk/mono/mono/mini/aot-compiler.c 2007-05-10 19:11:06 UTC (rev 77154)
@@ -69,7 +69,7 @@
 } MonoAotOptions;
 
 typedef struct MonoAotStats {
-       int ccount, mcount, lmfcount, abscount, wrappercount, gcount, ocount;
+       int ccount, mcount, lmfcount, abscount, wrappercount, gcount, ocount, 
genericcount;
        int code_size, info_size, ex_info_size, got_size, class_info_size, 
got_info_size, got_info_offsets_size;
        int methods_without_got_slots, direct_calls, all_calls;
        int got_slots;
@@ -2275,7 +2275,9 @@
 
        no_special_static = !mono_class_has_special_static_fields (klass);
 
-       if (1) {
+       if (klass->generic_container) {
+               encode_value (-1, p, &p);
+       } else {
                encode_value (klass->vtable_size, p, &p);
                encode_value ((no_special_static << 7) | 
(klass->has_static_refs << 6) | (klass->has_references << 5) | 
((klass->blittable << 4) | (klass->nested_classes ? 1 : 0) << 3) | 
(klass->has_cctor << 2) | (klass->has_finalize << 1) | klass->ghcimpl, p, &p);
                if (klass->has_cctor)
@@ -2541,6 +2543,11 @@
                return;
        }
 
+       if (mono_method_signature (method)->has_type_parameters || 
method->klass->generic_container) {
+               acfg->stats.genericcount ++;
+               return;
+       }
+
        /*
         * Since these methods are the only ones which are compiled with
         * AOT support, and they are not used by runtime startup/shutdown code,
@@ -2562,11 +2569,14 @@
 
        skip = FALSE;
        for (patch_info = cfg->patch_info; patch_info; patch_info = 
patch_info->next) {
-               if (patch_info->type == MONO_PATCH_INFO_ABS) {
+               switch (patch_info->type) {
+               case MONO_PATCH_INFO_ABS:
                        /* unable to handle this */
                        //printf ("Skip (abs addr):   %s %d\n", 
mono_method_full_name (method, TRUE), patch_info->type);
                        skip = TRUE;    
                        break;
+               default:
+                       break;
                }
        }
 
@@ -2576,6 +2586,42 @@
                return;
        }
 
+       /* 
+        * We can't currently handle instantinated generic types/method
+        * since we save typedef/methoddef tokens, instead of 
typespec/methodref/methodspec 
+        * tokens.
+        */
+       for (patch_info = cfg->patch_info; patch_info; patch_info = 
patch_info->next) {
+               switch (patch_info->type) {
+               case MONO_PATCH_INFO_METHOD:
+               case MONO_PATCH_INFO_METHODCONST:
+                       /* Methods of instantinated generic types */
+                       if (patch_info->data.method->klass->generic_class)
+                               skip = TRUE;
+                       /* Instantinated generic methods */
+                       if (mono_method_signature 
(patch_info->data.method)->is_inflated)
+                               skip = TRUE;
+                       break;
+               case MONO_PATCH_INFO_VTABLE:
+               case MONO_PATCH_INFO_CLASS:
+               case MONO_PATCH_INFO_IID:
+               case MONO_PATCH_INFO_ADJUSTED_IID:
+               case MONO_PATCH_INFO_CLASS_INIT:
+                       if (patch_info->data.klass->generic_class)
+                               skip = TRUE;
+                       break;
+                       /* FIXME: Add more types of patches */
+               default:
+                       break;
+               }
+       }
+
+       if (skip) {
+               acfg->stats.genericcount++;
+               mono_destroy_compile (cfg);
+               return;
+       }
+
        skip = FALSE;
        for (patch_info = cfg->patch_info; patch_info; patch_info = 
patch_info->next) {
                if (patch_info->type == MONO_PATCH_INFO_METHOD_JUMP) {
@@ -3258,6 +3304,7 @@
 
        load_profile_files (acfg);
 
+#if 0
        if (mono_defaults.generic_nullable_class) {
                /* 
                 * FIXME: Its hard to skip generic methods or methods which use 
generics.
@@ -3265,6 +3312,7 @@
                printf ("Error: Can't AOT Net 2.0 assemblies.\n");
                return 1;
        }
+#endif
 
        emit_start (acfg);
 

Modified: trunk/mono/mono/mini/aot-runtime.c
===================================================================
--- trunk/mono/mono/mini/aot-runtime.c  2007-05-10 19:09:08 UTC (rev 77153)
+++ trunk/mono/mono/mini/aot-runtime.c  2007-05-10 19:11:06 UTC (rev 77154)
@@ -659,6 +659,9 @@
        guint32 flags;
 
        info->vtable_size = decode_value (buf, &buf);
+       if (info->vtable_size == -1)
+               /* Generic type */
+               return FALSE;
        flags = decode_value (buf, &buf);
        info->ghcimpl = (flags >> 0) & 0x1;
        info->has_finalize = (flags >> 1) & 0x1;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to