Skip to content

[Wasm Ryujit] Flow cannot fall through into a throw helper#123908

Merged
AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS:NoFallThroughToThrowHelper
Feb 2, 2026
Merged

[Wasm Ryujit] Flow cannot fall through into a throw helper#123908
AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS:NoFallThroughToThrowHelper

Conversation

@AndyAyersMS
Copy link
Member

Make sure we emit proper Wasm block/end for throw helpers, since we may branch to them mid-block, so can't fall through even if the helper is the next block.

Also make it clearer which blocks are throw helpers, instead of trying to guess by parsing block contents and such.

Make sure we emit proper Wasm `block/end` for throw helpers, since
we may branch to them mid-block, so can't fall through even if the
helper is the next block.

Also make it clearer which blocks are throw helpers, instead of trying
to guess by parsing block contents and such.
Copilot AI review requested due to automatic review settings February 2, 2026 19:13
@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 2, 2026
@AndyAyersMS
Copy link
Member Author

@adamperlin PTAL
fyi @dotnet/jit-contrib

Some minor diffs in non-Wasm targets, mainly throw helper blocks getting reordered.

@dotnet-policy-service
Copy link
Contributor

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

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 fixes a Wasm RyuJIT issue where control flow could incorrectly fall through into throw helper blocks. The solution introduces a new BBF_THROW_HELPER flag to explicitly mark throw helper blocks, replacing complex heuristic-based detection logic with a simple flag check.

Changes:

  • Introduces BBF_THROW_HELPER flag to explicitly mark throw helper blocks
  • Simplifies fgIsThrowHlpBlk() from ~60 lines of complex logic to a single flag check
  • Updates Wasm control flow to prevent fall-through to throw helper blocks

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/block.h Adds new BBF_THROW_HELPER flag and includes it in BBF_SPLIT_NONEXIST to prevent splitting throw helper blocks
src/coreclr/jit/flowgraph.cpp Sets BBF_THROW_HELPER flag when creating throw helper blocks and adds assertions to verify flag consistency
src/coreclr/jit/compiler.hpp Replaces complex ~60-line heuristic-based throw helper detection with simple flag check
src/coreclr/jit/fgwasm.cpp Updates control flow logic to prevent fall-through to throw helper blocks by checking the flag

Copy link
Contributor

@adamperlin adamperlin left a comment

Choose a reason for hiding this comment

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

Looks good to me, just one small comment!

@AndyAyersMS
Copy link
Member Author

/ba-g infrastructure abandoned some work

@AndyAyersMS AndyAyersMS merged commit 4e165c3 into dotnet:main Feb 2, 2026
112 of 121 checks passed
lewing pushed a commit to lewing/runtime that referenced this pull request Feb 9, 2026
…3908)

Make sure we emit proper Wasm `block/end` for throw helpers, since we
may branch to them mid-block, so can't fall through even if the helper
is the next block.

Also make it clearer which blocks are throw helpers, instead of trying
to guess by parsing block contents and such.
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