RFR 8160885 Unsafe.compareAndExchangeDouble/FloatAcquire should defer to compareAndExchangeLong/IntAcquire
Michael Haupt
michael.haupt at oracle.com
Thu Jul 7 10:44:49 UTC 2016
Hi Paul,
thumbs up.
Best,
Michael
> Am 07.07.2016 um 12:06 schrieb Paul Sandoz <paul.sandoz at oracle.com>:
>
> Hi,
>
> Please review the simple patch below.
>
> As spotted by Andrew Haley the Unsafe.compareAndExchangeDouble/FloatAcquire methods were incorrectly deferring to compareAndExchangeLong/IntVolatile rather than compareAndExchangeLong/IntAcquire. Other, related, double/float Unsafe methods defer correctly to the long/int variants.
>
> Thanks,
> Paul.
>
> diff -r 7ca81adc8bad src/java.base/share/classes/jdk/internal/misc/Unsafe.java
> --- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Wed Jul 06 17:38:29 2016 +0200
> +++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Wed Jul 06 19:08:55 2016 +0200
> @@ -1709,9 +1709,9 @@
> public final float compareAndExchangeFloatAcquire(Object o, long offset,
> float expected,
> float x) {
> - int w = compareAndExchangeIntVolatile(o, offset,
> - Float.floatToRawIntBits(expected),
> - Float.floatToRawIntBits(x));
> + int w = compareAndExchangeIntAcquire(o, offset,
> + Float.floatToRawIntBits(expected),
> + Float.floatToRawIntBits(x));
> return Float.intBitsToFloat(w);
> }
>
> @@ -1793,9 +1793,9 @@
> public final double compareAndExchangeDoubleAcquire(Object o, long offset,
> double expected,
> double x) {
> - long w = compareAndExchangeLongVolatile(o, offset,
> - Double.doubleToRawLongBits(expected),
> - Double.doubleToRawLongBits(x));
> + long w = compareAndExchangeLongAcquire(o, offset,
> + Double.doubleToRawLongBits(expected),
> + Double.doubleToRawLongBits(x));
> return Double.longBitsToDouble(w);
> }
>
--
<http://www.oracle.com/>
Dr. Michael Haupt | Principal Member of Technical Staff
Phone: +49 331 200 7277 | Fax: +49 331 200 7561
Oracle Java Platform Group | LangTools Team | Nashorn
Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany
ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstraße 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603
Komplementärin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Jan Schultheiss, Val Maher
<http://www.oracle.com/commitment> Oracle is committed to developing practices and products that help protect the environment
More information about the core-libs-dev
mailing list