diff options
-rwxr-xr-x | scripts/fuzz_opt.py | 1 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 6 | ||||
-rw-r--r-- | test/lit/validation/shared-ref-i31.wast | 12 |
3 files changed, 19 insertions, 0 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index e7826c0f3..0f3bc3f3f 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -362,6 +362,7 @@ INITIAL_CONTENTS_IGNORE = [ 'type-ssa-shared.wast', 'shared-ref_eq.wast', 'shared-types-no-gc.wast', + 'shared-ref-i31.wast', ] diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 29e7a2c9c..4e167df56 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2727,6 +2727,12 @@ void FunctionValidator::visitCallRef(CallRef* curr) { void FunctionValidator::visitRefI31(RefI31* curr) { shouldBeTrue( getModule()->features.hasGC(), curr, "ref.i31 requires gc [--enable-gc]"); + if (curr->type.isRef() && curr->type.getHeapType().isShared()) { + shouldBeTrue( + getModule()->features.hasSharedEverything(), + curr, + "ref.i31_shared requires shared-everything [--enable-shared-everything]"); + } shouldBeSubType(curr->value->type, Type::i32, curr->value, diff --git a/test/lit/validation/shared-ref-i31.wast b/test/lit/validation/shared-ref-i31.wast new file mode 100644 index 000000000..aaab2f47f --- /dev/null +++ b/test/lit/validation/shared-ref-i31.wast @@ -0,0 +1,12 @@ +;; Test that ref.i31_shared requires shared-everything threads + +;; RUN: not wasm-opt %s -all --disable-shared-everything 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.i31_shared requires shared-everything [--enable-shared-everything] +;; SHARED: (ref.i31_shared +;; SHARED-NEXT: (i32.const 0) + +(module + (func (drop (ref.i31_shared (i32.const 0)))) +) |