2009-02-04 Marek Habersack <mhabersack@novell.com>
[mono.git] / mono / metadata / loader.c
index 8e0b022faa14de8651d7f83e5d5fc8d122da7996..5d0cf48e9c3c9ed301dc46ae35b83b3ea2a35ad5 100644 (file)
@@ -6,8 +6,8 @@
  *   Miguel de Icaza (miguel@ximian.com)
  *   Patrik Torstensson (patrik.torstensson@labs2.com)
  *
- * (C) 2001 Ximian, Inc.
- * Copyright (C) 2002-2006 Novell, Inc.
+ * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  *
  * This file is used by the interpreter and the JIT engine to locate
  * assemblies.  Used to load AssemblyRef and later to resolve various
@@ -35,6 +35,7 @@
 #include <mono/metadata/profiler.h>
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/exception.h>
+#include <mono/metadata/marshal.h>
 #include <mono/utils/mono-logger.h>
 #include <mono/utils/mono-dl.h>
 #include <mono/utils/mono-membar.h>
@@ -44,6 +45,9 @@ MonoDefaults mono_defaults;
 /*
  * This lock protects the hash tables inside MonoImage used by the metadata 
  * loading functions in class.c and loader.c.
+ *
+ * See domain-internals.h for locking policy in combination with the
+ * domain lock.
  */
 static CRITICAL_SECTION loader_mutex;
 
@@ -755,10 +759,13 @@ mono_method_get_signature (MonoMethod *method, MonoImage *image, guint32 token)
 }
 
 /* this is only for the typespec array methods */
-static MonoMethod*
-search_in_array_class (MonoClass *klass, const char *name, MonoMethodSignature *sig)
+MonoMethod*
+mono_method_search_in_array_class (MonoClass *klass, const char *name, MonoMethodSignature *sig)
 {
        int i;
+
+       mono_class_setup_methods (klass);
+
        for (i = 0; i < klass->method.count; ++i) {
                MonoMethod *method = klass->methods [i];
                if (strcmp (method->name, name) == 0 && sig->param_count == method->signature->param_count)
@@ -871,7 +878,7 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *typesp
                }
 
                /* we're an array and we created these methods already in klass in mono_class_init () */
-               result = search_in_array_class (klass, mname, sig);
+               result = mono_method_search_in_array_class (klass, mname, sig);
                if (result)
                        return result;
 
@@ -1617,6 +1624,8 @@ mono_free_method  (MonoMethod *method)
                MonoMethodWrapper *mw = (MonoMethodWrapper*)method;
                int i;
 
+               mono_marshal_free_dynamic_wrappers (method);
+
                mono_loader_lock ();
                mono_property_hash_remove_object (method->klass->image->property_hash, method);
                mono_loader_unlock ();