Re:TIL: Go's CompareAndSwap is not always Compare-and-swap
by enz on Monday January 08, 2024 @05:59PM
(#38919619)
I believe Go wants to support "ARM64" that just works among the heterogeneous fleets of Arm machines (from Raspberry Pi to Graviton EC2 instances) and let the programmer not to worry about it. GCC seems to do the same if I believe the article linked on "MySQL on ARM": it emits code that dynamically decides to either use CAS or LL/SC depending on the LSE support.
MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4
CBZ R4, load_store_loop
Why is this a runtime decision? Shouldn't the compiler know if the target machine supports the instruction or not?