author | psandoz |
Thu, 05 May 2016 18:14:47 -0700 | |
changeset 38356 | 1e4ecca97792 |
parent 36934 | 590fc47a0aeb |
child 38358 | cb99c6d2af1b |
permissions | -rw-r--r-- |
36934 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
package java.lang.invoke; |
|
26 |
||
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
27 |
import jdk.internal.util.Preconditions; |
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
28 |
import jdk.internal.vm.annotation.ForceInline; |
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
29 |
|
36934 | 30 |
import java.util.Objects; |
31 |
||
32 |
import static java.lang.invoke.MethodHandleStatics.UNSAFE; |
|
33 |
||
34 |
#warn |
|
35 |
||
36 |
final class VarHandle$Type$s { |
|
37 |
||
38 |
static class FieldInstanceReadOnly extends VarHandle { |
|
39 |
final long fieldOffset; |
|
40 |
final Class<?> receiverType; |
|
41 |
#if[Object] |
|
42 |
final Class<?> fieldType; |
|
43 |
#end[Object] |
|
44 |
||
45 |
FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) { |
|
46 |
this(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadOnly.class); |
|
47 |
} |
|
48 |
||
49 |
protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}, |
|
50 |
Class<? extends FieldInstanceReadOnly> handle) { |
|
51 |
super(VarForm.createFromStatic(handle), receiverType, {#if[Object]?fieldType:$type$.class}); |
|
52 |
this.fieldOffset = fieldOffset; |
|
53 |
this.receiverType = receiverType; |
|
54 |
#if[Object] |
|
55 |
this.fieldType = fieldType; |
|
56 |
#end[Object] |
|
57 |
} |
|
58 |
||
59 |
@ForceInline |
|
60 |
static $type$ get(FieldInstanceReadOnly handle, Object holder) { |
|
61 |
return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
62 |
handle.fieldOffset); |
|
63 |
} |
|
64 |
||
65 |
@ForceInline |
|
66 |
static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) { |
|
67 |
return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
68 |
handle.fieldOffset); |
|
69 |
} |
|
70 |
||
71 |
@ForceInline |
|
72 |
static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) { |
|
73 |
return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
74 |
handle.fieldOffset); |
|
75 |
} |
|
76 |
||
77 |
@ForceInline |
|
78 |
static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) { |
|
79 |
return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
80 |
handle.fieldOffset); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
static class FieldInstanceReadWrite extends FieldInstanceReadOnly { |
|
85 |
||
86 |
FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) { |
|
87 |
super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.class); |
|
88 |
} |
|
89 |
||
90 |
@ForceInline |
|
91 |
static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
92 |
UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
93 |
handle.fieldOffset, |
|
94 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
95 |
} |
|
96 |
||
97 |
@ForceInline |
|
98 |
static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
99 |
UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
100 |
handle.fieldOffset, |
|
101 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
102 |
} |
|
103 |
||
104 |
@ForceInline |
|
105 |
static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
106 |
UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
107 |
handle.fieldOffset, |
|
108 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
109 |
} |
|
110 |
||
111 |
@ForceInline |
|
112 |
static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
113 |
UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
114 |
handle.fieldOffset, |
|
115 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
116 |
} |
|
117 |
#if[CAS] |
|
118 |
||
119 |
@ForceInline |
|
120 |
static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
121 |
return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
122 |
handle.fieldOffset, |
|
123 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
124 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
125 |
} |
|
126 |
||
127 |
@ForceInline |
|
128 |
static $type$ compareAndExchangeVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
129 |
return UNSAFE.compareAndExchange$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
130 |
handle.fieldOffset, |
|
131 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
132 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
133 |
} |
|
134 |
||
135 |
@ForceInline |
|
136 |
static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
137 |
return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
138 |
handle.fieldOffset, |
|
139 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
140 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
141 |
} |
|
142 |
||
143 |
@ForceInline |
|
144 |
static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
145 |
return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
146 |
handle.fieldOffset, |
|
147 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
148 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
149 |
} |
|
150 |
||
151 |
@ForceInline |
|
152 |
static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
153 |
return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
154 |
handle.fieldOffset, |
|
155 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
156 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
157 |
} |
|
158 |
||
159 |
@ForceInline |
|
160 |
static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
161 |
return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
162 |
handle.fieldOffset, |
|
163 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
164 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
165 |
} |
|
166 |
||
167 |
@ForceInline |
|
168 |
static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { |
|
169 |
return UNSAFE.weakCompareAndSwap$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
170 |
handle.fieldOffset, |
|
171 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
172 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
173 |
} |
|
174 |
||
175 |
@ForceInline |
|
176 |
static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
177 |
return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
178 |
handle.fieldOffset, |
|
179 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
180 |
} |
|
181 |
#end[CAS] |
|
182 |
#if[AtomicAdd] |
|
183 |
||
184 |
@ForceInline |
|
185 |
static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
186 |
return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
187 |
handle.fieldOffset, |
|
188 |
value); |
|
189 |
} |
|
190 |
||
191 |
@ForceInline |
|
192 |
static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) { |
|
193 |
return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), |
|
194 |
handle.fieldOffset, |
|
195 |
value) + value; |
|
196 |
} |
|
197 |
#end[AtomicAdd] |
|
198 |
} |
|
199 |
||
200 |
||
201 |
static class FieldStaticReadOnly extends VarHandle { |
|
202 |
final Object base; |
|
203 |
final long fieldOffset; |
|
204 |
#if[Object] |
|
205 |
final Class<?> fieldType; |
|
206 |
#end[Object] |
|
207 |
||
208 |
FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) { |
|
209 |
this(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.class); |
|
210 |
} |
|
211 |
||
212 |
protected FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}, |
|
213 |
Class<? extends FieldStaticReadOnly> handle) { |
|
214 |
super(VarForm.createFromStatic(handle), null, {#if[Object]?fieldType:$type$.class}); |
|
215 |
this.base = base; |
|
216 |
this.fieldOffset = fieldOffset; |
|
217 |
#if[Object] |
|
218 |
this.fieldType = fieldType; |
|
219 |
#end[Object] |
|
220 |
} |
|
221 |
||
222 |
@ForceInline |
|
223 |
static $type$ get(FieldStaticReadOnly handle) { |
|
224 |
return UNSAFE.get$Type$(handle.base, |
|
225 |
handle.fieldOffset); |
|
226 |
} |
|
227 |
||
228 |
@ForceInline |
|
229 |
static $type$ getVolatile(FieldStaticReadOnly handle) { |
|
230 |
return UNSAFE.get$Type$Volatile(handle.base, |
|
231 |
handle.fieldOffset); |
|
232 |
} |
|
233 |
||
234 |
@ForceInline |
|
235 |
static $type$ getOpaque(FieldStaticReadOnly handle) { |
|
236 |
return UNSAFE.get$Type$Opaque(handle.base, |
|
237 |
handle.fieldOffset); |
|
238 |
} |
|
239 |
||
240 |
@ForceInline |
|
241 |
static $type$ getAcquire(FieldStaticReadOnly handle) { |
|
242 |
return UNSAFE.get$Type$Acquire(handle.base, |
|
243 |
handle.fieldOffset); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
static class FieldStaticReadWrite extends FieldStaticReadOnly { |
|
248 |
||
249 |
FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) { |
|
250 |
super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.class); |
|
251 |
} |
|
252 |
||
253 |
@ForceInline |
|
254 |
static void set(FieldStaticReadWrite handle, $type$ value) { |
|
255 |
UNSAFE.put$Type$(handle.base, |
|
256 |
handle.fieldOffset, |
|
257 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
258 |
} |
|
259 |
||
260 |
@ForceInline |
|
261 |
static void setVolatile(FieldStaticReadWrite handle, $type$ value) { |
|
262 |
UNSAFE.put$Type$Volatile(handle.base, |
|
263 |
handle.fieldOffset, |
|
264 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
265 |
} |
|
266 |
||
267 |
@ForceInline |
|
268 |
static void setOpaque(FieldStaticReadWrite handle, $type$ value) { |
|
269 |
UNSAFE.put$Type$Opaque(handle.base, |
|
270 |
handle.fieldOffset, |
|
271 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
272 |
} |
|
273 |
||
274 |
@ForceInline |
|
275 |
static void setRelease(FieldStaticReadWrite handle, $type$ value) { |
|
276 |
UNSAFE.put$Type$Release(handle.base, |
|
277 |
handle.fieldOffset, |
|
278 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
279 |
} |
|
280 |
#if[CAS] |
|
281 |
||
282 |
@ForceInline |
|
283 |
static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
284 |
return UNSAFE.compareAndSwap$Type$(handle.base, |
|
285 |
handle.fieldOffset, |
|
286 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
287 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
288 |
} |
|
289 |
||
290 |
||
291 |
@ForceInline |
|
292 |
static $type$ compareAndExchangeVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
293 |
return UNSAFE.compareAndExchange$Type$Volatile(handle.base, |
|
294 |
handle.fieldOffset, |
|
295 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
296 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
297 |
} |
|
298 |
||
299 |
@ForceInline |
|
300 |
static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
301 |
return UNSAFE.compareAndExchange$Type$Acquire(handle.base, |
|
302 |
handle.fieldOffset, |
|
303 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
304 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
305 |
} |
|
306 |
||
307 |
@ForceInline |
|
308 |
static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
309 |
return UNSAFE.compareAndExchange$Type$Release(handle.base, |
|
310 |
handle.fieldOffset, |
|
311 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
312 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
313 |
} |
|
314 |
||
315 |
@ForceInline |
|
316 |
static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
317 |
return UNSAFE.weakCompareAndSwap$Type$(handle.base, |
|
318 |
handle.fieldOffset, |
|
319 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
320 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
321 |
} |
|
322 |
||
323 |
@ForceInline |
|
324 |
static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
325 |
return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base, |
|
326 |
handle.fieldOffset, |
|
327 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
328 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
329 |
} |
|
330 |
||
331 |
@ForceInline |
|
332 |
static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) { |
|
333 |
return UNSAFE.weakCompareAndSwap$Type$Release(handle.base, |
|
334 |
handle.fieldOffset, |
|
335 |
{#if[Object]?handle.fieldType.cast(expected):expected}, |
|
336 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
337 |
} |
|
338 |
||
339 |
@ForceInline |
|
340 |
static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) { |
|
341 |
return UNSAFE.getAndSet$Type$(handle.base, |
|
342 |
handle.fieldOffset, |
|
343 |
{#if[Object]?handle.fieldType.cast(value):value}); |
|
344 |
} |
|
345 |
#end[CAS] |
|
346 |
#if[AtomicAdd] |
|
347 |
||
348 |
@ForceInline |
|
349 |
static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) { |
|
350 |
return UNSAFE.getAndAdd$Type$(handle.base, |
|
351 |
handle.fieldOffset, |
|
352 |
value); |
|
353 |
} |
|
354 |
||
355 |
@ForceInline |
|
356 |
static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) { |
|
357 |
return UNSAFE.getAndAdd$Type$(handle.base, |
|
358 |
handle.fieldOffset, |
|
359 |
value) + value; |
|
360 |
} |
|
361 |
#end[AtomicAdd] |
|
362 |
} |
|
363 |
||
364 |
||
365 |
static final class Array extends VarHandle { |
|
366 |
final int abase; |
|
367 |
final int ashift; |
|
368 |
#if[Object] |
|
369 |
final Class<{#if[Object]??:$type$[]}> arrayType; |
|
370 |
final Class<?> componentType; |
|
371 |
#end[Object] |
|
372 |
||
373 |
Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) { |
|
374 |
super(VarForm.createFromStatic(Array.class), |
|
375 |
{#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class); |
|
376 |
this.abase = abase; |
|
377 |
this.ashift = ashift; |
|
378 |
#if[Object] |
|
379 |
this.arrayType = {#if[Object]?arrayType:$type$[].class}; |
|
380 |
this.componentType = arrayType.getComponentType(); |
|
381 |
#end[Object] |
|
382 |
} |
|
383 |
||
384 |
@ForceInline |
|
385 |
static $type$ get(Array handle, Object oarray, int index) { |
|
386 |
#if[Object] |
|
387 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
388 |
#else[Object] |
|
389 |
$type$[] array = ($type$[]) oarray; |
|
390 |
#end[Object] |
|
391 |
return array[index]; |
|
392 |
} |
|
393 |
||
394 |
@ForceInline |
|
395 |
static void set(Array handle, Object oarray, int index, $type$ value) { |
|
396 |
#if[Object] |
|
397 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
398 |
#else[Object] |
|
399 |
$type$[] array = ($type$[]) oarray; |
|
400 |
#end[Object] |
|
401 |
array[index] = {#if[Object]?handle.componentType.cast(value):value}; |
|
402 |
} |
|
403 |
||
404 |
@ForceInline |
|
405 |
static $type$ getVolatile(Array handle, Object oarray, int index) { |
|
406 |
#if[Object] |
|
407 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
408 |
#else[Object] |
|
409 |
$type$[] array = ($type$[]) oarray; |
|
410 |
#end[Object] |
|
411 |
return UNSAFE.get$Type$Volatile(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
412 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
36934 | 413 |
} |
414 |
||
415 |
@ForceInline |
|
416 |
static void setVolatile(Array handle, Object oarray, int index, $type$ value) { |
|
417 |
#if[Object] |
|
418 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
419 |
#else[Object] |
|
420 |
$type$[] array = ($type$[]) oarray; |
|
421 |
#end[Object] |
|
422 |
UNSAFE.put$Type$Volatile(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
423 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 424 |
{#if[Object]?handle.componentType.cast(value):value}); |
425 |
} |
|
426 |
||
427 |
@ForceInline |
|
428 |
static $type$ getOpaque(Array handle, Object oarray, int index) { |
|
429 |
#if[Object] |
|
430 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
431 |
#else[Object] |
|
432 |
$type$[] array = ($type$[]) oarray; |
|
433 |
#end[Object] |
|
434 |
return UNSAFE.get$Type$Opaque(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
435 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
36934 | 436 |
} |
437 |
||
438 |
@ForceInline |
|
439 |
static void setOpaque(Array handle, Object oarray, int index, $type$ value) { |
|
440 |
#if[Object] |
|
441 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
442 |
#else[Object] |
|
443 |
$type$[] array = ($type$[]) oarray; |
|
444 |
#end[Object] |
|
445 |
UNSAFE.put$Type$Opaque(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
446 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 447 |
{#if[Object]?handle.componentType.cast(value):value}); |
448 |
} |
|
449 |
||
450 |
@ForceInline |
|
451 |
static $type$ getAcquire(Array handle, Object oarray, int index) { |
|
452 |
#if[Object] |
|
453 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
454 |
#else[Object] |
|
455 |
$type$[] array = ($type$[]) oarray; |
|
456 |
#end[Object] |
|
457 |
return UNSAFE.get$Type$Acquire(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
458 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
36934 | 459 |
} |
460 |
||
461 |
@ForceInline |
|
462 |
static void setRelease(Array handle, Object oarray, int index, $type$ value) { |
|
463 |
#if[Object] |
|
464 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
465 |
#else[Object] |
|
466 |
$type$[] array = ($type$[]) oarray; |
|
467 |
#end[Object] |
|
468 |
UNSAFE.put$Type$Release(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
469 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 470 |
{#if[Object]?handle.componentType.cast(value):value}); |
471 |
} |
|
472 |
#if[CAS] |
|
473 |
||
474 |
@ForceInline |
|
475 |
static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
476 |
#if[Object] |
|
477 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
478 |
#else[Object] |
|
479 |
$type$[] array = ($type$[]) oarray; |
|
480 |
#end[Object] |
|
481 |
return UNSAFE.compareAndSwap$Type$(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
482 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 483 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
484 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
485 |
} |
|
486 |
||
487 |
@ForceInline |
|
488 |
static $type$ compareAndExchangeVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
489 |
#if[Object] |
|
490 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
491 |
#else[Object] |
|
492 |
$type$[] array = ($type$[]) oarray; |
|
493 |
#end[Object] |
|
494 |
return UNSAFE.compareAndExchange$Type$Volatile(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
495 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 496 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
497 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
498 |
} |
|
499 |
||
500 |
@ForceInline |
|
501 |
static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
502 |
#if[Object] |
|
503 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
504 |
#else[Object] |
|
505 |
$type$[] array = ($type$[]) oarray; |
|
506 |
#end[Object] |
|
507 |
return UNSAFE.compareAndExchange$Type$Acquire(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
508 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 509 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
510 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
511 |
} |
|
512 |
||
513 |
@ForceInline |
|
514 |
static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
515 |
#if[Object] |
|
516 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
517 |
#else[Object] |
|
518 |
$type$[] array = ($type$[]) oarray; |
|
519 |
#end[Object] |
|
520 |
return UNSAFE.compareAndExchange$Type$Release(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
521 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 522 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
523 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
524 |
} |
|
525 |
||
526 |
@ForceInline |
|
527 |
static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
528 |
#if[Object] |
|
529 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
530 |
#else[Object] |
|
531 |
$type$[] array = ($type$[]) oarray; |
|
532 |
#end[Object] |
|
533 |
return UNSAFE.weakCompareAndSwap$Type$(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
534 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 535 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
536 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
537 |
} |
|
538 |
||
539 |
@ForceInline |
|
540 |
static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
541 |
#if[Object] |
|
542 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
543 |
#else[Object] |
|
544 |
$type$[] array = ($type$[]) oarray; |
|
545 |
#end[Object] |
|
546 |
return UNSAFE.weakCompareAndSwap$Type$Acquire(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
547 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 548 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
549 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
550 |
} |
|
551 |
||
552 |
@ForceInline |
|
553 |
static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) { |
|
554 |
#if[Object] |
|
555 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
556 |
#else[Object] |
|
557 |
$type$[] array = ($type$[]) oarray; |
|
558 |
#end[Object] |
|
559 |
return UNSAFE.weakCompareAndSwap$Type$Release(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
560 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 561 |
{#if[Object]?handle.componentType.cast(expected):expected}, |
562 |
{#if[Object]?handle.componentType.cast(value):value}); |
|
563 |
} |
|
564 |
||
565 |
@ForceInline |
|
566 |
static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) { |
|
567 |
#if[Object] |
|
568 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
569 |
#else[Object] |
|
570 |
$type$[] array = ($type$[]) oarray; |
|
571 |
#end[Object] |
|
572 |
return UNSAFE.getAndSet$Type$(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
573 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 574 |
{#if[Object]?handle.componentType.cast(value):value}); |
575 |
} |
|
576 |
#end[CAS] |
|
577 |
#if[AtomicAdd] |
|
578 |
||
579 |
@ForceInline |
|
580 |
static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) { |
|
581 |
#if[Object] |
|
582 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
583 |
#else[Object] |
|
584 |
$type$[] array = ($type$[]) oarray; |
|
585 |
#end[Object] |
|
586 |
return UNSAFE.getAndAdd$Type$(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
587 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 588 |
value); |
589 |
} |
|
590 |
||
591 |
@ForceInline |
|
592 |
static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { |
|
593 |
#if[Object] |
|
594 |
Object[] array = (Object[]) handle.arrayType.cast(oarray); |
|
595 |
#else[Object] |
|
596 |
$type$[] array = ($type$[]) oarray; |
|
597 |
#end[Object] |
|
598 |
return UNSAFE.getAndAdd$Type$(array, |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
599 |
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
36934 | 600 |
value) + value; |
601 |
} |
|
602 |
#end[AtomicAdd] |
|
603 |
} |
|
604 |
} |