summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-03-24 19:08:26 -0700
committerGitHub <noreply@github.com>2020-03-24 19:08:26 -0700
commite01e7e9db72eeb688ecb774b58416521e320c3fe (patch)
tree587e8d5754ab165c127a6bbf0fcbfcd97157d780
parente7315448c95d248fb1bcdb869a39da30974f73ea (diff)
downloadbinaryen-e01e7e9db72eeb688ecb774b58416521e320c3fe.tar.gz
binaryen-e01e7e9db72eeb688ecb774b58416521e320c3fe.tar.bz2
binaryen-e01e7e9db72eeb688ecb774b58416521e320c3fe.zip
Disallow tuples in MVP (#2707)
Previously the multivalue feature enabled tuples in control flow positions, but tuples elsewhere did not require the multivalue feature. However, allowing tuple operations and locals in MVP modules means that all passes and tools need to support tuples, even if it isn't a high priority for them to support multivalue. Allowing tuples in MVP modules doesn't provide much value, so this changes disallows them entirely unless multivalue is enabled.
-rw-r--r--src/wasm/wasm-type.cpp6
-rw-r--r--src/wasm/wasm-validator.cpp6
-rw-r--r--test/passes/asyncify_enable-multivalue.txt (renamed from test/passes/asyncify.txt)0
-rw-r--r--test/passes/asyncify_enable-multivalue.wast (renamed from test/passes/asyncify.wast)0
4 files changed, 11 insertions, 1 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index a98d10be4..3fb783fba 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -198,7 +198,11 @@ Type Type::reinterpret() const {
FeatureSet Type::getFeatures() const {
FeatureSet feats = FeatureSet::MVP;
- for (Type t : expand()) {
+ const auto& elements = expand();
+ if (elements.size() > 1) {
+ feats = FeatureSet::Multivalue;
+ }
+ for (Type t : elements) {
switch (t.getSingle()) {
case Type::v128:
feats |= FeatureSet::SIMD;
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index d81297408..368c01bdc 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -1906,6 +1906,9 @@ void FunctionValidator::visitBrOnExn(BrOnExn* curr) {
}
void FunctionValidator::visitTupleMake(TupleMake* curr) {
+ shouldBeTrue(getModule()->features.hasMultivalue(),
+ curr,
+ "Tuples are not allowed unless multivalue is enabled");
std::vector<Type> types;
for (auto* op : curr->operands) {
if (op->type == Type::unreachable) {
@@ -1924,6 +1927,9 @@ void FunctionValidator::visitTupleMake(TupleMake* curr) {
}
void FunctionValidator::visitTupleExtract(TupleExtract* curr) {
+ shouldBeTrue(getModule()->features.hasMultivalue(),
+ curr,
+ "Tuples are not allowed unless multivalue is enabled");
if (curr->tuple->type == Type::unreachable) {
shouldBeTrue(
curr->type == Type::unreachable,
diff --git a/test/passes/asyncify.txt b/test/passes/asyncify_enable-multivalue.txt
index 07fecce10..07fecce10 100644
--- a/test/passes/asyncify.txt
+++ b/test/passes/asyncify_enable-multivalue.txt
diff --git a/test/passes/asyncify.wast b/test/passes/asyncify_enable-multivalue.wast
index b34338bd0..b34338bd0 100644
--- a/test/passes/asyncify.wast
+++ b/test/passes/asyncify_enable-multivalue.wast