if ((res = mono_marshal_find_in_cache (cache, sig)))
return res;
-#if 0
- fprintf (stderr, "generating wrapper for signature %s\n", mono_signature_full_name (sig));
-#endif
-
- /* FIXME: better wrapper name */
- char * name = g_strdup_printf ("wrapper_native_indirect_%p", sig);
+ char *name = mono_signature_to_name (sig, "wrapper_native_indirect");
MonoMethodBuilder *mb = mono_mb_new (caller_class, name, MONO_WRAPPER_MANAGED_TO_NATIVE);
mb->method->save_lmf = 1;
WrapperInfo *info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NATIVE_FUNC_INDIRECT);
- //info->d.managed_to_native.method = NULL;
info->d.native_func.klass = caller_class;
info->d.native_func.sig = sig;
mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, /*func*/NULL, flags);
g_free (mspecs);
+ /* Add an extra argument which the caller will use to pass in the ftnptr to call */
MonoMethodSignature *csig = mono_metadata_signature_dup_add_this (image, sig, mono_defaults.int_class);
csig->pinvoke = 0;
add_gsharedvt_wrappers (acfg, mono_method_signature_internal (cfg->method), FALSE, TRUE, TRUE);
}
+ for (GSList *l = cfg->pinvoke_calli_signatures; l; l = l->next) {
+ MonoMethodSignature *sig = mono_metadata_signature_dup ((MonoMethodSignature*)l->data);
+
+ MonoMethod *wrapper = mono_marshal_get_native_func_wrapper_indirect (cfg->method->klass, sig, TRUE);
+ add_extra_method (acfg, wrapper);
+ }
+
if (cfg->llvm_only)
acfg->stats.llvm_count ++;
#if 0
fprintf (stderr, "generating wrapper for calli in method %s with wrapper type %s\n", method->name, mono_wrapper_type_to_str (method->wrapper_type));
#endif
+
+ if (cfg->compile_aot)
+ cfg->pinvoke_calli_signatures = g_slist_prepend_mempool (cfg->mempool, cfg->pinvoke_calli_signatures, fsig);
+
/* Call the wrapper that will do the GC transition instead */
MonoMethod *wrapper = mono_marshal_get_native_func_wrapper_indirect (method->klass, fsig, cfg->compile_aot);