< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.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.putFloat(base, offset, 1.0f); // Compare { ! boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 2.0f); ! assertEquals(r, true, "success compareAndSwap float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "success compareAndSwap float value"); } { ! boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 3.0f); ! assertEquals(r, false, "failing compareAndSwap float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "failing compareAndSwap float value"); } // Advanced compare { ! float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 1.0f); ! assertEquals(r, 2.0f, "success compareAndExchangeVolatile float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "success compareAndExchangeVolatile float value"); } { ! float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 3.0f); ! assertEquals(r, 1.0f, "failing compareAndExchangeVolatile float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "failing compareAndExchangeVolatile float value"); } { float r = UNSAFE.compareAndExchangeFloatAcquire(base, offset, 1.0f, 2.0f); assertEquals(r, 1.0f, "success compareAndExchangeAcquire float"); --- 178,213 ---- UNSAFE.putFloat(base, offset, 1.0f); // Compare { ! boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 2.0f); ! assertEquals(r, true, "success compareAndSet float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "success compareAndSet float value"); } { ! boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 3.0f); ! assertEquals(r, false, "failing compareAndSet float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "failing compareAndSet float value"); } // Advanced compare { ! float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 1.0f); ! assertEquals(r, 2.0f, "success compareAndExchange float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "success compareAndExchange float value"); } { ! float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 3.0f); ! assertEquals(r, 1.0f, "failing compareAndExchange float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "failing compareAndExchange float value"); } { float r = UNSAFE.compareAndExchangeFloatAcquire(base, offset, 1.0f, 2.0f); assertEquals(r, 1.0f, "success compareAndExchangeAcquire float");
*** 237,281 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapFloat(base, offset, 1.0f, 2.0f); } ! assertEquals(success, true, "weakCompareAndSwap float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "weakCompareAndSwap float value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapFloatAcquire(base, offset, 2.0f, 1.0f); } ! assertEquals(success, true, "weakCompareAndSwapAcquire float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "weakCompareAndSwapAcquire float"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapFloatRelease(base, offset, 1.0f, 2.0f); } ! assertEquals(success, true, "weakCompareAndSwapRelease float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "weakCompareAndSwapRelease float"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapFloatVolatile(base, offset, 2.0f, 1.0f); } ! assertEquals(success, true, "weakCompareAndSwapVolatile float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "weakCompareAndSwapVolatile float"); } UNSAFE.putFloat(base, offset, 2.0f); // Compare set and get --- 237,281 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetFloatPlain(base, offset, 1.0f, 2.0f); } ! assertEquals(success, true, "weakCompareAndSetPlain float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetFloatAcquire(base, offset, 2.0f, 1.0f); } ! assertEquals(success, true, "weakCompareAndSetAcquire float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "weakCompareAndSetAcquire float"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetFloatRelease(base, offset, 1.0f, 2.0f); } ! assertEquals(success, true, "weakCompareAndSetRelease float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 2.0f, "weakCompareAndSetRelease float"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetFloat(base, offset, 2.0f, 1.0f); } ! assertEquals(success, true, "weakCompareAndSet float"); float x = UNSAFE.getFloat(base, offset); ! assertEquals(x, 1.0f, "weakCompareAndSet float"); } UNSAFE.putFloat(base, offset, 2.0f); // Compare set and get
*** 304,309 **** float x = UNSAFE.getFloat(address); assertEquals(x, 1.0f, "set float value"); } } } - --- 304,308 ----
< prev index next >