author | psandoz |
Mon, 22 Jan 2018 13:27:28 -0800 | |
changeset 49788 | 5375d426822a |
parent 47216 | 71c04702a3d5 |
child 52914 | 4fa75d8ad418 |
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 |
||
49788 | 63 |
|
36934 | 64 |
@BeforeClass |
65 |
public void setup() throws Exception { |
|
66 |
vhFinalField = MethodHandles.lookup().findVarHandle( |
|
67 |
VarHandleTestAccessFloat.class, "final_v", float.class); |
|
68 |
||
69 |
vhField = MethodHandles.lookup().findVarHandle( |
|
70 |
VarHandleTestAccessFloat.class, "v", float.class); |
|
71 |
||
72 |
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( |
|
73 |
VarHandleTestAccessFloat.class, "static_final_v", float.class); |
|
74 |
||
75 |
vhStaticField = MethodHandles.lookup().findStaticVarHandle( |
|
76 |
VarHandleTestAccessFloat.class, "static_v", float.class); |
|
77 |
||
78 |
vhArray = MethodHandles.arrayElementVarHandle(float[].class); |
|
79 |
} |
|
80 |
||
81 |
||
82 |
@DataProvider |
|
83 |
public Object[][] varHandlesProvider() throws Exception { |
|
84 |
List<VarHandle> vhs = new ArrayList<>(); |
|
85 |
vhs.add(vhField); |
|
86 |
vhs.add(vhStaticField); |
|
87 |
vhs.add(vhArray); |
|
88 |
||
89 |
return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new); |
|
90 |
} |
|
91 |
||
92 |
@Test(dataProvider = "varHandlesProvider") |
|
93 |
public void testIsAccessModeSupported(VarHandle vh) { |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
94 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
95 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
96 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
97 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
98 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
99 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
100 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE)); |
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
101 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE)); |
36934 | 102 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
103 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
107 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); |
39471
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)); |
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_ACQUIRE)); |
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.WEAK_COMPARE_AND_SET_RELEASE)); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
111 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
112 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
113 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); |
36934 | 114 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
115 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
116 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
117 |
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); |
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 |
// Work around issue with jtreg summary reporting which truncates |
|
215 |
// the String result of Object.toString to 30 characters, hence |
|
216 |
// the first dummy argument |
|
217 |
return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new); |
|
218 |
} |
|
219 |
||
220 |
@Test(dataProvider = "accessTestCaseProvider") |
|
221 |
public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable { |
|
222 |
T t = atc.get(); |
|
223 |
int iters = atc.requiresLoop() ? ITERS : 1; |
|
224 |
for (int c = 0; c < iters; c++) { |
|
225 |
atc.testAccess(t); |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
||
230 |
||
231 |
||
232 |
static void testInstanceFinalField(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
233 |
// Plain |
|
234 |
{ |
|
235 |
float x = (float) vh.get(recv); |
|
236 |
assertEquals(x, 1.0f, "get float value"); |
|
237 |
} |
|
238 |
||
239 |
||
240 |
// Volatile |
|
241 |
{ |
|
242 |
float x = (float) vh.getVolatile(recv); |
|
243 |
assertEquals(x, 1.0f, "getVolatile float value"); |
|
244 |
} |
|
245 |
||
246 |
// Lazy |
|
247 |
{ |
|
248 |
float x = (float) vh.getAcquire(recv); |
|
249 |
assertEquals(x, 1.0f, "getRelease float value"); |
|
250 |
} |
|
251 |
||
252 |
// Opaque |
|
253 |
{ |
|
254 |
float x = (float) vh.getOpaque(recv); |
|
255 |
assertEquals(x, 1.0f, "getOpaque float value"); |
|
256 |
} |
|
257 |
} |
|
258 |
||
259 |
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
260 |
checkUOE(() -> { |
|
261 |
vh.set(recv, 2.0f); |
|
262 |
}); |
|
263 |
||
264 |
checkUOE(() -> { |
|
265 |
vh.setVolatile(recv, 2.0f); |
|
266 |
}); |
|
267 |
||
268 |
checkUOE(() -> { |
|
269 |
vh.setRelease(recv, 2.0f); |
|
270 |
}); |
|
271 |
||
272 |
checkUOE(() -> { |
|
273 |
vh.setOpaque(recv, 2.0f); |
|
274 |
}); |
|
275 |
||
276 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
277 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
278 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
279 |
float o = (float) vh.getAndBitwiseOr(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
280 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
281 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
282 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
283 |
float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
284 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
287 |
float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
288 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
291 |
float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
292 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
293 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
294 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
295 |
float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
296 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
299 |
float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
300 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
301 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
302 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
303 |
float o = (float) vh.getAndBitwiseXor(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
304 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
307 |
float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
308 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
309 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
310 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
311 |
float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
312 |
}); |
36934 | 313 |
} |
314 |
||
315 |
||
316 |
static void testStaticFinalField(VarHandle vh) { |
|
317 |
// Plain |
|
318 |
{ |
|
319 |
float x = (float) vh.get(); |
|
320 |
assertEquals(x, 1.0f, "get float value"); |
|
321 |
} |
|
322 |
||
323 |
||
324 |
// Volatile |
|
325 |
{ |
|
326 |
float x = (float) vh.getVolatile(); |
|
327 |
assertEquals(x, 1.0f, "getVolatile float value"); |
|
328 |
} |
|
329 |
||
330 |
// Lazy |
|
331 |
{ |
|
332 |
float x = (float) vh.getAcquire(); |
|
333 |
assertEquals(x, 1.0f, "getRelease float value"); |
|
334 |
} |
|
335 |
||
336 |
// Opaque |
|
337 |
{ |
|
338 |
float x = (float) vh.getOpaque(); |
|
339 |
assertEquals(x, 1.0f, "getOpaque float value"); |
|
340 |
} |
|
341 |
} |
|
342 |
||
343 |
static void testStaticFinalFieldUnsupported(VarHandle vh) { |
|
344 |
checkUOE(() -> { |
|
345 |
vh.set(2.0f); |
|
346 |
}); |
|
347 |
||
348 |
checkUOE(() -> { |
|
349 |
vh.setVolatile(2.0f); |
|
350 |
}); |
|
351 |
||
352 |
checkUOE(() -> { |
|
353 |
vh.setRelease(2.0f); |
|
354 |
}); |
|
355 |
||
356 |
checkUOE(() -> { |
|
357 |
vh.setOpaque(2.0f); |
|
358 |
}); |
|
359 |
||
360 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
361 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
362 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
363 |
float o = (float) vh.getAndBitwiseOr(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
364 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
365 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
366 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
367 |
float o = (float) vh.getAndBitwiseOrAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
368 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
369 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
370 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
371 |
float o = (float) vh.getAndBitwiseOrRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
372 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
375 |
float o = (float) vh.getAndBitwiseAnd(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
376 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
379 |
float o = (float) vh.getAndBitwiseAndAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
380 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
383 |
float o = (float) vh.getAndBitwiseAndRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
384 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
387 |
float o = (float) vh.getAndBitwiseXor(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
388 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
391 |
float o = (float) vh.getAndBitwiseXorAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
392 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
395 |
float o = (float) vh.getAndBitwiseXorRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
396 |
}); |
36934 | 397 |
} |
398 |
||
399 |
||
400 |
static void testInstanceField(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
401 |
// Plain |
|
402 |
{ |
|
403 |
vh.set(recv, 1.0f); |
|
404 |
float x = (float) vh.get(recv); |
|
405 |
assertEquals(x, 1.0f, "set float value"); |
|
406 |
} |
|
407 |
||
408 |
||
409 |
// Volatile |
|
410 |
{ |
|
411 |
vh.setVolatile(recv, 2.0f); |
|
412 |
float x = (float) vh.getVolatile(recv); |
|
413 |
assertEquals(x, 2.0f, "setVolatile float value"); |
|
414 |
} |
|
415 |
||
416 |
// Lazy |
|
417 |
{ |
|
418 |
vh.setRelease(recv, 1.0f); |
|
419 |
float x = (float) vh.getAcquire(recv); |
|
420 |
assertEquals(x, 1.0f, "setRelease float value"); |
|
421 |
} |
|
422 |
||
423 |
// Opaque |
|
424 |
{ |
|
425 |
vh.setOpaque(recv, 2.0f); |
|
426 |
float x = (float) vh.getOpaque(recv); |
|
427 |
assertEquals(x, 2.0f, "setOpaque float value"); |
|
428 |
} |
|
429 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
430 |
vh.set(recv, 1.0f); |
36934 | 431 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
432 |
// Compare |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
433 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
434 |
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
|
435 |
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
|
436 |
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
|
437 |
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
|
438 |
} |
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 |
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
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
} |
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 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
448 |
float r = (float) vh.compareAndExchange(recv, 2.0f, 1.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
449 |
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
|
450 |
float x = (float) vh.get(recv); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
451 |
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
|
452 |
} |
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 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
455 |
float r = (float) vh.compareAndExchange(recv, 2.0f, 3.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
456 |
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
|
457 |
float x = (float) vh.get(recv); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
458 |
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
|
459 |
} |
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 |
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
|
463 |
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
|
464 |
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
|
465 |
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
|
466 |
} |
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 |
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
|
470 |
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
|
471 |
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
|
472 |
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
|
473 |
} |
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 |
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
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
} |
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 |
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
|
484 |
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
|
485 |
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
|
486 |
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
|
487 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
491 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
492 |
success = vh.weakCompareAndSetPlain(recv, 1.0f, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
493 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
494 |
assertEquals(success, true, "weakCompareAndSetPlain float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
495 |
float x = (float) vh.get(recv); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
496 |
assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
497 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
501 |
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
|
502 |
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
|
503 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
504 |
assertEquals(success, true, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
505 |
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
|
506 |
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
|
507 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
511 |
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
|
512 |
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
|
513 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
514 |
assertEquals(success, true, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
515 |
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
|
516 |
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
|
517 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
521 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
522 |
success = vh.weakCompareAndSet(recv, 2.0f, 1.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
523 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
524 |
assertEquals(success, true, "weakCompareAndSet float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
525 |
float x = (float) vh.get(recv); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
526 |
assertEquals(x, 1.0f, "weakCompareAndSet float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
527 |
} |
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 |
// Compare set and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
530 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
531 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
532 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
533 |
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
|
534 |
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
|
535 |
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
|
536 |
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
|
537 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
538 |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
539 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
540 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
541 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
542 |
float o = (float) vh.getAndSetAcquire(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
543 |
assertEquals(o, 1.0f, "getAndSetAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
544 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
545 |
assertEquals(x, 2.0f, "getAndSetAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
546 |
} |
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 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
550 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
551 |
float o = (float) vh.getAndSetRelease(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
552 |
assertEquals(o, 1.0f, "getAndSetRelease float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
553 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
554 |
assertEquals(x, 2.0f, "getAndSetRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
555 |
} |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
556 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
557 |
// 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
|
558 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
559 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
560 |
|
40733 | 561 |
float o = (float) vh.getAndAdd(recv, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
562 |
assertEquals(o, 1.0f, "getAndAdd float"); |
40733 | 563 |
float x = (float) vh.get(recv); |
564 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
565 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
566 |
|
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 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
569 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
570 |
float o = (float) vh.getAndAddAcquire(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
571 |
assertEquals(o, 1.0f, "getAndAddAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
572 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
573 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
574 |
} |
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 |
vh.set(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
578 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
579 |
float o = (float) vh.getAndAddRelease(recv, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
580 |
assertEquals(o, 1.0f, "getAndAddReleasefloat"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
581 |
float x = (float) vh.get(recv); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
582 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
583 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
584 |
|
36934 | 585 |
} |
586 |
||
587 |
static void testInstanceFieldUnsupported(VarHandleTestAccessFloat recv, VarHandle vh) { |
|
588 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
589 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
590 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
591 |
float o = (float) vh.getAndBitwiseOr(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
592 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
595 |
float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
596 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
597 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
598 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
599 |
float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
600 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
603 |
float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
604 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
607 |
float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
608 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
611 |
float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
612 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
615 |
float o = (float) vh.getAndBitwiseXor(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
616 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
617 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
618 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
619 |
float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
620 |
}); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
621 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
622 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
623 |
float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
624 |
}); |
36934 | 625 |
} |
626 |
||
627 |
||
628 |
static void testStaticField(VarHandle vh) { |
|
629 |
// Plain |
|
630 |
{ |
|
631 |
vh.set(1.0f); |
|
632 |
float x = (float) vh.get(); |
|
633 |
assertEquals(x, 1.0f, "set float value"); |
|
634 |
} |
|
635 |
||
636 |
||
637 |
// Volatile |
|
638 |
{ |
|
639 |
vh.setVolatile(2.0f); |
|
640 |
float x = (float) vh.getVolatile(); |
|
641 |
assertEquals(x, 2.0f, "setVolatile float value"); |
|
642 |
} |
|
643 |
||
644 |
// Lazy |
|
645 |
{ |
|
646 |
vh.setRelease(1.0f); |
|
647 |
float x = (float) vh.getAcquire(); |
|
648 |
assertEquals(x, 1.0f, "setRelease float value"); |
|
649 |
} |
|
650 |
||
651 |
// Opaque |
|
652 |
{ |
|
653 |
vh.setOpaque(2.0f); |
|
654 |
float x = (float) vh.getOpaque(); |
|
655 |
assertEquals(x, 2.0f, "setOpaque float value"); |
|
656 |
} |
|
657 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
658 |
vh.set(1.0f); |
36934 | 659 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
660 |
// Compare |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
661 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
662 |
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
|
663 |
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
|
664 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
665 |
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
|
666 |
} |
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 |
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
|
670 |
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
|
671 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
672 |
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
|
673 |
} |
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 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
676 |
float r = (float) vh.compareAndExchange(2.0f, 1.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
677 |
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
|
678 |
float x = (float) vh.get(); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
679 |
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
|
680 |
} |
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 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
683 |
float r = (float) vh.compareAndExchange(2.0f, 3.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
684 |
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
|
685 |
float x = (float) vh.get(); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
686 |
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
|
687 |
} |
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 |
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
|
691 |
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
|
692 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
693 |
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
|
694 |
} |
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 |
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
|
698 |
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
|
699 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
700 |
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
|
701 |
} |
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 |
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
|
705 |
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
|
706 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
707 |
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
|
708 |
} |
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 |
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
|
712 |
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
|
713 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
714 |
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
|
715 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
719 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
720 |
success = vh.weakCompareAndSetPlain(1.0f, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
721 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
722 |
assertEquals(success, true, "weakCompareAndSetPlain float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
723 |
float x = (float) vh.get(); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
724 |
assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
725 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
729 |
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
|
730 |
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
|
731 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
732 |
assertEquals(success, true, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
733 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
734 |
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
|
735 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
739 |
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
|
740 |
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
|
741 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
742 |
assertEquals(success, true, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
743 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
744 |
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
|
745 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
749 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
750 |
success = vh.weakCompareAndSet(2.0f, 1.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
751 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
752 |
assertEquals(success, true, "weakCompareAndSet float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
753 |
float x = (float) vh.get(); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
754 |
assertEquals(x, 1.0f, "weakCompareAndSet float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
755 |
} |
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 |
// Compare set and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
758 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
759 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
760 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
761 |
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
|
762 |
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
|
763 |
float x = (float) vh.get(); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
764 |
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
|
765 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
766 |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
767 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
768 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
769 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
770 |
float o = (float) vh.getAndSetAcquire(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
771 |
assertEquals(o, 1.0f, "getAndSetAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
772 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
773 |
assertEquals(x, 2.0f, "getAndSetAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
774 |
} |
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 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
778 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
779 |
float o = (float) vh.getAndSetRelease(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
780 |
assertEquals(o, 1.0f, "getAndSetRelease float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
781 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
782 |
assertEquals(x, 2.0f, "getAndSetRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
783 |
} |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
784 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
785 |
// 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
|
786 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
787 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
788 |
|
40733 | 789 |
float o = (float) vh.getAndAdd(2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
790 |
assertEquals(o, 1.0f, "getAndAdd float"); |
40733 | 791 |
float x = (float) vh.get(); |
792 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
793 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
794 |
|
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 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
797 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
798 |
float o = (float) vh.getAndAddAcquire(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
799 |
assertEquals(o, 1.0f, "getAndAddAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
800 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
801 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
802 |
} |
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 |
vh.set(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
806 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
807 |
float o = (float) vh.getAndAddRelease(2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
808 |
assertEquals(o, 1.0f, "getAndAddReleasefloat"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
809 |
float x = (float) vh.get(); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
810 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
811 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
812 |
|
36934 | 813 |
} |
814 |
||
815 |
static void testStaticFieldUnsupported(VarHandle vh) { |
|
816 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
817 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
818 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
819 |
float o = (float) vh.getAndBitwiseOr(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
820 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
823 |
float o = (float) vh.getAndBitwiseOrAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
824 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
827 |
float o = (float) vh.getAndBitwiseOrRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
828 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
831 |
float o = (float) vh.getAndBitwiseAnd(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
832 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
835 |
float o = (float) vh.getAndBitwiseAndAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
836 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
839 |
float o = (float) vh.getAndBitwiseAndRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
840 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
843 |
float o = (float) vh.getAndBitwiseXor(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
844 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
847 |
float o = (float) vh.getAndBitwiseXorAcquire(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
848 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
851 |
float o = (float) vh.getAndBitwiseXorRelease(1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
852 |
}); |
36934 | 853 |
} |
854 |
||
855 |
||
856 |
static void testArray(VarHandle vh) { |
|
857 |
float[] array = new float[10]; |
|
858 |
||
859 |
for (int i = 0; i < array.length; i++) { |
|
860 |
// Plain |
|
861 |
{ |
|
862 |
vh.set(array, i, 1.0f); |
|
863 |
float x = (float) vh.get(array, i); |
|
864 |
assertEquals(x, 1.0f, "get float value"); |
|
865 |
} |
|
866 |
||
867 |
||
868 |
// Volatile |
|
869 |
{ |
|
870 |
vh.setVolatile(array, i, 2.0f); |
|
871 |
float x = (float) vh.getVolatile(array, i); |
|
872 |
assertEquals(x, 2.0f, "setVolatile float value"); |
|
873 |
} |
|
874 |
||
875 |
// Lazy |
|
876 |
{ |
|
877 |
vh.setRelease(array, i, 1.0f); |
|
878 |
float x = (float) vh.getAcquire(array, i); |
|
879 |
assertEquals(x, 1.0f, "setRelease float value"); |
|
880 |
} |
|
881 |
||
882 |
// Opaque |
|
883 |
{ |
|
884 |
vh.setOpaque(array, i, 2.0f); |
|
885 |
float x = (float) vh.getOpaque(array, i); |
|
886 |
assertEquals(x, 2.0f, "setOpaque float value"); |
|
887 |
} |
|
888 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
889 |
vh.set(array, i, 1.0f); |
36934 | 890 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
891 |
// Compare |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
892 |
{ |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
893 |
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
|
894 |
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
|
895 |
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
|
896 |
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
|
897 |
} |
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 |
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
|
901 |
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
|
902 |
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
|
903 |
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
|
904 |
} |
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 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
907 |
float r = (float) vh.compareAndExchange(array, i, 2.0f, 1.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
908 |
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
|
909 |
float x = (float) vh.get(array, i); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
910 |
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
|
911 |
} |
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 |
{ |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
914 |
float r = (float) vh.compareAndExchange(array, i, 2.0f, 3.0f); |
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
915 |
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
|
916 |
float x = (float) vh.get(array, i); |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
917 |
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
|
918 |
} |
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 |
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
|
922 |
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
|
923 |
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
|
924 |
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
|
925 |
} |
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 |
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
|
929 |
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
|
930 |
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
|
931 |
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
|
932 |
} |
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 |
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
|
936 |
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
|
937 |
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
|
938 |
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
|
939 |
} |
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 |
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
|
943 |
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
|
944 |
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
|
945 |
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
|
946 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
950 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
951 |
success = vh.weakCompareAndSetPlain(array, i, 1.0f, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
952 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
953 |
assertEquals(success, true, "weakCompareAndSetPlain float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
954 |
float x = (float) vh.get(array, i); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
955 |
assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
956 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
960 |
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
|
961 |
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
|
962 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
963 |
assertEquals(success, true, "weakCompareAndSetAcquire float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
964 |
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
|
965 |
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
|
966 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
970 |
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
|
971 |
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
|
972 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
973 |
assertEquals(success, true, "weakCompareAndSetRelease float"); |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
974 |
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
|
975 |
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
|
976 |
} |
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 |
boolean success = false; |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
980 |
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
981 |
success = vh.weakCompareAndSet(array, i, 2.0f, 1.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
982 |
} |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
983 |
assertEquals(success, true, "weakCompareAndSet float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
984 |
float x = (float) vh.get(array, i); |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
985 |
assertEquals(x, 1.0f, "weakCompareAndSet float"); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
986 |
} |
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 |
// Compare set and get |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
989 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
990 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
991 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
992 |
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
|
993 |
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
|
994 |
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
|
995 |
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
|
996 |
} |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
997 |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
998 |
{ |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
999 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1000 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1001 |
float o = (float) vh.getAndSetAcquire(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1002 |
assertEquals(o, 1.0f, "getAndSetAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1003 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1004 |
assertEquals(x, 2.0f, "getAndSetAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1005 |
} |
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 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1009 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1010 |
float o = (float) vh.getAndSetRelease(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1011 |
assertEquals(o, 1.0f, "getAndSetRelease float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1012 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1013 |
assertEquals(x, 2.0f, "getAndSetRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1014 |
} |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1015 |
|
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1016 |
// 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
|
1017 |
{ |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1018 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1019 |
|
40733 | 1020 |
float o = (float) vh.getAndAdd(array, i, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1021 |
assertEquals(o, 1.0f, "getAndAdd float"); |
40733 | 1022 |
float x = (float) vh.get(array, i); |
1023 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1024 |
} |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1025 |
|
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 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1028 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1029 |
float o = (float) vh.getAndAddAcquire(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1030 |
assertEquals(o, 1.0f, "getAndAddAcquire float"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1031 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1032 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1033 |
} |
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 |
vh.set(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1037 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1038 |
float o = (float) vh.getAndAddRelease(array, i, 2.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1039 |
assertEquals(o, 1.0f, "getAndAddReleasefloat"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1040 |
float x = (float) vh.get(array, i); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1041 |
assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1042 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1043 |
|
36934 | 1044 |
} |
1045 |
} |
|
1046 |
||
1047 |
static void testArrayUnsupported(VarHandle vh) { |
|
1048 |
float[] array = new float[10]; |
|
1049 |
||
1050 |
int i = 0; |
|
1051 |
||
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1052 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1053 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1054 |
float o = (float) vh.getAndBitwiseOr(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1055 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1058 |
float o = (float) vh.getAndBitwiseOrAcquire(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1059 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1062 |
float o = (float) vh.getAndBitwiseOrRelease(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1063 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1066 |
float o = (float) vh.getAndBitwiseAnd(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1067 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1070 |
float o = (float) vh.getAndBitwiseAndAcquire(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1071 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1074 |
float o = (float) vh.getAndBitwiseAndRelease(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1075 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1078 |
float o = (float) vh.getAndBitwiseXor(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1079 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1082 |
float o = (float) vh.getAndBitwiseXorAcquire(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1083 |
}); |
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 |
checkUOE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1086 |
float o = (float) vh.getAndBitwiseXorRelease(array, i, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1087 |
}); |
36934 | 1088 |
} |
1089 |
||
1090 |
static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { |
|
1091 |
float[] array = new float[10]; |
|
1092 |
||
1093 |
for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) { |
|
1094 |
final int ci = i; |
|
1095 |
||
1096 |
checkIOOBE(() -> { |
|
1097 |
float x = (float) vh.get(array, ci); |
|
1098 |
}); |
|
1099 |
||
1100 |
checkIOOBE(() -> { |
|
1101 |
vh.set(array, ci, 1.0f); |
|
1102 |
}); |
|
1103 |
||
1104 |
checkIOOBE(() -> { |
|
1105 |
float x = (float) vh.getVolatile(array, ci); |
|
1106 |
}); |
|
1107 |
||
1108 |
checkIOOBE(() -> { |
|
1109 |
vh.setVolatile(array, ci, 1.0f); |
|
1110 |
}); |
|
1111 |
||
1112 |
checkIOOBE(() -> { |
|
1113 |
float x = (float) vh.getAcquire(array, ci); |
|
1114 |
}); |
|
1115 |
||
1116 |
checkIOOBE(() -> { |
|
1117 |
vh.setRelease(array, ci, 1.0f); |
|
1118 |
}); |
|
1119 |
||
1120 |
checkIOOBE(() -> { |
|
1121 |
float x = (float) vh.getOpaque(array, ci); |
|
1122 |
}); |
|
1123 |
||
1124 |
checkIOOBE(() -> { |
|
1125 |
vh.setOpaque(array, ci, 1.0f); |
|
1126 |
}); |
|
1127 |
||
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1128 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1129 |
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
|
1130 |
}); |
36934 | 1131 |
|
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1132 |
checkIOOBE(() -> { |
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
39471
diff
changeset
|
1133 |
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
|
1134 |
}); |
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 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1137 |
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
|
1138 |
}); |
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 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1141 |
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
|
1142 |
}); |
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 |
checkIOOBE(() -> { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
1145 |
boolean r = vh.weakCompareAndSetPlain(array, ci, 1.0f, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1146 |
}); |
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 |
checkIOOBE(() -> { |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
1149 |
boolean r = vh.weakCompareAndSet(array, ci, 1.0f, 2.0f); |
39471
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1150 |
}); |
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 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1153 |
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
|
1154 |
}); |
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 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1157 |
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
|
1158 |
}); |
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 |
checkIOOBE(() -> { |
6622892a347a
8158039: VarHandle float/double field/array access should support CAS/set/add atomics
psandoz
parents:
38429
diff
changeset
|
1161 |
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
|
1162 |
}); |
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 |
checkIOOBE(() -> { |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1165 |
float o = (float) vh.getAndSetAcquire(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1166 |
}); |
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 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1169 |
float o = (float) vh.getAndSetRelease(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1170 |
}); |
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 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1173 |
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
|
1174 |
}); |
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 |
checkIOOBE(() -> { |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1177 |
float o = (float) vh.getAndAddAcquire(array, ci, 1.0f); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1178 |
}); |
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 |
checkIOOBE(() -> { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1181 |
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
|
1182 |
}); |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
1183 |
|
36934 | 1184 |
} |
1185 |
} |
|
49788 | 1186 |
|
36934 | 1187 |
} |
1188 |