From 593b42c47f616ed666fb3bfeeb3e2cfb74010d42 Mon Sep 17 00:00:00 2001 From: Changqing Jing Date: Mon, 27 Oct 2025 13:48:34 +0800 Subject: [PATCH 1/2] chore: [fuzz] only emit call-export and call-export-catch when exception handling is enabled --- src/tools/fuzzing/fuzzing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 8702d7f2dca..d6fc1695ba3 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -991,7 +991,7 @@ void TranslateToFuzzReader::addImportCallingSupport() { auto choice = upTo(16); - if (choice & 1) { + if (wasm.features.hasExceptionHandling() && (choice & 1)) { // Given an export index, call it from JS. // A second parameter has flags. The first bit determines whether we catch // and rethrow all exceptions. (This ends up giving us the same signature @@ -1007,7 +1007,7 @@ void TranslateToFuzzReader::addImportCallingSupport() { wasm.addFunction(std::move(func)); } - if (choice & 2) { + if (wasm.features.hasExceptionHandling() && (choice & 2)) { // Given an export index, call it from JS and catch all exceptions. Return // whether we caught. Exceptions are common (if the index is invalid, in // particular), so a variant that catches is useful to avoid halting. From 5f53e59ad6ae8d2c82a1e3a51092d28bef9607e8 Mon Sep 17 00:00:00 2001 From: Changqing Jing Date: Mon, 27 Oct 2025 14:24:00 +0800 Subject: [PATCH 2/2] Fix --- test/passes/fuzz_metrics_noprint.bin.txt | 70 +++++++++++++----------- test/passes/fuzz_metrics_noprint.passes | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/test/passes/fuzz_metrics_noprint.bin.txt b/test/passes/fuzz_metrics_noprint.bin.txt index 344e931f9e0..66eecec43eb 100644 --- a/test/passes/fuzz_metrics_noprint.bin.txt +++ b/test/passes/fuzz_metrics_noprint.bin.txt @@ -1,35 +1,43 @@ Metrics total - [exports] : 139 - [funcs] : 217 - [globals] : 7 - [imports] : 6 + [exports] : 59 + [funcs] : 75 + [globals] : 9 + [imports] : 9 [memories] : 1 [memory-data] : 23 - [table-data] : 71 - [tables] : 1 - [tags] : 0 - [total] : 15952 - [vars] : 628 - Binary : 1172 - Block : 2734 - Break : 525 - Call : 628 - CallIndirect : 146 - Const : 2648 - Drop : 185 - GlobalGet : 1418 - GlobalSet : 1052 - If : 866 - Load : 259 - LocalGet : 1011 - LocalSet : 708 - Loop : 309 - Nop : 227 - RefFunc : 71 - Return : 159 - Select : 83 - Store : 105 - Switch : 1 - Unary : 1112 - Unreachable : 533 + [table-data] : 8 + [tables] : 2 + [tags] : 2 + [total] : 8420 + [vars] : 330 + Binary : 560 + Block : 1409 + Break : 214 + Call : 354 + CallIndirect : 54 + Const : 1338 + Drop : 87 + GlobalGet : 685 + GlobalSet : 527 + If : 418 + Load : 149 + LocalGet : 628 + LocalSet : 408 + Loop : 183 + Nop : 78 + Pop : 66 + RefFunc : 23 + RefIsNull : 33 + RefNull : 35 + Return : 73 + Select : 77 + Store : 31 + TableGet : 1 + TableSet : 5 + Throw : 9 + ThrowRef : 5 + Try : 85 + TryTable : 82 + Unary : 543 + Unreachable : 260 diff --git a/test/passes/fuzz_metrics_noprint.passes b/test/passes/fuzz_metrics_noprint.passes index 10392fdedf9..f3a58699103 100644 --- a/test/passes/fuzz_metrics_noprint.passes +++ b/test/passes/fuzz_metrics_noprint.passes @@ -1 +1 @@ -translate-to-fuzz_metrics +translate-to-fuzz_metrics_enable-exception-handling_enable-reference-types