[jmm-dev] bitwise RMW operators, specifically testAndSetBit/BTS
Doug Lea
dl at cs.oswego.edu
Fri Jul 22 12:27:30 UTC 2016
On 07/22/2016 07:38 AM, Paul Sandoz wrote:
> The concern i have implementation-wise is AtomicLong has this:
>
> /**
> * Records whether the underlying JVM supports lockless
> * compareAndSwap for longs. While the intrinsic compareAndSwapLong
> * method works in either case, some constructions should be
> * handled at Java level to avoid locking user-visible locks.
> */
> static final boolean VM_SUPPORTS_LONG_CAS = VMSupportsCS8();
>
This was initially needed to support Power5. I am not sure if
it returns false on any jdk9-supported platforms -- if so,
probably only non-OpenJDK "closed" ones. This problem is/was
that volatile long reads are implemented differently than
AtomicLong.get (i.e., VH getVolatile) and that the lock-based
CAS implementation relied on the latter. The internal
AtomicLongFieldUpdater.LockedUpdater was used to make sure that
the locked versions were always used so long as all accesses
used the Updater. People working on closed hotspot ports are
invited to help figure out whether this is still necessary.
-Doug
More information about the jmm-dev
mailing list