2009-11-28 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Sat, 28 Nov 2009 19:05:19 +0000 (19:05 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Sat, 28 Nov 2009 19:05:19 +0000 (19:05 -0000)
* reflection.c (ensure_generic_class_runtime_vtable): Split this function in 2
so we can avoid calling ensure_runtime_vtable multiple times for the GTD during
its TypeBuilder::CreateType ().

* reflection.c (ensure_generic_class_runtime_vtable): Avoid initializing interfaces
if not needed.

* reflection.c: Every time we change the interface array, set interfaces_packed to NULL
to make setup_interface_offsets happy.

* reflection.c (remove_instantiations_of_and_ensure_contents): Fix instances again as corlib
compilation now works.

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

mono/metadata/ChangeLog
mono/metadata/reflection.c

index 5830dd08de4a6eff14ad8229fd56b45a393dee5e..f3d49cbe6f4c7284bbca21e6d8a7729354a80df9 100644 (file)
@@ -1,3 +1,18 @@
+2009-11-28  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * reflection.c (ensure_generic_class_runtime_vtable): Split this function in 2
+       so we can avoid calling ensure_runtime_vtable multiple times for the GTD during
+       its TypeBuilder::CreateType ().
+
+       * reflection.c (ensure_generic_class_runtime_vtable): Avoid initializing interfaces
+       if not needed.
+
+       * reflection.c: Every time we change the interface array, set interfaces_packed to NULL
+       to make setup_interface_offsets happy.
+
+       * reflection.c (remove_instantiations_of_and_ensure_contents): Fix instances again as corlib
+       compilation now works.
+
 2009-11-28  Zoltan Varga  <vargaz@gmail.com>
 
        * appdomain.c (create_exceptions): New helper function extracted from
index 0861f0fe3850a6cc2c62dc27e3e7027b592df2eb..ec27724f53abe3e76049c735faa63b30f59b926f 100644 (file)
@@ -10273,7 +10273,7 @@ mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, Mono
 }
 
 static void
-ensure_generic_class_runtime_vtable (MonoClass *klass)
+fix_partial_generic_class (MonoClass *klass)
 {
        MonoClass *gklass = klass->generic_class->container_class;
        MonoDynamicGenericClass *dgclass;
@@ -10282,8 +10282,6 @@ ensure_generic_class_runtime_vtable (MonoClass *klass)
        if (klass->wastypebuilder)
                return;
 
-       ensure_runtime_vtable (gklass);
-
        dgclass = (MonoDynamicGenericClass *)  klass->generic_class;
 
        if (!dgclass->initialized)
@@ -10299,10 +10297,12 @@ ensure_generic_class_runtime_vtable (MonoClass *klass)
                }
        }
 
-       if (klass->interface_count != gklass->interface_count) {
+       if (klass->interface_count && klass->interface_count != gklass->interface_count) {
                klass->interface_count = gklass->interface_count;
-               klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * klass->interface_count);
-               for (i = 0; i < klass->interface_count; ++i) {
+               klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * gklass->interface_count);
+               klass->interfaces_packed = NULL; /*make setup_interface_offsets happy*/
+
+               for (i = 0; i < gklass->interface_count; ++i) {
                        MonoType *iface_type = mono_class_inflate_generic_type (&gklass->interfaces [i]->byval_arg, mono_class_get_context (klass));
                        klass->interfaces [i] = mono_class_from_mono_type (iface_type);
                        mono_metadata_free_type (iface_type);
@@ -10329,6 +10329,16 @@ ensure_generic_class_runtime_vtable (MonoClass *klass)
        return;
 }
 
+static void
+ensure_generic_class_runtime_vtable (MonoClass *klass)
+{
+       MonoClass *gklass = klass->generic_class->container_class;
+
+       ensure_runtime_vtable (gklass); 
+
+       fix_partial_generic_class (klass);
+}
+
 static void
 ensure_runtime_vtable (MonoClass *klass)
 {
@@ -10371,6 +10381,7 @@ ensure_runtime_vtable (MonoClass *klass)
                for (i = 0; i < klass->method.count; ++i)
                        klass->methods [i]->slot = i;
                
+               klass->interfaces_packed = NULL; /*make setup_interface_offsets happy*/
                mono_class_setup_interface_offsets (klass);
                mono_class_setup_interface_id (klass);
        }
@@ -10630,7 +10641,7 @@ remove_instantiations_of_and_ensure_contents (gpointer key,
        MonoClass *klass = (MonoClass*)user_data;
 
        if ((type->type == MONO_TYPE_GENERICINST) && (type->data.generic_class->container_class == klass)) {
-               //ensure_runtime_vtable (mono_class_from_mono_type (type)); //Make sure the vtable is complete
+               fix_partial_generic_class (mono_class_from_mono_type (type)); //Ensure it's safe to use it.
                return TRUE;
        } else
                return FALSE;