Skip to content

Commit 257298c

Browse files
authored
Fuzzer: Do not return 0 from upTo when input is finished (#8653)
This was added to simplify our output when the random data is small - it makes us pick simpler options, which helps a little there - but the downsides are large, so revert this part. Specifically, we consume all the random input to generate functions. We then do a small amount of random usage at the end, things like export mutation. To handle that, we keep returning random values even after the random input is consumed (using some xor-ing to try to keep things random). But if we just return 0 at that point, we are missing out on a lot of variety. This was added in #7832. All the rest of that PR makes sense - we can check for the end of the random data and do simpler things - but we should not do the simplest possible thing in the generic `upTo` method which would simplify everything, even things we don't want to.
1 parent d951c04 commit 257298c

4 files changed

Lines changed: 45 additions & 48 deletions

File tree

src/tools/fuzzing/random.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ float Random::getFloat() { return Literal(get32()).reinterpretf32(); }
6666
double Random::getDouble() { return Literal(get64()).reinterpretf64(); }
6767

6868
uint32_t Random::upTo(uint32_t x) {
69-
if (finished()) {
70-
return 0;
71-
}
7269
if (x == 0) {
7370
return 0;
7471
}

test/passes/fuzz_metrics_noprint.bin.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ total
99
[table-data] : 23
1010
[tables] : 1
1111
[tags] : 0
12-
[total] : 9732
12+
[total] : 9511
1313
[vars] : 165
14-
Binary : 710
15-
Block : 1566
16-
Break : 305
17-
Call : 257
14+
Binary : 701
15+
Block : 1509
16+
Break : 303
17+
Call : 255
1818
CallIndirect : 109
19-
Const : 1657
20-
Drop : 148
21-
GlobalGet : 787
22-
GlobalSet : 552
23-
If : 510
24-
Load : 177
19+
Const : 1586
20+
Drop : 99
21+
GlobalGet : 784
22+
GlobalSet : 550
23+
If : 507
24+
Load : 174
2525
LocalGet : 802
26-
LocalSet : 593
27-
Loop : 217
28-
Nop : 128
26+
LocalSet : 585
27+
Loop : 216
28+
Nop : 127
2929
RefFunc : 23
30-
Return : 95
30+
Return : 93
3131
Select : 88
32-
Store : 71
32+
Store : 70
3333
Switch : 4
34-
Unary : 660
35-
Unreachable : 273
34+
Unary : 654
35+
Unreachable : 272

test/passes/fuzz_metrics_passes_noprint.bin.txt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ total
99
[table-data] : 28
1010
[tables] : 1
1111
[tags] : 0
12-
[total] : 8649
12+
[total] : 9880
1313
[vars] : 253
14-
Binary : 597
15-
Block : 1475
16-
Break : 252
17-
Call : 323
18-
CallIndirect : 46
19-
Const : 1348
20-
Drop : 91
21-
GlobalGet : 732
22-
GlobalSet : 543
23-
If : 491
24-
Load : 135
25-
LocalGet : 683
26-
LocalSet : 507
27-
Loop : 182
28-
Nop : 131
14+
Binary : 685
15+
Block : 1660
16+
Break : 304
17+
Call : 343
18+
CallIndirect : 57
19+
Const : 1537
20+
Drop : 102
21+
GlobalGet : 812
22+
GlobalSet : 601
23+
If : 560
24+
Load : 159
25+
LocalGet : 820
26+
LocalSet : 611
27+
Loop : 210
28+
Nop : 151
2929
RefFunc : 28
30-
Return : 78
31-
Select : 84
32-
Store : 43
30+
Return : 84
31+
Select : 95
32+
Store : 56
3333
Switch : 2
34-
Unary : 607
35-
Unreachable : 271
34+
Unary : 704
35+
Unreachable : 299

test/passes/translate-to-fuzz_all-features_metrics_noprint.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metrics
22
total
3-
[exports] : 14
3+
[exports] : 13
44
[funcs] : 18
55
[globals] : 2
66
[imports] : 13
@@ -9,21 +9,21 @@ total
99
[table-data] : 3
1010
[tables] : 2
1111
[tags] : 2
12-
[total] : 527
13-
[vars] : 50
12+
[total] : 525
13+
[vars] : 51
1414
ArrayNewFixed : 2
1515
AtomicFence : 1
1616
Binary : 27
1717
Block : 97
1818
Break : 9
1919
Call : 17
2020
CallRef : 1
21-
Const : 103
21+
Const : 101
2222
Drop : 8
2323
GlobalGet : 48
2424
GlobalSet : 44
2525
If : 29
26-
LocalGet : 14
26+
LocalGet : 15
2727
LocalSet : 10
2828
Loop : 4
2929
MemoryInit : 1
@@ -45,6 +45,6 @@ total
4545
TableSet : 1
4646
TryTable : 2
4747
TupleExtract : 1
48-
TupleMake : 4
48+
TupleMake : 3
4949
Unary : 29
5050
Unreachable : 23

0 commit comments

Comments
 (0)