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




Reply via email to