r/rust • u/folkertdev • 43m ago
🧠educational Implementing 128-bit atomics in Cranelift
https://trifectatech.org/blog/implementing-128-bit-atomics-in-cranelift/rustc_codegen_cranelift previously could not compile the Rust standard library without patches; now it can! This is thanks to the addition of 128-bit atomic support in Cranelift for AArch64 and s390x.
17
Upvotes
1
u/nithinrdy 21m ago
Slightly unrelated: I've only recently started learning atomics beyond just the surface-level and as I understand it, the x64 processor can only perform atomic operations on ≤64 bits and 128-bit atomics were shoehorned in later down the line (no dedicated stores/loads, have to use 128-bit compxhg in a roundabout way).
I wonder what exactly was the need for this, why not just CAS-loop it in (like any arbitrary size), why the need for a dedicated instruction specifically for 128 bits (given that using the 128bit-cmpxchg every time, for even simple reads and stuff, had extra overhead anyway)?