RFR 8158039 VarHandle float/double field/array access should support CAS/set/add atomics

Andrew Haley aph at redhat.com
Wed Jul 6 11:01:10 UTC 2016


I'm baffled by

    @ForceInline
    public final float compareAndExchangeFloatAcquire(Object o, long offset,
                                                  float expected,
                                                  float x) {
        int w = compareAndExchangeIntVolatile(o, offset,
                                              Float.floatToRawIntBits(expected),
                                              Float.floatToRawIntBits(x));
        return Float.intBitsToFloat(w);
    }

Why does it use compareAndExchangeIntVolatile?  It's a minor
inefficiency, but it does generate an unnecessary write fence on a
machine with relaxed memory consistency.

Andrew.


More information about the jdk9-dev mailing list