From 75a120af238ccf0404c4e1e2d9a7474ec734b9dd Mon Sep 17 00:00:00 2001 From: stevenfontanella Date: Fri, 30 Jan 2026 18:28:08 +0000 Subject: [PATCH 1/4] Use member initializer --- src/tools/fuzzing.h | 4 ++-- src/tools/fuzzing/fuzzing.cpp | 39 +++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 4e9a6f3dd18..f12735636a2 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -194,7 +194,7 @@ class TranslateToFuzzReader { std::unordered_map> immutableGlobalsByType; std::unordered_map> importedImmutableGlobalsByType; - std::vector loggableTypes; + const std::vector loggableTypes; // The heap types we can pick from to generate instructions. std::vector interestingHeapTypes; @@ -276,7 +276,7 @@ class TranslateToFuzzReader { // overridden using another context in an RAII manner). std::unique_ptr globalParams; - std::vector atomicMemoryOrders; + const std::vector atomicMemoryOrders; public: int nesting = 0; diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 6c21d939d1f..d7d4c305b60 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -29,27 +29,40 @@ namespace wasm { +namespace { +template +std::vector concat(const std::vector a, const std::vector b) { + auto added = a; + std::copy(b.begin(), b.end(), std::back_inserter(added)); + return added; +} +} // namespace + TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm, std::vector&& input, bool closedWorld) : wasm(wasm), closedWorld(closedWorld), builder(wasm), random(std::move(input), wasm.features), - publicTypeValidator(wasm.features) { - - atomicMemoryOrders = wasm.features.hasRelaxedAtomics() + // - funcref cannot be logged because referenced functions can be inlined or + // removed during optimization + // - there's no point in logging anyref because it is opaque + // - don't bother logging tuples + loggableTypes(concat( + std::vector{ + Type::i32, + Type::i64, + Type::f32, + Type::f64, + }, + wasm.features.hasSIMD() ? std::vector{Type::v128} + : std::vector())), + atomicMemoryOrders(wasm.features.hasRelaxedAtomics() ? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst} - : std::vector{MemoryOrder::SeqCst}; + : std::vector{MemoryOrder::SeqCst}), - haveInitialFunctions = !wasm.functions.empty(); + publicTypeValidator(wasm.features) { - // - funcref cannot be logged because referenced functions can be inlined or - // removed during optimization - // - there's no point in logging anyref because it is opaque - // - don't bother logging tuples - loggableTypes = {Type::i32, Type::i64, Type::f32, Type::f64}; - if (wasm.features.hasSIMD()) { - loggableTypes.push_back(Type::v128); - } + haveInitialFunctions = !wasm.functions.empty(); // Setup params. Start with the defaults. globalParams = std::make_unique(*this); From bd03c512c8ca04b5bed482795e32996f49e34ab3 Mon Sep 17 00:00:00 2001 From: stevenfontanella Date: Tue, 10 Feb 2026 06:14:41 +0000 Subject: [PATCH 2/4] PR update --- src/tools/fuzzing/fuzzing.cpp | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index d7d4c305b60..1d9eccd7a48 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -30,12 +30,24 @@ namespace wasm { namespace { -template -std::vector concat(const std::vector a, const std::vector b) { - auto added = a; - std::copy(b.begin(), b.end(), std::back_inserter(added)); - return added; + +std::vector getLoggableTypes(bool hasSimd) { + // - funcref cannot be logged because referenced functions can be inlined or + // removed during optimization + // - there's no point in logging anyref because it is opaque + // - don't bother logging tuples + std::vector loggableTypes = { + Type::i32, + Type::i64, + Type::f32, + Type::f64, + }; + if (hasSimd) { + loggableTypes.push_back(Type::v128); + } + return loggableTypes; } + } // namespace TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm, @@ -43,19 +55,7 @@ TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm, bool closedWorld) : wasm(wasm), closedWorld(closedWorld), builder(wasm), random(std::move(input), wasm.features), - // - funcref cannot be logged because referenced functions can be inlined or - // removed during optimization - // - there's no point in logging anyref because it is opaque - // - don't bother logging tuples - loggableTypes(concat( - std::vector{ - Type::i32, - Type::i64, - Type::f32, - Type::f64, - }, - wasm.features.hasSIMD() ? std::vector{Type::v128} - : std::vector())), + loggableTypes(getLoggableTypes(wasm.features.hasSIMD())), atomicMemoryOrders(wasm.features.hasRelaxedAtomics() ? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst} : std::vector{MemoryOrder::SeqCst}), From a76fa7d8f6541fbe8264735907c9d46b4d9d0121 Mon Sep 17 00:00:00 2001 From: stevenfontanella Date: Thu, 12 Feb 2026 23:45:14 +0000 Subject: [PATCH 3/4] Remove comment --- src/tools/fuzzing/fuzzing.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index aad2a71fbc8..527bf2f2437 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -32,10 +32,6 @@ namespace wasm { namespace { std::vector getLoggableTypes(const FeatureSet& features) { - // - funcref cannot be logged because referenced functions can be inlined or - // removed during optimization - // - there's no point in logging anyref because it is opaque - // - don't bother logging tuples std::vector loggableTypes = { Type::i32, Type::i64, Type::f32, Type::f64}; if (features.hasSIMD()) { From 102c9eb86b703e1189042bc1dde73dfe7c34fe6d Mon Sep 17 00:00:00 2001 From: stevenfontanella Date: Fri, 13 Feb 2026 00:18:03 +0000 Subject: [PATCH 4/4] Fix param --- src/tools/fuzzing/fuzzing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 527bf2f2437..07f8fdb8d80 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -59,7 +59,7 @@ TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm, bool closedWorld) : wasm(wasm), closedWorld(closedWorld), builder(wasm), random(std::move(input), wasm.features), - loggableTypes(getLoggableTypes(wasm.features.hasSIMD())), + loggableTypes(getLoggableTypes(wasm.features)), atomicMemoryOrders(wasm.features.hasRelaxedAtomics() ? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst} : std::vector{MemoryOrder::SeqCst}),