< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java

Print this page
rev 12711 : 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
Reviewed-by: psandoz, dholmes, thartmann
Contributed-by: ron.pressler@oracle.com, claes.redestad@oracle.com

*** 1,7 **** /* ! * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 178,213 **** UNSAFE.putDouble(base, offset, 1.0d); // Compare { ! boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 2.0d); ! assertEquals(r, true, "success compareAndSwap double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "success compareAndSwap double value"); } { ! boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 3.0d); ! assertEquals(r, false, "failing compareAndSwap double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "failing compareAndSwap double value"); } // Advanced compare { ! double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 1.0d); ! assertEquals(r, 2.0d, "success compareAndExchangeVolatile double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "success compareAndExchangeVolatile double value"); } { ! double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 3.0d); ! assertEquals(r, 1.0d, "failing compareAndExchangeVolatile double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "failing compareAndExchangeVolatile double value"); } { double r = UNSAFE.compareAndExchangeDoubleAcquire(base, offset, 1.0d, 2.0d); assertEquals(r, 1.0d, "success compareAndExchangeAcquire double"); --- 178,213 ---- UNSAFE.putDouble(base, offset, 1.0d); // Compare { ! boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 2.0d); ! assertEquals(r, true, "success compareAndSet double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "success compareAndSet double value"); } { ! boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 3.0d); ! assertEquals(r, false, "failing compareAndSet double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "failing compareAndSet double value"); } // Advanced compare { ! double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 1.0d); ! assertEquals(r, 2.0d, "success compareAndExchange double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "success compareAndExchange double value"); } { ! double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 3.0d); ! assertEquals(r, 1.0d, "failing compareAndExchange double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "failing compareAndExchange double value"); } { double r = UNSAFE.compareAndExchangeDoubleAcquire(base, offset, 1.0d, 2.0d); assertEquals(r, 1.0d, "success compareAndExchangeAcquire double");
*** 237,281 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapDouble(base, offset, 1.0d, 2.0d); } ! assertEquals(success, true, "weakCompareAndSwap double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "weakCompareAndSwap double value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapDoubleAcquire(base, offset, 2.0d, 1.0d); } ! assertEquals(success, true, "weakCompareAndSwapAcquire double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "weakCompareAndSwapAcquire double"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapDoubleRelease(base, offset, 1.0d, 2.0d); } ! assertEquals(success, true, "weakCompareAndSwapRelease double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "weakCompareAndSwapRelease double"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapDoubleVolatile(base, offset, 2.0d, 1.0d); } ! assertEquals(success, true, "weakCompareAndSwapVolatile double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "weakCompareAndSwapVolatile double"); } UNSAFE.putDouble(base, offset, 2.0d); // Compare set and get --- 237,281 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetDoublePlain(base, offset, 1.0d, 2.0d); } ! assertEquals(success, true, "weakCompareAndSetPlain double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetDoubleAcquire(base, offset, 2.0d, 1.0d); } ! assertEquals(success, true, "weakCompareAndSetAcquire double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "weakCompareAndSetAcquire double"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetDoubleRelease(base, offset, 1.0d, 2.0d); } ! assertEquals(success, true, "weakCompareAndSetRelease double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 2.0d, "weakCompareAndSetRelease double"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetDouble(base, offset, 2.0d, 1.0d); } ! assertEquals(success, true, "weakCompareAndSet double"); double x = UNSAFE.getDouble(base, offset); ! assertEquals(x, 1.0d, "weakCompareAndSet double"); } UNSAFE.putDouble(base, offset, 2.0d); // Compare set and get
*** 304,309 **** double x = UNSAFE.getDouble(address); assertEquals(x, 1.0d, "set double value"); } } } - --- 304,308 ----
< prev index next >