Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Oct 14, 2024

This found #6995

@kripken kripken requested a review from tlively October 14, 2024 22:04
AtomicFence : 1
Binary : 77
Block : 79
BrOn : 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got lucky here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(easy come, easy go... update lost it)

&Self::makeRefCast);
}
if (wasm.features.hasGC()) {
options.add(FeatureSet::ReferenceTypes | FeatureSet::GC, &Self::makeBrOn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably go up in the if (canMakeControlFlow) block rather than here. No need to explicitly guard on wasm.features.hasGC(), since that guard is already built into the option.

.add(FeatureSet::GC | FeatureSet::ReferenceTypes, &Self::makeCallRef)
.add(FeatureSet::GC | FeatureSet::ReferenceTypes, &Self::makeStructSet)
.add(FeatureSet::GC | FeatureSet::ReferenceTypes, &Self::makeArraySet)
.add(FeatureSet::ReferenceTypes | FeatureSet::GC, &Self::makeBrOn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make the order of the features consistent with those in the surrounding lines.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I fixed up a few more as well, all going with "references | GC", based on the logic of using the same order as the order of the proposals.

case BrOnNonNull: {
// The sent type is the non-nullable version of the reference, so any ref
// of that type is ok, nullable or not.
refType = Type(targetType.getHeapType(), getNullability());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well hard-code Nullable here and let make() choose to make a non-nullable subtype later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow. That might conflict with the behavior of the other variants, as they all share the same make at the bottom?

It seems simpler to pick random nullability here, which lets refType be equal to the type that make will produce later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first thing make does is choose a random subtype of the requested type, though. Choosing a random subtype of the allowed type before calling make is therefore redundant. (And I guess actually this applies to where we now randomly pick a subtype when setting refType in the BrOnCast and BrOnCastFail cases as well.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Though I'm not sure I'd like to depend on the behavior of make always picking a subtype. E.g. maybe in the future we'll make it do that only rarely, or something like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough 👍

Comment on lines 4017 to 4019
castType = getSubType(targetType);
// The ref's type must be castable to the target, or we'd not validate.
refType = getSuperType(castType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe with some small probability we should have the refType be a subtype of the castType, which is valid and just makes the cast trivially succeed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Added.

if (targetType.isNonNullable()) {
// And it must have the right nullability for the target, as mentioned
// above.
refType = Type(refType.getHeapType(), NonNullable);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the target type is non-nullable, either the refType or the castType must be non-nullable, but it's not necessary for them both to be non-nullable. We should be able to generate it all three ways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done.

Comment on lines 4035 to 4037
castType = getSubType(refType);
// There is no nullability to adjust: if targetType is non-nullable then
// both refType and castType are as well, as subtypes of it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the targetType is non-nullable, then castType should be allowed to be nullable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

@kripken kripken merged commit 33abf08 into WebAssembly:main Oct 16, 2024
13 checks passed
@kripken kripken deleted the fuzz.br_on branch October 16, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants