Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def is_git_repo():
'type-ssa-shared.wast',
'shared-ref_eq.wast',
'shared-types-no-gc.wast',
'shared-ref-i31.wast',
]


Expand Down
6 changes: 6 additions & 0 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions test/lit/validation/shared-ref-i31.wast
Original file line number Diff line number Diff line change
@@ -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))))
)