summaryrefslogtreecommitdiff
path: root/src/tools/fuzzing/fuzzing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/fuzzing/fuzzing.cpp')
-rw-r--r--src/tools/fuzzing/fuzzing.cpp10
1 files changed, 7 insertions, 3 deletions
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);