summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-type.cpp8
-rw-r--r--test/lit/validation/shared-absheaptype.wast11
2 files changed, 15 insertions, 4 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index adb2c7fa8..bfab4b955 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -1526,6 +1526,10 @@ FeatureSet HeapType::getFeatures() const {
FeatureSet feats = FeatureSet::None;
void noteChild(HeapType* heapType) {
+ if (heapType->isShared()) {
+ feats |= FeatureSet::SharedEverything;
+ }
+
if (heapType->isBasic()) {
switch (heapType->getBasic(Unshared)) {
case HeapType::ext:
@@ -1565,10 +1569,6 @@ FeatureSet HeapType::getFeatures() const {
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()) {
diff --git a/test/lit/validation/shared-absheaptype.wast b/test/lit/validation/shared-absheaptype.wast
new file mode 100644
index 000000000..6ab3c0219
--- /dev/null
+++ b/test/lit/validation/shared-absheaptype.wast
@@ -0,0 +1,11 @@
+;; Test that shared structs require shared-everything threads
+
+;; RUN: not wasm-opt %s 2>&1 | filecheck %s --check-prefix NO-SHARED
+;; RUN: wasm-opt %s --enable-reference-types --enable-gc --enable-shared-everything -o - -S | filecheck %s --check-prefix SHARED
+
+;; NO-SHARED: global type requires additional features [--enable-reference-types --enable-gc --enable-shared-everything]
+;; SHARED: (import "" "" (global $gimport$0 (ref null (shared any))))
+
+(module
+ (global (import "" "") (ref null (shared any)))
+)