[Wasm RyuJit] Zero init gc shadow stack slots in the prolog#129073
Conversation
|
@dotnet/wasm-contrib PTAL |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR updates the CoreCLR JIT’s WASM backend prolog generation to ensure stack-frame zero-initialization is emitted as a single memory.fill, with the goal of explicitly zeroing GC-ref slots on the WASM shadow stack.
Changes:
- Add a WASM-specific
CodeGen::genZeroInitFrameimplementation that emits a singlememory.fill. - Update
genCheckUseBlockInit()so WASM always uses block-init when there are any init slots. - Adjust
genFnProlog()on WASM to compute the prolog zero-init byte range from memory-residentlvMustInitlocals (skipping certain WASM frame-header locals).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/jit/codegenwasm.cpp | Adds WASM-specific prolog frame zero-init via memory.fill and marks the block-init helper as unreachable. |
| src/coreclr/jit/codegencommon.cpp | Forces block-init selection on WASM and changes prolog range computation to WASM-specific logic. |
|
With this applied to my local branch, my spilling test scenario works without GC crashes, so I think you're right! |
Use a single memory.fill to zero the slots. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
45a9808 to
1f9b88e
Compare
Address PR review feedback: drop the confusing reference to `register-init bookkeeping below`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Seems to be working and showing what we'd expect; memory.fills in the prologs. |
Address PR review feedback: genCheckUseBlockInit now uses block-init on WASM whenever there are any init slots, so fgVarNeedsExplicitZeroInit should mirror that and skip the per-target size threshold for WASM. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
We must explicitly zero GC ref slots on the shadow stack in the prolog. Do this via a single memory.fill.