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
3 changes: 2 additions & 1 deletion src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2894,7 +2894,8 @@ Expression* TranslateToFuzzReader::_makeConcrete(Type type) {
&Self::makeStringEq,
&Self::makeStringMeasure,
&Self::makeStringGet);
options.add(FeatureSet::ReferenceTypes | FeatureSet::SharedEverything,
options.add(FeatureSet::ReferenceTypes | FeatureSet::GC |
FeatureSet::SharedEverything,
&Self::makeWaitqueueNotify);
if (!structWaitFields.empty()) {
options.add(FeatureSet::ReferenceTypes | FeatureSet::GC |
Expand Down
3 changes: 2 additions & 1 deletion src/wasm/wasm-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,8 @@ FeatureSet HeapType::getFeatures() const {
return;
case HeapType::waitqueue:
case HeapType::nowaitqueue:
feats |= FeatureSet::ReferenceTypes | FeatureSet::SharedEverything;
feats |= FeatureSet::ReferenceTypes | FeatureSet::GC |
FeatureSet::SharedEverything;
return;
case HeapType::noext:
case HeapType::nofunc:
Expand Down
33 changes: 21 additions & 12 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3696,10 +3696,13 @@ void FunctionValidator::visitStructCmpxchg(StructCmpxchg* curr) {
}

void FunctionValidator::visitStructWait(StructWait* curr) {
shouldBeTrue(
!getModule() || getModule()->features.hasSharedEverything(),
curr,
"struct.wait requires shared-everything [--enable-shared-everything]");
FeatureSet expected =
FeatureSet::GC | FeatureSet::SharedEverything | FeatureSet::ReferenceTypes;
if (!shouldBeTrue(expected.isSubsetOf(getModule()->features),
curr,
"struct.wait requires additional features")) {
getStream() << getMissingFeaturesList(*getModule(), expected) << '\n';
}

shouldBeSubType(curr->waitqueue->type,
Type(HeapTypes::sharedWaitqueue, Nullable),
Expand Down Expand Up @@ -3747,17 +3750,23 @@ void FunctionValidator::visitStructWait(StructWait* curr) {
}

void FunctionValidator::visitWaitqueueNew(WaitqueueNew* curr) {
shouldBeTrue(
!getModule() || getModule()->features.hasSharedEverything(),
curr,
"waitqueue.new requires shared-everything [--enable-shared-everything]");
FeatureSet expected =
FeatureSet::GC | FeatureSet::SharedEverything | FeatureSet::ReferenceTypes;
if (!shouldBeTrue(expected.isSubsetOf(getModule()->features),
curr,
"waitqueue.new requires additional features")) {
getStream() << getMissingFeaturesList(*getModule(), expected) << '\n';
}
}

void FunctionValidator::visitWaitqueueNotify(WaitqueueNotify* curr) {
shouldBeTrue(
!getModule() || getModule()->features.hasSharedEverything(),
curr,
"waitqueue.notify requires shared-everything [--enable-shared-everything]");
FeatureSet expected =
FeatureSet::GC | FeatureSet::SharedEverything | FeatureSet::ReferenceTypes;
if (!shouldBeTrue(expected.isSubsetOf(getModule()->features),
curr,
"waitqueue.notify requires additional features")) {
getStream() << getMissingFeaturesList(*getModule(), expected) << '\n';
}

shouldBeSubType(
curr->waitqueue->type,
Expand Down
13 changes: 10 additions & 3 deletions test/lit/validation/waitqueue.wast
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
;; RUN: not wasm-opt --enable-reference-types --enable-gc %s 2>&1 | filecheck %s
;; RUN: not wasm-opt %s 2>&1 | filecheck %s

;; Tests feature-related validations.
;; Other validations are in the spec test spec/waitqueue.wast.
(module
(type $struct (struct (field i32)))
;; CHECK: waitqueue.new requires shared-everything [--enable-shared-everything]
;; CHECK: waitqueue.new requires additional features
;; CHECK: [--enable-reference-types --enable-gc --enable-shared-everything]
(func $new
(drop (waitqueue.new))
)
;; CHECK: struct.wait requires shared-everything [--enable-shared-everything]
;; CHECK: waitqueue.notify requires additional features
;; CHECK: [--enable-reference-types --enable-gc --enable-shared-everything]
(func $notify (param $wq (ref null (shared waitqueue)))
(drop (waitqueue.notify (local.get $wq) (i32.const 1)))
)
;; CHECK: struct.wait requires additional features
;; CHECK: [--enable-reference-types --enable-gc --enable-shared-everything]
(func $wait-no-feature (param $ref (ref $struct)) (param $wq (ref null (shared waitqueue)))
(drop (struct.wait $struct 0 (local.get $ref) (local.get $wq) (i32.const 0) (i64.const 0)))
)
Expand Down
Loading