< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.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.
*** 196,231 **** UNSAFE.putInt(base, offset, 0x01234567); // Compare { ! boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF); ! assertEquals(r, true, "success compareAndSwap int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "success compareAndSwap int value"); } { ! boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0xCAFEBABE); ! assertEquals(r, false, "failing compareAndSwap int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "failing compareAndSwap int value"); } // Advanced compare { ! int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0x01234567); ! assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value"); } { ! int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0xCAFEBABE); ! assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value"); } { int r = UNSAFE.compareAndExchangeIntAcquire(base, offset, 0x01234567, 0x89ABCDEF); assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int"); --- 196,231 ---- UNSAFE.putInt(base, offset, 0x01234567); // Compare { ! boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0x89ABCDEF); ! assertEquals(r, true, "success compareAndSet int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "success compareAndSet int value"); } { ! boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0xCAFEBABE); ! assertEquals(r, false, "failing compareAndSet int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value"); } // Advanced compare { ! int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0x01234567); ! assertEquals(r, 0x89ABCDEF, "success compareAndExchange int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "success compareAndExchange int value"); } { ! int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0xCAFEBABE); ! assertEquals(r, 0x01234567, "failing compareAndExchange int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "failing compareAndExchange int value"); } { int r = UNSAFE.compareAndExchangeIntAcquire(base, offset, 0x01234567, 0x89ABCDEF); assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
*** 255,299 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF); } ! assertEquals(success, true, "weakCompareAndSwap int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "weakCompareAndSwap int value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 0x89ABCDEF, 0x01234567); } ! assertEquals(success, true, "weakCompareAndSwapAcquire int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "weakCompareAndSwapAcquire int"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 0x01234567, 0x89ABCDEF); } ! assertEquals(success, true, "weakCompareAndSwapRelease int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "weakCompareAndSwapRelease int"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 0x89ABCDEF, 0x01234567); } ! assertEquals(success, true, "weakCompareAndSwapVolatile int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "weakCompareAndSwapVolatile int"); } UNSAFE.putInt(base, offset, 0x89ABCDEF); // Compare set and get --- 255,299 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetIntPlain(base, offset, 0x01234567, 0x89ABCDEF); } ! assertEquals(success, true, "weakCompareAndSetPlain int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetIntAcquire(base, offset, 0x89ABCDEF, 0x01234567); } ! assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetIntRelease(base, offset, 0x01234567, 0x89ABCDEF); } ! assertEquals(success, true, "weakCompareAndSetRelease int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetInt(base, offset, 0x89ABCDEF, 0x01234567); } ! assertEquals(success, true, "weakCompareAndSet int"); int x = UNSAFE.getInt(base, offset); ! assertEquals(x, 0x01234567, "weakCompareAndSet int"); } UNSAFE.putInt(base, offset, 0x89ABCDEF); // Compare set and get
*** 322,327 **** int x = UNSAFE.getInt(address); assertEquals(x, 0x01234567, "set int value"); } } } - --- 322,326 ----
< prev index next >