author | alanb |
Fri, 10 Feb 2017 09:04:39 +0000 | |
changeset 43712 | 5dfd0950317c |
parent 40734 | 48879ea67e2a |
permissions | -rw-r--r-- |
36934 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccess$Type$ |
|
27 |
*/ |
|
28 |
||
29 |
import org.testng.annotations.BeforeClass; |
|
30 |
import org.testng.annotations.DataProvider; |
|
31 |
import org.testng.annotations.Test; |
|
32 |
||
33 |
import java.lang.invoke.MethodHandles; |
|
34 |
import java.lang.invoke.VarHandle; |
|
35 |
import java.util.ArrayList; |
|
36 |
import java.util.Arrays; |
|
37 |
import java.util.List; |
|
38 |
||
39 |
import static org.testng.Assert.*; |
|
40 |
||
41 |
public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { |
|
42 |
static final $type$ static_final_v = $value1$; |
|
43 |
||
44 |
static $type$ static_v; |
|
45 |
||
46 |
final $type$ final_v = $value1$; |
|
47 |
||
48 |
$type$ v; |
|
49 |
||
50 |
VarHandle vhFinalField; |
|
51 |
||
52 |
VarHandle vhField; |
|
53 |
||
54 |
VarHandle vhStaticField; |
|
55 |
||
56 |
VarHandle vhStaticFinalField; |
|
57 |
||
58 |
VarHandle vhArray; |
|
59 |
||
60 |
@BeforeClass |
|
61 |
public void setup() throws Exception { |
|
62 |
vhFinalField = MethodHandles.lookup().findVarHandle( |
|
63 |
VarHandleTestMethodHandleAccess$Type$.class, "final_v", $type$.class); |
|
64 |
||
65 |
vhField = MethodHandles.lookup().findVarHandle( |
|
66 |
VarHandleTestMethodHandleAccess$Type$.class, "v", $type$.class); |
|
67 |
||
68 |
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( |
|
69 |
VarHandleTestMethodHandleAccess$Type$.class, "static_final_v", $type$.class); |
|
70 |
||
71 |
vhStaticField = MethodHandles.lookup().findStaticVarHandle( |
|
72 |
VarHandleTestMethodHandleAccess$Type$.class, "static_v", $type$.class); |
|
73 |
||
74 |
vhArray = MethodHandles.arrayElementVarHandle($type$[].class); |
|
75 |
} |
|
76 |
||
77 |
||
78 |
@DataProvider |
|
79 |
public Object[][] accessTestCaseProvider() throws Exception { |
|
80 |
List<AccessTestCase<?>> cases = new ArrayList<>(); |
|
81 |
||
82 |
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { |
|
83 |
cases.add(new MethodHandleAccessTestCase("Instance field", |
|
84 |
vhField, f, hs -> testInstanceField(this, hs))); |
|
85 |
cases.add(new MethodHandleAccessTestCase("Instance field unsupported", |
|
86 |
vhField, f, hs -> testInstanceFieldUnsupported(this, hs), |
|
87 |
false)); |
|
88 |
||
89 |
cases.add(new MethodHandleAccessTestCase("Static field", |
|
90 |
vhStaticField, f, VarHandleTestMethodHandleAccess$Type$::testStaticField)); |
|
91 |
cases.add(new MethodHandleAccessTestCase("Static field unsupported", |
|
92 |
vhStaticField, f, VarHandleTestMethodHandleAccess$Type$::testStaticFieldUnsupported, |
|
93 |
false)); |
|
94 |
||
95 |
cases.add(new MethodHandleAccessTestCase("Array", |
|
96 |
vhArray, f, VarHandleTestMethodHandleAccess$Type$::testArray)); |
|
97 |
cases.add(new MethodHandleAccessTestCase("Array unsupported", |
|
98 |
vhArray, f, VarHandleTestMethodHandleAccess$Type$::testArrayUnsupported, |
|
99 |
false)); |
|
100 |
cases.add(new MethodHandleAccessTestCase("Array index out of bounds", |
|
101 |
vhArray, f, VarHandleTestMethodHandleAccess$Type$::testArrayIndexOutOfBounds, |
|
102 |
false)); |
|
103 |
} |
|
104 |
||
105 |
// Work around issue with jtreg summary reporting which truncates |
|
106 |
// the String result of Object.toString to 30 characters, hence |
|
107 |
// the first dummy argument |
|
108 |
return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new); |
|
109 |
} |
|
110 |
||
111 |
@Test(dataProvider = "accessTestCaseProvider") |
|
112 |
public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable { |
|
113 |
T t = atc.get(); |
|
114 |
int iters = atc.requiresLoop() ? ITERS : 1; |
|
115 |
for (int c = 0; c < iters; c++) { |
|
116 |
atc.testAccess(t); |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
||
121 |
static void testInstanceField(VarHandleTestMethodHandleAccess$Type$ recv, Handles hs) throws Throwable { |
|
122 |
// Plain |
|
123 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
124 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
125 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 126 |
assertEquals(x, $value1$, "set $type$ value"); |
127 |
} |
|
128 |
||
129 |
||
130 |
// Volatile |
|
131 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
132 |
hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, $value2$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
133 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv); |
36934 | 134 |
assertEquals(x, $value2$, "setVolatile $type$ value"); |
135 |
} |
|
136 |
||
137 |
// Lazy |
|
138 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
139 |
hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, $value1$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
140 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv); |
36934 | 141 |
assertEquals(x, $value1$, "setRelease $type$ value"); |
142 |
} |
|
143 |
||
144 |
// Opaque |
|
145 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
146 |
hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, $value2$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
147 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv); |
36934 | 148 |
assertEquals(x, $value2$, "setOpaque $type$ value"); |
149 |
} |
|
150 |
||
151 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
152 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
36934 | 153 |
|
154 |
// Compare |
|
155 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
156 |
boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); |
36934 | 157 |
assertEquals(r, true, "success compareAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
158 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 159 |
assertEquals(x, $value2$, "success compareAndSet $type$ value"); |
160 |
} |
|
161 |
||
162 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
163 |
boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, $value1$, $value3$); |
36934 | 164 |
assertEquals(r, false, "failing compareAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
165 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 166 |
assertEquals(x, $value2$, "failing compareAndSet $type$ value"); |
167 |
} |
|
168 |
||
169 |
{ |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
170 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, $value2$, $value1$); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
171 |
assertEquals(r, $value2$, "success compareAndExchange $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
172 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
173 |
assertEquals(x, $value1$, "success compareAndExchange $type$ value"); |
36934 | 174 |
} |
175 |
||
176 |
{ |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
177 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, $value2$, $value3$); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
178 |
assertEquals(r, $value1$, "failing compareAndExchange $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
179 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
180 |
assertEquals(x, $value1$, "failing compareAndExchange $type$ value"); |
36934 | 181 |
} |
182 |
||
183 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
184 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, $value1$, $value2$); |
36934 | 185 |
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
186 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 187 |
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value"); |
188 |
} |
|
189 |
||
190 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
191 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, $value1$, $value3$); |
36934 | 192 |
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
193 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 194 |
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value"); |
195 |
} |
|
196 |
||
197 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
198 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, $value2$, $value1$); |
36934 | 199 |
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
200 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 201 |
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value"); |
202 |
} |
|
203 |
||
204 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
205 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, $value2$, $value3$); |
36934 | 206 |
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
207 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 208 |
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
209 |
} |
|
210 |
||
211 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
212 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
213 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
214 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, $value1$, $value2$); |
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
215 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
216 |
assertEquals(success, true, "weakCompareAndSetPlain $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
217 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
218 |
assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); |
36934 | 219 |
} |
220 |
||
221 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
222 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
223 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
224 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
225 |
} |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
226 |
assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
227 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 228 |
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
229 |
} |
|
230 |
||
231 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
232 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
233 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
234 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
235 |
} |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
236 |
assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
237 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
36934 | 238 |
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
239 |
} |
|
240 |
||
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
241 |
{ |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
242 |
boolean success = false; |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
243 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
244 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value2$, $value1$); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
245 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
246 |
assertEquals(success, true, "weakCompareAndSet $type$"); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
247 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
248 |
assertEquals(x, $value1$, "weakCompareAndSet $type$"); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
249 |
} |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
250 |
|
36934 | 251 |
// Compare set and get |
252 |
{ |
|
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
253 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value2$); |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
254 |
assertEquals(o, $value1$, "getAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
255 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
256 |
assertEquals(x, $value2$, "getAndSet $type$ value"); |
36934 | 257 |
} |
258 |
#end[CAS] |
|
259 |
||
260 |
#if[AtomicAdd] |
|
261 |
// get and add, add and get |
|
262 |
{ |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
263 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
264 |
|
40733 | 265 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value2$); |
36934 | 266 |
assertEquals(o, $value1$, "getAndAdd $type$"); |
40733 | 267 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
268 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); |
|
36934 | 269 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
270 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
271 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
272 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
273 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
274 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
275 |
assertEquals(o, $value1$, "getAndAddAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
276 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
277 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
278 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
279 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
280 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
281 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
282 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
283 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
284 |
assertEquals(o, $value1$, "getAndAddRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
285 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
286 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
287 |
} |
36934 | 288 |
#end[AtomicAdd] |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
289 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
290 |
#if[Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
291 |
// get and bitwise or |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
292 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
293 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
294 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
295 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
296 |
assertEquals(o, $value1$, "getAndBitwiseOr $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
297 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
298 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
299 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
300 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
301 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
302 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
303 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
304 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
305 |
assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
306 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
307 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
308 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
309 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
310 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
311 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
312 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
313 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
314 |
assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
315 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
316 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
317 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
318 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
319 |
// get and bitwise and |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
320 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
321 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
322 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
323 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
324 |
assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
325 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
326 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
327 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
328 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
329 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
330 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
331 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
332 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
333 |
assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
334 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
335 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
336 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
337 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
338 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
339 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
340 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
341 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
342 |
assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
343 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
344 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
345 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
346 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
347 |
// get and bitwise xor |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
348 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
349 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
350 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
351 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
352 |
assertEquals(o, $value1$, "getAndBitwiseXor $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
353 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
354 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
355 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
356 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
357 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
358 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
359 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
360 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
361 |
assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
362 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
363 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
364 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
365 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
366 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
367 |
hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
368 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
369 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
370 |
assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
371 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
372 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
373 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
374 |
#end[Bitwise] |
36934 | 375 |
} |
376 |
||
377 |
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccess$Type$ recv, Handles hs) throws Throwable { |
|
378 |
#if[!CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
379 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 380 |
checkUOE(am, () -> { |
381 |
boolean r = (boolean) hs.get(am).invokeExact(recv, $value1$, $value2$); |
|
382 |
}); |
|
383 |
} |
|
384 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
385 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 386 |
checkUOE(am, () -> { |
387 |
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$, $value2$); |
|
388 |
}); |
|
389 |
} |
|
390 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
391 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 392 |
checkUOE(am, () -> { |
393 |
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$); |
|
394 |
}); |
|
395 |
} |
|
396 |
#end[CAS] |
|
397 |
||
398 |
#if[!AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
399 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 400 |
checkUOE(am, () -> { |
401 |
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$); |
|
402 |
}); |
|
403 |
} |
|
404 |
#end[AtomicAdd] |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
405 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
406 |
#if[!Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
407 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
408 |
checkUOE(am, () -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
409 |
$type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
410 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
411 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
412 |
#end[Bitwise] |
36934 | 413 |
} |
414 |
||
415 |
||
416 |
static void testStaticField(Handles hs) throws Throwable { |
|
417 |
// Plain |
|
418 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
419 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
420 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 421 |
assertEquals(x, $value1$, "set $type$ value"); |
422 |
} |
|
423 |
||
424 |
||
425 |
// Volatile |
|
426 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
427 |
hs.get(TestAccessMode.SET_VOLATILE).invokeExact($value2$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
428 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(); |
36934 | 429 |
assertEquals(x, $value2$, "setVolatile $type$ value"); |
430 |
} |
|
431 |
||
432 |
// Lazy |
|
433 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
434 |
hs.get(TestAccessMode.SET_RELEASE).invokeExact($value1$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
435 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(); |
36934 | 436 |
assertEquals(x, $value1$, "setRelease $type$ value"); |
437 |
} |
|
438 |
||
439 |
// Opaque |
|
440 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
441 |
hs.get(TestAccessMode.SET_OPAQUE).invokeExact($value2$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
442 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(); |
36934 | 443 |
assertEquals(x, $value2$, "setOpaque $type$ value"); |
444 |
} |
|
445 |
||
446 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
447 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
36934 | 448 |
|
449 |
// Compare |
|
450 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
451 |
boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact($value1$, $value2$); |
36934 | 452 |
assertEquals(r, true, "success compareAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
453 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 454 |
assertEquals(x, $value2$, "success compareAndSet $type$ value"); |
455 |
} |
|
456 |
||
457 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
458 |
boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact($value1$, $value3$); |
36934 | 459 |
assertEquals(r, false, "failing compareAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
460 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 461 |
assertEquals(x, $value2$, "failing compareAndSet $type$ value"); |
462 |
} |
|
463 |
||
464 |
{ |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
465 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact($value2$, $value1$); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
466 |
assertEquals(r, $value2$, "success compareAndExchange $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
467 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
468 |
assertEquals(x, $value1$, "success compareAndExchange $type$ value"); |
36934 | 469 |
} |
470 |
||
471 |
{ |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
472 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact($value2$, $value3$); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
473 |
assertEquals(r, $value1$, "failing compareAndExchange $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
474 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
475 |
assertEquals(x, $value1$, "failing compareAndExchange $type$ value"); |
36934 | 476 |
} |
477 |
||
478 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
479 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact($value1$, $value2$); |
36934 | 480 |
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
481 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 482 |
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value"); |
483 |
} |
|
484 |
||
485 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
486 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact($value1$, $value3$); |
36934 | 487 |
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
488 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 489 |
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value"); |
490 |
} |
|
491 |
||
492 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
493 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact($value2$, $value1$); |
36934 | 494 |
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
495 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 496 |
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value"); |
497 |
} |
|
498 |
||
499 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
500 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact($value2$, $value3$); |
36934 | 501 |
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
502 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 503 |
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
504 |
} |
|
505 |
||
506 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
507 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
508 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
509 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact($value1$, $value2$); |
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
510 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
511 |
assertEquals(success, true, "weakCompareAndSetPlain $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
512 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
513 |
assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); |
36934 | 514 |
} |
515 |
||
516 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
517 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
518 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
519 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
520 |
} |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
521 |
assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
522 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 523 |
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
524 |
} |
|
525 |
||
526 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
527 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
528 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
529 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$); |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
530 |
} |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
531 |
assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
532 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
36934 | 533 |
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
534 |
} |
|
535 |
||
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
536 |
{ |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
537 |
boolean success = false; |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
538 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
539 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value2$, $value1$); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
540 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
541 |
assertEquals(success, true, "weakCompareAndSet $type$"); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
542 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
543 |
assertEquals(x, $value1$, "weakCompareAndSet $type$"); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
544 |
} |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
545 |
|
36934 | 546 |
// Compare set and get |
547 |
{ |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
548 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
549 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
550 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
551 |
assertEquals(o, $value1$, "getAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
552 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
553 |
assertEquals(x, $value2$, "getAndSet $type$ value"); |
36934 | 554 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
555 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
556 |
// Compare set and get |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
557 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
558 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
559 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
560 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
561 |
assertEquals(o, $value1$, "getAndSetAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
562 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
563 |
assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
564 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
565 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
566 |
// Compare set and get |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
567 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
568 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
569 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
570 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
571 |
assertEquals(o, $value1$, "getAndSetRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
572 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
573 |
assertEquals(x, $value2$, "getAndSetRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
574 |
} |
36934 | 575 |
#end[CAS] |
576 |
||
577 |
#if[AtomicAdd] |
|
578 |
// get and add, add and get |
|
579 |
{ |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
580 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
581 |
|
40733 | 582 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact($value2$); |
36934 | 583 |
assertEquals(o, $value1$, "getAndAdd $type$"); |
40733 | 584 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
585 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); |
|
36934 | 586 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
587 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
588 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
589 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
590 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
591 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
592 |
assertEquals(o, $value1$, "getAndAddAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
593 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
594 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
595 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
596 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
597 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
598 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
599 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
600 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
601 |
assertEquals(o, $value1$, "getAndAddRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
602 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
603 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
604 |
} |
36934 | 605 |
#end[AtomicAdd] |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
606 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
607 |
#if[Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
608 |
// get and bitwise or |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
609 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
610 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
611 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
612 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
613 |
assertEquals(o, $value1$, "getAndBitwiseOr $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
614 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
615 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
616 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
617 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
618 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
619 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
620 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
621 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
622 |
assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
623 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
624 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
625 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
626 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
627 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
628 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
629 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
630 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
631 |
assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
632 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
633 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
634 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
635 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
636 |
// get and bitwise and |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
637 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
638 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
639 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
640 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
641 |
assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
642 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
643 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
644 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
645 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
646 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
647 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
648 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
649 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
650 |
assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
651 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
652 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
653 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
654 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
655 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
656 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
657 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
658 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
659 |
assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
660 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
661 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
662 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
663 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
664 |
// get and bitwise xor |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
665 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
666 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
667 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
668 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
669 |
assertEquals(o, $value1$, "getAndBitwiseXor $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
670 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
671 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
672 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
673 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
674 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
675 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
676 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
677 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
678 |
assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
679 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
680 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
681 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
682 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
683 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
684 |
hs.get(TestAccessMode.SET).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
685 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
686 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact($value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
687 |
assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
688 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
689 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
690 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
691 |
#end[Bitwise] |
36934 | 692 |
} |
693 |
||
694 |
static void testStaticFieldUnsupported(Handles hs) throws Throwable { |
|
695 |
#if[!CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
696 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 697 |
checkUOE(am, () -> { |
698 |
boolean r = (boolean) hs.get(am).invokeExact($value1$, $value2$); |
|
699 |
}); |
|
700 |
} |
|
701 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
702 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 703 |
checkUOE(am, () -> { |
704 |
$type$ r = ($type$) hs.get(am).invokeExact($value1$, $value2$); |
|
705 |
}); |
|
706 |
} |
|
707 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
708 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 709 |
checkUOE(am, () -> { |
710 |
$type$ r = ($type$) hs.get(am).invokeExact($value1$); |
|
711 |
}); |
|
712 |
} |
|
713 |
#end[CAS] |
|
714 |
||
715 |
#if[!AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
716 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 717 |
checkUOE(am, () -> { |
718 |
$type$ r = ($type$) hs.get(am).invokeExact($value1$); |
|
719 |
}); |
|
720 |
} |
|
721 |
#end[AtomicAdd] |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
722 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
723 |
#if[!Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
724 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
725 |
checkUOE(am, () -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
726 |
$type$ r = ($type$) hs.get(am).invokeExact($value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
727 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
728 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
729 |
#end[Bitwise] |
36934 | 730 |
} |
731 |
||
732 |
||
733 |
static void testArray(Handles hs) throws Throwable { |
|
734 |
$type$[] array = new $type$[10]; |
|
735 |
||
736 |
for (int i = 0; i < array.length; i++) { |
|
737 |
// Plain |
|
738 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
739 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
740 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 741 |
assertEquals(x, $value1$, "get $type$ value"); |
742 |
} |
|
743 |
||
744 |
||
745 |
// Volatile |
|
746 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
747 |
hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, $value2$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
748 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i); |
36934 | 749 |
assertEquals(x, $value2$, "setVolatile $type$ value"); |
750 |
} |
|
751 |
||
752 |
// Lazy |
|
753 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
754 |
hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, $value1$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
755 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i); |
36934 | 756 |
assertEquals(x, $value1$, "setRelease $type$ value"); |
757 |
} |
|
758 |
||
759 |
// Opaque |
|
760 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
761 |
hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, $value2$); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
762 |
$type$ x = ($type$) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i); |
36934 | 763 |
assertEquals(x, $value2$, "setOpaque $type$ value"); |
764 |
} |
|
765 |
||
766 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
767 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
36934 | 768 |
|
769 |
// Compare |
|
770 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
771 |
boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); |
36934 | 772 |
assertEquals(r, true, "success compareAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
773 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 774 |
assertEquals(x, $value2$, "success compareAndSet $type$ value"); |
775 |
} |
|
776 |
||
777 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
778 |
boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, $value1$, $value3$); |
36934 | 779 |
assertEquals(r, false, "failing compareAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
780 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 781 |
assertEquals(x, $value2$, "failing compareAndSet $type$ value"); |
782 |
} |
|
783 |
||
784 |
{ |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
785 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, $value2$, $value1$); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
786 |
assertEquals(r, $value2$, "success compareAndExchange $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
787 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
788 |
assertEquals(x, $value1$, "success compareAndExchange $type$ value"); |
36934 | 789 |
} |
790 |
||
791 |
{ |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
792 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, $value2$, $value3$); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
793 |
assertEquals(r, $value1$, "failing compareAndExchange $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
794 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39470
diff
changeset
|
795 |
assertEquals(x, $value1$, "failing compareAndExchange $type$ value"); |
36934 | 796 |
} |
797 |
||
798 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
799 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, $value1$, $value2$); |
36934 | 800 |
assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
801 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 802 |
assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value"); |
803 |
} |
|
804 |
||
805 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
806 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, $value1$, $value3$); |
36934 | 807 |
assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
808 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 809 |
assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value"); |
810 |
} |
|
811 |
||
812 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
813 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, $value2$, $value1$); |
36934 | 814 |
assertEquals(r, $value2$, "success compareAndExchangeRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
815 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 816 |
assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value"); |
817 |
} |
|
818 |
||
819 |
{ |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
820 |
$type$ r = ($type$) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, $value2$, $value3$); |
36934 | 821 |
assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
822 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 823 |
assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
824 |
} |
|
825 |
||
826 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
827 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
828 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
829 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, $value1$, $value2$); |
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
830 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
831 |
assertEquals(success, true, "weakCompareAndSetPlain $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
832 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
833 |
assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); |
36934 | 834 |
} |
835 |
||
836 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
837 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
838 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
839 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
840 |
} |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
841 |
assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
842 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 843 |
assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
844 |
} |
|
845 |
||
846 |
{ |
|
38355
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
847 |
boolean success = false; |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
848 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
849 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
850 |
} |
674cfd9b90cf
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
shade
parents:
37343
diff
changeset
|
851 |
assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
852 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
36934 | 853 |
assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
854 |
} |
|
855 |
||
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
856 |
{ |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
857 |
boolean success = false; |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
858 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
859 |
success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value2$, $value1$); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
860 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
861 |
assertEquals(success, true, "weakCompareAndSet $type$"); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
862 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
863 |
assertEquals(x, $value1$, "weakCompareAndSet $type$"); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
864 |
} |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
865 |
|
36934 | 866 |
// Compare set and get |
867 |
{ |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
868 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
869 |
|
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
870 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value2$); |
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
871 |
assertEquals(o, $value1$, "getAndSet $type$"); |
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
872 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38368
diff
changeset
|
873 |
assertEquals(x, $value2$, "getAndSet $type$ value"); |
36934 | 874 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
875 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
876 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
877 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
878 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
879 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
880 |
assertEquals(o, $value1$, "getAndSetAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
881 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
882 |
assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
883 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
884 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
885 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
886 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
887 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
888 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
889 |
assertEquals(o, $value1$, "getAndSetRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
890 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
891 |
assertEquals(x, $value2$, "getAndSetRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
892 |
} |
36934 | 893 |
#end[CAS] |
894 |
||
895 |
#if[AtomicAdd] |
|
896 |
// get and add, add and get |
|
897 |
{ |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
898 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
899 |
|
40733 | 900 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value2$); |
36934 | 901 |
assertEquals(o, $value1$, "getAndAdd $type$"); |
40733 | 902 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
903 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); |
|
36934 | 904 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
905 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
906 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
907 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
908 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
909 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
910 |
assertEquals(o, $value1$, "getAndAddAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
911 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
912 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
913 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
914 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
915 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
916 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
917 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
918 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
919 |
assertEquals(o, $value1$, "getAndAddRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
920 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
921 |
assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
922 |
} |
36934 | 923 |
#end[AtomicAdd] |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
924 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
925 |
#if[Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
926 |
// get and bitwise or |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
927 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
928 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
929 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
930 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
931 |
assertEquals(o, $value1$, "getAndBitwiseOr $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
932 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
933 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
934 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
935 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
936 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
937 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
938 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
939 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
940 |
assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
941 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
942 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
943 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
944 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
945 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
946 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
947 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
948 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
949 |
assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
950 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
951 |
assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
952 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
953 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
954 |
// get and bitwise and |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
955 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
956 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
957 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
958 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
959 |
assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
960 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
961 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
962 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
963 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
964 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
965 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
966 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
967 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
968 |
assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
969 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
970 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
971 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
972 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
973 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
974 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
975 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
976 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
977 |
assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
978 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
979 |
assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
980 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
981 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
982 |
// get and bitwise xor |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
983 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
984 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
985 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
986 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
987 |
assertEquals(o, $value1$, "getAndBitwiseXor $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
988 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
989 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
990 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
991 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
992 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
993 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
994 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
995 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
996 |
assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
997 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
998 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
999 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1000 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1001 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1002 |
hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1003 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1004 |
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, $value2$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1005 |
assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1006 |
$type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1007 |
assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1008 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1009 |
#end[Bitwise] |
36934 | 1010 |
} |
1011 |
} |
|
1012 |
||
1013 |
static void testArrayUnsupported(Handles hs) throws Throwable { |
|
1014 |
$type$[] array = new $type$[10]; |
|
1015 |
||
1016 |
final int i = 0; |
|
1017 |
#if[!CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1018 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 1019 |
checkUOE(am, () -> { |
1020 |
boolean r = (boolean) hs.get(am).invokeExact(array, i, $value1$, $value2$); |
|
1021 |
}); |
|
1022 |
} |
|
1023 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1024 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 1025 |
checkUOE(am, () -> { |
1026 |
$type$ r = ($type$) hs.get(am).invokeExact(array, i, $value1$, $value2$); |
|
1027 |
}); |
|
1028 |
} |
|
1029 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1030 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 1031 |
checkUOE(am, () -> { |
1032 |
$type$ r = ($type$) hs.get(am).invokeExact(array, i, $value1$); |
|
1033 |
}); |
|
1034 |
} |
|
1035 |
#end[CAS] |
|
1036 |
||
1037 |
#if[!AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1038 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 1039 |
checkUOE(am, () -> { |
1040 |
$type$ o = ($type$) hs.get(am).invokeExact(array, i, $value1$); |
|
1041 |
}); |
|
1042 |
} |
|
1043 |
#end[AtomicAdd] |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1044 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1045 |
#if[!Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1046 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1047 |
checkUOE(am, () -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1048 |
$type$ o = ($type$) hs.get(am).invokeExact(array, i, $value1$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1049 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1050 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1051 |
#end[Bitwise] |
36934 | 1052 |
} |
1053 |
||
1054 |
static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { |
|
1055 |
$type$[] array = new $type$[10]; |
|
1056 |
||
1057 |
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) { |
|
1058 |
final int ci = i; |
|
1059 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1060 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { |
36934 | 1061 |
checkIOOBE(am, () -> { |
1062 |
$type$ x = ($type$) hs.get(am).invokeExact(array, ci); |
|
1063 |
}); |
|
1064 |
} |
|
1065 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1066 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { |
36934 | 1067 |
checkIOOBE(am, () -> { |
1068 |
hs.get(am).invokeExact(array, ci, $value1$); |
|
1069 |
}); |
|
1070 |
} |
|
1071 |
||
1072 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1073 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 1074 |
checkIOOBE(am, () -> { |
1075 |
boolean r = (boolean) hs.get(am).invokeExact(array, ci, $value1$, $value2$); |
|
1076 |
}); |
|
1077 |
} |
|
1078 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1079 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 1080 |
checkIOOBE(am, () -> { |
1081 |
$type$ r = ($type$) hs.get(am).invokeExact(array, ci, $value2$, $value1$); |
|
1082 |
}); |
|
1083 |
} |
|
1084 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1085 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 1086 |
checkIOOBE(am, () -> { |
1087 |
$type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value1$); |
|
1088 |
}); |
|
1089 |
} |
|
1090 |
#end[CAS] |
|
1091 |
||
1092 |
#if[AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1093 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 1094 |
checkIOOBE(am, () -> { |
1095 |
$type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value3$); |
|
1096 |
}); |
|
1097 |
} |
|
1098 |
#end[AtomicAdd] |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1099 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1100 |
#if[Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1101 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1102 |
checkIOOBE(am, () -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1103 |
$type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value3$); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1104 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1105 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1106 |
#end[Bitwise] |
36934 | 1107 |
} |
1108 |
} |
|
1109 |
} |
|
1110 |