author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 45514 | hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template@0fc9cc73ce45 |
child 53769 | 291944be3f92 |
permissions | -rw-r--r-- |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
1 |
/* |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
4 |
* |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
8 |
* |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
13 |
* accompanied this code). |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
14 |
* |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
18 |
* |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
21 |
* questions. |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
22 |
*/ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
23 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
24 |
/* |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
25 |
* @test |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
26 |
* @bug 8143628 |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
27 |
* @summary Test unsafe access for $type$ |
40059 | 28 |
* |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
29 |
#if[JdkInternalMisc] |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
30 |
* @modules $module$/$package$:+open |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
31 |
#else[JdkInternalMisc] |
36851 | 32 |
* @modules $module$/$package$ |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
33 |
#end[JdkInternalMisc] |
40059 | 34 |
* @run testng/othervm -Diters=100 -Xint compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ |
35 |
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ |
|
36 |
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ |
|
37 |
* @run testng/othervm -Diters=20000 compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ |
|
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
38 |
*/ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
39 |
|
40059 | 40 |
package compiler.unsafe; |
41 |
||
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
42 |
import org.testng.annotations.Test; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
43 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
44 |
import java.lang.reflect.Field; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
45 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
46 |
import static org.testng.Assert.*; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
47 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
48 |
public class $Qualifier$UnsafeAccessTest$Type$ { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
49 |
static final int ITERS = Integer.getInteger("iters", 1); |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
50 |
static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
51 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
52 |
static final $package$.Unsafe UNSAFE; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
53 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
54 |
static final long V_OFFSET; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
55 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
56 |
static final Object STATIC_V_BASE; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
57 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
58 |
static final long STATIC_V_OFFSET; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
59 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
60 |
static int ARRAY_OFFSET; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
61 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
62 |
static int ARRAY_SHIFT; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
63 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
64 |
static { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
65 |
try { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
66 |
Field f = $package$.Unsafe.class.getDeclaredField("theUnsafe"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
67 |
f.setAccessible(true); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
68 |
UNSAFE = ($package$.Unsafe) f.get(null); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
69 |
} catch (Exception e) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
70 |
throw new RuntimeException("Unable to get Unsafe instance.", e); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
71 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
72 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
73 |
try { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
74 |
Field staticVField = $Qualifier$UnsafeAccessTest$Type$.class.getDeclaredField("static_v"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
75 |
STATIC_V_BASE = UNSAFE.staticFieldBase(staticVField); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
76 |
STATIC_V_OFFSET = UNSAFE.staticFieldOffset(staticVField); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
77 |
} catch (Exception e) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
78 |
throw new RuntimeException(e); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
79 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
80 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
81 |
try { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
82 |
Field vField = $Qualifier$UnsafeAccessTest$Type$.class.getDeclaredField("v"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
83 |
V_OFFSET = UNSAFE.objectFieldOffset(vField); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
84 |
} catch (Exception e) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
85 |
throw new RuntimeException(e); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
86 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
87 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
88 |
ARRAY_OFFSET = UNSAFE.arrayBaseOffset($type$[].class); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
89 |
int ascale = UNSAFE.arrayIndexScale($type$[].class); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
90 |
ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(ascale); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
91 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
92 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
93 |
static $type$ static_v; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
94 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
95 |
$type$ v; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
96 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
97 |
@Test |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
98 |
public void testFieldInstance() { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
99 |
$Qualifier$UnsafeAccessTest$Type$ t = new $Qualifier$UnsafeAccessTest$Type$(); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
100 |
for (int c = 0; c < ITERS; c++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
101 |
testAccess(t, V_OFFSET); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
102 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
103 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
104 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
105 |
@Test |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
106 |
public void testFieldStatic() { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
107 |
for (int c = 0; c < ITERS; c++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
108 |
testAccess(STATIC_V_BASE, STATIC_V_OFFSET); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
109 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
110 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
111 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
112 |
@Test |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
113 |
public void testArray() { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
114 |
$type$[] array = new $type$[10]; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
115 |
for (int c = 0; c < ITERS; c++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
116 |
for (int i = 0; i < array.length; i++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
117 |
testAccess(array, (((long) i) << ARRAY_SHIFT) + ARRAY_OFFSET); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
118 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
119 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
120 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
121 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
122 |
#if[!Object] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
123 |
#if[!boolean] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
124 |
@Test |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
125 |
public void testArrayOffHeap() { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
126 |
int size = 10; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
127 |
long address = UNSAFE.allocateMemory(size << ARRAY_SHIFT); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
128 |
try { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
129 |
for (int c = 0; c < ITERS; c++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
130 |
for (int i = 0; i < size; i++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
131 |
testAccess(null, (((long) i) << ARRAY_SHIFT) + address); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
132 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
133 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
134 |
} finally { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
135 |
UNSAFE.freeMemory(address); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
136 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
137 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
138 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
139 |
@Test |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
140 |
public void testArrayOffHeapDirect() { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
141 |
int size = 10; |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
142 |
long address = UNSAFE.allocateMemory(size << ARRAY_SHIFT); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
143 |
try { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
144 |
for (int c = 0; c < ITERS; c++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
145 |
for (int i = 0; i < size; i++) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
146 |
testAccess((((long) i) << ARRAY_SHIFT) + address); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
147 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
148 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
149 |
} finally { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
150 |
UNSAFE.freeMemory(address); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
151 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
152 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
153 |
#end[!boolean] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
154 |
#end[!Object] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
155 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
156 |
static void testAccess(Object base, long offset) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
157 |
// Plain |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
158 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
159 |
UNSAFE.put$Type$(base, offset, $value1$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
160 |
$type$ x = UNSAFE.get$Type$(base, offset); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
161 |
assertEquals(x, $value1$, "set $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
162 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
163 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
164 |
// Volatile |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
165 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
166 |
UNSAFE.put$Type$Volatile(base, offset, $value2$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
167 |
$type$ x = UNSAFE.get$Type$Volatile(base, offset); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
168 |
assertEquals(x, $value2$, "putVolatile $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
169 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
170 |
|
36827
53d2d43551d2
8152698: Remove obsolete Unsafe.putOrdered{X} methods, usages, runtime and compiler support
shade
parents:
36316
diff
changeset
|
171 |
#if[!JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
172 |
#if[Ordered] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
173 |
// Lazy |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
174 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
175 |
UNSAFE.putOrdered$Type$(base, offset, $value1$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
176 |
$type$ x = UNSAFE.get$Type$Volatile(base, offset); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
177 |
assertEquals(x, $value1$, "putRelease $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
178 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
179 |
#end[Ordered] |
36827
53d2d43551d2
8152698: Remove obsolete Unsafe.putOrdered{X} methods, usages, runtime and compiler support
shade
parents:
36316
diff
changeset
|
180 |
#end[!JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
181 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
182 |
#if[JdkInternalMisc] |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
183 |
// Lazy |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
184 |
{ |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
185 |
UNSAFE.put$Type$Release(base, offset, $value1$); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
186 |
$type$ x = UNSAFE.get$Type$Acquire(base, offset); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
187 |
assertEquals(x, $value1$, "putRelease $type$ value"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
188 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
189 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
190 |
// Opaque |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
191 |
{ |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
192 |
UNSAFE.put$Type$Opaque(base, offset, $value2$); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
193 |
$type$ x = UNSAFE.get$Type$Opaque(base, offset); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
194 |
assertEquals(x, $value2$, "putOpaque $type$ value"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
195 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
196 |
#end[JdkInternalMisc] |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
197 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
198 |
#if[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
199 |
#if[Unaligned] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
200 |
// Unaligned |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
201 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
202 |
UNSAFE.put$Type$Unaligned(base, offset, $value2$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
203 |
$type$ x = UNSAFE.get$Type$Unaligned(base, offset); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
204 |
assertEquals(x, $value2$, "putUnaligned $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
205 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
206 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
207 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
208 |
UNSAFE.put$Type$Unaligned(base, offset, $value1$, true); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
209 |
$type$ x = UNSAFE.get$Type$Unaligned(base, offset, true); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
210 |
assertEquals(x, $value1$, "putUnaligned big endian $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
211 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
212 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
213 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
214 |
UNSAFE.put$Type$Unaligned(base, offset, $value2$, false); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
215 |
$type$ x = UNSAFE.get$Type$Unaligned(base, offset, false); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
216 |
assertEquals(x, $value2$, "putUnaligned little endian $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
217 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
218 |
#end[Unaligned] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
219 |
#end[JdkInternalMisc] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
220 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
221 |
#if[CAS] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
222 |
UNSAFE.put$Type$(base, offset, $value1$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
223 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
224 |
// Compare |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
225 |
{ |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
226 |
#if[JdkInternalMisc] |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
227 |
boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value2$); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
228 |
assertEquals(r, true, "success compareAndSet $type$"); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
229 |
#else[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
230 |
boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value2$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
231 |
assertEquals(r, true, "success compareAndSwap $type$"); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
232 |
#end[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
233 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
234 |
#if[JdkInternalMisc] |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
235 |
assertEquals(x, $value2$, "success compareAndSet $type$ value"); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
236 |
#else[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
237 |
assertEquals(x, $value2$, "success compareAndSwap $type$ value"); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
238 |
#end[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
239 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
240 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
241 |
{ |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
242 |
#if[JdkInternalMisc] |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
243 |
boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value3$); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
244 |
assertEquals(r, false, "failing compareAndSet $type$"); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
245 |
#else[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
246 |
boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value3$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
247 |
assertEquals(r, false, "failing compareAndSwap $type$"); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
248 |
#end[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
249 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
250 |
#if[JdkInternalMisc] |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
251 |
assertEquals(x, $value2$, "failing compareAndSet $type$ value"); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
252 |
#else[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
253 |
assertEquals(x, $value2$, "failing compareAndSwap $type$ value"); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
254 |
#end[JdkInternalMisc] |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
255 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
256 |
|
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
257 |
#if[JdkInternalMisc] |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
258 |
// Advanced compare |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
259 |
{ |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
260 |
$type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value1$); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
261 |
assertEquals(r, $value2$, "success compareAndExchange $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
262 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
263 |
assertEquals(x, $value1$, "success compareAndExchange $type$ value"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
264 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
265 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
266 |
{ |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
267 |
$type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value3$); |
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
268 |
assertEquals(r, $value1$, "failing compareAndExchange $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
269 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
270 |
assertEquals(x, $value1$, "failing compareAndExchange $type$ value"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
271 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
272 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
273 |
{ |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
274 |
$type$ r = UNSAFE.compareAndExchange$Type$Acquire(base, offset, $value1$, $value2$); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
275 |
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
276 |
$type$ x = UNSAFE.get$Type$(base, offset); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
277 |
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
278 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
279 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
280 |
{ |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
281 |
$type$ r = UNSAFE.compareAndExchange$Type$Acquire(base, offset, $value1$, $value3$); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
282 |
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
283 |
$type$ x = UNSAFE.get$Type$(base, offset); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
284 |
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
285 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
286 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
287 |
{ |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
288 |
$type$ r = UNSAFE.compareAndExchange$Type$Release(base, offset, $value2$, $value1$); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
289 |
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
290 |
$type$ x = UNSAFE.get$Type$(base, offset); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
291 |
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
292 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
293 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
294 |
{ |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
295 |
$type$ r = UNSAFE.compareAndExchange$Type$Release(base, offset, $value2$, $value3$); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
296 |
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
297 |
$type$ x = UNSAFE.get$Type$(base, offset); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
298 |
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
299 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
300 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
301 |
{ |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
302 |
boolean success = false; |
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
303 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
304 |
success = UNSAFE.weakCompareAndSet$Type$Plain(base, offset, $value1$, $value2$); |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
305 |
} |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
306 |
assertEquals(success, true, "weakCompareAndSetPlain $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
307 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
308 |
assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
309 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
310 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
311 |
{ |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
312 |
boolean success = false; |
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
313 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
314 |
success = UNSAFE.weakCompareAndSet$Type$Acquire(base, offset, $value2$, $value1$); |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
315 |
} |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
316 |
assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
317 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
318 |
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
319 |
} |
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
320 |
|
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
321 |
{ |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
322 |
boolean success = false; |
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
323 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
324 |
success = UNSAFE.weakCompareAndSet$Type$Release(base, offset, $value1$, $value2$); |
38234
06263a71233c
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
36851
diff
changeset
|
325 |
} |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
326 |
assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
327 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
328 |
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
329 |
} |
38281
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
330 |
|
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
331 |
{ |
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
332 |
boolean success = false; |
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
333 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
334 |
success = UNSAFE.weakCompareAndSet$Type$(base, offset, $value2$, $value1$); |
38281
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
335 |
} |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
336 |
assertEquals(success, true, "weakCompareAndSet $type$"); |
38281
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
337 |
$type$ x = UNSAFE.get$Type$(base, offset); |
45514
0fc9cc73ce45
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
40059
diff
changeset
|
338 |
assertEquals(x, $value1$, "weakCompareAndSet $type$"); |
38281
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
339 |
} |
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
340 |
|
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
341 |
#end[JdkInternalMisc] |
38281
b28e2739b429
8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics
shade
parents:
38234
diff
changeset
|
342 |
UNSAFE.put$Type$(base, offset, $value2$); |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
343 |
|
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
344 |
// Compare set and get |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
345 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
346 |
$type$ o = UNSAFE.getAndSet$Type$(base, offset, $value1$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
347 |
assertEquals(o, $value2$, "getAndSet $type$"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
348 |
$type$ x = UNSAFE.get$Type$(base, offset); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
349 |
assertEquals(x, $value1$, "getAndSet $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
350 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
351 |
#end[CAS] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
352 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
353 |
#if[AtomicAdd] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
354 |
UNSAFE.put$Type$(base, offset, $value1$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
355 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
356 |
// get and add, add and get |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
357 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
358 |
$type$ o = UNSAFE.getAndAdd$Type$(base, offset, $value2$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
359 |
assertEquals(o, $value1$, "getAndAdd $type$"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
360 |
$type$ x = UNSAFE.get$Type$(base, offset); |
39419
cc993a4ab581
8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents:
38281
diff
changeset
|
361 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$"); |
35103
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
362 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
363 |
#end[AtomicAdd] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
364 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
365 |
|
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
366 |
#if[!Object] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
367 |
#if[!boolean] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
368 |
static void testAccess(long address) { |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
369 |
// Plain |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
370 |
{ |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
371 |
UNSAFE.put$Type$(address, $value1$); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
372 |
$type$ x = UNSAFE.get$Type$(address); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
373 |
assertEquals(x, $value1$, "set $type$ value"); |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
374 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
375 |
} |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
376 |
#end[!boolean] |
d19354bcbfa6
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
diff
changeset
|
377 |
#end[!Object] |
36316
7a83de7aabca
8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
shade
parents:
35103
diff
changeset
|
378 |
} |