diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing.h | 1 | ||||
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index d761bc3bd..b8be67499 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -106,6 +106,7 @@ private: Name funcrefTableName; std::unordered_map<Type, std::vector<Name>> globalsByType; + std::unordered_map<Type, std::vector<Name>> mutableGlobalsByType; std::vector<Type> loggableTypes; diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 75eb3bd21..9beedc7fd 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -358,9 +358,13 @@ void TranslateToFuzzReader::setupGlobals() { type = getMVPType(); init = makeConst(type); } + auto mutability = oneIn(2) ? Builder::Mutable : Builder::Immutable; auto global = builder.makeGlobal( - Names::getValidGlobalName(wasm, "global$"), type, init, Builder::Mutable); + Names::getValidGlobalName(wasm, "global$"), type, init, mutability); globalsByType[type].push_back(global->name); + if (mutability == Builder::Mutable) { + mutableGlobalsByType[type].push_back(global->name); + } wasm.addGlobal(std::move(global)); } } @@ -1489,8 +1493,8 @@ Expression* TranslateToFuzzReader::makeGlobalGet(Type type) { Expression* TranslateToFuzzReader::makeGlobalSet(Type type) { assert(type == Type::none); type = getConcreteType(); - auto it = globalsByType.find(type); - if (it == globalsByType.end() || it->second.empty()) { + auto it = mutableGlobalsByType.find(type); + if (it == mutableGlobalsByType.end() || it->second.empty()) { return makeTrivial(Type::none); } auto name = pick(it->second); |