Skip to content

[wasm] Insert GC Polls in Cycles - #136406

Closed
adamperlin wants to merge 3 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-gc-polls
Closed

adamperlin wants to merge 3 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-gc-polls

Conversation

@adamperlin

@adamperlin adamperlin commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #133431. We don't have fully interruptible GC mode in Wasm, so if we have a cycle there may not be an opportunity for a GC; insert GC polls at cycle headers to conservatively ensure we do have GC opporunities.

@adamperlin
adamperlin requested a balanced review from Copilot October 24, 2026 00:05
@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 Oct 24, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@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.

🟡 Changes recommended

The regression tests do not deterministically verify poll emission or collection safety with live references and interior byrefs.

1 open issue
What changed in this PR

Adds GC poll placement for WebAssembly control-flow cycles, addressing the Wasm ReadyToRun polling gap described in #133431.

Changes:

  • Marks cycle headers for polling, including implicit cycles through tail calls.
  • Makes the frame-size node available outside target guards and adds debug display support.
  • Adds browser/CoreCLR regression cases for loops, live references, interior byrefs, and tail calls.
File Description
src/​tests/​JIT/​Regression_3/​WasmGCPolls/​WasmGCPollsTailCalls.ilproj Builds the IL test helper library.
src/​tests/​JIT/​Regression_3/​WasmGCPolls/​WasmGCPollsTailCalls.il Adds tail-call and control-flow edge cases.
src/​tests/​JIT/​Regression_3/​WasmGCPolls/​WasmGCPolls.csproj Configures isolated browser/CoreCLR ReadyToRun tests.
src/​tests/​JIT/​Regression_3/​WasmGCPolls/​WasmGCPolls.cs Checks results across several cycle shapes.
src/​coreclr/​jit/​gtlist.h Moves the frame-size node into the unconditional node list.
src/​coreclr/​jit/​gentree.cpp Handles frame-size nodes in debug output.
src/​coreclr/​jit/​flowgraph.cpp Detects cycles and marks headers for GC polls.
src/​coreclr/​jit/​compiler.h Declares the cycle-marking helper.

Review effort: Balanced

Comment on lines +18 to +20
Assert.Equal(expected, SimpleCycle(iterations));
Assert.Equal(expected, ReferenceCycle(iterations));
Assert.Equal(expected, InteriorByrefCycle(iterations));
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.

[Wasm R2R]: emit GC polls

2 participants