dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.64k stars 4.57k forks source link

wish: allow mono runtime components to provide QCalls to the runtime #53607

Open lambdageek opened 3 years ago

lambdageek commented 3 years ago

See, for example, https://github.com/dotnet/runtime/pull/53500/files#diff-8fa4a2213aa9c853fd1afd18bf447a57ba660d5ef23e04525c614594f8942e89 where the mono EventPipe component adds icalls. There is a lot of boilerplate: adding the methods to icall-def-netcore.h, adding methods to the component vtable, implementing stub methods in the comoponent stub, adding boilerplate icall implementations that call the component methods.

Maybe we ought to have a way for a component to provide the runtime with a list of qcall implementations.

(Using qcalls would be better because then we can share more managed code with CoreCLR; but icalls would be ok, too).

Potential complications:

ghost commented 3 years ago

Tagging subscribers to this area: @CoffeeFlux See info in area-owners.md if you want to be subscribed.

Issue Details
See, for example, https://github.com/dotnet/runtime/pull/53500/files#diff-8fa4a2213aa9c853fd1afd18bf447a57ba660d5ef23e04525c614594f8942e89 where the mono EventPipe component adds icalls. There is a lot of boilerplate: adding the methods to icall-def-netcore.h, adding methods to the component vtable, implementing stub methods in the comoponent stub, adding boilerplate icall implementations that call the component methods. Maybe we ought to have a way for a component to provide the runtime with a list of qcall implementations. (Using qcalls would be better because then we can share more managed code with CoreCLR; but icalls would be ok, too). Potential complications: * on Wasm the linker knows how to generate a slimmed down icall table that just includes the icalls actually used by managed code; it would be a shame to lose that * complexity due to all the variations in dynamic/static component linking
Author: lambdageek
Assignees: -
Labels: `area-VM-meta-mono`
Milestone: -
lewing commented 3 years ago

@lambdageek we scan for pinvokes too, does this not already work?

lambdageek commented 3 years ago

yea it probably works. but we haven't really validated it. Also at some point we added qcall registration but I don't think it's used at all. I think we just use __Internal