Add special casing for string constructors for WebAssembly#130104
Open
davidwrighton wants to merge 3 commits into
Open
Add special casing for string constructors for WebAssembly#130104davidwrighton wants to merge 3 commits into
davidwrighton wants to merge 3 commits into
Conversation
davidwrighton
commented
Jul 1, 2026
Member
- String constructors are special. Notably, they are implemented by static functions with a slightly different calling convention
- Add logic to tweak the JIT to notify crossgen2 that its working with one of them
- Add logic to let the stubs generated be the correct ones
- Add logic to find the right thunks
- String constructors are special. Notably, they are implemented by static functions with a slightly different calling convention - Add logic to tweak the JIT to notify crossgen2 that its working with one of them - Add logic to let the stubs generated be the correct ones - Add logic to find the right thunks
Member
Author
|
@AndyAyersMS We probably also need the interpreter to R2R variant handling for this, but I'll tackle that when I work on bringup of using the compiled System.Private.CoreLib.dll |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the WebAssembly JIT/EE and crossgen2 wasm signature plumbing to special-case string constructors, which are treated as “constructor-like” entrypoints but implemented via static helpers with a different effective calling convention/signature for thunk generation and lookup.
Changes:
- Adds a shared helper (
WasmLowering.GetStringCtorActualSignature) to reinterpretstringctor signatures as static methods returningstring. - Updates crossgen2 wasm signature handling to apply the adjusted signature for thunk generation in relevant paths.
- Updates the wasm VM thunk lookup path to select special portable-entrypoint-to-interpreter thunk keys for
stringconstructors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/wasm/helpers.cpp | Adds string-ctor-specific portable entrypoint thunk key selection. |
| src/coreclr/tools/Common/JitInterface/WasmLowering.cs | Adds helper to rewrite string ctor signatures to their effective wasm signature. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs | Adds detection/rewriting for the string-ctor special-case when recording wasm managed call signatures. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/WasmImportThunkPortableEntrypoint.cs | Uses rewritten signature for string ctor internal calls when computing wasm import thunk signatures. |
| src/coreclr/jit/codegenwasm.cpp | Adjusts the signature reported to crossgen2 for special-cased ctor calls (intended for string ctors). |
AndyAyersMS
reviewed
Jul 2, 2026
AndyAyersMS
left a comment
Member
There was a problem hiding this comment.
LGTM
You will need to fix formatting so ping me and I'll approve after that goes through.
3 tasks
Comment on lines
+1446
to
+1449
| default: | ||
| PORTABILITY_ASSERT("GetPortableEntryPointToInterpreterThunk: unknown thunk for string constructor"); | ||
| break; | ||
| } |
Comment on lines
+2875
to
+2881
| if (callRetType == TYP_REF && sigInfoCall->retType == CORINFO_TYPE_VOID && | ||
| sigInfoCall->callConv == CORINFO_CALLCONV_HASTHIS) | ||
| { | ||
| // Adjust sigInfoCall for string ctor case | ||
| sigInfoCall->retType = CORINFO_TYPE_CLASS; | ||
| sigInfoCall->callConv = CORINFO_CALLCONV_DEFAULT; | ||
| } |
Comment on lines
+3615
to
+3622
| if (callSig->callConv == CorInfoCallConv.CORINFO_CALLCONV_DEFAULT && | ||
| callSig->retType == CorInfoType.CORINFO_TYPE_CLASS && | ||
| !sig.IsStatic && | ||
| sig.ReturnType == sig.Context.GetWellKnownType(WellKnownType.Void)) | ||
| { | ||
| // Detect special case for string ctors | ||
| sig = WasmLowering.GetStringCtorActualSignature(sig); | ||
| } |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.