2007-06-06 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Wed, 6 Jun 2007 12:17:43 +0000 (12:17 -0000)
committerMark Probst <mark.probst@gmail.com>
Wed, 6 Jun 2007 12:17:43 +0000 (12:17 -0000)
* class.c, image.c, class-internals.h (MonoImage): class_cache is
a MonoInternalHashTable again (fixed bug in internal hash table
code).

svn path=/trunk/mono/; revision=78728

mono/metadata/ChangeLog
mono/metadata/class-internals.h
mono/metadata/class.c
mono/metadata/image.c
mono/metadata/metadata-internals.h

index 355fd3ccfcc58474819598dca7dec3ae367e6340..8ec5efb2ec32a582c0e662e78c2eb6df1630ec81 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-06  Mark Probst  <mark.probst@gmail.com>
+
+       * class.c, image.c, class-internals.h (MonoImage): class_cache is
+       a MonoInternalHashTable again (fixed bug in internal hash table
+       code).
+
 2007-06-06  Mark Probst  <mark.probst@gmail.com>
 
        * domain.c, domain-internals.h (MonoDomain): jit_code_hash is a
index 6b4960c896d9afc72dc2e4dd663ada50e161cbe7..7e56037bdf019aba3f83912e0fe5af155666ea34 100644 (file)
@@ -323,6 +323,9 @@ struct _MonoClass {
 
        MonoClassRuntimeInfo *runtime_info;
 
+       /* next element in the class_cache hash list (in MonoImage) */
+       MonoClass *next_class_cache;
+
        /* Generic vtable. Initialized by a call to mono_class_setup_vtable () */
        MonoMethod **vtable;    
 };
index 80ef08e8c67a21952e48615ae1712210cd38f42b..18e49b596404586e25a54f09b4e30bd4b9815953 100644 (file)
@@ -3058,7 +3058,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
 
        mono_loader_lock ();
 
-       if ((class = g_hash_table_lookup (image->class_cache, GUINT_TO_POINTER (type_token)))) {
+       if ((class = mono_internal_hash_table_lookup (&image->class_cache, GUINT_TO_POINTER (type_token)))) {
                mono_loader_unlock ();
                return class;
        }
@@ -3079,7 +3079,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
        class->type_token = type_token;
        class->flags = cols [MONO_TYPEDEF_FLAGS];
 
-       g_hash_table_insert (image->class_cache, GUINT_TO_POINTER (type_token), class);
+       mono_internal_hash_table_insert (&image->class_cache, GUINT_TO_POINTER (type_token), class);
 
        /*
         * Check whether we're a generic type definition.
@@ -3096,7 +3096,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
                parent = mono_class_get_full (
                        image, mono_metadata_token_from_dor (cols [MONO_TYPEDEF_EXTENDS]), context);
                if (parent == NULL){
-                       g_hash_table_remove (image->class_cache, GUINT_TO_POINTER (type_token));
+                       mono_internal_hash_table_remove (&image->class_cache, GUINT_TO_POINTER (type_token));
                        mono_loader_unlock ();
                        return NULL;
                }
index 4155a0ae3b689a5b58c119cba2eb6a664d5736f6..735ef6cdd9bf5a8364ffe7e2ca4f8191299029e6 100644 (file)
@@ -26,6 +26,7 @@
 #include <mono/io-layer/io-layer.h>
 #include <mono/utils/mono-logger.h>
 #include <mono/utils/mono-path.h>
+#include <mono/metadata/class-internals.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #ifdef HAVE_UNISTD_H
@@ -577,12 +578,31 @@ build_guid_table (gboolean refonly)
        g_hash_table_foreach (loaded_images, register_guid, NULL);
 }
 
+static gpointer
+class_key_extract (gpointer value)
+{
+       MonoClass *class = value;
+
+       return GUINT_TO_POINTER (class->type_token);
+}
+
+static gpointer*
+class_next_value (gpointer value)
+{
+       MonoClass *class = value;
+
+       return (gpointer*)&class->next_class_cache;
+}
+
 void
 mono_image_init (MonoImage *image)
 {
        image->mempool = mono_mempool_new ();
        image->method_cache = g_hash_table_new (NULL, NULL);
-       image->class_cache = g_hash_table_new (NULL, NULL);
+       mono_internal_hash_table_init (&image->class_cache,
+                                      g_direct_hash,
+                                      class_key_extract,
+                                      class_next_value);
        image->field_cache = g_hash_table_new (NULL, NULL);
 
        image->delegate_begin_invoke_cache = 
@@ -1132,7 +1152,7 @@ mono_image_close (MonoImage *image)
        }
 
        g_hash_table_destroy (image->method_cache);
-       g_hash_table_destroy (image->class_cache);
+       mono_internal_hash_table_destroy (&image->class_cache);
        g_hash_table_destroy (image->field_cache);
        if (image->array_cache) {
                g_hash_table_foreach (image->array_cache, free_array_cache_entry, NULL);
index fc2fa6bb7d75cf82ab1d1d493ad54b4b2c3e8678..710d2d8ffea9b2f0fa931639fb5b356dedce39cf 100644 (file)
@@ -139,7 +139,7 @@ struct _MonoImage {
         * Indexed by method tokens and typedef tokens.
         */
        GHashTable *method_cache;
-       GHashTable *class_cache;
+       MonoInternalHashTable class_cache;
        /*
         * Indexed by fielddef and memberref tokens
         */