author | psandoz |
Thu, 01 Sep 2016 10:16:57 -0700 | |
changeset 40732 | 2fd9cf42bb3c |
parent 39472 | 6df82f4c63ac |
child 40733 | 8d1263354d62 |
permissions | -rw-r--r-- |
36934 | 1 |
/* |
2 |
* Copyright (c) 2015, 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=10 -Xint VarHandleTestAccessFloat |
|
27 |
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessFloat |
|
28 |
* @run testng/othervm -Diters=20000 VarHandleTestAccessFloat |
|
29 |
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessFloat |
|
30 |
*/ |
|
31 |
||
32 |
import org.testng.annotations.BeforeClass; |
|
33 |
import org.testng.annotations.DataProvider; |
|
34 |
import org.testng.annotations.Test; |
|
35 |
||
36 |
import java.lang.invoke.MethodHandles; |
|
37 |
import java.lang.invoke.VarHandle; |
|
38 |
import java.util.ArrayList; |
|
39 |
import java.util.Arrays; |
|
40 |
import java.util.List; |
|
41 |
||
42 |
import static org.testng.Assert.*; |
|
43 |
||
44 |
public class VarHandleTestAccessFloat extends VarHandleBaseTest { |
|
45 |
static final float static_final_v = 1.0f; |
|
46 |
||
47 |
static float static_v; |
|
48 |
||
49 |
final float final_v = 1.0f; |
|
50 |
||
51 |
float v; |
|
52 |
||
53 |
VarHandle vhFinalField; |
|
54 |
||
55 |
VarHandle vhField; |
|
56 |
||
57 |
VarHandle vhStaticField; |
|
58 |
||
59 |
VarHandle vhStaticFinalField; |
|
60 |
||
61 |
VarHandle vhArray; |
|
62 |
||
63 |
@BeforeClass |
|
64 |
public void setup() throws Exception { |
|
65 |
vhFinalField = MethodHandles.lookup().findVarHandle( |
|
66 |
VarHandleTestAccessFloat.class, "final_v", float.class); |
|
67 |
||
68 |
vhField = MethodHandles.lookup().findVarHandle( |
|
69 |
VarHandleTestAccessFloat.class, "v", float.class); |
|
70 |
||
71 |
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( |
|
72 |
VarHandleTestAccessFloat.class, "static_final_v", float.class); |
|
73 |
||
74 |
vhStaticField = MethodHandles.lookup().findStaticVarHandle( |
|
75 |
VarHandleTestAccessFloat.class, "static_v", float.class); |
|
76 |
||
77 |
vhArray = MethodHandles.arrayElementVarHandle(float[].class); |
|
78 |
} |
|
79 |
||
80 |
||
81 |
@DataProvider |
|
82 |
public Object[][] varHandlesProvider() throws Exception { |
|
83 |
List<VarHandle> vhs = new ArrayList<>(); |
|
84 |
vhs.add(vhField); |
|
85 |
vhs.add(vhStaticField); |
|
86 |
vhs.add(vhArray); |
|
87 |
||
88 |
return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new); |
|
89 |
} |
|
90 |
||
91 |
@Test(dataProvider = "varHandlesProvider") |
|
92 |
public void testIsAccessModeSupported(VarHandle vh) { |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
93 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
94 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
95 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
96 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
97 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
98 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
99 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
100 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE)); |
36934 | 101 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
102 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
103 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
104 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
105 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
106 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
107 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
108 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
109 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
110 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
111 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
112 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); |
36934 | 113 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
114 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
115 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
116 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
117 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
118 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
119 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
120 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
121 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
122 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
123 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
124 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
125 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
126 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
127 |
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); |
36934 | 128 |
} |
129 |
||
130 |
||
131 |
@DataProvider |
|
132 |
public Object[][] typesProvider() throws Exception { |
|
133 |
List<Object[]> types = new ArrayList<>(); |
|
134 |
types.add(new Object[] {vhField, Arrays.asList(VarHandleTestAccessFloat.class)}); |
|
135 |
types.add(new Object[] {vhStaticField, Arrays.asList()}); |
|
136 |
types.add(new Object[] {vhArray, Arrays.asList(float[].class, int.class)}); |
|
137 |
||
138 |
return types.stream().toArray(Object[][]::new); |
|
139 |
} |
|
140 |
||
141 |
@Test(dataProvider = "typesProvider") |
|
142 |
public void testTypes(VarHandle vh, List<Class<?>> pts) { |
|
143 |
assertEquals(vh.varType(), float.class); |
|
144 |
||
145 |
assertEquals(vh.coordinateTypes(), pts); |
|
146 |
||
147 |
testTypes(vh); |
|
148 |
} |
|
149 |
||
150 |
||
151 |
@Test |
|
152 |
public void testLookupInstanceToStatic() { |
|
153 |
checkIAE("Lookup of static final field to instance final field", () -> { |
|
154 |
MethodHandles.lookup().findStaticVarHandle( |
|
155 |
VarHandleTestAccessFloat.class, "final_v", float.class); |
|
156 |
}); |
|
157 |
||
158 |
checkIAE("Lookup of static field to instance field", () -> { |
|
159 |
MethodHandles.lookup().findStaticVarHandle( |
|
160 |
VarHandleTestAccessFloat.class, "v", float.class); |
|
161 |
}); |
|
162 |
} |
|
163 |
||
164 |
@Test |
|
165 |
public void testLookupStaticToInstance() { |
|
166 |
checkIAE("Lookup of instance final field to static final field", () -> { |
|
167 |
MethodHandles.lookup().findVarHandle( |
|
168 |
VarHandleTestAccessFloat.class, "static_final_v", float.class); |
|
169 |
}); |
|
170 |
||
171 |
checkIAE("Lookup of instance field to static field", () -> { |
|
172 |
vhStaticField = MethodHandles.lookup().findVarHandle( |
|
173 |
VarHandleTestAccessFloat.class, "static_v", float.class); |
|
174 |
}); |
|
175 |
} |
|
176 |
||
177 |
||
178 |
@DataProvider |
|
179 |
public Object[][] accessTestCaseProvider() throws Exception { |
|
180 |
List<AccessTestCase<?>> cases = new ArrayList<>(); |
|
181 |
||
182 |
cases.add(new VarHandleAccessTestCase("Instance final field", |
|
183 |
vhFinalField, vh -> testInstanceFinalField(this, vh))); |
|
184 |
cases.add(new VarHandleAccessTestCase("Instance final field unsupported", |
|
185 |
vhFinalField, vh -> testInstanceFinalFieldUnsupported(this, vh), |
|
186 |
false)); |
|
187 |
||
188 |
cases.add(new VarHandleAccessTestCase("Static final field", |
|
189 |
vhStaticFinalField, VarHandleTestAccessFloat::testStaticFinalField)); |
|
190 |
cases.add(new VarHandleAccessTestCase("Static final field unsupported", |
|
191 |
vhStaticFinalField, VarHandleTestAccessFloat::testStaticFinalFieldUnsupported, |
|
192 |
false)); |
|
193 |
||
194 |
cases.add(new VarHandleAccessTestCase("Instance field", |
|
195 |
vhField, vh -> testInstanceField(this, vh))); |
|
196 |
cases.add(new VarHandleAccessTestCase("Instance field unsupported", |
|
197 |
vhField, vh -> testInstanceFieldUnsupported(this, vh), |
|
198 |
false)); |
|
199 |
||
200 |
cases.add(new VarHandleAccessTestCase("Static field", |
|
201 |
vhStaticField, VarHandleTestAccessFloat::testStaticField)); |
|
202 |
cases.add(new VarHandleAccessTestCase("Static field unsupported", |
|
203 |
vhStaticField, VarHandleTestAccessFloat::testStaticFieldUnsupported, |
|
204 |
false)); |
|
205 |
||
206 |
cases.add(new VarHandleAccessTestCase("Array", |
|
207 |
vhArray, VarHandleTestAccessFloat::testArray)); |
|
208 |
cases.add(new VarHandleAccessTestCase("Array unsupported", |
|
209 |
vhArray, VarHandleTestAccessFloat::testArrayUnsupported, |
|
210 |
false)); |
|
211 |
cases.add(new VarHandleAccessTestCase("Array index out of bounds", |
|
212 |
vhArray, VarHandleTestAccessFloat::testArrayIndexOutOfBounds, |
|
213 |
false)); |
|
214 |
||
215 |
// Work around issue with jtreg summary reporting which truncates |
|
216 |
// the String result of Object.toString to 30 characters, hence |
|
217 |
// the first dummy argument |
|
218 |
return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new); |
|
219 |
} |
|
220 |
||
221 |
@Test(dataProvider = "accessTestCaseProvider") |
|
222 |
public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable { |
|
223 |
T t = atc.get(); |
|
224 |
int iters = atc.requiresLoop() ? ITERS : 1; |
|
225 |
for (int c = 0; c < iters; c++) { |
|
226 |
atc.testAccess(t); |
|
227 |
} |
|
228 |
} |
|
229 |
||
230 |
||
231 |
||
232 |
||
233 |
static void testInstanceFinalField(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
234 |
// Plain |
|
235 |
{ |
|
236 |
float x = (float) vh.get(recv); |
|
237 |
assertEquals(x, 1.0f, "get float value"); |
|
238 |
} |
|
239 |
||
240 |
||
241 |
// Volatile |
|
242 |
{ |
|
243 |
float x = (float) vh.getVolatile(recv); |
|
244 |
assertEquals(x, 1.0f, "getVolatile float value"); |
|
245 |
} |
|
246 |
||
247 |
// Lazy |
|
248 |
{ |
|
249 |
float x = (float) vh.getAcquire(recv); |
|
250 |
assertEquals(x, 1.0f, "getRelease float value"); |
|
251 |
} |
|
252 |
||
253 |
// Opaque |
|
254 |
{ |
|
255 |
float x = (float) vh.getOpaque(recv); |
|
256 |
assertEquals(x, 1.0f, "getOpaque float value"); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
261 |
checkUOE(() -> { |
|
262 |
vh.set(recv, 2.0f); |
|
263 |
}); |
|
264 |
||
265 |
checkUOE(() -> { |
|
266 |
vh.setVolatile(recv, 2.0f); |
|
267 |
}); |
|
268 |
||
269 |
checkUOE(() -> { |
|
270 |
vh.setRelease(recv, 2.0f); |
|
271 |
}); |
|
272 |
||
273 |
checkUOE(() -> { |
|
274 |
vh.setOpaque(recv, 2.0f); |
|
275 |
}); |
|
276 |
||
277 |
||
40732
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
280 |
float o = (float) vh.getAndBitwiseOr(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
281 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
284 |
float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
285 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
286 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
287 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
288 |
float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); |
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 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
291 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
292 |
float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
293 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
296 |
float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
297 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
298 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
299 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
300 |
float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); |
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 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
303 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
304 |
float o = (float) vh.getAndBitwiseXor(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
305 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
306 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
307 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
308 |
float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
312 |
float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
313 |
}); |
36934 | 314 |
} |
315 |
||
316 |
||
317 |
static void testStaticFinalField(VarHandle vh) { |
|
318 |
// Plain |
|
319 |
{ |
|
320 |
float x = (float) vh.get(); |
|
321 |
assertEquals(x, 1.0f, "get float value"); |
|
322 |
} |
|
323 |
||
324 |
||
325 |
// Volatile |
|
326 |
{ |
|
327 |
float x = (float) vh.getVolatile(); |
|
328 |
assertEquals(x, 1.0f, "getVolatile float value"); |
|
329 |
} |
|
330 |
||
331 |
// Lazy |
|
332 |
{ |
|
333 |
float x = (float) vh.getAcquire(); |
|
334 |
assertEquals(x, 1.0f, "getRelease float value"); |
|
335 |
} |
|
336 |
||
337 |
// Opaque |
|
338 |
{ |
|
339 |
float x = (float) vh.getOpaque(); |
|
340 |
assertEquals(x, 1.0f, "getOpaque float value"); |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
static void testStaticFinalFieldUnsupported(VarHandle vh) { |
|
345 |
checkUOE(() -> { |
|
346 |
vh.set(2.0f); |
|
347 |
}); |
|
348 |
||
349 |
checkUOE(() -> { |
|
350 |
vh.setVolatile(2.0f); |
|
351 |
}); |
|
352 |
||
353 |
checkUOE(() -> { |
|
354 |
vh.setRelease(2.0f); |
|
355 |
}); |
|
356 |
||
357 |
checkUOE(() -> { |
|
358 |
vh.setOpaque(2.0f); |
|
359 |
}); |
|
360 |
||
361 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
362 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
363 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
364 |
float o = (float) vh.getAndBitwiseOr(1.0f); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
368 |
float o = (float) vh.getAndBitwiseOrAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
369 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
370 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
371 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
372 |
float o = (float) vh.getAndBitwiseOrRelease(1.0f); |
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 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
375 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
376 |
float o = (float) vh.getAndBitwiseAnd(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
377 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
378 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
379 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
380 |
float o = (float) vh.getAndBitwiseAndAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
381 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
382 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
383 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
384 |
float o = (float) vh.getAndBitwiseAndRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
385 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
386 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
387 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
388 |
float o = (float) vh.getAndBitwiseXor(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
389 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
390 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
391 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
392 |
float o = (float) vh.getAndBitwiseXorAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
393 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
394 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
395 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
396 |
float o = (float) vh.getAndBitwiseXorRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
397 |
}); |
36934 | 398 |
} |
399 |
||
400 |
||
401 |
static void testInstanceField(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
402 |
// Plain |
|
403 |
{ |
|
404 |
vh.set(recv, 1.0f); |
|
405 |
float x = (float) vh.get(recv); |
|
406 |
assertEquals(x, 1.0f, "set float value"); |
|
407 |
} |
|
408 |
||
409 |
||
410 |
// Volatile |
|
411 |
{ |
|
412 |
vh.setVolatile(recv, 2.0f); |
|
413 |
float x = (float) vh.getVolatile(recv); |
|
414 |
assertEquals(x, 2.0f, "setVolatile float value"); |
|
415 |
} |
|
416 |
||
417 |
// Lazy |
|
418 |
{ |
|
419 |
vh.setRelease(recv, 1.0f); |
|
420 |
float x = (float) vh.getAcquire(recv); |
|
421 |
assertEquals(x, 1.0f, "setRelease float value"); |
|
422 |
} |
|
423 |
||
424 |
// Opaque |
|
425 |
{ |
|
426 |
vh.setOpaque(recv, 2.0f); |
|
427 |
float x = (float) vh.getOpaque(recv); |
|
428 |
assertEquals(x, 2.0f, "setOpaque float value"); |
|
429 |
} |
|
430 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
431 |
vh.set(recv, 1.0f); |
36934 | 432 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
433 |
// Compare |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
434 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
435 |
boolean r = vh.compareAndSet(recv, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
436 |
assertEquals(r, true, "success compareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
437 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
438 |
assertEquals(x, 2.0f, "success compareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
439 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
440 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
441 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
442 |
boolean r = vh.compareAndSet(recv, 1.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
443 |
assertEquals(r, false, "failing compareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
444 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
445 |
assertEquals(x, 2.0f, "failing compareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
446 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
447 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
448 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
449 |
float r = (float) vh.compareAndExchange(recv, 2.0f, 1.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
450 |
assertEquals(r, 2.0f, "success compareAndExchange float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
451 |
float x = (float) vh.get(recv); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
452 |
assertEquals(x, 1.0f, "success compareAndExchange float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
453 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
454 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
455 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
456 |
float r = (float) vh.compareAndExchange(recv, 2.0f, 3.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
457 |
assertEquals(r, 1.0f, "failing compareAndExchange float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
458 |
float x = (float) vh.get(recv); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
459 |
assertEquals(x, 1.0f, "failing compareAndExchange float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
460 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
461 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
462 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
463 |
float r = (float) vh.compareAndExchangeAcquire(recv, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
464 |
assertEquals(r, 1.0f, "success compareAndExchangeAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
465 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
466 |
assertEquals(x, 2.0f, "success compareAndExchangeAcquire float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
467 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
468 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
469 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
470 |
float r = (float) vh.compareAndExchangeAcquire(recv, 1.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
471 |
assertEquals(r, 2.0f, "failing compareAndExchangeAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
472 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
473 |
assertEquals(x, 2.0f, "failing compareAndExchangeAcquire float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
474 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
475 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
476 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
477 |
float r = (float) vh.compareAndExchangeRelease(recv, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
478 |
assertEquals(r, 2.0f, "success compareAndExchangeRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
479 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
480 |
assertEquals(x, 1.0f, "success compareAndExchangeRelease float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
481 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
482 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
483 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
484 |
float r = (float) vh.compareAndExchangeRelease(recv, 2.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
485 |
assertEquals(r, 1.0f, "failing compareAndExchangeRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
486 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
487 |
assertEquals(x, 1.0f, "failing compareAndExchangeRelease float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
488 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
489 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
490 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
491 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
492 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
493 |
success = vh.weakCompareAndSet(recv, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
494 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
495 |
assertEquals(success, true, "weakCompareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
496 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
497 |
assertEquals(x, 2.0f, "weakCompareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
498 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
499 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
500 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
501 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
502 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
503 |
success = vh.weakCompareAndSetAcquire(recv, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
504 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
505 |
assertEquals(success, true, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
506 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
507 |
assertEquals(x, 1.0f, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
508 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
509 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
510 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
511 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
512 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
513 |
success = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
514 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
515 |
assertEquals(success, true, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
516 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
517 |
assertEquals(x, 2.0f, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
518 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
519 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
520 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
521 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
522 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
523 |
success = vh.weakCompareAndSetVolatile(recv, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
524 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
525 |
assertEquals(success, true, "weakCompareAndSetVolatile float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
526 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
527 |
assertEquals(x, 1.0f, "weakCompareAndSetVolatile float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
528 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
529 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
530 |
// Compare set and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
531 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
532 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
533 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
534 |
float o = (float) vh.getAndSet(recv, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
535 |
assertEquals(o, 1.0f, "getAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
536 |
float x = (float) vh.get(recv); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
537 |
assertEquals(x, 2.0f, "getAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
538 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
539 |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
540 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
541 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
542 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
543 |
float o = (float) vh.getAndSetAcquire(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
544 |
assertEquals(o, 1.0f, "getAndSetAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
545 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
546 |
assertEquals(x, 2.0f, "getAndSetAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
547 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
548 |
|
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 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
551 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
552 |
float o = (float) vh.getAndSetRelease(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
553 |
assertEquals(o, 1.0f, "getAndSetRelease float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
554 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
555 |
assertEquals(x, 2.0f, "getAndSetRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
556 |
} |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
557 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
558 |
// get and add, add and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
559 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
560 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
561 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
562 |
float o = (float) vh.getAndAdd(recv, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
563 |
assertEquals(o, 1.0f, "getAndAdd float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
564 |
float c = (float) vh.addAndGet(recv, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
565 |
assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
566 |
} |
40732
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 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
569 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
570 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
571 |
float o = (float) vh.getAndAddAcquire(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
572 |
assertEquals(o, 1.0f, "getAndAddAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
573 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
574 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
575 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
576 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
577 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
578 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
579 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
580 |
float o = (float) vh.getAndAddRelease(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
581 |
assertEquals(o, 1.0f, "getAndAddReleasefloat"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
582 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
583 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
584 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
585 |
|
36934 | 586 |
} |
587 |
||
588 |
static void testInstanceFieldUnsupported(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
589 |
||
40732
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
592 |
float o = (float) vh.getAndBitwiseOr(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
593 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
594 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
595 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
596 |
float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); |
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 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
599 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
600 |
float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
601 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
602 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
603 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
604 |
float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
605 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
608 |
float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); |
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 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
611 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
612 |
float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
613 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
614 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
615 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
616 |
float o = (float) vh.getAndBitwiseXor(recv, 1.0f); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
620 |
float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
621 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
622 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
623 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
624 |
float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
625 |
}); |
36934 | 626 |
} |
627 |
||
628 |
||
629 |
static void testStaticField(VarHandle vh) { |
|
630 |
// Plain |
|
631 |
{ |
|
632 |
vh.set(1.0f); |
|
633 |
float x = (float) vh.get(); |
|
634 |
assertEquals(x, 1.0f, "set float value"); |
|
635 |
} |
|
636 |
||
637 |
||
638 |
// Volatile |
|
639 |
{ |
|
640 |
vh.setVolatile(2.0f); |
|
641 |
float x = (float) vh.getVolatile(); |
|
642 |
assertEquals(x, 2.0f, "setVolatile float value"); |
|
643 |
} |
|
644 |
||
645 |
// Lazy |
|
646 |
{ |
|
647 |
vh.setRelease(1.0f); |
|
648 |
float x = (float) vh.getAcquire(); |
|
649 |
assertEquals(x, 1.0f, "setRelease float value"); |
|
650 |
} |
|
651 |
||
652 |
// Opaque |
|
653 |
{ |
|
654 |
vh.setOpaque(2.0f); |
|
655 |
float x = (float) vh.getOpaque(); |
|
656 |
assertEquals(x, 2.0f, "setOpaque float value"); |
|
657 |
} |
|
658 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
659 |
vh.set(1.0f); |
36934 | 660 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
661 |
// Compare |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
662 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
663 |
boolean r = vh.compareAndSet(1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
664 |
assertEquals(r, true, "success compareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
665 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
666 |
assertEquals(x, 2.0f, "success compareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
667 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
668 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
669 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
670 |
boolean r = vh.compareAndSet(1.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
671 |
assertEquals(r, false, "failing compareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
672 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
673 |
assertEquals(x, 2.0f, "failing compareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
674 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
675 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
676 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
677 |
float r = (float) vh.compareAndExchange(2.0f, 1.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
678 |
assertEquals(r, 2.0f, "success compareAndExchange float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
679 |
float x = (float) vh.get(); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
680 |
assertEquals(x, 1.0f, "success compareAndExchange float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
681 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
682 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
683 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
684 |
float r = (float) vh.compareAndExchange(2.0f, 3.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
685 |
assertEquals(r, 1.0f, "failing compareAndExchange float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
686 |
float x = (float) vh.get(); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
687 |
assertEquals(x, 1.0f, "failing compareAndExchange float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
688 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
689 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
690 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
691 |
float r = (float) vh.compareAndExchangeAcquire(1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
692 |
assertEquals(r, 1.0f, "success compareAndExchangeAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
693 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
694 |
assertEquals(x, 2.0f, "success compareAndExchangeAcquire float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
695 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
696 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
697 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
698 |
float r = (float) vh.compareAndExchangeAcquire(1.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
699 |
assertEquals(r, 2.0f, "failing compareAndExchangeAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
700 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
701 |
assertEquals(x, 2.0f, "failing compareAndExchangeAcquire float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
702 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
703 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
704 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
705 |
float r = (float) vh.compareAndExchangeRelease(2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
706 |
assertEquals(r, 2.0f, "success compareAndExchangeRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
707 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
708 |
assertEquals(x, 1.0f, "success compareAndExchangeRelease float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
709 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
710 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
711 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
712 |
float r = (float) vh.compareAndExchangeRelease(2.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
713 |
assertEquals(r, 1.0f, "failing compareAndExchangeRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
714 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
715 |
assertEquals(x, 1.0f, "failing compareAndExchangeRelease float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
716 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
717 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
718 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
719 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
720 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
721 |
success = vh.weakCompareAndSet(1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
722 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
723 |
assertEquals(success, true, "weakCompareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
724 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
725 |
assertEquals(x, 2.0f, "weakCompareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
726 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
727 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
728 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
729 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
730 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
731 |
success = vh.weakCompareAndSetAcquire(2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
732 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
733 |
assertEquals(success, true, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
734 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
735 |
assertEquals(x, 1.0f, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
736 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
737 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
738 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
739 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
740 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
741 |
success = vh.weakCompareAndSetRelease(1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
742 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
743 |
assertEquals(success, true, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
744 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
745 |
assertEquals(x, 2.0f, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
746 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
747 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
748 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
749 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
750 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
751 |
success = vh.weakCompareAndSetRelease(2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
752 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
753 |
assertEquals(success, true, "weakCompareAndSetVolatile float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
754 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
755 |
assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
756 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
757 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
758 |
// Compare set and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
759 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
760 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
761 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
762 |
float o = (float) vh.getAndSet(2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
763 |
assertEquals(o, 1.0f, "getAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
764 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
765 |
assertEquals(x, 2.0f, "getAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
766 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
767 |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
768 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
769 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
770 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
771 |
float o = (float) vh.getAndSetAcquire(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
772 |
assertEquals(o, 1.0f, "getAndSetAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
773 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
774 |
assertEquals(x, 2.0f, "getAndSetAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
775 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
776 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
777 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
778 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
779 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
780 |
float o = (float) vh.getAndSetRelease(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
781 |
assertEquals(o, 1.0f, "getAndSetRelease float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
782 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
783 |
assertEquals(x, 2.0f, "getAndSetRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
784 |
} |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
785 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
786 |
// get and add, add and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
787 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
788 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
789 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
790 |
float o = (float) vh.getAndAdd( 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
791 |
assertEquals(o, 1.0f, "getAndAdd float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
792 |
float c = (float) vh.addAndGet(3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
793 |
assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
794 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
795 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
796 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
797 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
798 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
799 |
float o = (float) vh.getAndAddAcquire(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
800 |
assertEquals(o, 1.0f, "getAndAddAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
801 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
802 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
803 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
804 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
805 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
806 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
807 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
808 |
float o = (float) vh.getAndAddRelease(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
809 |
assertEquals(o, 1.0f, "getAndAddReleasefloat"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
810 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
811 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
812 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
813 |
|
36934 | 814 |
} |
815 |
||
816 |
static void testStaticFieldUnsupported(VarHandle vh) { |
|
817 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
818 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
819 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
820 |
float o = (float) vh.getAndBitwiseOr(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
821 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
822 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
823 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
824 |
float o = (float) vh.getAndBitwiseOrAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
825 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
826 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
827 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
828 |
float o = (float) vh.getAndBitwiseOrRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
829 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
830 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
831 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
832 |
float o = (float) vh.getAndBitwiseAnd(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
833 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
834 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
835 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
836 |
float o = (float) vh.getAndBitwiseAndAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
837 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
838 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
839 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
840 |
float o = (float) vh.getAndBitwiseAndRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
841 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
842 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
843 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
844 |
float o = (float) vh.getAndBitwiseXor(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
845 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
846 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
847 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
848 |
float o = (float) vh.getAndBitwiseXorAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
849 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
850 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
851 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
852 |
float o = (float) vh.getAndBitwiseXorRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
853 |
}); |
36934 | 854 |
} |
855 |
||
856 |
||
857 |
static void testArray(VarHandle vh) { |
|
858 |
float[] array = new float[10]; |
|
859 |
||
860 |
for (int i = 0; i < array.length; i++) { |
|
861 |
// Plain |
|
862 |
{ |
|
863 |
vh.set(array, i, 1.0f); |
|
864 |
float x = (float) vh.get(array, i); |
|
865 |
assertEquals(x, 1.0f, "get float value"); |
|
866 |
} |
|
867 |
||
868 |
||
869 |
// Volatile |
|
870 |
{ |
|
871 |
vh.setVolatile(array, i, 2.0f); |
|
872 |
float x = (float) vh.getVolatile(array, i); |
|
873 |
assertEquals(x, 2.0f, "setVolatile float value"); |
|
874 |
} |
|
875 |
||
876 |
// Lazy |
|
877 |
{ |
|
878 |
vh.setRelease(array, i, 1.0f); |
|
879 |
float x = (float) vh.getAcquire(array, i); |
|
880 |
assertEquals(x, 1.0f, "setRelease float value"); |
|
881 |
} |
|
882 |
||
883 |
// Opaque |
|
884 |
{ |
|
885 |
vh.setOpaque(array, i, 2.0f); |
|
886 |
float x = (float) vh.getOpaque(array, i); |
|
887 |
assertEquals(x, 2.0f, "setOpaque float value"); |
|
888 |
} |
|
889 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
890 |
vh.set(array, i, 1.0f); |
36934 | 891 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
892 |
// Compare |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
893 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
894 |
boolean r = vh.compareAndSet(array, i, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
895 |
assertEquals(r, true, "success compareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
896 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
897 |
assertEquals(x, 2.0f, "success compareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
898 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
899 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
900 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
901 |
boolean r = vh.compareAndSet(array, i, 1.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
902 |
assertEquals(r, false, "failing compareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
903 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
904 |
assertEquals(x, 2.0f, "failing compareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
905 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
906 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
907 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
908 |
float r = (float) vh.compareAndExchange(array, i, 2.0f, 1.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
909 |
assertEquals(r, 2.0f, "success compareAndExchange float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
910 |
float x = (float) vh.get(array, i); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
911 |
assertEquals(x, 1.0f, "success compareAndExchange float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
912 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
913 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
914 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
915 |
float r = (float) vh.compareAndExchange(array, i, 2.0f, 3.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
916 |
assertEquals(r, 1.0f, "failing compareAndExchange float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
917 |
float x = (float) vh.get(array, i); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
918 |
assertEquals(x, 1.0f, "failing compareAndExchange float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
919 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
920 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
921 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
922 |
float r = (float) vh.compareAndExchangeAcquire(array, i, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
923 |
assertEquals(r, 1.0f, "success compareAndExchangeAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
924 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
925 |
assertEquals(x, 2.0f, "success compareAndExchangeAcquire float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
926 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
927 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
928 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
929 |
float r = (float) vh.compareAndExchangeAcquire(array, i, 1.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
930 |
assertEquals(r, 2.0f, "failing compareAndExchangeAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
931 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
932 |
assertEquals(x, 2.0f, "failing compareAndExchangeAcquire float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
933 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
934 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
935 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
936 |
float r = (float) vh.compareAndExchangeRelease(array, i, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
937 |
assertEquals(r, 2.0f, "success compareAndExchangeRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
938 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
939 |
assertEquals(x, 1.0f, "success compareAndExchangeRelease float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
940 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
941 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
942 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
943 |
float r = (float) vh.compareAndExchangeRelease(array, i, 2.0f, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
944 |
assertEquals(r, 1.0f, "failing compareAndExchangeRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
945 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
946 |
assertEquals(x, 1.0f, "failing compareAndExchangeRelease float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
947 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
948 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
949 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
950 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
951 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
952 |
success = vh.weakCompareAndSet(array, i, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
953 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
954 |
assertEquals(success, true, "weakCompareAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
955 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
956 |
assertEquals(x, 2.0f, "weakCompareAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
957 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
958 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
959 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
960 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
961 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
962 |
success = vh.weakCompareAndSetAcquire(array, i, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
963 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
964 |
assertEquals(success, true, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
965 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
966 |
assertEquals(x, 1.0f, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
967 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
968 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
969 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
970 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
971 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
972 |
success = vh.weakCompareAndSetRelease(array, i, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
973 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
974 |
assertEquals(success, true, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
975 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
976 |
assertEquals(x, 2.0f, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
977 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
978 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
979 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
980 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
981 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
982 |
success = vh.weakCompareAndSetVolatile(array, i, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
983 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
984 |
assertEquals(success, true, "weakCompareAndSetVolatile float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
985 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
986 |
assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
987 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
988 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
989 |
// Compare set and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
990 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
991 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
992 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
993 |
float o = (float) vh.getAndSet(array, i, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
994 |
assertEquals(o, 1.0f, "getAndSet float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
995 |
float x = (float) vh.get(array, i); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
996 |
assertEquals(x, 2.0f, "getAndSet float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
997 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
998 |
|
40732
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 |
vh.set(array, i, 1.0f); |
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 |
float o = (float) vh.getAndSetAcquire(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1003 |
assertEquals(o, 1.0f, "getAndSetAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1004 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1005 |
assertEquals(x, 2.0f, "getAndSetAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1006 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1007 |
|
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 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1010 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1011 |
float o = (float) vh.getAndSetRelease(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1012 |
assertEquals(o, 1.0f, "getAndSetRelease float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1013 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1014 |
assertEquals(x, 2.0f, "getAndSetRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1015 |
} |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1016 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1017 |
// get and add, add and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1018 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1019 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1020 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1021 |
float o = (float) vh.getAndAdd(array, i, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1022 |
assertEquals(o, 1.0f, "getAndAdd float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1023 |
float c = (float) vh.addAndGet(array, i, 3.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1024 |
assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1025 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1026 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1027 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1028 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1029 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1030 |
float o = (float) vh.getAndAddAcquire(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1031 |
assertEquals(o, 1.0f, "getAndAddAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1032 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1033 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1034 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1035 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1036 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1037 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1038 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1039 |
float o = (float) vh.getAndAddRelease(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1040 |
assertEquals(o, 1.0f, "getAndAddReleasefloat"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1041 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1042 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1043 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1044 |
|
36934 | 1045 |
} |
1046 |
} |
|
1047 |
||
1048 |
static void testArrayUnsupported(VarHandle vh) { |
|
1049 |
float[] array = new float[10]; |
|
1050 |
||
1051 |
int i = 0; |
|
1052 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1053 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1054 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1055 |
float o = (float) vh.getAndBitwiseOr(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1056 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1057 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1058 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1059 |
float o = (float) vh.getAndBitwiseOrAcquire(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1060 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1061 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1062 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1063 |
float o = (float) vh.getAndBitwiseOrRelease(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1064 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1065 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1066 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1067 |
float o = (float) vh.getAndBitwiseAnd(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1068 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1069 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1070 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1071 |
float o = (float) vh.getAndBitwiseAndAcquire(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1072 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1073 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1074 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1075 |
float o = (float) vh.getAndBitwiseAndRelease(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1076 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1077 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1078 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1079 |
float o = (float) vh.getAndBitwiseXor(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1080 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1081 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1082 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1083 |
float o = (float) vh.getAndBitwiseXorAcquire(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1084 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1085 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1086 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1087 |
float o = (float) vh.getAndBitwiseXorRelease(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1088 |
}); |
36934 | 1089 |
} |
1090 |
||
1091 |
static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { |
|
1092 |
float[] array = new float[10]; |
|
1093 |
||
1094 |
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) { |
|
1095 |
final int ci = i; |
|
1096 |
||
1097 |
checkIOOBE(() -> { |
|
1098 |
float x = (float) vh.get(array, ci); |
|
1099 |
}); |
|
1100 |
||
1101 |
checkIOOBE(() -> { |
|
1102 |
vh.set(array, ci, 1.0f); |
|
1103 |
}); |
|
1104 |
||
1105 |
checkIOOBE(() -> { |
|
1106 |
float x = (float) vh.getVolatile(array, ci); |
|
1107 |
}); |
|
1108 |
||
1109 |
checkIOOBE(() -> { |
|
1110 |
vh.setVolatile(array, ci, 1.0f); |
|
1111 |
}); |
|
1112 |
||
1113 |
checkIOOBE(() -> { |
|
1114 |
float x = (float) vh.getAcquire(array, ci); |
|
1115 |
}); |
|
1116 |
||
1117 |
checkIOOBE(() -> { |
|
1118 |
vh.setRelease(array, ci, 1.0f); |
|
1119 |
}); |
|
1120 |
||
1121 |
checkIOOBE(() -> { |
|
1122 |
float x = (float) vh.getOpaque(array, ci); |
|
1123 |
}); |
|
1124 |
||
1125 |
checkIOOBE(() -> { |
|
1126 |
vh.setOpaque(array, ci, 1.0f); |
|
1127 |
}); |
|
1128 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1129 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1130 |
boolean r = vh.compareAndSet(array, ci, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1131 |
}); |
36934 | 1132 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1133 |
checkIOOBE(() -> { |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
1134 |
float r = (float) vh.compareAndExchange(array, ci, 2.0f, 1.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1135 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1136 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1137 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1138 |
float r = (float) vh.compareAndExchangeAcquire(array, ci, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1139 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1140 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1141 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1142 |
float r = (float) vh.compareAndExchangeRelease(array, ci, 2.0f, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1143 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1144 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1145 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1146 |
boolean r = vh.weakCompareAndSet(array, ci, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1147 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1148 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1149 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1150 |
boolean r = vh.weakCompareAndSetVolatile(array, ci, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1151 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1152 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1153 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1154 |
boolean r = vh.weakCompareAndSetAcquire(array, ci, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1155 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1156 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1157 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1158 |
boolean r = vh.weakCompareAndSetRelease(array, ci, 1.0f, 2.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1159 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1160 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1161 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1162 |
float o = (float) vh.getAndSet(array, ci, 1.0f); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1163 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1164 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1165 |
checkIOOBE(() -> { |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1166 |
float o = (float) vh.getAndSetAcquire(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1167 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1168 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1169 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1170 |
float o = (float) vh.getAndSetRelease(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1171 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1172 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1173 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1174 |
float o = (float) vh.getAndAdd(array, ci, 1.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1175 |
}); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1176 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1177 |
checkIOOBE(() -> { |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1178 |
float o = (float) vh.getAndAddAcquire(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1179 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1180 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1181 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1182 |
float o = (float) vh.getAndAddRelease(array, ci, 1.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1183 |
}); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1184 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1185 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1186 |
float o = (float) vh.addAndGet(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1187 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1188 |
|
36934 | 1189 |
} |
1190 |
} |
|
1191 |
} |
|
1192 |