+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
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)
{
/*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);
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);
/* 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.
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 *