< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.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.
*** 149,184 **** UNSAFE.putBoolean(base, offset, true); // Compare { ! boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false); ! assertEquals(r, true, "success compareAndSwap boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "success compareAndSwap boolean value"); } { ! boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false); ! assertEquals(r, false, "failing compareAndSwap boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "failing compareAndSwap boolean value"); } // Advanced compare { ! boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, true); ! assertEquals(r, false, "success compareAndExchangeVolatile boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "success compareAndExchangeVolatile boolean value"); } { ! boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, false); ! assertEquals(r, true, "failing compareAndExchangeVolatile boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "failing compareAndExchangeVolatile boolean value"); } { boolean r = UNSAFE.compareAndExchangeBooleanAcquire(base, offset, true, false); assertEquals(r, true, "success compareAndExchangeAcquire boolean"); --- 149,184 ---- UNSAFE.putBoolean(base, offset, true); // Compare { ! boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false); ! assertEquals(r, true, "success compareAndSet boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "success compareAndSet boolean value"); } { ! boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false); ! assertEquals(r, false, "failing compareAndSet boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "failing compareAndSet boolean value"); } // Advanced compare { ! boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, true); ! assertEquals(r, false, "success compareAndExchange boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "success compareAndExchange boolean value"); } { ! boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, false); ! assertEquals(r, true, "failing compareAndExchange boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "failing compareAndExchange boolean value"); } { boolean r = UNSAFE.compareAndExchangeBooleanAcquire(base, offset, true, false); assertEquals(r, true, "success compareAndExchangeAcquire boolean");
*** 208,252 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapBoolean(base, offset, true, false); } ! assertEquals(success, true, "weakCompareAndSwap boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "weakCompareAndSwap boolean value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapBooleanAcquire(base, offset, false, true); } ! assertEquals(success, true, "weakCompareAndSwapAcquire boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "weakCompareAndSwapAcquire boolean"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapBooleanRelease(base, offset, true, false); } ! assertEquals(success, true, "weakCompareAndSwapRelease boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "weakCompareAndSwapRelease boolean"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapBooleanVolatile(base, offset, false, true); } ! assertEquals(success, true, "weakCompareAndSwapVolatile boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "weakCompareAndSwapVolatile boolean"); } UNSAFE.putBoolean(base, offset, false); // Compare set and get --- 208,252 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetBooleanPlain(base, offset, true, false); } ! assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetBooleanAcquire(base, offset, false, true); } ! assertEquals(success, true, "weakCompareAndSetAcquire boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "weakCompareAndSetAcquire boolean"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetBooleanRelease(base, offset, true, false); } ! assertEquals(success, true, "weakCompareAndSetRelease boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, false, "weakCompareAndSetRelease boolean"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetBoolean(base, offset, false, true); } ! assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = UNSAFE.getBoolean(base, offset); ! assertEquals(x, true, "weakCompareAndSet boolean"); } UNSAFE.putBoolean(base, offset, false); // Compare set and get
*** 258,263 **** } } } - --- 258,262 ----
< prev index next >