Skip to content

[Wasm Ryujit] Wasm SP is implicitly referenced#124115

Merged
AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS:WasmSPImplicitReference
Feb 7, 2026
Merged

[Wasm Ryujit] Wasm SP is implicitly referenced#124115
AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS:WasmSPImplicitReference

Conversation

@AndyAyersMS
Copy link
Member

Fixes an issue where SP mentions are introduced late (say from a throw helper).

Fixes an issue where SP mentions are introduced late (say from a throw helper).
Copilot AI review requested due to automatic review settings February 7, 2026 00:26
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 7, 2026
@AndyAyersMS
Copy link
Member Author

@SingleAccretion not sure if this is what we agreed on or you have other ideas.

Fixes things like

Assertion failed '(WasmValueType::Invalid < wasmType) && (wasmType < WasmValueType::Count)' 
   in 'System.Reflection.BlobUtilities:WriteByte(byte[],int,byte)' during 'Generate code'

where the only SP mention is in the bounds check helper.

@AndyAyersMS
Copy link
Member Author

fyi @dotnet/jit-contrib

Copy link
Contributor

Copilot AI left a 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 ensures the Wasm shadow stack pointer local (lvaWasmSpArg) is treated as “implicitly referenced” so it won’t be considered unused when references to it are introduced later in compilation (e.g., via late-added helper calls).

Changes:

  • Mark the Wasm stack pointer argument local as lvImplicitlyReferenced.
  • Mark the reverse-P/Invoke Wasm stack pointer temp local as lvImplicitlyReferenced when it is allocated.

Copy link
Contributor

@SingleAccretion SingleAccretion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ordering issue between the stack level setter and liveness / ref counting still needs to be fixed, but this is also a correct change (since there are implicit references at nodes like LCLHEAP).

@AndyAyersMS
Copy link
Member Author

@adamperlin @kg can one of you approve?

@AndyAyersMS AndyAyersMS merged commit 18a3069 into dotnet:main Feb 7, 2026
130 of 132 checks passed
@am11 am11 added the arch-wasm WebAssembly architecture label Feb 8, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants