< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.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.putByte(base, offset, (byte)0x01); // Compare { ! boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x23); ! assertEquals(r, true, "success compareAndSwap byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "success compareAndSwap byte value"); } { ! boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x45); ! assertEquals(r, false, "failing compareAndSwap byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "failing compareAndSwap byte value"); } // Advanced compare { ! byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x01); ! assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value"); } { ! byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x45); ! assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value"); } { byte r = UNSAFE.compareAndExchangeByteAcquire(base, offset, (byte)0x01, (byte)0x23); assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte"); --- 178,213 ---- UNSAFE.putByte(base, offset, (byte)0x01); // Compare { ! boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x23); ! assertEquals(r, true, "success compareAndSet byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "success compareAndSet byte value"); } { ! boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x45); ! assertEquals(r, false, "failing compareAndSet byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "failing compareAndSet byte value"); } // Advanced compare { ! byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x01); ! assertEquals(r, (byte)0x23, "success compareAndExchange byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "success compareAndExchange byte value"); } { ! byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x45); ! assertEquals(r, (byte)0x01, "failing compareAndExchange byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "failing compareAndExchange byte value"); } { byte r = UNSAFE.compareAndExchangeByteAcquire(base, offset, (byte)0x01, (byte)0x23); assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
*** 237,281 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapByte(base, offset, (byte)0x01, (byte)0x23); } ! assertEquals(success, true, "weakCompareAndSwap byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "weakCompareAndSwap byte value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapByteAcquire(base, offset, (byte)0x23, (byte)0x01); } ! assertEquals(success, true, "weakCompareAndSwapAcquire byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "weakCompareAndSwapAcquire byte"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapByteRelease(base, offset, (byte)0x01, (byte)0x23); } ! assertEquals(success, true, "weakCompareAndSwapRelease byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "weakCompareAndSwapRelease byte"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapByteVolatile(base, offset, (byte)0x23, (byte)0x01); } ! assertEquals(success, true, "weakCompareAndSwapVolatile byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "weakCompareAndSwapVolatile byte"); } UNSAFE.putByte(base, offset, (byte)0x23); // Compare set and get --- 237,281 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetBytePlain(base, offset, (byte)0x01, (byte)0x23); } ! assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetByteAcquire(base, offset, (byte)0x23, (byte)0x01); } ! assertEquals(success, true, "weakCompareAndSetAcquire byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetByteRelease(base, offset, (byte)0x01, (byte)0x23); } ! assertEquals(success, true, "weakCompareAndSetRelease byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetByte(base, offset, (byte)0x23, (byte)0x01); } ! assertEquals(success, true, "weakCompareAndSet byte"); byte x = UNSAFE.getByte(base, offset); ! assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } UNSAFE.putByte(base, offset, (byte)0x23); // Compare set and get
*** 304,309 **** byte x = UNSAFE.getByte(address); assertEquals(x, (byte)0x01, "set byte value"); } } } - --- 304,308 ----
< prev index next >