2009-08-14 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Fri, 14 Aug 2009 13:50:26 +0000 (13:50 -0000)
committerMark Probst <mark.probst@gmail.com>
Fri, 14 Aug 2009 13:50:26 +0000 (13:50 -0000)
* appdomain.c, metadata-internals.h, image.c: In MonoImage add a
list of classes for which we have to unregister reflection_info
with the GC and which are not in the namespace cache.

* reflection.c (mono_reflection_initialize_generic_parameter): Add
the class to the list.

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

mono/metadata/ChangeLog
mono/metadata/appdomain.c
mono/metadata/image.c
mono/metadata/metadata-internals.h
mono/metadata/reflection.c

index 78a87c5699f7144437b6b18ad5a4b6baf746c0c3..e9b9096a1f4eac5b4ab936f85d646accf5c766c4 100644 (file)
@@ -1,3 +1,12 @@
+2009-08-14  Mark Probst  <mark.probst@gmail.com>
+
+       * appdomain.c, metadata-internals.h, image.c: In MonoImage add a
+       list of classes for which we have to unregister reflection_info
+       with the GC and which are not in the namespace cache.
+
+       * reflection.c (mono_reflection_initialize_generic_parameter): Add
+       the class to the list.
+
 2009-08-14  Mark Probst  <mark.probst@gmail.com>
 
        * domain.c (mono_domain_free): Unregister the GC roots in
index 475aa1b4b5e662ea78fd3d1755899661fbd4137a..2858dd77e41137b02b0842e22ca24f54a68eda44 100644 (file)
@@ -1991,6 +1991,24 @@ deregister_reflection_info_roots_name_space (gpointer key, gpointer value, gpoin
        g_hash_table_foreach (value, deregister_reflection_info_roots_nspace_table, user_data);
 }
 
+static void
+deregister_reflection_info_roots_from_list (MonoImage *image)
+{
+       GSList *list = image->reflection_info_unregister_classes;
+
+       while (list) {
+               MonoClass *class = list->data;
+
+               g_assert (class->reflection_info);
+               mono_gc_deregister_root ((char*) &class->reflection_info);
+
+               list = list->next;
+       }
+
+       g_slist_free (image->reflection_info_unregister_classes);
+       image->reflection_info_unregister_classes = NULL;
+}
+
 static void
 deregister_reflection_info_roots (MonoDomain *domain)
 {
@@ -2005,10 +2023,16 @@ deregister_reflection_info_roots (MonoDomain *domain)
                /*No need to take the image lock here since dynamic images are appdomain bound and at this point the mutator is gone.*/
                if (image->dynamic && image->name_cache)
                        g_hash_table_foreach (image->name_cache, deregister_reflection_info_roots_name_space, image);
+               deregister_reflection_info_roots_from_list (image);
                for (i = 0; i < image->module_count; ++i) {
                        MonoImage *module = image->modules [i];
-                       if (module && module->dynamic && module->name_cache)
-                               g_hash_table_foreach (module->name_cache, deregister_reflection_info_roots_name_space, module);
+                       if (module) {
+                               if (module->dynamic && module->name_cache) {
+                                       g_hash_table_foreach (module->name_cache,
+                                                       deregister_reflection_info_roots_name_space, module);
+                               }
+                               deregister_reflection_info_roots_from_list (module);
+                       }
                }
        }
        mono_domain_assemblies_unlock (domain);
index 47e85ea3690f288ec47d69d71eecf955f1c90f19..e6312b4d71454089f839c970899671623bd4d091 100644 (file)
@@ -1555,6 +1555,8 @@ mono_image_close (MonoImage *image)
        if (image->property_hash)
                mono_property_hash_destroy (image->property_hash);
 
+       g_slist_free (image->reflection_info_unregister_classes);
+
        if (image->interface_bitset) {
                mono_unload_interface_ids (image->interface_bitset);
                mono_bitset_free (image->interface_bitset);
index 7183e63f7b348850d40f22575b48119fb7e9a882..58ae36c460b46c4a71ba16d8080cf16df91a3827 100644 (file)
@@ -254,6 +254,8 @@ struct _MonoImage {
        /* interfaces IDs from this image */
        MonoBitSet *interface_bitset;
 
+       GSList *reflection_info_unregister_classes;
+
        /*
         * No other runtime locks must be taken while holding this lock.
         * It's meant to be used only to mutate and query structures part of this image.
index 1389024d3c84f8070a3ebc2ed30173deb9b6d1ea..ba982c471ef8647e9ac73e696ce8279b18d5f300 100644 (file)
@@ -10687,6 +10687,9 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
 
        MOVING_GC_REGISTER (&pklass->reflection_info);
        pklass->reflection_info = gparam; /* FIXME: GC pin gparam */
+       mono_image_lock (image);
+       image->reflection_info_unregister_classes = g_slist_prepend (image->reflection_info_unregister_classes, pklass);
+       mono_image_unlock (image);
 }
 
 MonoArray *