Skip to content

wasm: report the generic context to the GC stack walk#130000

Merged
AndyAyersMS merged 2 commits into
dotnet:mainfrom
AndyAyersMS:wasm-r2r-generic-context-gc
Jun 30, 2026
Merged

wasm: report the generic context to the GC stack walk#130000
AndyAyersMS merged 2 commits into
dotnet:mainfrom
AndyAyersMS:wasm-r2r-generic-context-gc

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Spill the generic context to its GC slot in the prolog, and populate the frame pointer in TransitionFrame::UpdateRegDisplay so the stack walk can locate it.

Spill the generic context to its GC slot in the prolog, and populate the
frame pointer in TransitionFrame::UpdateRegDisplay so the stack walk can
locate it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 20:23
@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 Jun 29, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@davidwrighton PTAL
fyi @dotnet/wasm-contrib

Fixes a few more Pri-1 test failures.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates CoreCLR’s WASM stack-walking/GC reporting path so the generic context (“rgctx generics context arg” / sometimes this) can be found reliably during GC stack walks by (1) spilling it into the dedicated GC-reportable frame slot in the prolog and (2) ensuring the regdisplay has enough frame information to locate FP-based frame slots.

Changes:

  • Add a WASM-specific CodeGen::genReportGenericContextArg implementation to spill the generic context into lvaCachedGenericContextArgOffset() during prolog generation.
  • Enable genReportGenericContextArg during prolog generation on WASM by removing the previous TARGET_WASM exclusion in the shared prolog code.
  • Populate InterpreterFP in TransitionFrame::UpdateRegDisplay_Impl by recovering it from the stack pointer.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/vm/wasm/helpers.cpp Sets InterpreterFP in TransitionFrame::UpdateRegDisplay_Impl using GetWasmFramePointerFromStackPointer, so FP-based GC slots can be located during stack walks.
src/coreclr/jit/codegenwasm.cpp Implements CodeGen::genReportGenericContextArg for WASM to spill the generic context into its GC-reportable frame slot in the prolog.
src/coreclr/jit/codegencommon.cpp Calls genReportGenericContextArg unconditionally (including WASM) during prolog generation.

Comment thread src/coreclr/vm/wasm/helpers.cpp

@davidwrighton davidwrighton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs more VM side work/testing, and various mixed interpreter/not interpreter scenarios.

Comment thread src/coreclr/vm/wasm/helpers.cpp Outdated
The TransitionFrame fp fix will go in a separate change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@davidwrighton revised to just jit changes now

@AndyAyersMS AndyAyersMS merged commit b882159 into dotnet:main Jun 30, 2026
137 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants