Behavior of `t.atomic.rmw.cmpxchg` instructions
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- wasm
- Domain
- compilers
Research direction
Start with steps 17–21 of the linked WebAssembly threads specification and compare their t.atomic.rmw.cmpxchg semantics with C++ std::atomic<T>::compare_exchange_strong. No repository files or tests are identified; done would require resolving whether the specified behavior is intentional and determining any resulting specification change.
Written by the indexing model from the issue text.
Description
Hi,
As the 17. and 18. steps in the spec:
17. If c1 equals c2, then:
Let c be c2.
18. Else:
Let c be c3.
And the 21. step will write the c back to the memory.
Where c1 is the origin value on the memory, c2 is the expected value, c3 is the value to replace.
Maybe I can realize this as following simply:
if (memory[addr] != expected)
memory[addr] = replacement;
But the closest function in C++ std::atomic<T>::compare_exchange_strong has the different behavior.
if (memory[addr] == expected)
memory[addr] = replacement;
The atomic_rmw instructions are similar to the member functions of std::atomic<T> in C++ STL, such as fetch_add(), fetch_xor, etc.
Is it necessary to have the same behavior between cmpxchg instructions and std::atomic<T>::compare_exchange_strong in C++?
Thanks.
- Dominant language
- WebAssembly
- Stars
- 767
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WebAssembly/threads
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
WebAssembly/threads#254 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
WebAssembly/threads#253 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
WebAssembly/threads#245 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
WebAssembly/threads#240 ·
-
Branch renaming Open
Difficulty 1/5 Under an hour Newbie friendliness 20/100
WebAssembly/threads#237 ·
All issues in WebAssembly/threads
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
bradcypert/plum#58 ·
-
flang:fir-hlfir
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
llvm/llvm-project#225935 ·
-
area:cards hand-tail ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
fil-donadoni/tolaria#4446 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo#8923 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100