Skip to content

[Wasm RyuJit]: don't skip top-level catchrets when marking try resumption#129205

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-wasm-try-catch
Open

[Wasm RyuJit]: don't skip top-level catchrets when marking try resumption#129205
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-wasm-try-catch

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

In FlowGraphTryRegions::Build, the BBJ_EHCATCHRET check sat below the early bailout on hasTryIndex, so the catchret of an outer catch was never marking its try region as requiring runtime resumption.

In FlowGraphTryRegions::Build, the BBJ_EHCATCHRET check sat below the
early bailout on hasTryIndex, so the catchret of an outer catch was
never marking its try region as requiring runtime resumption.

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

Copy link
Copy Markdown
Member Author

@dotnet/jit-contrib PTAL
@davidwrighton @dotnet/wasm-contrib FYI

Fixes a dumb logic bug.

With this and #129197 I'm able to resume after catch in simple R2R methods. Haven't tested more widely yet.

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

Adjusts FlowGraphTryRegions::Build so BBJ_EHCATCHRET blocks always mark their associated “dispatching try” region as requiring runtime resumption, even when the catchret block itself has no TryIndex (e.g., outermost catch).

Changes:

  • Move the BBJ_EHCATCHRET handling before the early !block->hasTryIndex() bailout.
  • Preserve existing behavior for try-region membership/entry-edge discovery while ensuring top-level catchrets are no longer skipped.

Comment on lines +7747 to +7758
// If this block is a BBJ_EHCATCHRET, mark the "dispatching try" region
// as requiring runtime resumption.
//
if (block->KindIs(BBJ_EHCATCHRET))
{
assert(block->hasHndIndex());
unsigned const ehRegionIndex = block->getHndIndex();
BasicBlock* const dispatchingTryBlock = comp->ehGetDsc(ehRegionIndex)->ebdTryBeg;
FlowGraphTryRegion* const dispatchingTryRegion = regions->GetTryRegionByHeader(dispatchingTryBlock);

dispatchingTryRegion->SetRequiresRuntimeResumption();
}
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