diff options
-rw-r--r-- | src/tools/fuzzing.h | 12 | ||||
-rw-r--r-- | test/passes/fuzz_metrics_noprint.bin.txt | 48 | ||||
-rw-r--r-- | test/passes/translate-to-fuzz_all-features_metrics_noprint.txt | 60 |
3 files changed, 63 insertions, 57 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 4150ac725..66f175414 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -723,6 +723,14 @@ private: builder.makeSequence(makeHangLimitCheck(), func->body, func->sig.results); } + // Recombination and mutation can replace a node with another node of the same + // type, but should not do so for certain types that are dangerous. For + // example, it would be bad to add an RTT in a tuple, as that would force us + // to use temporary locals for the tuple, but RTTs are not defaultable. + bool canBeArbitrarilyReplaced(Expression* curr) { + return curr->type.isDefaultable(); + } + void recombine(Function* func) { // Don't always do this. if (oneIn(2)) { @@ -776,7 +784,7 @@ private: : wasm(wasm), scanner(scanner), parent(parent) {} void visitExpression(Expression* curr) { - if (parent.oneIn(10)) { + if (parent.oneIn(10) && parent.canBeArbitrarilyReplaced(curr)) { // Replace it! auto& candidates = scanner.exprsByType[curr->type]; assert(!candidates.empty()); // this expression itself must be there @@ -803,7 +811,7 @@ private: : wasm(wasm), parent(parent) {} void visitExpression(Expression* curr) { - if (parent.oneIn(10)) { + if (parent.oneIn(10) && parent.canBeArbitrarilyReplaced(curr)) { // For constants, perform only a small tweaking in some cases. if (auto* c = curr->dynCast<Const>()) { if (parent.oneIn(2)) { diff --git a/test/passes/fuzz_metrics_noprint.bin.txt b/test/passes/fuzz_metrics_noprint.bin.txt index 13861d353..fd335ce6f 100644 --- a/test/passes/fuzz_metrics_noprint.bin.txt +++ b/test/passes/fuzz_metrics_noprint.bin.txt @@ -1,30 +1,30 @@ total [events] : 0 - [exports] : 51 - [funcs] : 67 + [exports] : 35 + [funcs] : 45 [globals] : 7 [imports] : 4 [memory-data] : 4 - [table-data] : 18 - [total] : 4870 - [vars] : 236 - Binary : 368 - Block : 699 - Break : 191 - Call : 300 - CallIndirect : 39 - Const : 847 - Drop : 91 - GlobalGet : 403 - GlobalSet : 171 - If : 260 - Load : 85 - LocalGet : 374 - LocalSet : 251 - Loop : 111 - Nop : 86 - Return : 187 - Select : 30 - Store : 36 - Unary : 340 + [table-data] : 16 + [total] : 9206 + [vars] : 186 + Binary : 715 + Block : 1348 + Break : 397 + Call : 285 + CallIndirect : 20 + Const : 1464 + Drop : 63 + GlobalGet : 749 + GlobalSet : 324 + If : 537 + Load : 171 + LocalGet : 888 + LocalSet : 610 + Loop : 248 + Nop : 190 + Return : 338 + Select : 77 + Store : 122 + Unary : 659 Unreachable : 1 diff --git a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt index 2348b7418..158c9b49a 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,39 +1,37 @@ total [events] : 2 - [exports] : 8 - [funcs] : 9 + [exports] : 11 + [funcs] : 11 [globals] : 6 [imports] : 5 [memory-data] : 22 - [table-data] : 3 - [total] : 549 - [vars] : 37 + [table-data] : 1 + [total] : 850 + [vars] : 29 AtomicFence : 1 - AtomicNotify : 1 - AtomicRMW : 1 - Binary : 80 - Block : 69 - Break : 10 - Call : 11 - CallRef : 3 - Const : 117 - Drop : 7 - GlobalGet : 30 - GlobalSet : 16 - If : 24 - Load : 26 - LocalGet : 35 - LocalSet : 18 - Loop : 9 + Binary : 95 + Block : 122 + Break : 19 + Call : 44 + CallRef : 5 + Const : 126 + Drop : 10 + GlobalGet : 62 + GlobalSet : 30 + If : 35 + Load : 24 + LocalGet : 69 + LocalSet : 39 + Loop : 23 MemoryFill : 1 - MemoryInit : 1 - Nop : 24 - RefFunc : 3 + Nop : 14 + RefFunc : 5 RefIs : 2 - RefNull : 9 - Return : 18 - SIMDExtract : 1 - Select : 2 - Store : 2 - TupleMake : 2 - Unary : 26 + RefNull : 28 + Return : 33 + SIMDExtract : 4 + Select : 5 + Store : 3 + TupleExtract : 4 + TupleMake : 6 + Unary : 41 |