summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-binary.cpp11
-rw-r--r--src/wasm/wasm-type.cpp13
-rw-r--r--src/wasm/wasm-validator.cpp19
-rw-r--r--src/wasm/wasm.cpp1
4 files changed, 39 insertions, 5 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 32dcc883a..7b88bdd76 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1319,9 +1319,14 @@ void WasmBinaryWriter::writeFeaturesSection() {
return BinaryConsts::CustomSections::MultiMemoryFeature;
case FeatureSet::TypedContinuations:
return BinaryConsts::CustomSections::TypedContinuationsFeature;
- default:
- WASM_UNREACHABLE("unexpected feature flag");
+ case FeatureSet::SharedEverything:
+ return BinaryConsts::CustomSections::SharedEverythingFeature;
+ case FeatureSet::None:
+ case FeatureSet::Default:
+ case FeatureSet::All:
+ break;
}
+ WASM_UNREACHABLE("unexpected feature flag");
};
std::vector<const char*> features;
@@ -3825,6 +3830,8 @@ void WasmBinaryReader::readFeatures(size_t payloadLen) {
} else if (name ==
BinaryConsts::CustomSections::TypedContinuationsFeature) {
feature = FeatureSet::TypedContinuations;
+ } else if (name == BinaryConsts::CustomSections::SharedEverythingFeature) {
+ feature = FeatureSet::SharedEverything;
} else {
// Silently ignore unknown features (this may be and old binaryen running
// on a new wasm).
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index 83bf47107..532ebb913 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -932,10 +932,17 @@ FeatureSet Type::getFeatures() const {
}
}
- if (heapType->isStruct() || heapType->isArray() ||
- heapType->getRecGroup().size() > 1 ||
+ if (heapType->getRecGroup().size() > 1 ||
heapType->getDeclaredSuperType() || heapType->isOpen()) {
feats |= FeatureSet::ReferenceTypes | FeatureSet::GC;
+ }
+
+ if (heapType->isShared()) {
+ feats |= FeatureSet::SharedEverything;
+ }
+
+ if (heapType->isStruct() || heapType->isArray()) {
+ feats |= FeatureSet::ReferenceTypes | FeatureSet::GC;
} else if (heapType->isSignature()) {
// This is a function reference, which requires reference types and
// possibly also multivalue (if it has multiple returns). Note that
@@ -969,7 +976,7 @@ FeatureSet Type::getFeatures() const {
collector.noteChild(&heapType);
return collector.feats;
}
- TODO_SINGLE_COMPOUND(t);
+
switch (t.getBasic()) {
case Type::v128:
return FeatureSet::SIMD;
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 689872a19..f8bd08e1d 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -3701,6 +3701,25 @@ static void validateGlobals(Module& module, ValidationInfo& info) {
seen.insert(curr);
}
});
+
+ // Check that globals have allowed types.
+ for (auto& g : module.globals) {
+ auto globalFeats = g->type.getFeatures();
+ if (!info.shouldBeTrue(globalFeats <= module.features, g->name, "")) {
+ auto& stream = info.getStream(nullptr);
+ stream << "global type requires additional features [";
+ bool first = true;
+ (globalFeats - module.features).iterFeatures([&](FeatureSet feat) {
+ if (first) {
+ first = false;
+ } else {
+ stream << " ";
+ }
+ stream << "--enable-" << feat.toString();
+ });
+ stream << "]\n";
+ }
+ }
}
static void validateMemories(Module& module, ValidationInfo& info) {
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index cae413397..ed05e9b47 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -54,6 +54,7 @@ const char* ExtendedConstFeature = "extended-const";
const char* StringsFeature = "strings";
const char* MultiMemoryFeature = "multimemory";
const char* TypedContinuationsFeature = "typed-continuations";
+const char* SharedEverythingFeature = "shared-everything";
} // namespace CustomSections
} // namespace BinaryConsts