summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/fuzz_opt.py2
-rw-r--r--src/wasm/wasm-validator.cpp40
-rw-r--r--test/lit/validation/shared-absheaptype.wast2
-rw-r--r--test/lit/validation/shared-null.wast12
4 files changed, 40 insertions, 16 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index c6a68e85c..f4b64f44c 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -357,6 +357,8 @@ INITIAL_CONTENTS_IGNORE = [
'shared-struct.wast',
'shared-array.wast',
'shared-i31.wast',
+ 'shared-null.wast',
+ 'shared-absheaptype.wast',
'type-ssa-shared.wast',
]
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 143baee41..e18191bea 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -223,6 +223,22 @@ struct ValidationInfo {
}
};
+std::string getMissingFeaturesList(Module& wasm, FeatureSet feats) {
+ std::stringstream ss;
+ bool first = true;
+ ss << '[';
+ (feats - wasm.features).iterFeatures([&](FeatureSet feat) {
+ if (first) {
+ first = false;
+ } else {
+ ss << " ";
+ }
+ ss << "--enable-" << feat.toString();
+ });
+ ss << ']';
+ return ss.str();
+}
+
struct FunctionValidator : public WalkerPass<PostWalker<FunctionValidator>> {
bool isFunctionParallel() override { return true; }
@@ -2188,9 +2204,12 @@ void FunctionValidator::visitRefNull(RefNull* curr) {
// If we are not in a function, this is a global location like a table. We
// allow RefNull there as we represent tables that way regardless of what
// features are enabled.
- shouldBeTrue(!getFunction() || getModule()->features.hasReferenceTypes(),
- curr,
- "ref.null requires reference-types [--enable-reference-types]");
+ auto feats = curr->type.getFeatures();
+ if (!shouldBeTrue(!getFunction() || feats <= getModule()->features,
+ curr,
+ "ref.null requires additional features")) {
+ getStream() << getMissingFeaturesList(*getModule(), feats) << '\n';
+ }
if (!shouldBeTrue(
curr->type.isNullable(), curr, "ref.null types must be nullable")) {
return;
@@ -3711,18 +3730,9 @@ static void validateGlobals(Module& module, ValidationInfo& info) {
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";
+ info.getStream(nullptr)
+ << "global type requires additional features "
+ << getMissingFeaturesList(module, globalFeats) << '\n';
}
}
}
diff --git a/test/lit/validation/shared-absheaptype.wast b/test/lit/validation/shared-absheaptype.wast
index 6ab3c0219..4426f31b3 100644
--- a/test/lit/validation/shared-absheaptype.wast
+++ b/test/lit/validation/shared-absheaptype.wast
@@ -1,4 +1,4 @@
-;; Test that shared structs require shared-everything threads
+;; Test that shared basic heap types 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
diff --git a/test/lit/validation/shared-null.wast b/test/lit/validation/shared-null.wast
new file mode 100644
index 000000000..1c34873bb
--- /dev/null
+++ b/test/lit/validation/shared-null.wast
@@ -0,0 +1,12 @@
+;; Test that shared nulls 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: ref.null requires additional features
+;; NO-SHARED: [--enable-reference-types --enable-shared-everything]
+;; SHARED: (ref.null (shared none))
+
+(module
+ (func (drop (ref.null (shared none))))
+)