Make SCCs and graph traversals reusable#12590
Open
fitzgen wants to merge 2 commits intobytecodealliance:mainfrom
Open
Make SCCs and graph traversals reusable#12590fitzgen wants to merge 2 commits intobytecodealliance:mainfrom
fitzgen wants to merge 2 commits intobytecodealliance:mainfrom
Conversation
This moves our existing SCC computation and DFS graph traversals out of `wasmtime::compile` and into `wasmtime_environ::graphs`, where they can be reused elsewhere in the workspace. These functions and types were already generally generic over an iterator of nodes and/or an edge function to get a particular node's successors, but I've gone one step further and packaged up those two things together into a `Graph` trait. In the process, I also moved the `NonMaxU32` type to `wasmtime_internal_core` and made it so we have other non-max integer types as well. This will let us reuse SCC computation in our GC ops fuzzer, where we need SCCs to figure out how to merge fuzzer-generated rec groups, if necessary, since cyclic type references are constrained to within the same rec group. The GC ops fuzzer can also reuse the DFS traversal code in its topological sorting of supertypes and subtypes as well.
cfallin
approved these changes
Feb 13, 2026
Member
cfallin
left a comment
There was a problem hiding this comment.
Seems reasonable!
I was idly wondering whether it would make more sense to put the graph-related bits in crates/core/ since that is becoming a home for data structures in general, but I guess the focus there is more on foundational containers (with explicit OOM handling) than algorithms, and also the bits here are not adapted for OOM so we'd be mixing universes if we did that? I'm fine either way honestly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This moves our existing SCC computation and DFS graph traversals out of
wasmtime::compileand intowasmtime_environ::graphs, where they can be reused elsewhere in the workspace. These functions and types were already generally generic over an iterator of nodes and/or an edge function to get a particular node's successors, but I've gone one step further and packaged up those two things together into aGraphtrait.In the process, I also moved the
NonMaxU32type towasmtime_internal_coreand made it so we have other non-max integer types as well.This will let us reuse SCC computation in our GC ops fuzzer, where we need SCCs to figure out how to merge fuzzer-generated rec groups, if necessary, since cyclic type references are constrained to within the same rec group. The GC ops fuzzer can also reuse the DFS traversal code in its topological sorting of supertypes and subtypes as well.
This is mostly, but not quite completely, code motion and fixups of paths and such.
@cfallin, I'm flagging you for review on this one because you reviewed the initial PRs that landed this code.