Use user-arg accessors when expanding runtime lookups#130949
Open
tannergooding wants to merge 2 commits into
Open
Use user-arg accessors when expanding runtime lookups#130949tannergooding wants to merge 2 commits into
tannergooding wants to merge 2 commits into
Conversation
fgExpandRuntimeLookupsForCall indexed the helper call's arguments with the raw CountArgs/GetArgByIndex accessors, assuming the runtime-lookup helper has exactly its two user args (genericCtx, signatureCns). On wasm, AddFinalArgsAndDetermineABIInfo prepends a non-user WasmShadowStackPointer arg to every managed call during global morph, which runs before the runtime-lookup expansion phase. That leading arg shifted the raw indices, tripping assert(CountArgs() == 2) and, with asserts off, reading the context and signature from the wrong nodes. Switch to CountUserArgs/GetUserArgByIndex, which skip non-user args (r2r cell, wasm sp) the same way the rest of the JIT already reads helper-call args. This is identical on targets that don't prepend such args. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Member
Author
|
CC. @dotnet/jit-contrib, @adamperlin, @lewing this fixes around 10k helperexpansion asserts from SPMI, is product code impacting |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates fgExpandRuntimeLookupsForCall to read runtime-lookup helper-call arguments via the “user arg” APIs (CountUserArgs / GetUserArgByIndex) instead of raw indices, so non-user arguments prepended during morphing (e.g., on TARGET_WASM) don’t shift the expected (genericCtx, signatureCns) positions.
Changes:
- Switch runtime-lookup helper-call arity assertion from
CountArgs()toCountUserArgs(). - Switch argument reads from
GetArgByIndex(0/1)toGetUserArgByIndex(0/1)when extractinggenericCtxandsignatureCns.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/helperexpansion.cpp | Uses user-arg accessors for runtime lookup helper-call argument indexing to avoid non-user arg prepends shifting indices (notably on wasm). |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Both fgExpandThreadLocalAccessForCall and fgExpandStackArrayAllocation indexed the IL args by raw position, which the wasm shadow-stack arg prepended during morph shifts. Switch them to the user-arg accessors used elsewhere in the file so they skip the non-user leading arg. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Jul 17, 2026
Open
Open
Member
Author
|
CC. @dotnet/wasm-contrib |
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.
fgExpandRuntimeLookupsForCallindexed the runtime-lookup helper call's arguments with the rawCountArgs/GetArgByIndexaccessors, assuming exactly its two user args(genericCtx, signatureCns).On wasm,
AddFinalArgsAndDetermineABIInfoprepends a non-userWasmShadowStackPointerarg to the front of every managed call during global morph, which runs beforefgExpandRuntimeLookups. That leading arg shifts the raw indices, so:assert(call->gtArgs.CountArgs() == 2)fires (there are three args), andGetArgByIndex(0)/GetArgByIndex(1)read the shadow-stack pointer and the context instead of the context and the signature.Switch to
CountUserArgs/GetUserArgByIndex, which skip non-user args (r2r cell,wasm sp) the same way the rest of the JIT already reads helper-call args. This is behavior-identical on targets that don't prepend such args, and fixes shared-generic runtime lookups on wasm.This shows up across shared-generic (
[System.__Canon]) methods; it accounts for ~10k of the assert-failing methods in a wasm SuperPMI altjit replay over the libraries/coreclr test collections.Note
This PR was authored with GitHub Copilot.