Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Behavior of `t.atomic.rmw.cmpxchg` instructions

Aperta
#195 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
wasm
Ambito
compilers

Direzione di ricerca

Inizia con i passaggi 17–21 della specifica dei thread WebAssembly collegata e confronta la semantica di t.atomic.rmw.cmpxchg con quella di std::atomic<T>::compare_exchange_strong in C++. Non sono stati identificati file del repository o test; il lavoro sarebbe completato dopo aver stabilito se il comportamento specificato è intenzionale e aver determinato ogni conseguente modifica alla specifica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
WebAssembly
Stelle
769
Fork
54
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WebAssembly/threads

Tutte le issue di WebAssembly/threads

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.