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
1 change: 1 addition & 0 deletions src/tools/fuzzing.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ class TranslateToFuzzReader {
Expression* makeDataDrop();
Expression* makeMemoryCopy();
Expression* makeMemoryFill();
Expression* makeElemDrop();

// Getters for Types
Type getSingleConcreteType();
Expand Down
16 changes: 12 additions & 4 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5640,12 +5640,9 @@ Expression* TranslateToFuzzReader::makeSIMDLoad() {
}

Expression* TranslateToFuzzReader::makeBulkMemory(Type type) {
if (!allowMemory) {
return makeTrivial(type);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What removed the need for this check?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It turns out that makeMemoryInit, makeMemoryCopy, and makeMemoryFill already do this check. makeDataDrop and makeElemDrop can still make sense to do even when there is no memory.

assert(wasm.features.hasBulkMemory());
assert(type == Type::none);
switch (upTo(4)) {
switch (upTo(5)) {
case 0:
return makeMemoryInit();
case 1:
Expand All @@ -5654,6 +5651,8 @@ Expression* TranslateToFuzzReader::makeBulkMemory(Type type) {
return makeMemoryCopy();
case 3:
return makeMemoryFill();
case 4:
return makeElemDrop();
}
WASM_UNREACHABLE("invalid value");
}
Expand Down Expand Up @@ -6576,6 +6575,15 @@ Expression* TranslateToFuzzReader::makeMemoryFill() {
return builder.makeMemoryFill(dest, value, size, wasm.memories[0]->name);
}

Expression* TranslateToFuzzReader::makeElemDrop() {
if (wasm.elementSegments.empty()) {
return makeTrivial(Type::none);
}
Index segIdx = upTo(wasm.elementSegments.size());
Name segment = wasm.elementSegments[segIdx]->name;
return builder.makeElemDrop(segment);
}

Type TranslateToFuzzReader::getSingleConcreteType() {
if (wasm.features.hasReferenceTypes() && !interestingHeapTypes.empty() &&
oneIn(3)) {
Expand Down
166 changes: 86 additions & 80 deletions test/passes/translate-to-fuzz_all-features_metrics_noprint.txt
Original file line number Diff line number Diff line change
@@ -1,89 +1,95 @@
Metrics
total
[exports] : 42
[funcs] : 98
[exports] : 78
[funcs] : 163
[globals] : 13
[imports] : 12
[memories] : 1
[memory-data] : 31
[table-data] : 26
[table-data] : 39
[tables] : 2
[tags] : 2
[total] : 51844
[vars] : 3186
ArrayCmpxchg : 15
ArrayCopy : 24
ArrayFill : 22
ArrayGet : 227
ArrayLen : 315
ArrayNew : 626
ArrayNewFixed : 176
ArrayRMW : 9
ArraySet : 35
AtomicCmpxchg : 15
AtomicFence : 39
AtomicNotify : 5
AtomicRMW : 13
AtomicWait : 5
Binary : 1921
Block : 3625
BrOn : 329
Break : 539
Call : 527
CallIndirect : 44
CallRef : 99
Const : 6799
ContNew : 58
DataDrop : 4
Drop : 443
GlobalGet : 2648
GlobalSet : 1044
I31Get : 41
If : 1304
Load : 143
LocalGet : 6906
LocalSet : 2161
Loop : 423
MemoryCopy : 8
MemoryFill : 8
MemoryInit : 7
Nop : 360
Pop : 97
RefAs : 4588
RefCast : 374
RefEq : 128
RefFunc : 1000
RefGetDesc : 34
RefI31 : 318
RefIsNull : 21
RefNull : 4688
RefTest : 33
Return : 221
SIMDExtract : 54
SIMDShift : 1
Select : 164
Store : 73
StringConst : 200
StringEncode : 38
StringEq : 35
StringMeasure : 35
StringNew : 4
[total] : 93958
[vars] : 3603
ArrayCmpxchg : 19
ArrayCopy : 20
ArrayFill : 28
ArrayGet : 307
ArrayLen : 415
ArrayNew : 1092
ArrayNewFixed : 288
ArrayRMW : 11
ArraySet : 48
AtomicCmpxchg : 31
AtomicFence : 49
AtomicNotify : 17
AtomicRMW : 17
AtomicWait : 10
Binary : 3070
Block : 5914
BrOn : 559
Break : 820
Call : 930
CallIndirect : 146
CallRef : 167
Const : 12562
ContBind : 4
ContNew : 98
DataDrop : 14
Drop : 721
ElemDrop : 8
GlobalGet : 4766
GlobalSet : 1777
I31Get : 40
If : 2028
Load : 263
LocalGet : 10162
LocalSet : 3451
Loop : 720
MemoryCopy : 6
MemoryFill : 12
MemoryInit : 13
Nop : 531
Pop : 168
RefAs : 9573
RefCast : 666
RefEq : 216
RefFunc : 1946
RefGetDesc : 79
RefI31 : 601
RefIsNull : 44
RefNull : 11542
RefTest : 50
Return : 330
SIMDExtract : 115
SIMDLoad : 2
SIMDReplace : 3
SIMDShuffle : 4
SIMDTernary : 4
Select : 270
Store : 94
StringConcat : 2
StringConst : 425
StringEncode : 45
StringEq : 53
StringMeasure : 52
StringNew : 3
StringSliceWTF : 2
StringWTF16Get : 36
StructCmpxchg : 19
StructGet : 234
StructNew : 6141
StructRMW : 21
StructSet : 31
Switch : 4
TableSet : 29
Throw : 37
ThrowRef : 5
Try : 184
TryTable : 232
TupleExtract : 114
TupleMake : 107
Unary : 1009
Unreachable : 546
WideIntAddSub : 12
WideIntMul : 8
StringWTF16Get : 56
StructCmpxchg : 33
StructGet : 449
StructNew : 11929
StructRMW : 38
StructSet : 47
Switch : 6
TableSet : 56
Throw : 76
ThrowRef : 8
Try : 350
TryTable : 394
TupleExtract : 225
TupleMake : 273
Unary : 1657
Unreachable : 916
WideIntAddSub : 13
WideIntMul : 9
Loading