[runtime] Replace hand-written type look up/caching with GENERATE_GET_CLASS_WITH_CACH...
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 16 Nov 2015 05:22:56 +0000 (00:22 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 17 Feb 2016 00:28:23 +0000 (19:28 -0500)
The macro generates the right form of corlib type lookup & caching.

mono/metadata/threads.c

index 2eb4e4a4dbb648d67d37e738743c8a1a613d691b..3c04b893353af7833b67fbbb70cc52f2f6a1c9aa 100644 (file)
@@ -225,6 +225,9 @@ static gboolean shutting_down = FALSE;
 
 static gint32 managed_thread_id_counter = 0;
 
+/* Class lazy loading functions */
+static GENERATE_GET_CLASS_WITH_CACHE (appdomain_unloaded_exception, System, AppDomainUnloadedException)
+
 static void
 mono_threads_lock (void)
 {
@@ -4961,13 +4964,7 @@ mono_thread_internal_check_for_interruption_critical (MonoInternalThread *thread
 static inline gboolean
 is_appdomainunloaded_exception (MonoClass *klass)
 {
-       static MonoClass *app_domain_unloaded_exception_klass = NULL;
-
-       if (!app_domain_unloaded_exception_klass)
-               app_domain_unloaded_exception_klass = mono_class_from_name (mono_defaults.corlib, "System", "AppDomainUnloadedException");
-       g_assert (app_domain_unloaded_exception_klass);
-
-       return klass == app_domain_unloaded_exception_klass;
+       return klass == mono_class_get_appdomain_unloaded_exception_class ();
 }
 
 static inline gboolean