Fri Sep 28 17:19:40 CEST 2007 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Fri, 28 Sep 2007 15:09:08 +0000 (15:09 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Fri, 28 Sep 2007 15:09:08 +0000 (15:09 -0000)
* marshal.c: when possible, do not duplicate the name of the methods
in the method builder and in the generated MonoMethod.

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

mono/metadata/ChangeLog
mono/metadata/marshal.c

index 43728a7090e8c438adbfb9a549d97d3cccab572c..9ad8845c3b8926ce155ef84ba4dd39b56af85278 100644 (file)
@@ -1,3 +1,9 @@
+
+Fri Sep 28 17:19:40 CEST 2007 Paolo Molaro <lupus@ximian.com>
+
+       * marshal.c: when possible, do not duplicate the name of the methods
+       in the method builder and in the generated MonoMethod.
+
 2007-09-27  Rodrigo Kumpera  <rkumpera@novell.com>
        * verify.c: added support for type checking ldind_* opcodes.
 
index 214e4b11fd7da6f7803f1d5348e89b5b29378b31..33b7fe490594b74b3eaeacab8a1e3bb55fca6c22 100644 (file)
@@ -52,6 +52,7 @@ struct _MonoMethodBuilder {
        GList *locals_list;
        int locals;
        gboolean dynamic;
+       gboolean no_dup_name;
        guint32 code_size, pos;
        unsigned char *code;
 };
@@ -1209,20 +1210,20 @@ mono_mb_free (MonoMethodBuilder *mb)
        g_list_free (mb->locals_list);
        if (!mb->dynamic) {
                g_free (mb->method);
-               g_free (mb->name);
+               if (!mb->no_dup_name)
+                       g_free (mb->name);
                g_free (mb->code);
        }
        g_free (mb);
 }
 
-MonoMethodBuilder *
-mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type)
+static MonoMethodBuilder *
+mono_mb_new_base (MonoClass *klass, MonoWrapperType type)
 {
        MonoMethodBuilder *mb;
        MonoMethod *m;
 
        g_assert (klass != NULL);
-       g_assert (name != NULL);
 
        mb = g_new0 (MonoMethodBuilder, 1);
 
@@ -1232,13 +1233,29 @@ mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type)
        m->inline_info = 1;
        m->wrapper_type = type;
 
-       mb->name = g_strdup (name);
        mb->code_size = 40;
        mb->code = g_malloc (mb->code_size);
        
        return mb;
 }
 
+static MonoMethodBuilder *
+mono_mb_new_no_dup_name (MonoClass *klass, const char *name, MonoWrapperType type)
+{
+       MonoMethodBuilder *mb = mono_mb_new_base (klass, type);
+       mb->name = (char*)name;
+       mb->no_dup_name = TRUE;
+       return mb;
+}
+
+MonoMethodBuilder *
+mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type)
+{
+       MonoMethodBuilder *mb = mono_mb_new_base (klass, type);
+       mb->name = g_strdup (name);
+       return mb;
+}
+
 int
 mono_mb_add_local (MonoMethodBuilder *mb, MonoType *type)
 {
@@ -1297,7 +1314,10 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
                method = mono_mempool_alloc (mp, sizeof (MonoMethodWrapper));
                memcpy (method, mb->method, sizeof (MonoMethodWrapper));
 
-               method->name = mono_mempool_strdup (mp, mb->name);
+               if (mb->no_dup_name)
+                       method->name = mb->name;
+               else
+                       method->name = mono_mempool_strdup (mp, mb->name);
 
                ((MonoMethodNormal *)method)->header = header = (MonoMethodHeader *) 
                        mono_mempool_alloc0 (mp, sizeof (MonoMethodHeader) + mb->locals * sizeof (MonoType *));
@@ -11374,7 +11394,7 @@ mono_marshal_get_generic_array_helper (MonoClass *class, MonoClass *iface, gchar
        MonoMethod *res;
        int i;
 
-       mb = mono_mb_new (class, name, MONO_WRAPPER_MANAGED_TO_MANAGED);
+       mb = mono_mb_new_no_dup_name (class, name, MONO_WRAPPER_MANAGED_TO_MANAGED);
        mb->method->slot = -1;
 
        mb->method->flags = METHOD_ATTRIBUTE_PRIVATE | METHOD_ATTRIBUTE_VIRTUAL |