[Wasm / RyuJit]: don't mark CORINFO_HELP_GETREFANY pure on wasm#129060
Open
AndyAyersMS wants to merge 1 commit into
Open
[Wasm / RyuJit]: don't mark CORINFO_HELP_GETREFANY pure on wasm#129060AndyAyersMS wants to merge 1 commit into
AndyAyersMS wants to merge 1 commit into
Conversation
The wasm ABI passes any struct without a single scalar lowering by implicit byref (WasmClassifier::Classify -> passByRef = true for CORINFO_WASM_TYPE_VOID). TypedReference is two pointers and has no scalar lowering, so its struct arg to GETREFANY is implicit byref -- the same situation as win-x64 that dotnet#80292 already guarded against. Marking the helper pure in this case violates the contract enforced by fgValueNumberHelperCallFunc's default branch and trips: Assertion failed '!arg.AbiInfo.IsPassedByReference() && "Helpers taking implicit byref arguments should not be marked as pure"' in 'JitTest_array2_refany_il.Test:TestRef(System.TypedReference)' during 'Do value numbering' (valuenum.cpp:14328) Affects refanyval users JIT/Methodical/refany/array2_{d,r} and array3_{d,r}. Fix: exclude TARGET_WASM from the pure-marking guard alongside WINDOWS_AMD64_ABI, and expand the comment so future ports know to re-evaluate. Other FEATURE_IMPLICIT_BYREFS targets (arm64, riscv64, loongarch64) pass the 16-byte aggregate in two registers and are not affected. Verified: with the fix, crossgen2 emits array2_d.wasm and array3_r.wasm successfully (no assert), and both tests pass at runtime under R2R. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@dotnet/wasm-contrib PTAL |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
kg
approved these changes
Jun 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts JIT helper-call metadata so CORINFO_HELP_GETREFANY is not treated as a pure helper when targeting Wasm, aligning with the Wasm ABI behavior where TypedReference is passed as an implicit byref (i.e., the helper can observe memory).
Changes:
- Stop marking
CORINFO_HELP_GETREFANYasisPureforTARGET_WASMinHelperCallProperties::init(). - Expand the existing comment to document why Wasm matches the Windows x64 “implicit byref” purity restriction for this helper.
This was referenced Jun 6, 2026
Open
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.
The wasm ABI passes TypedReference as implicit byref. So CORINFO_HELP_GETREFANY cannot be considered pure (just like on windows x64).
Affects refanyval users JIT/Methodical/refany/array2_{d,r} and array3_{d,r}.
See #128234 (comment)