-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mono][wasm] Add interpreter support for calls to UnmanagedCallersOnly EntryPoint without managed delegate reference #95087
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue Details#94615 added EntryPoint support to UCO
[UnmanagedCallersOnly(EntryPoint = "display_meaning")]
public static void DisplayMeaningExport(int meaning)
{
Console.WriteLine($"The meaning of life is {meaning}");
} but there is currently an issue with when invoking the export from unmanaged when there is no managed delegate pointing to it. Intptr workaround = (IntPtr)(delegate* unmanaged<int,void>)&display_meaning; // needs to be in method loaded by interp prior to unmanaged call
|
Tagging subscribers to this area: @BrzVlad, @kotlarmilos Issue Details#94615 added EntryPoint support to UCO
[UnmanagedCallersOnly(EntryPoint = "display_meaning")]
public static void DisplayMeaningExport(int meaning)
{
Console.WriteLine($"The meaning of life is {meaning}");
} but there is currently an issue with when invoking the export from unmanaged when there is no managed delegate pointing to it. Intptr workaround = (IntPtr)(delegate* unmanaged<int,void>)&display_meaning; // needs to be in method loaded by interp prior to unmanaged call unless
|
@maraf this is essentially the same issue you are seeing with the JSExport for nativeAOT changes, by which I mean for mono we could drastically simplify the current initialization code if we fix the fallback case here |
@steveisok @vitek-karas this is blocking wasi work |
The generator probably needs to generate some extra code to lookup the MonoMethod*, and call something like |
Something like:
Will force the pointers to be initialized. This can be done either on startup at the end of
|
@lewing Do you have any more details (or even better an example I can look at) on the mentioned workaround? I tried adding some code like that to the |
@knutwannheden It's something that can't be done in user. I needs to happen in generate C code that works as a trampoline to call managed code |
Excellent news! Looking forward to the next release containing this fix ❤️ |
#94615 (comment)
#94615 added EntryPoint support to UCO on wasm (it was missing before)
but there is currently an issue with when invoking the export from unmanaged when there is no managed delegate pointing to it and something akin to the following workaround is required:
This is because
get_native_to_interp
must be called before attempting to invoke the unmanaged entry point or the call will fail. Without the callwasm_native_to_interp_ftndescs
is never initialized. For the workaround to work the delegate * does not need to be reached/reachable, the interpreter simply needs to resolve the method prior to calling it from unmanaged.The text was updated successfully, but these errors were encountered: