[wasm][coreclr] First part of the call generator, interp to native#121491
Merged
radekdoulik merged 11 commits intodotnet:mainfrom Nov 18, 2025
Merged
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.
14 tasks
Contributor
There was a problem hiding this comment.
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]>
Member
|
/cc @agocke @jkoritzinsky |
This was referenced Nov 10, 2025
Open
jkotas
reviewed
Nov 10, 2025
jkotas
reviewed
Nov 10, 2025
This was referenced Nov 11, 2025
Co-authored-by: Jan Kotas <[email protected]>
…sm-callhelpers-generator-1st-part
lewing
reviewed
Nov 14, 2025
AaronRobinsonMSFT
approved these changes
Nov 14, 2025
Co-authored-by: Larry Ewing <[email protected]>
Member
Author
|
/ba-g unrelated timeout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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