Skip to content

Conversation

@AndyAyersMS
Copy link
Member

@AndyAyersMS AndyAyersMS commented Nov 7, 2025

Loops for Wasm control flow codegen don't involve EH or runtime mediated
control flow transfers.

Implement a custom block successor enumerator for Wasm, and adjust fgRunDFS
to allow using this and also to generalize how the DFS is initiated. Use
this to build a "Wasm" DFS. In that DFS handle both the main method and
all funclets (by specifying funclet entries as additional DFS starting points).

Update the loop finding code to make suitable changes when it is driven from
a "Wasm" DFS instead of the typical all successor / all predecessor DFS.

Remove the restriction in the Wasm control flow codegen that only handles
the main method; now it works for the main method and all funclets.

Contributes to #121178.

Dependent on #121417.

AndyAyersMS and others added 7 commits November 6, 2025 11:34
Determine how to emit Wasm control flow from the JIT's control flow graph.

Relies on loop-aware RPO to determine the block order. Currently only
handles the main method. Assumes irreducible loops have been fixed
upstream (which is not yet guaranteed; bails out if not so).

Doesn't actually do any emission, just prints a textual description in
the JIT dump (along with a dot markup version).

Uses only LOOP and BLOCK. Tries to limit the extent of BLOCK.

Run for now as an optional phase even if not targeting Wasm, to
do some stress testing.

Contributes to dotnet#121178
Co-authored-by: Copilot <[email protected]>
Loops for Wasm control flow codegen don't involve EH or runtime mediated
control flow transfers.

Implement a custom block successor enumerator for Wasm, and adjust `fgRunDFS`
to allow using this and also to generalize how the DFS is initiated. Use
this to build a "Wasm" DFS. In that DFS handle both the main method and
all funclets (by specifying funclet entries as additional DFS starting points).

Update the loop finding code to make suitable changes when it is driven from
a "Wasm" DFS instead of the typical all successor / all predecessor DFS.

Remove the restriction in the Wasm control flow codegen that only handles
the main method; now it works for the main method and all funclets.

Contributes to dotnet#121178.
@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 Nov 7, 2025
@AndyAyersMS AndyAyersMS changed the title Wasm depth first search [Wasm RyuJIT] Implement Wasm DFS and Loop Finding Nov 7, 2025
@am11 am11 added the arch-wasm WebAssembly architecture label Nov 7, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture 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.

2 participants