Reoder 4.x supported_runtimes versions to load correct mscorlib when <supportedRuntim...
[mono.git] / mono / metadata / marshal.c
index dd2f4c71165072990b8977a380500767d5f1f91d..ed60cb7234a585f18c1362181c75e6f16dcbaebf 100644 (file)
@@ -37,6 +37,7 @@
 #include "mono/metadata/cominterop.h"
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/mono-tls.h"
+#include "mono/utils/mono-memory-model.h"
 #include <string.h>
 #include <errno.h>
 
@@ -9031,6 +9032,8 @@ mono_marshal_get_castclass_with_cache (void)
        mono_mb_emit_byte (mb, CEE_RET);
 
        res = mono_mb_create_method (mb, sig, 8);
+       STORE_STORE_FENCE;
+
        if (InterlockedCompareExchangePointer ((volatile gpointer *)&cached, res, NULL)) {
                mono_free_method (res);
                mono_metadata_free_method_signature (sig);
@@ -9145,6 +9148,8 @@ mono_marshal_get_isinst_with_cache (void)
        mono_mb_emit_byte (mb, CEE_RET);
 
        res = mono_mb_create_method (mb, sig, 8);
+       STORE_STORE_FENCE;
+
        if (InterlockedCompareExchangePointer ((volatile gpointer *)&cached, res, NULL)) {
                mono_free_method (res);
                mono_metadata_free_method_signature (sig);
@@ -9315,7 +9320,7 @@ mono_marshal_get_proxy_cancast (MonoClass *klass)
        GHashTable *cache;
        MonoMethod *res;
        int pos_failed, pos_end;
-       char *name;
+       char *name, *klass_name;
        MonoMethod *can_cast_to;
        MonoMethodDesc *desc;
        MonoMethodBuilder *mb;
@@ -9330,9 +9335,11 @@ mono_marshal_get_proxy_cancast (MonoClass *klass)
                isint_sig->ret = &mono_defaults.object_class->byval_arg;
                isint_sig->pinvoke = 0;
        }
-       
-       name = g_strdup_printf ("__proxy_isinst_wrapper_%s", klass->name); 
+
+       klass_name = mono_type_full_name (&klass->byval_arg);
+       name = g_strdup_printf ("__proxy_isinst_wrapper_%s", klass_name); 
        mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_PROXY_ISINST);
+       g_free (klass_name);
        g_free (name);
        
        mb->method->save_lmf = 1;