summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-04-02 10:36:19 -0700
committerGitHub <noreply@github.com>2020-04-02 10:36:19 -0700
commit80c5164e1f50ed26e6fab373a563fd7a84135429 (patch)
treeac944407ac6bf1b26e524d31a3db8c410e4599e7 /src/wasm/wasm-validator.cpp
parent702b99508487bc5f56c409d890644b3b9212ae81 (diff)
downloadbinaryen-80c5164e1f50ed26e6fab373a563fd7a84135429.tar.gz
binaryen-80c5164e1f50ed26e6fab373a563fd7a84135429.tar.bz2
binaryen-80c5164e1f50ed26e6fab373a563fd7a84135429.zip
Tuple globals (#2718)
Since it wasn't easy to support tuples in Asyncify's call support using temporary functions, we decided to allow tuple-typed globals after all. This PR adds support for parsing, printing, lowering, and interpreting tuple globals and also adds validation ensuring that imported and exported globals do not have tuple types.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 368c01bdc..c152e4b98 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2137,12 +2137,14 @@ static void validateImports(Module& module, ValidationInfo& info) {
}
}
});
- if (!module.features.hasMutableGlobals()) {
- ModuleUtils::iterImportedGlobals(module, [&](Global* curr) {
+ ModuleUtils::iterImportedGlobals(module, [&](Global* curr) {
+ if (!module.features.hasMutableGlobals()) {
info.shouldBeFalse(
curr->mutable_, curr->name, "Imported global cannot be mutable");
- });
- }
+ }
+ info.shouldBeTrue(
+ curr->type.isSingle(), curr->name, "Imported global cannot be tuple");
+ });
}
static void validateExports(Module& module, ValidationInfo& info) {
@@ -2164,11 +2166,14 @@ static void validateExports(Module& module, ValidationInfo& info) {
"Exported function must not have i64 results");
}
}
- } else if (curr->kind == ExternalKind::Global &&
- !module.features.hasMutableGlobals()) {
+ } else if (curr->kind == ExternalKind::Global) {
if (Global* g = module.getGlobalOrNull(curr->value)) {
- info.shouldBeFalse(
- g->mutable_, g->name, "Exported global cannot be mutable");
+ if (!module.features.hasMutableGlobals()) {
+ info.shouldBeFalse(
+ g->mutable_, g->name, "Exported global cannot be mutable");
+ }
+ info.shouldBeTrue(
+ g->type.isSingle(), g->name, "Exported global cannot be tuple");
}
}
}