Author: zoltan
Date: 2007-03-07 10:41:51 -0500 (Wed, 07 Mar 2007)
New Revision: 73888

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/aot-runtime.c
Log:
2007-03-07  Zoltan Varga  <[EMAIL PROTECTED]>

        * aot-runtime.c (mono_aot_get_class_from_name): Add a cache.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-03-07 14:51:22 UTC (rev 73887)
+++ trunk/mono/mono/mini/ChangeLog      2007-03-07 15:41:51 UTC (rev 73888)
@@ -1,5 +1,7 @@
 2007-03-07  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * aot-runtime.c (mono_aot_get_class_from_name): Add a cache.
+
        * aot-compiler.c (encode_patch): Remove an obsolete comment.
 
 2007-03-06  Zoltan Varga  <[EMAIL PROTECTED]>

Modified: trunk/mono/mono/mini/aot-runtime.c
===================================================================
--- trunk/mono/mono/mini/aot-runtime.c  2007-03-07 14:51:22 UTC (rev 73887)
+++ trunk/mono/mono/mini/aot-runtime.c  2007-03-07 15:41:51 UTC (rev 73888)
@@ -69,6 +69,7 @@
        /* Pointer to the Global Offset Table */
        gpointer *got;
        guint32 got_size;
+       GHashTable *name_cache;
        MonoAssemblyName *image_names;
        char **image_guids;
        MonoImage **image_table;
@@ -798,6 +799,7 @@
        const char *name2, *name_space2;
        MonoTableInfo  *t;
        guint32 cols [MONO_TYPEDEF_SIZE];
+       GHashTable *nspace_table;
 
        if (!aot_modules)
                return FALSE;
@@ -812,6 +814,18 @@
 
        *klass = NULL;
 
+       /* First look in the cache */
+       if (!aot_module->name_cache)
+               aot_module->name_cache = g_hash_table_new (g_str_hash, 
g_str_equal);
+       nspace_table = g_hash_table_lookup (aot_module->name_cache, name_space);
+       if (nspace_table) {
+               *klass = g_hash_table_lookup (nspace_table, name);
+               if (*klass) {
+                       mono_aot_unlock ();
+                       return TRUE;
+               }
+       }
+
        table_size = aot_module->class_name_table [0];
        table = aot_module->class_name_table + 1;
 
@@ -849,6 +863,18 @@
                        if (!strcmp (name, name2) && !strcmp (name_space, 
name_space2)) {
                                mono_aot_unlock ();
                                *klass = mono_class_get (image, token);
+
+                               /* Add to cache */
+                               if (*klass) {
+                                       mono_aot_lock ();
+                                       nspace_table = g_hash_table_lookup 
(aot_module->name_cache, name_space);
+                                       if (!nspace_table) {
+                                               nspace_table = g_hash_table_new 
(g_str_hash, g_str_equal);
+                                               g_hash_table_insert 
(aot_module->name_cache, (char*)name_space2, nspace_table);
+                                       }
+                                       g_hash_table_insert (nspace_table, 
(char*)name2, *klass);
+                                       mono_aot_unlock ();
+                               }
                                return TRUE;
                        }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to