< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.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.putLong(base, offset, 0x0123456789ABCDEFL); // Compare { ! boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); ! assertEquals(r, true, "success compareAndSwap long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSwap long value"); } { ! boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL); ! assertEquals(r, false, "failing compareAndSwap long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSwap long value"); } // Advanced compare { ! long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); ! assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value"); } { ! long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL); ! assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value"); } { long r = UNSAFE.compareAndExchangeLongAcquire(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long"); --- 196,231 ---- UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL); // Compare { ! boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); ! assertEquals(r, true, "success compareAndSet long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value"); } { ! boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL); ! assertEquals(r, false, "failing compareAndSet long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value"); } // Advanced compare { ! long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); ! assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchange long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchange long value"); } { ! long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL); ! assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchange long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchange long value"); } { long r = UNSAFE.compareAndExchangeLongAcquire(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
*** 255,299 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } ! assertEquals(success, true, "weakCompareAndSwap long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwap long value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } ! assertEquals(success, true, "weakCompareAndSwapAcquire long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapAcquire long"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } ! assertEquals(success, true, "weakCompareAndSwapRelease long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwapRelease long"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } ! assertEquals(success, true, "weakCompareAndSwapVolatile long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapVolatile long"); } UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL); // Compare set and get --- 255,299 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetLongPlain(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } ! assertEquals(success, true, "weakCompareAndSetPlain long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } ! assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } ! assertEquals(success, true, "weakCompareAndSetRelease long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } ! assertEquals(success, true, "weakCompareAndSet long"); long x = UNSAFE.getLong(base, offset); ! assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL); // Compare set and get
*** 322,327 **** long x = UNSAFE.getLong(address); assertEquals(x, 0x0123456789ABCDEFL, "set long value"); } } } - --- 322,326 ----
< prev index next >