Merge pull request #3247 from lateralusX/jlorenss/win-x64-lmf-exception
[mono.git] / mono / mini / mini-generic-sharing.c
index 84c21c5890e9dfedf73e95a441857fc6875f370a..aca368c9dba9e1ad8ef382fa8e7532a93981ffe5 100644 (file)
@@ -607,6 +607,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
                MonoMethod *inflated_method;
                MonoType *inflated_type = mono_class_inflate_generic_type_checked (&method->klass->byval_arg, context, &error);
                mono_error_assert_ok (&error); /* FIXME don't swallow the error */
+               WrapperInfo *winfo = NULL;
 
                MonoClass *inflated_class = mono_class_from_mono_type (inflated_type);
                MonoJumpInfoGSharedVtCall *res;
@@ -620,7 +621,13 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
 
                mono_class_init (inflated_class);
 
-               g_assert (!method->wrapper_type);
+               if (method->wrapper_type) {
+                       winfo = mono_marshal_get_wrapper_info (method);
+
+                       g_assert (winfo);
+                       g_assert (winfo->subtype == WRAPPER_SUBTYPE_SYNCHRONIZED_INNER);
+                       method = winfo->d.synchronized_inner.method;
+               }
 
                if (inflated_class->byval_arg.type == MONO_TYPE_ARRAY ||
                                inflated_class->byval_arg.type == MONO_TYPE_SZARRAY) {
@@ -633,6 +640,12 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
                }
                mono_class_init (inflated_method->klass);
                g_assert (inflated_method->klass == inflated_class);
+
+               if (winfo) {
+                       g_assert (winfo->subtype == WRAPPER_SUBTYPE_SYNCHRONIZED_INNER);
+                       inflated_method = mono_marshal_get_synchronized_inner_wrapper (inflated_method);
+               }
+
                res->method = inflated_method;
 
                return res;
@@ -862,7 +875,7 @@ class_type_info (MonoDomain *domain, MonoClass *klass, MonoRgctxInfoType info_ty
        case MONO_RGCTX_INFO_STATIC_DATA: {
                MonoVTable *vtable = mono_class_vtable (domain, klass);
                if (!vtable) {
-                       mono_error_set_exception_instance (error, mono_class_get_exception_for_failure (klass));
+                       mono_error_set_for_class_failure (error, klass);
                        return NULL;
                }
                return mono_vtable_get_static_field_data (vtable);
@@ -874,7 +887,7 @@ class_type_info (MonoDomain *domain, MonoClass *klass, MonoRgctxInfoType info_ty
        case MONO_RGCTX_INFO_VTABLE: {
                MonoVTable *vtable = mono_class_vtable (domain, klass);
                if (!vtable) {
-                       mono_error_set_exception_instance (error, mono_class_get_exception_for_failure (klass));
+                       mono_error_set_for_class_failure (error, klass);
                        return NULL;
                }
                return vtable;
@@ -1704,7 +1717,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
 
                vtable = mono_class_vtable (domain, method->method.method.klass);
                if (!vtable) {
-                       mono_error_set_exception_instance (error, mono_class_get_exception_for_failure (method->method.method.klass));
+                       mono_error_set_for_class_failure (error, method->method.method.klass);
                        return NULL;
                }
 
@@ -1758,6 +1771,9 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
 
                g_assert (method->is_inflated);
 
+               if (mono_llvm_only && (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED))
+                       method = mono_marshal_get_synchronized_wrapper (method);
+
                if (!virtual_) {
                        addr = mono_compile_method_checked (method, error);
                        return_val_if_nok (error, NULL);