diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index e06160332b0..803e13d5d0b 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -376,6 +376,9 @@ class TranslateToFuzzReader { bool isValidPublicType(Type type) { return publicTypeValidator.isValidPublicType(type); } + bool isValidPublicType(HeapType type) { + return publicTypeValidator.isValidPublicType(type); + } // Function operations. The main processFunctions() loop will call addFunction // as well as modFunction(). diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 91531904a0d..759061da88f 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -846,6 +846,17 @@ void TranslateToFuzzReader::setupTags() { jsTag->base = "jstag"; wasm.addTag(std::move(jsTag)); } + + // Export some tags, sometimes. + if (!preserveImportsAndExports) { + for (auto& tag : wasm.tags) { + if (isValidPublicType(tag->type) && oneIn(2)) { + auto exportName = Names::getValidExportName(wasm, tag->name); + wasm.addExport( + Builder::makeExport(exportName, tag->name, ExternalKind::Tag)); + } + } + } } void TranslateToFuzzReader::addTag() { 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 7f56b028dc0..961f8e1e8bc 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,50 +1,55 @@ Metrics total - [exports] : 13 - [funcs] : 18 + [exports] : 10 + [funcs] : 5 [globals] : 2 [imports] : 13 [memories] : 1 [memory-data] : 16 - [table-data] : 3 + [table-data] : 2 [tables] : 2 - [tags] : 2 - [total] : 525 - [vars] : 51 - ArrayNewFixed : 2 - AtomicFence : 1 - Binary : 27 - Block : 97 - Break : 9 - Call : 17 - CallRef : 1 - Const : 101 - Drop : 8 - GlobalGet : 48 - GlobalSet : 44 - If : 29 - LocalGet : 15 - LocalSet : 10 - Loop : 4 + [tags] : 3 + [total] : 704 + [vars] : 26 + ArrayNewFixed : 6 + AtomicFence : 3 + Binary : 30 + Block : 130 + BrOn : 6 + Break : 23 + Call : 30 + CallRef : 2 + Const : 103 + Drop : 10 + GlobalGet : 44 + GlobalSet : 42 + I31Get : 3 + If : 39 + Load : 6 + LocalGet : 25 + LocalSet : 27 + Loop : 16 MemoryInit : 1 Nop : 7 - RefAs : 1 - RefEq : 2 - RefFunc : 7 - RefI31 : 6 - RefNull : 5 - Return : 4 - SIMDExtract : 2 - Select : 2 - Store : 1 - StringConst : 5 - StringEncode : 1 + Pop : 6 + RefEq : 1 + RefFunc : 11 + RefI31 : 10 + RefNull : 10 + RefTest : 7 + Return : 3 + Select : 1 + Store : 2 + StringConst : 7 StringEq : 1 - StringMeasure : 1 - StructNew : 7 - TableSet : 1 - TryTable : 2 - TupleExtract : 1 - TupleMake : 3 - Unary : 29 - Unreachable : 23 + StringMeasure : 2 + StringWTF16Get : 2 + StructNew : 8 + TableSet : 2 + Throw : 2 + Try : 6 + TryTable : 6 + TupleExtract : 3 + TupleMake : 5 + Unary : 35 + Unreachable : 21