[runtime]Fix deregister_reflection_info_roots_from_list to avoid full type resolution...
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 4 Dec 2013 23:56:25 +0000 (18:56 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 5 Dec 2013 19:11:58 +0000 (14:11 -0500)
mono/metadata/appdomain.c
mono/metadata/reflection.c

index f6658b2460e34a2602d059b9889d8c37c1bb3d16..c77822d7dc2ae98d367de8b3986fa5d8fe31770a 100644 (file)
@@ -2199,23 +2199,6 @@ unload_data_unref (unload_data *data)
        } while (InterlockedCompareExchange (&data->refcount, count, count - 1) != count);
 }
 
-static void
-deregister_reflection_info_roots_nspace_table (gpointer key, gpointer value, gpointer image)
-{
-       guint32 index = GPOINTER_TO_UINT (value);
-       MonoClass *class = mono_class_get (image, MONO_TOKEN_TYPE_DEF | index);
-
-       g_assert (class);
-
-       mono_class_free_ref_info (class);
-}
-
-static void
-deregister_reflection_info_roots_name_space (gpointer key, gpointer value, gpointer user_data)
-{
-       g_hash_table_foreach (value, deregister_reflection_info_roots_nspace_table, user_data);
-}
-
 static void
 deregister_reflection_info_roots_from_list (MonoImage *image)
 {
@@ -2246,20 +2229,13 @@ 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.
                Taking the image lock here would mean promoting it from a simple lock to a complex lock, which we better avoid if possible.
                */
-               if (image->dynamic) {
-                       if (image->name_cache)
-                               g_hash_table_foreach (image->name_cache, deregister_reflection_info_roots_name_space, image);
+               if (image->dynamic)
                        deregister_reflection_info_roots_from_list (image);
-               }
+
                for (i = 0; i < image->module_count; ++i) {
                        MonoImage *module = image->modules [i];
-                       if (module && module->dynamic) {
-                               if (module->name_cache) {
-                                       g_hash_table_foreach (module->name_cache,
-                                                       deregister_reflection_info_roots_name_space, module);
-                               }
+                       if (module && module->dynamic)
                                deregister_reflection_info_roots_from_list (module);
-                       }
                }
        }
        mono_domain_assemblies_unlock (domain);
index 88bb0d38d14c3725dc689c36759433fdd06ef317..eddd5dc570f8fb0d819d253181d7aabf62d2686c 100644 (file)
@@ -9840,11 +9840,16 @@ mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb)
 
                /* Put into cache so mono_class_get () will find it.
                Skip nested types as those should not be available on the global scope. */
-               if (!tb->nesting_type) {
+               if (!tb->nesting_type)
                        mono_image_add_to_name_cache (klass->image, klass->name_space, klass->name, tb->table_idx);
-               } else {
-                       mono_image_append_class_to_reflection_info_set (klass);
-               }
+
+               /*
+               We must register all types as we cannot rely on the name_cache hashtable since we find the class
+               by performing a mono_class_get which does the full resolution.
+
+               Working around this semantics would require us to write a lot of code for no clear advantage.
+               */
+               mono_image_append_class_to_reflection_info_set (klass);
        } else {
                g_assert (mono_class_get_ref_info (klass) == tb);
        }