[Wasm Ryujit] Flow cannot fall through into a throw helper#123908
[Wasm Ryujit] Flow cannot fall through into a throw helper#123908AndyAyersMS merged 1 commit intodotnet:mainfrom
Conversation
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.
|
@adamperlin PTAL Some minor diffs in non-Wasm targets, mainly throw helper blocks getting reordered. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib |
There was a problem hiding this comment.
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_HELPERflag 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 |
adamperlin
left a comment
There was a problem hiding this comment.
Looks good to me, just one small comment!
|
/ba-g infrastructure abandoned some work |
…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.
Make sure we emit proper Wasm
block/endfor 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.