RFR 8161444 VarHandles should provide access bitwise atomics

Aleksey Shipilev aleksey.shipilev at gmail.com
Wed Aug 10 16:41:18 UTC 2016


On 08/10/2016 03:14 AM, Paul Sandoz wrote:
>   http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8161444-vhs-bitwise-atomics/webrev/

 *) I probably missed this discussion, but why do we have bitwise ops on
boolean? I don't think boolean is a integral type to have exposed bit
representation. (Edit: this seems useful to get atomic {add, or, xor}
over the booleans themselves, not their "bits" -- confusing at first.)

 *) I wonder if weakCASAcquire is redundant in cases like these, and
relaxed weakCAS can be used instead? You definitely need
weakCAS{Volatile|Release} for *{Volatile|Release} methods, but *Acquire
seems special -- we would only exit with the value "acquired" by the
get*Acquire read inside the loop:

   @ForceInline
   public final int getAndAddIntAcquire(Object o, long offset, int delta) {
       int v;
       do {
            v = getIntAcquire(o, offset);
       } while (!weakCompareAndSwapIntAcquire(o, offset, v, v +
       return v;
   }


Thanks,
-Aleksey




More information about the core-libs-dev mailing list