Skip to content

Commit b92b68d

Browse files
Require --enable-shared-everything with WaitQueues (#8342)
Validate that shared-everything is enabled when a WaitQueue is seen during TypeBuilder::build. Part of #8315.
1 parent 6a67b87 commit b92b68d

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/wasm-type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,8 @@ struct TypeBuilder {
907907
InvalidFuncType,
908908
// A shared type with shared-everything disabled.
909909
InvalidSharedType,
910+
// WaitQueue was used with shared-everything disabled.
911+
InvalidWaitQueue,
910912
// A string type with strings disabled.
911913
InvalidStringType,
912914
// A non-shared field of a shared heap type.

src/wasm/wasm-type.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,8 @@ std::ostream& operator<<(std::ostream& os, TypeBuilder::ErrorReason reason) {
14471447
return os << "Continuation has invalid function type";
14481448
case TypeBuilder::ErrorReason::InvalidSharedType:
14491449
return os << "Shared types require shared-everything";
1450+
case TypeBuilder::ErrorReason::InvalidWaitQueue:
1451+
return os << "Waitqueues require shared-everything";
14501452
case TypeBuilder::ErrorReason::InvalidStringType:
14511453
return os << "String types require strings feature";
14521454
case TypeBuilder::ErrorReason::InvalidUnsharedField:
@@ -2455,6 +2457,10 @@ validateStruct(const Struct& struct_, FeatureSet feats, bool isShared) {
24552457
if (auto err = validateType(field.type, feats, isShared)) {
24562458
return err;
24572459
}
2460+
if (field.packedType == Field::PackedType::WaitQueue &&
2461+
!feats.hasSharedEverything()) {
2462+
return TypeBuilder::ErrorReason::InvalidWaitQueue;
2463+
}
24582464
}
24592465
return std::nullopt;
24602466
}

test/lit/validation/waitqueue.wast

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;; RUN: not wasm-opt --enable-reference-types --enable-gc %s 2>&1 | filecheck %s
2+
3+
(module
4+
;; CHECK: invalid type: Waitqueues require shared-everything
5+
(type $t (struct (field waitqueue)))
6+
7+
;; use $t so wasm-opt doesn't drop the definition
8+
(global (ref null $t) (ref.null $t))
9+
)

0 commit comments

Comments
 (0)