[jmm-dev] bitwise RMW operators, specifically testAndSetBit/BTS

John Rose john.r.rose at oracle.com
Wed Jul 20 16:32:21 UTC 2016

On Jul 20, 2016, at 7:18 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> On second thoughts it may be better if the currently non-intrinsic Unsafe acquire/release variants defer to the stronger volatile variant that is intrinsic. Any opinions on that?

I would prefer that the default implementations of the various bitwise ops defer to the same-flavored CAS ops instead of to the volatile bitwise ops.

Reason:  On platforms without rich bitwise ops (x86, SPARC) you lose memory ordering information if you alias to the volatile version.

(It's not a strong reason, since those CPUs are TSO.)

Platforms with rich bitwise ops are also likely to have rich fences, so again there's no benefit to aliasing to the volatile version.

— John

More information about the jmm-dev mailing list