-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[wasm][coreclr] First part of the call generator, interp to native #121491
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
[wasm][coreclr] First part of the call generator, interp to native #121491
Conversation
It can be now used to update wasm callhelpers manually. Example usage:
./dotnet.sh build /t:RunGenerator /p:GeneratorOutputPath="./" /p:AssembliesScanPath="<your-path-to-assemblies>" src/tasks/WasmAppBuilder/WasmAppBuilder.csproj
The call helper files are split to 2 files, similar as on mono. The
pinvoke/reverse parts of the generator will be updated in the
followup PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds managed-to-native code generation infrastructure for WebAssembly builds, implementing signature mapping and interop thunk generation for both Mono and CoreCLR runtimes.
- Introduces new
ManagedToNativeGenerator,SignatureMapper, andInterpToNativeGeneratorclasses to generate C++ interop code from managed assembly metadata - Splits the existing
callhelpers.cppinto separate files for forward and reverse thunks in CoreCLR - Adds runtime-flavor-specific compilation support in the build system to maintain separate implementations for Mono and CoreCLR
Reviewed Changes
Copilot reviewed 7 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/WasmAppBuilder/mono/SignatureMapper.cs | Maps .NET types to WASM signature characters (uppercase) for Mono runtime |
| src/tasks/WasmAppBuilder/mono/ManagedToNativeGenerator.cs | MSBuild task that orchestrates pinvoke and icall scanning/generation for Mono |
| src/tasks/WasmAppBuilder/mono/InterpToNativeGenerator.cs | Generates C trampoline functions for interpreter-to-native transitions in Mono |
| src/tasks/WasmAppBuilder/coreclr/SignatureMapper.cs | Maps .NET types to WASM signature characters (lowercase) with additional 'n' type for CoreCLR runtime |
| src/tasks/WasmAppBuilder/coreclr/ManagedToNativeGenerator.cs | MSBuild task with temporary hardcoded signatures for CoreCLR interop generation |
| src/tasks/WasmAppBuilder/coreclr/InterpToNativeGenerator.cs | Generates CallFunc_* helper functions for CoreCLR interpreter-to-native calls |
| src/tasks/WasmAppBuilder/WasmAppBuilder.csproj | Adds conditional compilation to exclude runtime-specific files and defines RunGenerator target |
| src/coreclr/vm/wasm/callhelpers-reverse.cpp | New file containing reverse thunk implementations for unmanaged-to-managed calls |
| src/coreclr/vm/wasm/callhelpers-interp-to-managed.cpp | Generated file with signature-specific trampoline functions for interpreter transitions |
| src/coreclr/vm/CMakeLists.txt | Updates build to reference split callhelpers files instead of single file |
Co-authored-by: Copilot <[email protected]>
|
/cc @agocke @jkoritzinsky |
Co-authored-by: Jan Kotas <[email protected]>
…sm-callhelpers-generator-1st-part
Co-authored-by: Larry Ewing <[email protected]>
|
/ba-g unrelated timeout |
Port of the generator task to the CoreCLR.
It can be now used to update wasm callhelpers manually. Example usage:
The call helper files are split to 2 files, similar as on Mono. The pinvoke/reverse parts of the generator will be updated in the followup PR.
Contributes to #113692