< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.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.putShort(base, offset, (short)0x0123); // Compare { ! boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x4567); ! assertEquals(r, true, "success compareAndSwap short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "success compareAndSwap short value"); } { ! boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x89AB); ! assertEquals(r, false, "failing compareAndSwap short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "failing compareAndSwap short value"); } // Advanced compare { ! short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x0123); ! assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value"); } { ! short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x89AB); ! assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value"); } { short r = UNSAFE.compareAndExchangeShortAcquire(base, offset, (short)0x0123, (short)0x4567); assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short"); --- 196,231 ---- UNSAFE.putShort(base, offset, (short)0x0123); // Compare { ! boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x4567); ! assertEquals(r, true, "success compareAndSet short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "success compareAndSet short value"); } { ! boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x89AB); ! assertEquals(r, false, "failing compareAndSet short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "failing compareAndSet short value"); } // Advanced compare { ! short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x0123); ! assertEquals(r, (short)0x4567, "success compareAndExchange short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "success compareAndExchange short value"); } { ! short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x89AB); ! assertEquals(r, (short)0x0123, "failing compareAndExchange short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "failing compareAndExchange short value"); } { short r = UNSAFE.compareAndExchangeShortAcquire(base, offset, (short)0x0123, (short)0x4567); assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
*** 255,299 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapShort(base, offset, (short)0x0123, (short)0x4567); } ! assertEquals(success, true, "weakCompareAndSwap short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "weakCompareAndSwap short value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapShortAcquire(base, offset, (short)0x4567, (short)0x0123); } ! assertEquals(success, true, "weakCompareAndSwapAcquire short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "weakCompareAndSwapAcquire short"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapShortRelease(base, offset, (short)0x0123, (short)0x4567); } ! assertEquals(success, true, "weakCompareAndSwapRelease short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "weakCompareAndSwapRelease short"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapShortVolatile(base, offset, (short)0x4567, (short)0x0123); } ! assertEquals(success, true, "weakCompareAndSwapVolatile short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "weakCompareAndSwapVolatile short"); } UNSAFE.putShort(base, offset, (short)0x4567); // Compare set and get --- 255,299 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetShortPlain(base, offset, (short)0x0123, (short)0x4567); } ! assertEquals(success, true, "weakCompareAndSetPlain short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetShortAcquire(base, offset, (short)0x4567, (short)0x0123); } ! assertEquals(success, true, "weakCompareAndSetAcquire short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetShortRelease(base, offset, (short)0x0123, (short)0x4567); } ! assertEquals(success, true, "weakCompareAndSetRelease short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetShort(base, offset, (short)0x4567, (short)0x0123); } ! assertEquals(success, true, "weakCompareAndSet short"); short x = UNSAFE.getShort(base, offset); ! assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } UNSAFE.putShort(base, offset, (short)0x4567); // Compare set and get
*** 322,327 **** short x = UNSAFE.getShort(address); assertEquals(x, (short)0x0123, "set short value"); } } } - --- 322,326 ----
< prev index next >