2009-09-01 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / appdomain.c
index 0451dee78ab4ac86deb540017c5c9edafdc93e82..2858dd77e41137b02b0842e22ca24f54a68eda44 100644 (file)
@@ -72,7 +72,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 76
+#define MONO_CORLIB_VERSION 82
 
 typedef struct
 {
@@ -414,9 +414,6 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *
        data->domain = ad;
        data->setup = setup;
        data->friendly_name = g_strdup (friendly_name);
-       // FIXME: The ctor runs in the current domain
-       // FIXME: Initialize null_reference_ex and stack_overflow_ex
-       data->out_of_memory_ex = mono_exception_from_name_domain (data, mono_defaults.corlib, "System", "OutOfMemoryException");
 
        if (!setup->application_base) {
                /* Inherit from the root domain since MS.NET does this */
@@ -436,7 +433,10 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *
        mono_debugger_event_create_appdomain (data, shadow_location);
        g_free (shadow_location);
 #endif
-       
+
+       // FIXME: Initialize null_reference_ex and stack_overflow_ex
+       data->out_of_memory_ex = mono_exception_from_name_domain (data, mono_defaults.corlib, "System", "OutOfMemoryException");
+
        return ad;
 }
 
@@ -818,6 +818,9 @@ mono_try_assembly_resolve (MonoDomain *domain, MonoString *fname, gboolean refon
        MonoBoolean isrefonly;
        gpointer params [2];
 
+       if (mono_runtime_get_no_exec ())
+               return NULL;
+
        g_assert (domain != NULL && fname != NULL);
 
        klass = domain->domain->mbr.obj.vtable->klass;
@@ -1988,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)
 {
@@ -1999,13 +2020,19 @@ deregister_reflection_info_roots (MonoDomain *domain)
                MonoAssembly *assembly = list->data;
                MonoImage *image = assembly->image;
                int i;
-
+               /*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);