Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GC][Threads] Atomic GC operations require --enable-threads #7185

Merged
merged 2 commits into from
Jan 6, 2025
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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ full changeset diff at the end of each section.
Current Trunk
-------------

- `struct.atomic.get`/`struct.atomic.set` now require the threads feature,
`--enable-threads`. (#7185)

v121
----

Expand Down
28 changes: 18 additions & 10 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2989,11 +2989,15 @@ void FunctionValidator::visitStructGet(StructGet* curr) {
shouldBeTrue(getModule()->features.hasGC(),
curr,
"struct.get requires gc [--enable-gc]");
shouldBeTrue(curr->order == MemoryOrder::Unordered ||
getModule()->features.hasSharedEverything(),
curr,
"struct.atomic.get requires shared-everything "
"[--enable-shared-everything]");
if (curr->order != MemoryOrder::Unordered) {
shouldBeTrue(getModule()->features.hasSharedEverything(),
curr,
"struct.atomic.get requires shared-everything "
"[--enable-shared-everything]");
shouldBeTrue(getModule()->features.hasAtomics(),
curr,
"struct.atomic.get requires threads [--enable-threads]");
}
if (curr->type == Type::unreachable || curr->ref->type.isNull()) {
return;
}
Expand Down Expand Up @@ -3021,11 +3025,15 @@ void FunctionValidator::visitStructSet(StructSet* curr) {
shouldBeTrue(getModule()->features.hasGC(),
curr,
"struct.set requires gc [--enable-gc]");
shouldBeTrue(curr->order == MemoryOrder::Unordered ||
getModule()->features.hasSharedEverything(),
curr,
"struct.atomic.set requires shared-everything "
"[--enable-shared-everything]");
if (curr->order != MemoryOrder::Unordered) {
shouldBeTrue(getModule()->features.hasSharedEverything(),
curr,
"struct.atomic.set requires shared-everything "
"[--enable-shared-everything]");
shouldBeTrue(getModule()->features.hasAtomics(),
curr,
"struct.atomic.set requires threads [--enable-threads]");
}
if (curr->ref->type == Type::unreachable) {
return;
}
Expand Down
8 changes: 6 additions & 2 deletions test/lit/validation/gc-atomics.wast
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
;; Test that shared-everything GC instructions require the shared-everything
;; feature.

;; RUN: not wasm-opt -all --disable-shared-everything %s 2>&1 | filecheck %s
;; RUN: not wasm-opt -all --disable-shared-everything --disable-threads %s 2>&1 | filecheck %s

(module
(type $struct (struct (field (mut i32))))

;; CHECK: struct.atomic.get requires shared-everything [--enable-shared-everything]
;; CHECK: struct.atomic.get requires threads [--enable-threads]
(func $get-seqcst (result i32)
(struct.atomic.get seqcst $struct 0
(struct.new_default $struct)
)
)

;; CHECK: struct.atomic.get requires shared-everything [--enable-shared-everything]
;; CHECK: struct.atomic.get requires threads [--enable-threads]
(func $get-acqrel (result i32)
(struct.atomic.get acqrel $struct 0
(struct.new_default $struct)
)
)

;; CHECK: struct.atomic.set requires shared-everything [--enable-shared-everything]
;; CHECK: struct.atomic.set requires threads [--enable-threads]
(func $set-seqcst
(struct.atomic.set seqcst $struct 0
(struct.new_default $struct)
Expand All @@ -29,10 +32,11 @@
)

;; CHECK: struct.atomic.set requires shared-everything [--enable-shared-everything]
;; CHECK: struct.atomic.set requires threads [--enable-threads]
(func $set-acqrel
(struct.atomic.set acqrel $struct 0
(struct.new_default $struct)
(i32.const 0)
)
)
)
)
Loading