[runtime] Fix the signature of native-func-aot wrappers. AOT the delegate invoke...
authorZoltan Varga <vargaz@gmail.com>
Thu, 14 May 2015 16:38:09 +0000 (18:38 +0200)
committerZoltan Varga <vargaz@gmail.com>
Thu, 14 May 2015 16:38:18 +0000 (18:38 +0200)
mono/metadata/marshal.c
mono/metadata/marshal.h
mono/mini/aot-compiler.c

index f2300aff49a53ddf5c45e72dcaf2d255d34aee0f..3a5578eff2bf546b02985a1832968541393e24bd 100644 (file)
@@ -3016,7 +3016,7 @@ free_signature_pointer_pair (SignaturePointerPair *pair)
        g_free (pair);
 }
 
-static MonoMethod *
+MonoMethod *
 mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method)
 {
        MonoMethodSignature *sig, *static_sig, *invoke_sig;
@@ -7555,7 +7555,7 @@ mono_marshal_get_native_func_wrapper_aot (MonoClass *klass)
        info->d.managed_to_native.method = invoke;
 
        g_assert (!sig->hasthis);
-       csig = signature_dup_add_this (image, sig, mono_defaults.int_class);
+       csig = signature_dup_add_this (image, sig, mono_defaults.object_class);
        csig->pinvoke = 0;
        res = mono_mb_create_and_cache_full (cache, invoke,
                                                                                 mb, csig, csig->param_count + 16,
index 22af5900a3ec04ee0602c0057f4d61c01e2ca04e..d2417e862953874d768d7bbb9973c3a0f9c5871d 100644 (file)
@@ -308,6 +308,9 @@ mono_marshal_get_delegate_end_invoke (MonoMethod *method);
 MonoMethod *
 mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del);
 
+MonoMethod *
+mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method);
+
 MonoMethod *
 mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual);
 
index 3072a5eabbcf30fac1defb16dfece70277b52d90..e16eb1f06eeeab6044a74239cdeabecfe53af4ae 100644 (file)
@@ -3668,8 +3668,18 @@ add_wrappers (MonoAotCompile *acfg)
                                for (j = 0; j < cattr->num_attrs; ++j)
                                        if (cattr->attrs [j].ctor && (!strcmp (cattr->attrs [j].ctor->klass->name, "MonoNativeFunctionWrapperAttribute") || !strcmp (cattr->attrs [j].ctor->klass->name, "UnmanagedFunctionPointerAttribute")))
                                                break;
-                               if (j < cattr->num_attrs)
-                                       add_method (acfg, mono_marshal_get_native_func_wrapper_aot (klass));
+                               if (j < cattr->num_attrs) {
+                                       MonoMethod *invoke;
+                                       MonoMethod *wrapper;
+                                       MonoMethod *del_invoke;
+
+                                       /* Add wrappers needed by mono_ftnptr_to_delegate () */
+                                       invoke = mono_get_delegate_invoke (klass);
+                                       wrapper = mono_marshal_get_native_func_wrapper_aot (klass);
+                                       del_invoke = mono_marshal_get_delegate_invoke_internal (invoke, FALSE, TRUE, wrapper);
+                                       add_method (acfg, wrapper);
+                                       add_method (acfg, del_invoke);
+                               }
                        }
                } else if ((acfg->opts & MONO_OPT_GSHAREDVT) && klass->generic_container) {
                        MonoError error;