Skip to content

Commit 67df62a

Browse files
committed
[threads] ref.i31_shared requires shared-everything in validation
1 parent 3ea493b commit 67df62a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

scripts/fuzz_opt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ def is_git_repo():
362362
'type-ssa-shared.wast',
363363
'shared-ref_eq.wast',
364364
'shared-types-no-gc.wast',
365+
'shared-ref-i31.wast',
365366
]
366367

367368

src/wasm/wasm-validator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,6 +2727,12 @@ void FunctionValidator::visitCallRef(CallRef* curr) {
27272727
void FunctionValidator::visitRefI31(RefI31* curr) {
27282728
shouldBeTrue(
27292729
getModule()->features.hasGC(), curr, "ref.i31 requires gc [--enable-gc]");
2730+
if (curr->type.isRef() && curr->type.getHeapType().isShared()) {
2731+
shouldBeTrue(
2732+
getModule()->features.hasGC(),
2733+
curr,
2734+
"ref.i31_shared requires shared-everything [--enable-shared-everything]");
2735+
}
27302736
shouldBeSubType(curr->value->type,
27312737
Type::i32,
27322738
curr->value,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
;; Test that ref.i31_shared requires shared-everything threads
2+
3+
;; RUN: not wasm-opt %s 2>&1 | filecheck %s --check-prefix NO-SHARED
4+
;; RUN: wasm-opt %s --enable-reference-types --enable-gc --enable-shared-everything -o - -S | filecheck %s --check-prefix SHARED
5+
6+
;; NO-SHARED: ref.i31_shared requires shared-everything [--enable-shared-everything]
7+
;; SHARED: (ref.i31_shared
8+
;; SHARED-NEXT: (i32.const 0)
9+
10+
(module
11+
(func (drop (ref.i31_shared (i32.const 0))))
12+
)

0 commit comments

Comments
 (0)