Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,8 @@ def get_random_opts():
# some features depend on other features, so if a required feature is
# disabled, its dependent features need to be disabled as well.
IMPLIED_FEATURE_OPTS = {
'--disable-reference-types': ['--disable-gc'],
'--disable-reference-types': ['--disable-gc', '--disable-strings'],
'--disable-gc': ['--disable-strings'],
Copy link
Member Author

Choose a reason for hiding this comment

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

This may actually be needed on main now that the previous PR landed - should have perhaps been included there just to be safe. If this PR can't land quickly then I'll split it out.

}

print('''
Expand Down
43 changes: 23 additions & 20 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2537,18 +2537,12 @@ Expression* TranslateToFuzzReader::makeBasicRef(Type type) {
// Choose a subtype we can materialize a constant for. We cannot
// materialize non-nullable refs to func or i31 in global contexts.
Nullability nullability = getSubType(type.getNullability());
HeapType subtype;
switch (upTo(3)) {
case 0:
subtype = HeapType::i31;
break;
case 1:
subtype = HeapType::struct_;
break;
case 2:
subtype = HeapType::array;
break;
}
auto subtype = pick(FeatureOptions<HeapType>()
.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
HeapType::i31,
HeapType::struct_,
HeapType::array)
.add(FeatureSet::Strings, HeapType::string));
return makeConst(Type(subtype, nullability));
}
case HeapType::eq: {
Expand Down Expand Up @@ -3994,7 +3988,10 @@ Type TranslateToFuzzReader::getSingleConcreteType() {
Type(HeapType::struct_, Nullable),
Type(HeapType::struct_, NonNullable),
Type(HeapType::array, Nullable),
Type(HeapType::array, NonNullable)));
Type(HeapType::array, NonNullable))
.add(FeatureSet::Strings,
Type(HeapType::string, Nullable),
Type(HeapType::string, NonNullable)));
}

Type TranslateToFuzzReader::getReferenceType() {
Expand All @@ -4017,7 +4014,10 @@ Type TranslateToFuzzReader::getReferenceType() {
Type(HeapType::struct_, Nullable),
Type(HeapType::struct_, NonNullable),
Type(HeapType::array, Nullable),
Type(HeapType::array, NonNullable)));
Type(HeapType::array, NonNullable))
.add(FeatureSet::Strings,
Type(HeapType::string, Nullable),
Type(HeapType::string, NonNullable)));
}

Type TranslateToFuzzReader::getEqReferenceType() {
Expand Down Expand Up @@ -4137,12 +4137,15 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) {
case HeapType::any:
assert(wasm.features.hasReferenceTypes());
assert(wasm.features.hasGC());
return pick(HeapType::any,
HeapType::eq,
HeapType::i31,
HeapType::struct_,
HeapType::array,
HeapType::none);
return pick(FeatureOptions<HeapType>()
.add(FeatureSet::GC,
HeapType::any,
HeapType::eq,
HeapType::i31,
HeapType::struct_,
HeapType::array,
HeapType::none)
.add(FeatureSet::Strings, HeapType::string));
case HeapType::eq:
assert(wasm.features.hasReferenceTypes());
assert(wasm.features.hasGC());
Expand Down
82 changes: 41 additions & 41 deletions test/passes/translate-to-fuzz_all-features_metrics_noprint.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
total
[exports] : 5
[funcs] : 8
[globals] : 1
[exports] : 4
[funcs] : 5
[globals] : 14
[imports] : 5
[memories] : 1
[memory-data] : 20
[table-data] : 1
[tables] : 1
[tags] : 2
[total] : 674
[vars] : 41
ArrayCopy : 1
ArrayGet : 3
ArrayLen : 4
ArrayNew : 5
[tags] : 1
[total] : 710
[vars] : 35
ArrayGet : 1
ArrayLen : 1
ArrayNew : 16
ArrayNewFixed : 1
ArraySet : 1
AtomicFence : 1
AtomicNotify : 3
AtomicRMW : 1
Binary : 84
Block : 75
Break : 12
Call : 21
Const : 133
Drop : 6
GlobalGet : 24
GlobalSet : 24
I31Get : 3
If : 21
Binary : 77
Block : 57
Break : 8
Call : 33
Const : 159
Drop : 7
GlobalGet : 17
GlobalSet : 14
I31Get : 2
If : 19
Load : 22
LocalGet : 65
LocalSet : 50
Loop : 6
Nop : 4
Pop : 7
RefAs : 7
LocalGet : 66
LocalSet : 37
Loop : 3
MemoryFill : 1
Nop : 7
Pop : 4
RefAs : 14
RefCast : 3
RefFunc : 2
RefI31 : 7
RefIsNull : 2
RefNull : 11
RefEq : 1
RefFunc : 4
RefI31 : 9
RefIsNull : 3
RefNull : 26
RefTest : 2
Return : 8
Select : 3
Return : 9
SIMDExtract : 3
StringConst : 2
StringNew : 1
StructGet : 1
StructNew : 3
StructSet : 2
StructNew : 27
Throw : 1
Try : 5
TupleExtract : 3
TupleMake : 4
Unary : 21
Unreachable : 13
TupleExtract : 15
TupleMake : 9
Unary : 15
Unreachable : 7
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ h e r e
d0
0.753538467597066
2.2339337309978227
3.14159
.................
lorem ipsum whatever

Expand Down