Skip to content

Commit 91a6772

Browse files
Fix validator
1 parent 41cfd56 commit 91a6772

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/wasm/wasm-validator.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,10 +3659,10 @@ void FunctionValidator::visitStructWait(StructWait* curr) {
36593659
Type(HeapTypes::sharedWaitqueue, Nullable),
36603660
curr,
36613661
"struct.wait waitqueue must be a shared waitqueue reference");
3662-
shouldBeEqual(curr->timeout->type,
3663-
Type(Type::BasicType::i64),
3664-
curr,
3665-
"struct.wait timeout must be an i64");
3662+
shouldBeEqualOrFirstIsUnreachable(curr->timeout->type,
3663+
Type(Type::BasicType::i64),
3664+
curr,
3665+
"struct.wait timeout must be an i64");
36663666

36673667
if (curr->ref->type == Type::unreachable || curr->ref->type.isNull()) {
36683668
return;
@@ -3717,10 +3717,10 @@ void FunctionValidator::visitWaitqueueNotify(WaitqueueNotify* curr) {
37173717
Type(HeapTypes::sharedWaitqueue, Nullable),
37183718
curr,
37193719
"waitqueue.notify waitqueue must be a shared waitqueue reference");
3720-
shouldBeEqual(curr->count->type,
3721-
Type(Type::BasicType::i32),
3722-
curr,
3723-
"waitqueue.notify count must be an i32");
3720+
shouldBeEqualOrFirstIsUnreachable(curr->count->type,
3721+
Type(Type::BasicType::i32),
3722+
curr,
3723+
"waitqueue.notify count must be an i32");
37243724
}
37253725

37263726
void FunctionValidator::visitArrayNew(ArrayNew* curr) {

test/spec/waitqueue.wast

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,26 @@
8282
;; unreachable is allowed
8383
(module
8484
(type $t (shared (struct (field i32))))
85+
(global $g (ref $t) (struct.new $t (i32.const 0)))
8586
(global $wq (ref (shared waitqueue)) (waitqueue.new))
8687
(func (param $expected i32) (param $timeout i64) (result i32)
8788
(struct.wait $t 0 (unreachable) (global.get $wq) (local.get $expected) (local.get $timeout))
8889
)
8990
(func (param $expected i32) (param $timeout i64) (result i32)
90-
(struct.wait $t 0 (ref.null $t) (unreachable) (local.get $expected) (local.get $timeout))
91+
(struct.wait $t 0 (global.get $g) (unreachable) (local.get $expected) (local.get $timeout))
92+
)
93+
(func (param $timeout i64) (result i32)
94+
(struct.wait $t 0 (global.get $g) (global.get $wq) (unreachable) (local.get $timeout))
95+
)
96+
(func (param $expected i32) (result i32)
97+
(struct.wait $t 0 (global.get $g) (global.get $wq) (local.get $expected) (unreachable))
9198
)
9299
(func (param $count i32) (result i32)
93100
(waitqueue.notify (unreachable) (local.get $count))
94101
)
102+
(func (result i32)
103+
(waitqueue.notify (global.get $wq) (unreachable))
104+
)
95105
)
96106

97107
;; i32 control word

0 commit comments

Comments
 (0)