[coop] Add missing coop checks for WFSO and WFMO.
[mono.git] / mono / metadata / cominterop.c
index a733a1bee61780edace981cde09c65d0f1189a90..31d794f6b1fd4f696056d7b627cef95a131acc09 100644 (file)
@@ -524,8 +524,6 @@ cominterop_type_from_handle (MonoType *handle)
        MonoDomain *domain = mono_domain_get (); 
        MonoClass *klass = mono_class_from_mono_type (handle);
 
-       MONO_ARCH_SAVE_REGS;
-
        mono_class_init (klass);
        return mono_type_get_object (domain, handle);
 }
@@ -595,7 +593,6 @@ mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type,
                static MonoClass* com_interop_proxy_class = NULL;
                static MonoMethod* com_interop_proxy_get_proxy = NULL;
                static MonoMethod* get_transparent_proxy = NULL;
-               int real_proxy;
                guint32 pos_null = 0, pos_ccw = 0, pos_end = 0;
                MonoClass *klass = NULL; 
 
@@ -627,7 +624,7 @@ mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type,
                        get_transparent_proxy = mono_class_get_method_from_name (mono_defaults.real_proxy_class, "GetTransparentProxy", 0);
 #endif
 
-               real_proxy = mono_mb_add_local (mb, &com_interop_proxy_class->byval_arg);
+               mono_mb_add_local (mb, &com_interop_proxy_class->byval_arg);
 
                mono_mb_emit_ldloc (mb, 0);
                mono_mb_emit_byte (mb, CEE_LDIND_I);
@@ -984,7 +981,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
        MonoMethodSignature *sig;
        MonoMethodBuilder *mb;
        MonoMethod *res;
-       int i, temp_obj;
+       int i;
        GHashTable* cache = mono_marshal_get_cache (&method->klass->image->cominterop_invoke_cache, mono_aligned_addr_hash, NULL);
 
        g_assert (method);
@@ -1001,7 +998,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP_INVOKE);
 
        /* get real proxy object, which is a ComInteropProxy in this case*/
-       temp_obj = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
+       mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
        mono_mb_emit_ldarg (mb, 0);
        mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoTransparentProxy, rp));
        mono_mb_emit_byte (mb, CEE_LDIND_REF);
@@ -1534,8 +1531,10 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (MonoObject* object, Mon
        g_assert (type->type);
        klass = mono_type_get_class (type->type);
        g_assert (klass);
-       if (!mono_class_init (klass))
-               mono_raise_exception (mono_class_get_exception_for_failure (klass));
+       if (!mono_class_init (klass)) {
+               mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
+               return NULL;
+       }
 
        itf = cominterop_get_ccw (object, klass);
        g_assert (itf);
@@ -1588,8 +1587,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (MonoO
 guint32
 ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (MonoReflectionMethod *m)
 {
-       MONO_ARCH_SAVE_REGS;
-
 #ifndef DISABLE_COM
        return cominterop_get_com_slot_for_method (m->method);
 #else
@@ -1605,8 +1602,6 @@ ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type)
        MonoDomain *domain;
        MonoObject *obj;
        
-       MONO_ARCH_SAVE_REGS;
-
        domain = mono_object_domain (type);
        klass = mono_class_from_mono_type (type->type);
 
@@ -1693,8 +1688,10 @@ ves_icall_System_ComObject_GetInterfaceInternal (MonoComObject* obj, MonoReflect
 {
 #ifndef DISABLE_COM
        MonoClass *class = mono_type_get_class (type->type);
-       if (!mono_class_init (class))
-               mono_raise_exception (mono_class_get_exception_for_failure (class));
+       if (!mono_class_init (class)) {
+               mono_set_pending_exception (mono_class_get_exception_for_failure (class));
+               return NULL;
+       }
 
        return cominterop_get_interface (obj, class, (gboolean)throw_exception);
 #else
@@ -3309,23 +3306,17 @@ ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (gpointe
 MonoString *
 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (gpointer ptr)
 {
-       MONO_ARCH_SAVE_REGS;
-
        return mono_string_from_bstr(ptr);
 }
 
 gpointer
 ves_icall_System_Runtime_InteropServices_Marshal_StringToBSTR (MonoString* ptr)
 {
-       MONO_ARCH_SAVE_REGS;
-
        return mono_string_to_bstr(ptr);
 }
 
 void
 ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (gpointer ptr)
 {
-       MONO_ARCH_SAVE_REGS;
-
        mono_free_bstr (ptr);
 }