Skip to content

[mono][wasm] Add interpreter support for calls to UnmanagedCallersOnly EntryPoint without managed delegate reference #95087

Closed
@lewing

Description

@lewing

#94615 (comment)

#94615 added EntryPoint support to UCO on wasm (it was missing before)

 
        [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 and something akin to the following workaround is required:

   Intptr workaround = (IntPtr)(delegate* unmanaged<int,void>)&display_meaning;  // needs to be in method loaded by interp prior to unmanaged call 

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 call wasm_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.

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-Codegen-Interpreter-monoin-prThere is an active PR which will close this issue when it is mergedos-browserBrowser variant of arch-wasmos-wasiRelated to WASI variant of arch-wasm

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions