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 |
|
|
27 |
import java.util.Objects;
|
|
28 |
import jdk.internal.vm.annotation.ForceInline;
|
|
29 |
|
|
30 |
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
|
|
31 |
|
|
32 |
#warn
|
|
33 |
|
|
34 |
final class VarHandle$Type$s {
|
|
35 |
|
|
36 |
static class FieldInstanceReadOnly extends VarHandle {
|
|
37 |
final long fieldOffset;
|
|
38 |
final Class<?> receiverType;
|
|
39 |
#if[Object]
|
|
40 |
final Class<?> fieldType;
|
|
41 |
#end[Object]
|
|
42 |
|
|
43 |
FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
|
|
44 |
this(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadOnly.class);
|
|
45 |
}
|
|
46 |
|
|
47 |
protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
|
|
48 |
Class<? extends FieldInstanceReadOnly> handle) {
|
|
49 |
super(VarForm.createFromStatic(handle), receiverType, {#if[Object]?fieldType:$type$.class});
|
|
50 |
this.fieldOffset = fieldOffset;
|
|
51 |
this.receiverType = receiverType;
|
|
52 |
#if[Object]
|
|
53 |
this.fieldType = fieldType;
|
|
54 |
#end[Object]
|
|
55 |
}
|
|
56 |
|
|
57 |
@ForceInline
|
|
58 |
static $type$ get(FieldInstanceReadOnly handle, Object holder) {
|
|
59 |
return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
60 |
handle.fieldOffset);
|
|
61 |
}
|
|
62 |
|
|
63 |
@ForceInline
|
|
64 |
static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) {
|
|
65 |
return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
66 |
handle.fieldOffset);
|
|
67 |
}
|
|
68 |
|
|
69 |
@ForceInline
|
|
70 |
static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) {
|
|
71 |
return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
72 |
handle.fieldOffset);
|
|
73 |
}
|
|
74 |
|
|
75 |
@ForceInline
|
|
76 |
static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) {
|
|
77 |
return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
78 |
handle.fieldOffset);
|
|
79 |
}
|
|
80 |
}
|
|
81 |
|
|
82 |
static class FieldInstanceReadWrite extends FieldInstanceReadOnly {
|
|
83 |
|
|
84 |
FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
|
|
85 |
super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.class);
|
|
86 |
}
|
|
87 |
|
|
88 |
@ForceInline
|
|
89 |
static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
90 |
UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
91 |
handle.fieldOffset,
|
|
92 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
93 |
}
|
|
94 |
|
|
95 |
@ForceInline
|
|
96 |
static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
97 |
UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
98 |
handle.fieldOffset,
|
|
99 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
100 |
}
|
|
101 |
|
|
102 |
@ForceInline
|
|
103 |
static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
104 |
UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
105 |
handle.fieldOffset,
|
|
106 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
107 |
}
|
|
108 |
|
|
109 |
@ForceInline
|
|
110 |
static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
111 |
UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
112 |
handle.fieldOffset,
|
|
113 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
114 |
}
|
|
115 |
#if[CAS]
|
|
116 |
|
|
117 |
@ForceInline
|
|
118 |
static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
119 |
return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
120 |
handle.fieldOffset,
|
|
121 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
122 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
123 |
}
|
|
124 |
|
|
125 |
@ForceInline
|
|
126 |
static $type$ compareAndExchangeVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
127 |
return UNSAFE.compareAndExchange$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
128 |
handle.fieldOffset,
|
|
129 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
130 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
131 |
}
|
|
132 |
|
|
133 |
@ForceInline
|
|
134 |
static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
135 |
return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
136 |
handle.fieldOffset,
|
|
137 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
138 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
139 |
}
|
|
140 |
|
|
141 |
@ForceInline
|
|
142 |
static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
143 |
return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
144 |
handle.fieldOffset,
|
|
145 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
146 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
147 |
}
|
|
148 |
|
|
149 |
@ForceInline
|
|
150 |
static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
151 |
return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
152 |
handle.fieldOffset,
|
|
153 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
154 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
155 |
}
|
|
156 |
|
|
157 |
@ForceInline
|
|
158 |
static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
159 |
return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
160 |
handle.fieldOffset,
|
|
161 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
162 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
163 |
}
|
|
164 |
|
|
165 |
@ForceInline
|
|
166 |
static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
|
|
167 |
return UNSAFE.weakCompareAndSwap$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
168 |
handle.fieldOffset,
|
|
169 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
170 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
171 |
}
|
|
172 |
|
|
173 |
@ForceInline
|
|
174 |
static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
175 |
return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
176 |
handle.fieldOffset,
|
|
177 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
178 |
}
|
|
179 |
#end[CAS]
|
|
180 |
#if[AtomicAdd]
|
|
181 |
|
|
182 |
@ForceInline
|
|
183 |
static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
184 |
return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
185 |
handle.fieldOffset,
|
|
186 |
value);
|
|
187 |
}
|
|
188 |
|
|
189 |
@ForceInline
|
|
190 |
static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
|
|
191 |
return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
|
|
192 |
handle.fieldOffset,
|
|
193 |
value) + value;
|
|
194 |
}
|
|
195 |
#end[AtomicAdd]
|
|
196 |
}
|
|
197 |
|
|
198 |
|
|
199 |
static class FieldStaticReadOnly extends VarHandle {
|
|
200 |
final Object base;
|
|
201 |
final long fieldOffset;
|
|
202 |
#if[Object]
|
|
203 |
final Class<?> fieldType;
|
|
204 |
#end[Object]
|
|
205 |
|
|
206 |
FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
|
|
207 |
this(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.class);
|
|
208 |
}
|
|
209 |
|
|
210 |
protected FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
|
|
211 |
Class<? extends FieldStaticReadOnly> handle) {
|
|
212 |
super(VarForm.createFromStatic(handle), null, {#if[Object]?fieldType:$type$.class});
|
|
213 |
this.base = base;
|
|
214 |
this.fieldOffset = fieldOffset;
|
|
215 |
#if[Object]
|
|
216 |
this.fieldType = fieldType;
|
|
217 |
#end[Object]
|
|
218 |
}
|
|
219 |
|
|
220 |
@ForceInline
|
|
221 |
static $type$ get(FieldStaticReadOnly handle) {
|
|
222 |
return UNSAFE.get$Type$(handle.base,
|
|
223 |
handle.fieldOffset);
|
|
224 |
}
|
|
225 |
|
|
226 |
@ForceInline
|
|
227 |
static $type$ getVolatile(FieldStaticReadOnly handle) {
|
|
228 |
return UNSAFE.get$Type$Volatile(handle.base,
|
|
229 |
handle.fieldOffset);
|
|
230 |
}
|
|
231 |
|
|
232 |
@ForceInline
|
|
233 |
static $type$ getOpaque(FieldStaticReadOnly handle) {
|
|
234 |
return UNSAFE.get$Type$Opaque(handle.base,
|
|
235 |
handle.fieldOffset);
|
|
236 |
}
|
|
237 |
|
|
238 |
@ForceInline
|
|
239 |
static $type$ getAcquire(FieldStaticReadOnly handle) {
|
|
240 |
return UNSAFE.get$Type$Acquire(handle.base,
|
|
241 |
handle.fieldOffset);
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
static class FieldStaticReadWrite extends FieldStaticReadOnly {
|
|
246 |
|
|
247 |
FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
|
|
248 |
super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.class);
|
|
249 |
}
|
|
250 |
|
|
251 |
@ForceInline
|
|
252 |
static void set(FieldStaticReadWrite handle, $type$ value) {
|
|
253 |
UNSAFE.put$Type$(handle.base,
|
|
254 |
handle.fieldOffset,
|
|
255 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
256 |
}
|
|
257 |
|
|
258 |
@ForceInline
|
|
259 |
static void setVolatile(FieldStaticReadWrite handle, $type$ value) {
|
|
260 |
UNSAFE.put$Type$Volatile(handle.base,
|
|
261 |
handle.fieldOffset,
|
|
262 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
263 |
}
|
|
264 |
|
|
265 |
@ForceInline
|
|
266 |
static void setOpaque(FieldStaticReadWrite handle, $type$ value) {
|
|
267 |
UNSAFE.put$Type$Opaque(handle.base,
|
|
268 |
handle.fieldOffset,
|
|
269 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
270 |
}
|
|
271 |
|
|
272 |
@ForceInline
|
|
273 |
static void setRelease(FieldStaticReadWrite handle, $type$ value) {
|
|
274 |
UNSAFE.put$Type$Release(handle.base,
|
|
275 |
handle.fieldOffset,
|
|
276 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
277 |
}
|
|
278 |
#if[CAS]
|
|
279 |
|
|
280 |
@ForceInline
|
|
281 |
static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
282 |
return UNSAFE.compareAndSwap$Type$(handle.base,
|
|
283 |
handle.fieldOffset,
|
|
284 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
285 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
286 |
}
|
|
287 |
|
|
288 |
|
|
289 |
@ForceInline
|
|
290 |
static $type$ compareAndExchangeVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
291 |
return UNSAFE.compareAndExchange$Type$Volatile(handle.base,
|
|
292 |
handle.fieldOffset,
|
|
293 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
294 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
295 |
}
|
|
296 |
|
|
297 |
@ForceInline
|
|
298 |
static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
299 |
return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
|
|
300 |
handle.fieldOffset,
|
|
301 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
302 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
303 |
}
|
|
304 |
|
|
305 |
@ForceInline
|
|
306 |
static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
307 |
return UNSAFE.compareAndExchange$Type$Release(handle.base,
|
|
308 |
handle.fieldOffset,
|
|
309 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
310 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
311 |
}
|
|
312 |
|
|
313 |
@ForceInline
|
|
314 |
static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
315 |
return UNSAFE.weakCompareAndSwap$Type$(handle.base,
|
|
316 |
handle.fieldOffset,
|
|
317 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
318 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
319 |
}
|
|
320 |
|
|
321 |
@ForceInline
|
|
322 |
static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
323 |
return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base,
|
|
324 |
handle.fieldOffset,
|
|
325 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
326 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
327 |
}
|
|
328 |
|
|
329 |
@ForceInline
|
|
330 |
static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
|
|
331 |
return UNSAFE.weakCompareAndSwap$Type$Release(handle.base,
|
|
332 |
handle.fieldOffset,
|
|
333 |
{#if[Object]?handle.fieldType.cast(expected):expected},
|
|
334 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
335 |
}
|
|
336 |
|
|
337 |
@ForceInline
|
|
338 |
static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) {
|
|
339 |
return UNSAFE.getAndSet$Type$(handle.base,
|
|
340 |
handle.fieldOffset,
|
|
341 |
{#if[Object]?handle.fieldType.cast(value):value});
|
|
342 |
}
|
|
343 |
#end[CAS]
|
|
344 |
#if[AtomicAdd]
|
|
345 |
|
|
346 |
@ForceInline
|
|
347 |
static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) {
|
|
348 |
return UNSAFE.getAndAdd$Type$(handle.base,
|
|
349 |
handle.fieldOffset,
|
|
350 |
value);
|
|
351 |
}
|
|
352 |
|
|
353 |
@ForceInline
|
|
354 |
static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) {
|
|
355 |
return UNSAFE.getAndAdd$Type$(handle.base,
|
|
356 |
handle.fieldOffset,
|
|
357 |
value) + value;
|
|
358 |
}
|
|
359 |
#end[AtomicAdd]
|
|
360 |
}
|
|
361 |
|
|
362 |
|
|
363 |
static final class Array extends VarHandle {
|
|
364 |
final int abase;
|
|
365 |
final int ashift;
|
|
366 |
#if[Object]
|
|
367 |
final Class<{#if[Object]??:$type$[]}> arrayType;
|
|
368 |
final Class<?> componentType;
|
|
369 |
#end[Object]
|
|
370 |
|
|
371 |
Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
|
|
372 |
super(VarForm.createFromStatic(Array.class),
|
|
373 |
{#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
|
|
374 |
this.abase = abase;
|
|
375 |
this.ashift = ashift;
|
|
376 |
#if[Object]
|
|
377 |
this.arrayType = {#if[Object]?arrayType:$type$[].class};
|
|
378 |
this.componentType = arrayType.getComponentType();
|
|
379 |
#end[Object]
|
|
380 |
}
|
|
381 |
|
|
382 |
@ForceInline
|
|
383 |
static $type$ get(Array handle, Object oarray, int index) {
|
|
384 |
#if[Object]
|
|
385 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
386 |
#else[Object]
|
|
387 |
$type$[] array = ($type$[]) oarray;
|
|
388 |
#end[Object]
|
|
389 |
return array[index];
|
|
390 |
}
|
|
391 |
|
|
392 |
@ForceInline
|
|
393 |
static void set(Array handle, Object oarray, int index, $type$ value) {
|
|
394 |
#if[Object]
|
|
395 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
396 |
#else[Object]
|
|
397 |
$type$[] array = ($type$[]) oarray;
|
|
398 |
#end[Object]
|
|
399 |
array[index] = {#if[Object]?handle.componentType.cast(value):value};
|
|
400 |
}
|
|
401 |
|
|
402 |
@ForceInline
|
|
403 |
static $type$ getVolatile(Array handle, Object oarray, int index) {
|
|
404 |
#if[Object]
|
|
405 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
406 |
#else[Object]
|
|
407 |
$type$[] array = ($type$[]) oarray;
|
|
408 |
#end[Object]
|
|
409 |
return UNSAFE.get$Type$Volatile(array,
|
|
410 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
|
|
411 |
}
|
|
412 |
|
|
413 |
@ForceInline
|
|
414 |
static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
|
|
415 |
#if[Object]
|
|
416 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
417 |
#else[Object]
|
|
418 |
$type$[] array = ($type$[]) oarray;
|
|
419 |
#end[Object]
|
|
420 |
UNSAFE.put$Type$Volatile(array,
|
|
421 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
422 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
423 |
}
|
|
424 |
|
|
425 |
@ForceInline
|
|
426 |
static $type$ getOpaque(Array handle, Object oarray, int index) {
|
|
427 |
#if[Object]
|
|
428 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
429 |
#else[Object]
|
|
430 |
$type$[] array = ($type$[]) oarray;
|
|
431 |
#end[Object]
|
|
432 |
return UNSAFE.get$Type$Opaque(array,
|
|
433 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
|
|
434 |
}
|
|
435 |
|
|
436 |
@ForceInline
|
|
437 |
static void setOpaque(Array handle, Object oarray, int index, $type$ value) {
|
|
438 |
#if[Object]
|
|
439 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
440 |
#else[Object]
|
|
441 |
$type$[] array = ($type$[]) oarray;
|
|
442 |
#end[Object]
|
|
443 |
UNSAFE.put$Type$Opaque(array,
|
|
444 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
445 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
446 |
}
|
|
447 |
|
|
448 |
@ForceInline
|
|
449 |
static $type$ getAcquire(Array handle, Object oarray, int index) {
|
|
450 |
#if[Object]
|
|
451 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
452 |
#else[Object]
|
|
453 |
$type$[] array = ($type$[]) oarray;
|
|
454 |
#end[Object]
|
|
455 |
return UNSAFE.get$Type$Acquire(array,
|
|
456 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
|
|
457 |
}
|
|
458 |
|
|
459 |
@ForceInline
|
|
460 |
static void setRelease(Array handle, Object oarray, int index, $type$ value) {
|
|
461 |
#if[Object]
|
|
462 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
463 |
#else[Object]
|
|
464 |
$type$[] array = ($type$[]) oarray;
|
|
465 |
#end[Object]
|
|
466 |
UNSAFE.put$Type$Release(array,
|
|
467 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
468 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
469 |
}
|
|
470 |
#if[CAS]
|
|
471 |
|
|
472 |
@ForceInline
|
|
473 |
static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
474 |
#if[Object]
|
|
475 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
476 |
#else[Object]
|
|
477 |
$type$[] array = ($type$[]) oarray;
|
|
478 |
#end[Object]
|
|
479 |
return UNSAFE.compareAndSwap$Type$(array,
|
|
480 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
481 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
482 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
483 |
}
|
|
484 |
|
|
485 |
@ForceInline
|
|
486 |
static $type$ compareAndExchangeVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
487 |
#if[Object]
|
|
488 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
489 |
#else[Object]
|
|
490 |
$type$[] array = ($type$[]) oarray;
|
|
491 |
#end[Object]
|
|
492 |
return UNSAFE.compareAndExchange$Type$Volatile(array,
|
|
493 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
494 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
495 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
496 |
}
|
|
497 |
|
|
498 |
@ForceInline
|
|
499 |
static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
500 |
#if[Object]
|
|
501 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
502 |
#else[Object]
|
|
503 |
$type$[] array = ($type$[]) oarray;
|
|
504 |
#end[Object]
|
|
505 |
return UNSAFE.compareAndExchange$Type$Acquire(array,
|
|
506 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
507 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
508 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
509 |
}
|
|
510 |
|
|
511 |
@ForceInline
|
|
512 |
static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
513 |
#if[Object]
|
|
514 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
515 |
#else[Object]
|
|
516 |
$type$[] array = ($type$[]) oarray;
|
|
517 |
#end[Object]
|
|
518 |
return UNSAFE.compareAndExchange$Type$Release(array,
|
|
519 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
520 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
521 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
522 |
}
|
|
523 |
|
|
524 |
@ForceInline
|
|
525 |
static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
526 |
#if[Object]
|
|
527 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
528 |
#else[Object]
|
|
529 |
$type$[] array = ($type$[]) oarray;
|
|
530 |
#end[Object]
|
|
531 |
return UNSAFE.weakCompareAndSwap$Type$(array,
|
|
532 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
533 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
534 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
535 |
}
|
|
536 |
|
|
537 |
@ForceInline
|
|
538 |
static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
539 |
#if[Object]
|
|
540 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
541 |
#else[Object]
|
|
542 |
$type$[] array = ($type$[]) oarray;
|
|
543 |
#end[Object]
|
|
544 |
return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
|
|
545 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
546 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
547 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
548 |
}
|
|
549 |
|
|
550 |
@ForceInline
|
|
551 |
static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
|
|
552 |
#if[Object]
|
|
553 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
554 |
#else[Object]
|
|
555 |
$type$[] array = ($type$[]) oarray;
|
|
556 |
#end[Object]
|
|
557 |
return UNSAFE.weakCompareAndSwap$Type$Release(array,
|
|
558 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
559 |
{#if[Object]?handle.componentType.cast(expected):expected},
|
|
560 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
561 |
}
|
|
562 |
|
|
563 |
@ForceInline
|
|
564 |
static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
|
|
565 |
#if[Object]
|
|
566 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
567 |
#else[Object]
|
|
568 |
$type$[] array = ($type$[]) oarray;
|
|
569 |
#end[Object]
|
|
570 |
return UNSAFE.getAndSet$Type$(array,
|
|
571 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
572 |
{#if[Object]?handle.componentType.cast(value):value});
|
|
573 |
}
|
|
574 |
#end[CAS]
|
|
575 |
#if[AtomicAdd]
|
|
576 |
|
|
577 |
@ForceInline
|
|
578 |
static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
|
|
579 |
#if[Object]
|
|
580 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
581 |
#else[Object]
|
|
582 |
$type$[] array = ($type$[]) oarray;
|
|
583 |
#end[Object]
|
|
584 |
return UNSAFE.getAndAdd$Type$(array,
|
|
585 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
586 |
value);
|
|
587 |
}
|
|
588 |
|
|
589 |
@ForceInline
|
|
590 |
static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) {
|
|
591 |
#if[Object]
|
|
592 |
Object[] array = (Object[]) handle.arrayType.cast(oarray);
|
|
593 |
#else[Object]
|
|
594 |
$type$[] array = ($type$[]) oarray;
|
|
595 |
#end[Object]
|
|
596 |
return UNSAFE.getAndAdd$Type$(array,
|
|
597 |
(((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
|
598 |
value) + value;
|
|
599 |
}
|
|
600 |
#end[AtomicAdd]
|
|
601 |
}
|
|
602 |
}
|