summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2019-03-18 20:38:07 -0700
committerGitHub <noreply@github.com>2019-03-18 20:38:07 -0700
commitdd3873375ca7375b79105742b30fa03f9f8a0c24 (patch)
treef07e51c24c124cc0981d1d87214aad200e67f1a8 /src/wasm/wasm-validator.cpp
parenta2dd7c4feae3c4da3a1f8de90171795d12eb8879 (diff)
downloadbinaryen-dd3873375ca7375b79105742b30fa03f9f8a0c24.tar.gz
binaryen-dd3873375ca7375b79105742b30fa03f9f8a0c24.tar.bz2
binaryen-dd3873375ca7375b79105742b30fa03f9f8a0c24.zip
Validate that types match features (#1949)
Refactors features into a new wasm-features.h file and updates the validator to check that all types are allowed. Currently this is only relevant for the v128 SIMD type, but new types will be added in the future. The test for this change is in #1948.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 84a0efbff..91e7e7398 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -1081,12 +1081,17 @@ void FunctionValidator::visitHost(Host* curr) {
}
void FunctionValidator::visitFunction(Function* curr) {
+ FeatureSet typeFeatures = getFeatures(curr->result);
for (auto type : curr->params) {
+ typeFeatures |= getFeatures(type);
shouldBeTrue(isConcreteType(type), curr, "params must be concretely typed");
}
for (auto type : curr->vars) {
+ typeFeatures |= getFeatures(type);
shouldBeTrue(isConcreteType(type), curr, "vars must be concretely typed");
}
+ shouldBeTrue(typeFeatures <= info.features, curr,
+ "all used types should be allowed");
// if function has no result, it is ignored
// if body is unreachable, it might be e.g. a return
if (curr->body->type != unreachable) {