Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tools/fuzzing.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class TranslateToFuzzReader {
std::unordered_map<Type, std::vector<Name>> immutableGlobalsByType;
std::unordered_map<Type, std::vector<Name>> importedImmutableGlobalsByType;

std::vector<Type> loggableTypes;
const std::vector<Type> loggableTypes;

// The heap types we can pick from to generate instructions.
std::vector<HeapType> interestingHeapTypes;
Expand Down Expand Up @@ -276,7 +276,7 @@ class TranslateToFuzzReader {
// overridden using another context in an RAII manner).
std::unique_ptr<FuzzParamsContext> globalParams;

std::vector<MemoryOrder> atomicMemoryOrders;
const std::vector<MemoryOrder> atomicMemoryOrders;

public:
int nesting = 0;
Expand Down
44 changes: 27 additions & 17 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,45 @@

namespace wasm {

TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm,
std::vector<char>&& input,
bool closedWorld)
: wasm(wasm), closedWorld(closedWorld), builder(wasm),
random(std::move(input), wasm.features),
publicTypeValidator(wasm.features) {
namespace {

atomicMemoryOrders = wasm.features.hasRelaxedAtomics()
? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst}
: std::vector{MemoryOrder::SeqCst};

haveInitialFunctions = !wasm.functions.empty();

loggableTypes = {Type::i32, Type::i64, Type::f32, Type::f64};
if (wasm.features.hasSIMD()) {
std::vector<Type> getLoggableTypes(const FeatureSet& features) {
std::vector<Type> loggableTypes = {
Type::i32, Type::i64, Type::f32, Type::f64};
if (features.hasSIMD()) {
loggableTypes.push_back(Type::v128);
}
if (wasm.features.hasReferenceTypes()) {
if (wasm.features.hasGC()) {
if (features.hasReferenceTypes()) {
if (features.hasGC()) {
loggableTypes.push_back(Type(HeapType::any, Nullable));
loggableTypes.push_back(Type(HeapType::func, Nullable));
loggableTypes.push_back(Type(HeapType::ext, Nullable));
}
if (wasm.features.hasStackSwitching()) {
if (features.hasStackSwitching()) {
loggableTypes.push_back(Type(HeapType::cont, Nullable));
}
// Note: exnref traps on the JS boundary, so we cannot try to log it.
}

return loggableTypes;
}

} // namespace

TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm,
std::vector<char>&& input,
bool closedWorld)
: wasm(wasm), closedWorld(closedWorld), builder(wasm),
random(std::move(input), wasm.features),
loggableTypes(getLoggableTypes(wasm.features)),
atomicMemoryOrders(wasm.features.hasRelaxedAtomics()
? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst}
: std::vector{MemoryOrder::SeqCst}),

publicTypeValidator(wasm.features) {

haveInitialFunctions = !wasm.functions.empty();

// Setup params. Start with the defaults.
globalParams = std::make_unique<FuzzParamsContext>(*this);

Expand Down
Loading