RFR (XS): CR 8004330: Add missing Unsafe entry points for addAndGet() family
Doug Lea
dl at cs.oswego.edu
Wed Jan 9 13:54:09 UTC 2013
On 01/09/13 08:04, Aleksey Shipilev wrote:
> c) While existing, Java-level AtomicLong.VM_SUPPORT_LONG_CAS is
> redundant, and can be eliminated. AtomicLongFieldUpdater can be
> rewritten to use Unsafe on all the paths.
>
There is one little nicety here that does rely on
VM_SUPPORT_LONG_CAS. There is a disclaimer
somewhere that CAS is guaranteed to atomic only wrt
other CASes. But in the emulation code for updaters, we also
lock unconditional writes, because not doing so would
be surprising. There is other code using Unsafe
that is not so careful/forgiving. A good case
can be made that the fallback wrapper for putLongVolatile
should itself use a lock in this case but for
reasons I don't remember, this wasn't done.
(and in any case wouldn't trap syntactically
generated volatile writes.) So there may be some
usage code that is officially wrong/surprising on
these grounds.
-Doug
More information about the core-libs-dev
mailing list