gc_ops: Add support for struct subtypes#12931
gc_ops: Add support for struct subtypes#12931khagankhan wants to merge 2 commits intobytecodealliance:mainfrom
Conversation
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
fitzgen
left a comment
There was a problem hiding this comment.
Thanks! One small thing before we merge
| let supertype = if types.type_defs.is_empty() { | ||
| None | ||
| } else { | ||
| ctx.rng().choose(types.type_defs.keys()).copied() | ||
| }; |
There was a problem hiding this comment.
choose already returns an None when 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?
There was a problem hiding this 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.
|
Thanks @fitzgen! Ready for review! |
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.rsadd_structnow generatesis_finalwith a 25% chance and picks a randomsupertypefrom existing types.fixuptrims some of these, so we still get a healthy mix of root types.duplicate_groupnow properly duplicates subtype info:is_finalsupertypeedges to the cloned type IDsops.rsencode_ty_idnow uses actualis_finalandsupertypeinstead of hardcodedtrue/None.types.rsDfs/Graphinfrastructure:SupertypeGraphRecGroupGraphsort_types_by_supertypefor topological sorting of types within a group.sort_rec_groups_topofor topological sorting of rec groups between groups.break_supertype_cyclesto drop type-level back edges.break_rec_group_cyclesto drop cross-group back edges at the rec-group level.fixupwith supertype validation:tests.rsAdded tests for:
cc @fitzgen @eeide