2009-05-06 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Wed, 6 May 2009 13:31:21 +0000 (13:31 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 6 May 2009 13:31:21 +0000 (13:31 -0000)
* aot-compiler.c aot-runtime.c: Use our own hash function instead of
g_str_hash () which can change.

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

mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c

index bb68d3401ca97338918469a845bed8c0f0367ee5..f42191355fc7077ceb884e6010d9a4daff1cb141 100644 (file)
@@ -1,5 +1,8 @@
 2009-05-06  Zoltan Varga  <vargaz@gmail.com>
 
+       * aot-compiler.c aot-runtime.c: Use our own hash function instead of
+       g_str_hash () which can change.
+
        * driver.c (mini_regression): Disable optimizations not supported by
        the cpu. Fixes #500019.
 
index 18f5aa3a4b953872385c9d6eb8f113e3a6ebeffc..181b2e045816a532a38707ca7930c50914374a95 100644 (file)
@@ -3323,6 +3323,27 @@ emit_info (MonoAotCompile *acfg)
 
 #endif /* #if !defined(DISABLE_AOT) && !defined(DISABLE_JIT) */
 
+/*
+ * mono_aot_str_hash:
+ *
+ * Hash function for strings which we use to hash strings for things which are
+ * saved in the AOT image, since g_str_hash () can change.
+ */
+guint
+mono_aot_str_hash (gconstpointer v1)
+{
+       /* Same as g_str_hash () in glib */
+       char *p = (char *) v1;
+       guint hash = *p;
+
+       while (*p++) {
+               if (*p)
+                       hash = (hash << 5) - hash + *p;
+       }
+
+       return hash;
+} 
+
 /*
  * mono_aot_method_hash:
  *
@@ -3334,11 +3355,11 @@ mono_aot_method_hash (MonoMethod *method)
        guint32 hash;
 
        if (method->wrapper_type) {
-               hash = g_str_hash (method->name);
+               hash = mono_aot_str_hash (method->name);
        } else {
                char *full_name = mono_method_full_name (method, TRUE);
                // FIXME: Improve this (changing this requires bumping MONO_AOT_FILE_VERSION)
-               hash = g_str_hash (full_name);
+               hash = mono_aot_str_hash (full_name);
                g_free (full_name);
        }
 
@@ -3755,7 +3776,7 @@ emit_class_name_table (MonoAotCompile *acfg)
                token = MONO_TOKEN_TYPE_DEF | (i + 1);
                klass = mono_class_get (acfg->image, token);
                full_name = mono_type_get_name_full (mono_class_get_type (klass), MONO_TYPE_NAME_FORMAT_FULL_NAME);
-               hash = g_str_hash (full_name) % table_size;
+               hash = mono_aot_str_hash (full_name) % table_size;
                g_free (full_name);
 
                /* FIXME: Allocate from the mempool */
index 4c95b1a2f47cca72ff47a7bac96e31795771e7fe..540c29cd1b97839fd27ea7f9f6fe17931ed98485 100644 (file)
@@ -1320,7 +1320,7 @@ mono_aot_get_class_from_name (MonoImage *image, const char *name_space, const ch
                        full_name = g_strdup_printf ("%s.%s", name_space, name);
                }
        }
-       hash = g_str_hash (full_name) % table_size;
+       hash = mono_aot_str_hash (full_name) % table_size;
        if (full_name != full_name_buf)
                g_free (full_name);