khagankhan opened PR #12931 from khagankhan:struct-subtyping-support to bytecodealliance:main:
Add struct subtype support
This adds
is_finalandsupertypefields toSubType, enabling struct subtype hierarchies in the GC fuzzer.Design change: DFS cycle breaking instead of SCC merging
The (unintentionally :/ ) deleted branch used SCC to find rec groups with cross-group supertype cycles and merge them. When I was analyzing the mutated modules, I saw that almost all groups end up in one huge merged group after a few iterations. The new approach runs a DFS on the rec-group dependency graph and drops only the supertype edges that form back edges, which is the minimum (apparently) needed to break cycles. Groups stay separate, and the
cranelift-entity/StronglyConnectedComponentsdependencies are removed. No SCC here at all.Changes by file
mutator.rs
add_structnow generatesis_finalwith a 25% chance and picks a randomsupertypefrom existing types.- Cycle breaking in
fixuptrims some of these, so we still get a healthy mix of root types.duplicate_groupnow properly duplicates subtype info:
- preserves
is_final- remaps intra-group
supertypeedges to the cloned type IDs
ops.rs
- Type encoding updated to emit types and rec groups in topologically sorted order:
- supertypes before subtypes
- depended-on groups before dependent groups
encode_ty_idnow uses actualis_finalandsupertypeinstead of hardcodedtrue/None.
types.rs
- Added two graph adapters for the existing
Dfs/Graphinfrastructure:
SupertypeGraphRecGroupGraph- Added
sort_types_by_supertypefor topological sorting of types within a group.- Added
sort_rec_groups_topofor topological sorting of rec groups between groups.- Added
break_supertype_cyclesto drop type-level back edges.- Added
break_rec_group_cyclesto drop cross-group back edges at the rec-group level.- Extended
fixupwith supertype validation:
- final-supertype checks
- cycle breaking
tests.rsAdded tests for:
- type topological sorting
- rec-group topological sorting
- supertype cycle breaking
- rec-group cycle breaking
cc @fitzgen @eeide
khagankhan requested alexcrichton for a review on PR #12931.
khagankhan requested wasmtime-fuzz-reviewers for a review on PR #12931.
github-actions[bot] added the label fuzzing on PR #12931.
github-actions[bot] commented on PR #12931:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
- fitzgen: fuzzing
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
fitzgen submitted PR review:
Thanks! One small thing before we merge
fitzgen created PR review comment:
choosealready returns anNonewhen there are no options given to it, so we don't need to have the empty check here.Also, we don't want to always generate supertypes. Better to do it with some probability, maybe a quarter of the time?
khagankhan submitted PR review.
khagankhan created PR review comment:
Oh cool! I wanted to do that because we already remove supertypes in cycle-checks so in the end we still end up with structs without supertypes. But I agree probability would be better since.
khagankhan edited PR review comment.
khagankhan updated PR #12931.
khagankhan commented on PR #12931:
Thanks @fitzgen! Ready for review!
khagankhan updated PR #12931.
fitzgen submitted PR review:
Thanks!
fitzgen added PR #12931 gc_ops: Add support for struct subtypes to the merge queue.
fitzgen removed PR #12931 gc_ops: Add support for struct subtypes from the merge queue.
fitzgen merged PR #12931.
Last updated: Apr 13 2026 at 00:25 UTC