Skip to content

Make CAS primops inline

Motivation

When using compare-and-swap to implement read-modify-write (perhaps its main application), it's important to minimize the delay between reading the old value and attempting the CAS—the longer the delay, the higher the risk that another thread will make a change in between, causing CAS to fail and requiring the operation to be repeated.

Proposal

Turn the following into inline primops: casMutVar#, casArray#, casSmallArray#, casInt64Array#, casInt32Array#, casInt16Array#, casInt8Array#, casIntArray#, and casIntArray#.

It looks like the following are already inline, I think?

atomicCasWord64Addr#, atomicCasWord32Addr#, atomicCasWord16Addr#, atomicCasWord8Addr#, atomicCasWordAddr#, and atomicCasAddrAddr#

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information