RFR 8161444 VarHandles should provide access bitwise atomics

Paul Sandoz paul.sandoz at oracle.com
Wed Aug 10 20:49:30 UTC 2016


I updated the webrev in place.

The doc of each bitwise access mode now includes:

* <p>If the variable type is the non-integral {@code boolean} type then a
* logical OR is performed instead of a bitwise OR.

The unsafe bitwise acquire CAS methods have:

public final int getAndBitwiseOrIntAcquire(Object o, long offset, int mask) {
    int current;
    do {
        // Plain read, the value is a hint, the acquire CAS does the work
        current = getInt(o, offset);
    } while (!weakCompareAndSwapIntAcquire(o, offset,
                                           current, current | mask));
    return current;


> On 9 Aug 2016, at 17:14, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
> Hi
> Please review the following webrev which combines:
>  8161444 VarHandles should provide access bitwise atomics
>  8162107 Add acquire/release variants for getAndSet and getAndAdd
>  http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8161444-vhs-bitwise-atomics/webrev/
>  http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8161444-vhs-bitwise-atomics/specdiff/overview-summary.html
> The set of access modes are expanded for support bitwise or/and/xor operations for volatile/acquire/release. Acquire/release getAndAdd and getAndSet access modes are also added (a future webrev will remove getAndAdd). This gets closer to parity with C++ atomics.
> As a follow on i will:
> - update the Hotspot Unsafe tests as a separate issue (the VarHandle tests implicitly test the Unsafe methods).
> - log HotSpot bugs for making the Unsafe bitwise atomics intrinsic for various platforms.
> Thanks,
> Paul.

More information about the core-libs-dev mailing list