diff options
author | Sam Clegg <sbc@chromium.org> | 2018-11-30 08:45:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-30 08:45:29 -0800 |
commit | f16a7605b8226502062c6ca24323d431669c90ec (patch) | |
tree | 325a9184c5b1c562fd27bc89ad1a35b951cd34f9 /src/wasm/wasm-validator.cpp | |
parent | 955a9a9440f26438ba50e35ebe57a86a5111d4a1 (diff) | |
download | binaryen-f16a7605b8226502062c6ca24323d431669c90ec.tar.gz binaryen-f16a7605b8226502062c6ca24323d431669c90ec.tar.bz2 binaryen-f16a7605b8226502062c6ca24323d431669c90ec.zip |
Add support for a mutable globals as a Feature (#1785)
This picks up from #1644 and indeed borrows the test case from there.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index a08c9a129..b88a94e6d 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -923,6 +923,11 @@ static void validateImports(Module& module, ValidationInfo& info) { } } }); + if (!(info.features & Feature::MutableGlobals)) { + ModuleUtils::iterImportedGlobals(module, [&](Global* curr) { + info.shouldBeFalse(curr->mutable_, curr->name, "Imported global cannot be mutable"); + }); + } } static void validateExports(Module& module, ValidationInfo& info) { @@ -935,6 +940,10 @@ static void validateExports(Module& module, ValidationInfo& info) { info.shouldBeUnequal(param, i64, f->name, "Exported function must not have i64 parameters"); } } + } else if (curr->kind == ExternalKind::Global && !(info.features & Feature::MutableGlobals)) { + if (Global* g = module.getGlobalOrNull(curr->value)) { + info.shouldBeFalse(g->mutable_, g->name, "Exported global cannot be mutable"); + } } } std::unordered_set<Name> exportNames; |