1
25 package java.lang.invoke;
26
27 import jdk.internal.util.Preconditions;
28 import jdk.internal.vm.annotation.ForceInline;
29
30 import java.util.Objects;
31
32 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
33
34
35
36 final class VarHandleLongs {
37
38 static class FieldInstanceReadOnly extends VarHandle {
39 final long fieldOffset;
40 final Class<?> receiverType;
41
42 FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset) {
43 this(receiverType, fieldOffset, FieldInstanceReadOnly.FORM);
44 }
45
46 protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset,
47 VarForm form) {
48 super(form);
49 this.fieldOffset = fieldOffset;
50 this.receiverType = receiverType;
51 }
52
53 @Override
54 final MethodType accessModeTypeUncached(AccessMode accessMode) {
55 return accessMode.at.accessModeType(receiverType, long.class);
56 }
57
58 @ForceInline
59 static long get(FieldInstanceReadOnly handle, Object holder) {
60 return UNSAFE.getLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
61 handle.fieldOffset);
62 }
63
64 @ForceInline
65 static long getVolatile(FieldInstanceReadOnly handle, Object holder) {
66 return UNSAFE.getLongVolatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
67 handle.fieldOffset);
68 }
69
70 @ForceInline
71 static long getOpaque(FieldInstanceReadOnly handle, Object holder) {
72 return UNSAFE.getLongOpaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
73 handle.fieldOffset);
74 }
75
76 @ForceInline
77 static long getAcquire(FieldInstanceReadOnly handle, Object holder) {
78 return UNSAFE.getLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
79 handle.fieldOffset);
80 }
81
82 static final VarForm FORM = new VarForm(FieldInstanceReadOnly.class, Object.class, long.class);
83 }
84
85 static final class FieldInstanceReadWrite extends FieldInstanceReadOnly {
86
87 FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset) {
88 super(receiverType, fieldOffset, FieldInstanceReadWrite.FORM);
89 }
90
91 @ForceInline
92 static void set(FieldInstanceReadWrite handle, Object holder, long value) {
93 UNSAFE.putLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
94 handle.fieldOffset,
95 value);
96 }
97
98 @ForceInline
99 static void setVolatile(FieldInstanceReadWrite handle, Object holder, long value) {
100 UNSAFE.putLongVolatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
101 handle.fieldOffset,
102 value);
103 }
104
105 @ForceInline
106 static void setOpaque(FieldInstanceReadWrite handle, Object holder, long value) {
107 UNSAFE.putLongOpaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
108 handle.fieldOffset,
109 value);
110 }
111
112 @ForceInline
113 static void setRelease(FieldInstanceReadWrite handle, Object holder, long value) {
114 UNSAFE.putLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
115 handle.fieldOffset,
116 value);
117 }
118
119 @ForceInline
120 static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
121 return UNSAFE.compareAndSetLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
122 handle.fieldOffset,
123 expected,
124 value);
125 }
126
127 @ForceInline
128 static long compareAndExchange(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
129 return UNSAFE.compareAndExchangeLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
130 handle.fieldOffset,
131 expected,
132 value);
133 }
134
135 @ForceInline
136 static long compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
137 return UNSAFE.compareAndExchangeLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
138 handle.fieldOffset,
139 expected,
140 value);
141 }
142
143 @ForceInline
144 static long compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
145 return UNSAFE.compareAndExchangeLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
146 handle.fieldOffset,
147 expected,
148 value);
149 }
150
151 @ForceInline
152 static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
153 return UNSAFE.weakCompareAndSetLongPlain(Objects.requireNonNull(handle.receiverType.cast(holder)),
154 handle.fieldOffset,
155 expected,
156 value);
157 }
158
159 @ForceInline
160 static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
161 return UNSAFE.weakCompareAndSetLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
162 handle.fieldOffset,
163 expected,
164 value);
165 }
166
167 @ForceInline
168 static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
169 return UNSAFE.weakCompareAndSetLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
170 handle.fieldOffset,
171 expected,
172 value);
173 }
174
175 @ForceInline
176 static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, long expected, long value) {
177 return UNSAFE.weakCompareAndSetLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
178 handle.fieldOffset,
179 expected,
180 value);
181 }
182
183 @ForceInline
184 static long getAndSet(FieldInstanceReadWrite handle, Object holder, long value) {
185 return UNSAFE.getAndSetLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
186 handle.fieldOffset,
187 value);
188 }
189
190 @ForceInline
191 static long getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, long value) {
192 return UNSAFE.getAndSetLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
193 handle.fieldOffset,
194 value);
195 }
196
197 @ForceInline
198 static long getAndSetRelease(FieldInstanceReadWrite handle, Object holder, long value) {
199 return UNSAFE.getAndSetLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
200 handle.fieldOffset,
201 value);
202 }
203
204 @ForceInline
205 static long getAndAdd(FieldInstanceReadWrite handle, Object holder, long value) {
206 return UNSAFE.getAndAddLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
207 handle.fieldOffset,
208 value);
209 }
210
211 @ForceInline
212 static long getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, long value) {
213 return UNSAFE.getAndAddLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
214 handle.fieldOffset,
215 value);
216 }
217
218 @ForceInline
219 static long getAndAddRelease(FieldInstanceReadWrite handle, Object holder, long value) {
220 return UNSAFE.getAndAddLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
221 handle.fieldOffset,
222 value);
223 }
224
225
226 @ForceInline
227 static long getAndBitwiseOr(FieldInstanceReadWrite handle, Object holder, long value) {
228 return UNSAFE.getAndBitwiseOrLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
229 handle.fieldOffset,
230 value);
231 }
232
233 @ForceInline
234 static long getAndBitwiseOrRelease(FieldInstanceReadWrite handle, Object holder, long value) {
235 return UNSAFE.getAndBitwiseOrLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
236 handle.fieldOffset,
237 value);
238 }
239
240 @ForceInline
241 static long getAndBitwiseOrAcquire(FieldInstanceReadWrite handle, Object holder, long value) {
242 return UNSAFE.getAndBitwiseOrLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
243 handle.fieldOffset,
244 value);
245 }
246
247 @ForceInline
248 static long getAndBitwiseAnd(FieldInstanceReadWrite handle, Object holder, long value) {
249 return UNSAFE.getAndBitwiseAndLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
250 handle.fieldOffset,
251 value);
252 }
253
254 @ForceInline
255 static long getAndBitwiseAndRelease(FieldInstanceReadWrite handle, Object holder, long value) {
256 return UNSAFE.getAndBitwiseAndLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
257 handle.fieldOffset,
258 value);
259 }
260
261 @ForceInline
262 static long getAndBitwiseAndAcquire(FieldInstanceReadWrite handle, Object holder, long value) {
263 return UNSAFE.getAndBitwiseAndLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
264 handle.fieldOffset,
265 value);
266 }
267
268 @ForceInline
269 static long getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, long value) {
270 return UNSAFE.getAndBitwiseXorLong(Objects.requireNonNull(handle.receiverType.cast(holder)),
271 handle.fieldOffset,
272 value);
273 }
274
275 @ForceInline
276 static long getAndBitwiseXorRelease(FieldInstanceReadWrite handle, Object holder, long value) {
277 return UNSAFE.getAndBitwiseXorLongRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
278 handle.fieldOffset,
279 value);
280 }
281
282 @ForceInline
283 static long getAndBitwiseXorAcquire(FieldInstanceReadWrite handle, Object holder, long value) {
284 return UNSAFE.getAndBitwiseXorLongAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
285 handle.fieldOffset,
286 value);
287 }
288
289 static final VarForm FORM = new VarForm(FieldInstanceReadWrite.class, Object.class, long.class);
290 }
291
292
293 static class FieldStaticReadOnly extends VarHandle {
294 final Object base;
295 final long fieldOffset;
296
297 FieldStaticReadOnly(Object base, long fieldOffset) {
298 this(base, fieldOffset, FieldStaticReadOnly.FORM);
299 }
300
301 protected FieldStaticReadOnly(Object base, long fieldOffset,
302 VarForm form) {
303 super(form);
304 this.base = base;
305 this.fieldOffset = fieldOffset;
306 }
307
308 @Override
309 final MethodType accessModeTypeUncached(AccessMode accessMode) {
310 return accessMode.at.accessModeType(null, long.class);
311 }
312
313 @ForceInline
314 static long get(FieldStaticReadOnly handle) {
315 return UNSAFE.getLong(handle.base,
316 handle.fieldOffset);
317 }
318
319 @ForceInline
320 static long getVolatile(FieldStaticReadOnly handle) {
321 return UNSAFE.getLongVolatile(handle.base,
322 handle.fieldOffset);
323 }
324
325 @ForceInline
326 static long getOpaque(FieldStaticReadOnly handle) {
327 return UNSAFE.getLongOpaque(handle.base,
328 handle.fieldOffset);
329 }
330
331 @ForceInline
332 static long getAcquire(FieldStaticReadOnly handle) {
333 return UNSAFE.getLongAcquire(handle.base,
334 handle.fieldOffset);
335 }
336
337 static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, long.class);
338 }
339
340 static final class FieldStaticReadWrite extends FieldStaticReadOnly {
341
342 FieldStaticReadWrite(Object base, long fieldOffset) {
343 super(base, fieldOffset, FieldStaticReadWrite.FORM);
344 }
345
346 @ForceInline
347 static void set(FieldStaticReadWrite handle, long value) {
348 UNSAFE.putLong(handle.base,
349 handle.fieldOffset,
350 value);
351 }
352
353 @ForceInline
354 static void setVolatile(FieldStaticReadWrite handle, long value) {
355 UNSAFE.putLongVolatile(handle.base,
356 handle.fieldOffset,
357 value);
358 }
359
360 @ForceInline
361 static void setOpaque(FieldStaticReadWrite handle, long value) {
362 UNSAFE.putLongOpaque(handle.base,
363 handle.fieldOffset,
364 value);
365 }
366
367 @ForceInline
368 static void setRelease(FieldStaticReadWrite handle, long value) {
369 UNSAFE.putLongRelease(handle.base,
370 handle.fieldOffset,
371 value);
372 }
373
374 @ForceInline
375 static boolean compareAndSet(FieldStaticReadWrite handle, long expected, long value) {
376 return UNSAFE.compareAndSetLong(handle.base,
377 handle.fieldOffset,
378 expected,
379 value);
380 }
381
382
383 @ForceInline
384 static long compareAndExchange(FieldStaticReadWrite handle, long expected, long value) {
385 return UNSAFE.compareAndExchangeLong(handle.base,
386 handle.fieldOffset,
387 expected,
388 value);
389 }
390
391 @ForceInline
392 static long compareAndExchangeAcquire(FieldStaticReadWrite handle, long expected, long value) {
393 return UNSAFE.compareAndExchangeLongAcquire(handle.base,
394 handle.fieldOffset,
395 expected,
396 value);
397 }
398
399 @ForceInline
400 static long compareAndExchangeRelease(FieldStaticReadWrite handle, long expected, long value) {
401 return UNSAFE.compareAndExchangeLongRelease(handle.base,
402 handle.fieldOffset,
403 expected,
404 value);
405 }
406
407 @ForceInline
408 static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, long expected, long value) {
409 return UNSAFE.weakCompareAndSetLongPlain(handle.base,
410 handle.fieldOffset,
411 expected,
412 value);
413 }
414
415 @ForceInline
416 static boolean weakCompareAndSet(FieldStaticReadWrite handle, long expected, long value) {
417 return UNSAFE.weakCompareAndSetLong(handle.base,
418 handle.fieldOffset,
419 expected,
420 value);
421 }
422
423 @ForceInline
424 static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, long expected, long value) {
425 return UNSAFE.weakCompareAndSetLongAcquire(handle.base,
426 handle.fieldOffset,
427 expected,
428 value);
429 }
430
431 @ForceInline
432 static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, long expected, long value) {
433 return UNSAFE.weakCompareAndSetLongRelease(handle.base,
434 handle.fieldOffset,
435 expected,
436 value);
437 }
438
439 @ForceInline
440 static long getAndSet(FieldStaticReadWrite handle, long value) {
441 return UNSAFE.getAndSetLong(handle.base,
442 handle.fieldOffset,
443 value);
444 }
445
446 @ForceInline
447 static long getAndSetAcquire(FieldStaticReadWrite handle, long value) {
448 return UNSAFE.getAndSetLongAcquire(handle.base,
449 handle.fieldOffset,
450 value);
451 }
452
453 @ForceInline
454 static long getAndSetRelease(FieldStaticReadWrite handle, long value) {
455 return UNSAFE.getAndSetLongRelease(handle.base,
456 handle.fieldOffset,
457 value);
458 }
459
460 @ForceInline
461 static long getAndAdd(FieldStaticReadWrite handle, long value) {
462 return UNSAFE.getAndAddLong(handle.base,
463 handle.fieldOffset,
464 value);
465 }
466
467 @ForceInline
468 static long getAndAddAcquire(FieldStaticReadWrite handle, long value) {
469 return UNSAFE.getAndAddLongAcquire(handle.base,
470 handle.fieldOffset,
471 value);
472 }
473
474 @ForceInline
475 static long getAndAddRelease(FieldStaticReadWrite handle, long value) {
476 return UNSAFE.getAndAddLongRelease(handle.base,
477 handle.fieldOffset,
478 value);
479 }
480
481 @ForceInline
482 static long getAndBitwiseOr(FieldStaticReadWrite handle, long value) {
483 return UNSAFE.getAndBitwiseOrLong(handle.base,
484 handle.fieldOffset,
485 value);
486 }
487
488 @ForceInline
489 static long getAndBitwiseOrRelease(FieldStaticReadWrite handle, long value) {
490 return UNSAFE.getAndBitwiseOrLongRelease(handle.base,
491 handle.fieldOffset,
492 value);
493 }
494
495 @ForceInline
496 static long getAndBitwiseOrAcquire(FieldStaticReadWrite handle, long value) {
497 return UNSAFE.getAndBitwiseOrLongAcquire(handle.base,
498 handle.fieldOffset,
499 value);
500 }
501
502 @ForceInline
503 static long getAndBitwiseAnd(FieldStaticReadWrite handle, long value) {
504 return UNSAFE.getAndBitwiseAndLong(handle.base,
505 handle.fieldOffset,
506 value);
507 }
508
509 @ForceInline
510 static long getAndBitwiseAndRelease(FieldStaticReadWrite handle, long value) {
511 return UNSAFE.getAndBitwiseAndLongRelease(handle.base,
512 handle.fieldOffset,
513 value);
514 }
515
516 @ForceInline
517 static long getAndBitwiseAndAcquire(FieldStaticReadWrite handle, long value) {
518 return UNSAFE.getAndBitwiseAndLongAcquire(handle.base,
519 handle.fieldOffset,
520 value);
521 }
522
523 @ForceInline
524 static long getAndBitwiseXor(FieldStaticReadWrite handle, long value) {
525 return UNSAFE.getAndBitwiseXorLong(handle.base,
526 handle.fieldOffset,
527 value);
528 }
529
530 @ForceInline
531 static long getAndBitwiseXorRelease(FieldStaticReadWrite handle, long value) {
532 return UNSAFE.getAndBitwiseXorLongRelease(handle.base,
533 handle.fieldOffset,
534 value);
535 }
536
537 @ForceInline
538 static long getAndBitwiseXorAcquire(FieldStaticReadWrite handle, long value) {
539 return UNSAFE.getAndBitwiseXorLongAcquire(handle.base,
540 handle.fieldOffset,
541 value);
542 }
543
544 static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, long.class);
545 }
546
547
548 static final class Array extends VarHandle {
549 final int abase;
550 final int ashift;
551
552 Array(int abase, int ashift) {
553 super(Array.FORM);
554 this.abase = abase;
555 this.ashift = ashift;
556 }
557
558 @Override
559 final MethodType accessModeTypeUncached(AccessMode accessMode) {
560 return accessMode.at.accessModeType(long[].class, long.class, int.class);
561 }
562
563
564 @ForceInline
565 static long get(Array handle, Object oarray, int index) {
566 long[] array = (long[]) oarray;
567 return array[index];
568 }
569
570 @ForceInline
571 static void set(Array handle, Object oarray, int index, long value) {
572 long[] array = (long[]) oarray;
573 array[index] = value;
574 }
575
576 @ForceInline
577 static long getVolatile(Array handle, Object oarray, int index) {
578 long[] array = (long[]) oarray;
579 return UNSAFE.getLongVolatile(array,
580 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
581 }
582
583 @ForceInline
584 static void setVolatile(Array handle, Object oarray, int index, long value) {
585 long[] array = (long[]) oarray;
586 UNSAFE.putLongVolatile(array,
587 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
588 value);
589 }
590
591 @ForceInline
592 static long getOpaque(Array handle, Object oarray, int index) {
593 long[] array = (long[]) oarray;
594 return UNSAFE.getLongOpaque(array,
595 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
596 }
597
598 @ForceInline
599 static void setOpaque(Array handle, Object oarray, int index, long value) {
600 long[] array = (long[]) oarray;
601 UNSAFE.putLongOpaque(array,
602 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
603 value);
604 }
605
606 @ForceInline
607 static long getAcquire(Array handle, Object oarray, int index) {
608 long[] array = (long[]) oarray;
609 return UNSAFE.getLongAcquire(array,
610 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
611 }
612
613 @ForceInline
614 static void setRelease(Array handle, Object oarray, int index, long value) {
615 long[] array = (long[]) oarray;
616 UNSAFE.putLongRelease(array,
617 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
618 value);
619 }
620
621 @ForceInline
622 static boolean compareAndSet(Array handle, Object oarray, int index, long expected, long value) {
623 long[] array = (long[]) oarray;
624 return UNSAFE.compareAndSetLong(array,
625 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
626 expected,
627 value);
628 }
629
630 @ForceInline
631 static long compareAndExchange(Array handle, Object oarray, int index, long expected, long value) {
632 long[] array = (long[]) oarray;
633 return UNSAFE.compareAndExchangeLong(array,
634 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
635 expected,
636 value);
637 }
638
639 @ForceInline
640 static long compareAndExchangeAcquire(Array handle, Object oarray, int index, long expected, long value) {
641 long[] array = (long[]) oarray;
642 return UNSAFE.compareAndExchangeLongAcquire(array,
643 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
644 expected,
645 value);
646 }
647
648 @ForceInline
649 static long compareAndExchangeRelease(Array handle, Object oarray, int index, long expected, long value) {
650 long[] array = (long[]) oarray;
651 return UNSAFE.compareAndExchangeLongRelease(array,
652 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
653 expected,
654 value);
655 }
656
657 @ForceInline
658 static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, long expected, long value) {
659 long[] array = (long[]) oarray;
660 return UNSAFE.weakCompareAndSetLongPlain(array,
661 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
662 expected,
663 value);
664 }
665
666 @ForceInline
667 static boolean weakCompareAndSet(Array handle, Object oarray, int index, long expected, long value) {
668 long[] array = (long[]) oarray;
669 return UNSAFE.weakCompareAndSetLong(array,
670 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
671 expected,
672 value);
673 }
674
675 @ForceInline
676 static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, long expected, long value) {
677 long[] array = (long[]) oarray;
678 return UNSAFE.weakCompareAndSetLongAcquire(array,
679 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
680 expected,
681 value);
682 }
683
684 @ForceInline
685 static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, long expected, long value) {
686 long[] array = (long[]) oarray;
687 return UNSAFE.weakCompareAndSetLongRelease(array,
688 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
689 expected,
690 value);
691 }
692
693 @ForceInline
694 static long getAndSet(Array handle, Object oarray, int index, long value) {
695 long[] array = (long[]) oarray;
696 return UNSAFE.getAndSetLong(array,
697 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
698 value);
699 }
700
701 @ForceInline
702 static long getAndSetAcquire(Array handle, Object oarray, int index, long value) {
703 long[] array = (long[]) oarray;
704 return UNSAFE.getAndSetLongAcquire(array,
705 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
706 value);
707 }
708
709 @ForceInline
710 static long getAndSetRelease(Array handle, Object oarray, int index, long value) {
711 long[] array = (long[]) oarray;
712 return UNSAFE.getAndSetLongRelease(array,
713 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
714 value);
715 }
716
717 @ForceInline
718 static long getAndAdd(Array handle, Object oarray, int index, long value) {
719 long[] array = (long[]) oarray;
720 return UNSAFE.getAndAddLong(array,
721 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
722 value);
723 }
724
725 @ForceInline
726 static long getAndAddAcquire(Array handle, Object oarray, int index, long value) {
727 long[] array = (long[]) oarray;
728 return UNSAFE.getAndAddLongAcquire(array,
729 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
730 value);
731 }
732
733 @ForceInline
734 static long getAndAddRelease(Array handle, Object oarray, int index, long value) {
735 long[] array = (long[]) oarray;
736 return UNSAFE.getAndAddLongRelease(array,
737 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
738 value);
739 }
740
741 @ForceInline
742 static long getAndBitwiseOr(Array handle, Object oarray, int index, long value) {
743 long[] array = (long[]) oarray;
744 return UNSAFE.getAndBitwiseOrLong(array,
745 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
746 value);
747 }
748
749 @ForceInline
750 static long getAndBitwiseOrRelease(Array handle, Object oarray, int index, long value) {
751 long[] array = (long[]) oarray;
752 return UNSAFE.getAndBitwiseOrLongRelease(array,
753 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
754 value);
755 }
756
757 @ForceInline
758 static long getAndBitwiseOrAcquire(Array handle, Object oarray, int index, long value) {
759 long[] array = (long[]) oarray;
760 return UNSAFE.getAndBitwiseOrLongAcquire(array,
761 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
762 value);
763 }
764
765 @ForceInline
766 static long getAndBitwiseAnd(Array handle, Object oarray, int index, long value) {
767 long[] array = (long[]) oarray;
768 return UNSAFE.getAndBitwiseAndLong(array,
769 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
770 value);
771 }
772
773 @ForceInline
774 static long getAndBitwiseAndRelease(Array handle, Object oarray, int index, long value) {
775 long[] array = (long[]) oarray;
776 return UNSAFE.getAndBitwiseAndLongRelease(array,
777 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
778 value);
779 }
780
781 @ForceInline
782 static long getAndBitwiseAndAcquire(Array handle, Object oarray, int index, long value) {
783 long[] array = (long[]) oarray;
784 return UNSAFE.getAndBitwiseAndLongAcquire(array,
785 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
786 value);
787 }
788
789 @ForceInline
790 static long getAndBitwiseXor(Array handle, Object oarray, int index, long value) {
791 long[] array = (long[]) oarray;
792 return UNSAFE.getAndBitwiseXorLong(array,
793 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
794 value);
795 }
796
797 @ForceInline
798 static long getAndBitwiseXorRelease(Array handle, Object oarray, int index, long value) {
799 long[] array = (long[]) oarray;
800 return UNSAFE.getAndBitwiseXorLongRelease(array,
801 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
802 value);
803 }
804
805 @ForceInline
806 static long getAndBitwiseXorAcquire(Array handle, Object oarray, int index, long value) {
807 long[] array = (long[]) oarray;
808 return UNSAFE.getAndBitwiseXorLongAcquire(array,
809 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
810 value);
811 }
812
813 static final VarForm FORM = new VarForm(Array.class, long[].class, long.class, int.class);
814 }
815 }
816