[coop] Switch finalizer locks to coop implementation
[mono.git] / mono / metadata / cominterop.c
index bdc8cb1f85481080cd96fda65eb3dbe64cc8c2d9..277ec6dcddd3c5ea6924ca5ddc73e2a51ebbd890 100644 (file)
 #include "mono/metadata/monitor.h"
 #include "mono/metadata/metadata-internals.h"
 #include "mono/metadata/domain-internals.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
 #include "mono/metadata/threads-types.h"
 #include "mono/metadata/string-icalls.h"
 #include "mono/metadata/attrdefs.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/strenc.h"
 #include "mono/utils/atomic.h"
@@ -75,8 +75,8 @@ enum {
 #undef OPDEF
 
 /* This mutex protects the various cominterop related caches in MonoImage */
-#define mono_cominterop_lock() mono_mutex_lock (&cominterop_mutex)
-#define mono_cominterop_unlock() mono_mutex_unlock (&cominterop_mutex)
+#define mono_cominterop_lock() mono_os_mutex_lock (&cominterop_mutex)
+#define mono_cominterop_unlock() mono_os_mutex_unlock (&cominterop_mutex)
 static mono_mutex_t cominterop_mutex;
 
 /* STDCALL on windows, CDECL everywhere else to work with XPCOM and MainWin COM */
@@ -532,7 +532,7 @@ mono_cominterop_init (void)
 {
        const char* com_provider_env;
 
-       mono_mutex_init_recursive (&cominterop_mutex);
+       mono_os_mutex_init_recursive (&cominterop_mutex);
 
        com_provider_env = g_getenv ("MONO_COM");
        if (com_provider_env && !strcmp(com_provider_env, "MS"))
@@ -564,7 +564,7 @@ mono_cominterop_init (void)
 void
 mono_cominterop_cleanup (void)
 {
-       mono_mutex_destroy (&cominterop_mutex);
+       mono_os_mutex_destroy (&cominterop_mutex);
 }
 
 void
@@ -872,7 +872,8 @@ mono_cominterop_get_native_wrapper (MonoMethod *method)
 
        g_assert (method);
 
-       cache = mono_marshal_get_cache (&method->klass->image->cominterop_wrapper_cache, mono_aligned_addr_hash, NULL);
+       cache = mono_marshal_get_cache (&mono_method_get_wrapper_cache (method)->cominterop_wrapper_cache, mono_aligned_addr_hash, NULL);
+
        if ((res = mono_marshal_find_in_cache (cache, method)))
                return res;
 
@@ -981,7 +982,9 @@ mono_cominterop_get_invoke (MonoMethod *method)
        MonoMethodBuilder *mb;
        MonoMethod *res;
        int i;
-       GHashTable* cache = mono_marshal_get_cache (&method->klass->image->cominterop_invoke_cache, mono_aligned_addr_hash, NULL);
+       GHashTable* cache;
+       
+       cache = mono_marshal_get_cache (&mono_method_get_wrapper_cache (method)->cominterop_invoke_cache, mono_aligned_addr_hash, NULL);
 
        g_assert (method);
 
@@ -1686,13 +1689,13 @@ gpointer
 ves_icall_System_ComObject_GetInterfaceInternal (MonoComObject* obj, MonoReflectionType* type, MonoBoolean throw_exception)
 {
 #ifndef DISABLE_COM
-       MonoClass *class = mono_type_get_class (type->type);
-       if (!mono_class_init (class)) {
-               mono_set_pending_exception (mono_class_get_exception_for_failure (class));
+       MonoClass *klass = mono_type_get_class (type->type);
+       if (!mono_class_init (klass)) {
+               mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
                return NULL;
        }
 
-       return cominterop_get_interface (obj, class, (gboolean)throw_exception);
+       return cominterop_get_interface (obj, klass, (gboolean)throw_exception);
 #else
        g_assert_not_reached ();
 #endif