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 VarHandleInts {
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, int.class);
56 }
57
58 @ForceInline
59 static int get(FieldInstanceReadOnly handle, Object holder) {
60 return UNSAFE.getInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
61 handle.fieldOffset);
62 }
63
64 @ForceInline
65 static int getVolatile(FieldInstanceReadOnly handle, Object holder) {
66 return UNSAFE.getIntVolatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
67 handle.fieldOffset);
68 }
69
70 @ForceInline
71 static int getOpaque(FieldInstanceReadOnly handle, Object holder) {
72 return UNSAFE.getIntOpaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
73 handle.fieldOffset);
74 }
75
76 @ForceInline
77 static int getAcquire(FieldInstanceReadOnly handle, Object holder) {
78 return UNSAFE.getIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
79 handle.fieldOffset);
80 }
81
82 static final VarForm FORM = new VarForm(FieldInstanceReadOnly.class, Object.class, int.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, int value) {
93 UNSAFE.putInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
94 handle.fieldOffset,
95 value);
96 }
97
98 @ForceInline
99 static void setVolatile(FieldInstanceReadWrite handle, Object holder, int value) {
100 UNSAFE.putIntVolatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
101 handle.fieldOffset,
102 value);
103 }
104
105 @ForceInline
106 static void setOpaque(FieldInstanceReadWrite handle, Object holder, int value) {
107 UNSAFE.putIntOpaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
108 handle.fieldOffset,
109 value);
110 }
111
112 @ForceInline
113 static void setRelease(FieldInstanceReadWrite handle, Object holder, int value) {
114 UNSAFE.putIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
115 handle.fieldOffset,
116 value);
117 }
118
119 @ForceInline
120 static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, int expected, int value) {
121 return UNSAFE.compareAndSetInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
122 handle.fieldOffset,
123 expected,
124 value);
125 }
126
127 @ForceInline
128 static int compareAndExchange(FieldInstanceReadWrite handle, Object holder, int expected, int value) {
129 return UNSAFE.compareAndExchangeInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
130 handle.fieldOffset,
131 expected,
132 value);
133 }
134
135 @ForceInline
136 static int compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, int expected, int value) {
137 return UNSAFE.compareAndExchangeIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
138 handle.fieldOffset,
139 expected,
140 value);
141 }
142
143 @ForceInline
144 static int compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, int expected, int value) {
145 return UNSAFE.compareAndExchangeIntRelease(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, int expected, int value) {
153 return UNSAFE.weakCompareAndSetIntPlain(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, int expected, int value) {
161 return UNSAFE.weakCompareAndSetInt(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, int expected, int value) {
169 return UNSAFE.weakCompareAndSetIntAcquire(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, int expected, int value) {
177 return UNSAFE.weakCompareAndSetIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
178 handle.fieldOffset,
179 expected,
180 value);
181 }
182
183 @ForceInline
184 static int getAndSet(FieldInstanceReadWrite handle, Object holder, int value) {
185 return UNSAFE.getAndSetInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
186 handle.fieldOffset,
187 value);
188 }
189
190 @ForceInline
191 static int getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, int value) {
192 return UNSAFE.getAndSetIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
193 handle.fieldOffset,
194 value);
195 }
196
197 @ForceInline
198 static int getAndSetRelease(FieldInstanceReadWrite handle, Object holder, int value) {
199 return UNSAFE.getAndSetIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
200 handle.fieldOffset,
201 value);
202 }
203
204 @ForceInline
205 static int getAndAdd(FieldInstanceReadWrite handle, Object holder, int value) {
206 return UNSAFE.getAndAddInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
207 handle.fieldOffset,
208 value);
209 }
210
211 @ForceInline
212 static int getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, int value) {
213 return UNSAFE.getAndAddIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
214 handle.fieldOffset,
215 value);
216 }
217
218 @ForceInline
219 static int getAndAddRelease(FieldInstanceReadWrite handle, Object holder, int value) {
220 return UNSAFE.getAndAddIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
221 handle.fieldOffset,
222 value);
223 }
224
225
226 @ForceInline
227 static int getAndBitwiseOr(FieldInstanceReadWrite handle, Object holder, int value) {
228 return UNSAFE.getAndBitwiseOrInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
229 handle.fieldOffset,
230 value);
231 }
232
233 @ForceInline
234 static int getAndBitwiseOrRelease(FieldInstanceReadWrite handle, Object holder, int value) {
235 return UNSAFE.getAndBitwiseOrIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
236 handle.fieldOffset,
237 value);
238 }
239
240 @ForceInline
241 static int getAndBitwiseOrAcquire(FieldInstanceReadWrite handle, Object holder, int value) {
242 return UNSAFE.getAndBitwiseOrIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
243 handle.fieldOffset,
244 value);
245 }
246
247 @ForceInline
248 static int getAndBitwiseAnd(FieldInstanceReadWrite handle, Object holder, int value) {
249 return UNSAFE.getAndBitwiseAndInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
250 handle.fieldOffset,
251 value);
252 }
253
254 @ForceInline
255 static int getAndBitwiseAndRelease(FieldInstanceReadWrite handle, Object holder, int value) {
256 return UNSAFE.getAndBitwiseAndIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
257 handle.fieldOffset,
258 value);
259 }
260
261 @ForceInline
262 static int getAndBitwiseAndAcquire(FieldInstanceReadWrite handle, Object holder, int value) {
263 return UNSAFE.getAndBitwiseAndIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
264 handle.fieldOffset,
265 value);
266 }
267
268 @ForceInline
269 static int getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, int value) {
270 return UNSAFE.getAndBitwiseXorInt(Objects.requireNonNull(handle.receiverType.cast(holder)),
271 handle.fieldOffset,
272 value);
273 }
274
275 @ForceInline
276 static int getAndBitwiseXorRelease(FieldInstanceReadWrite handle, Object holder, int value) {
277 return UNSAFE.getAndBitwiseXorIntRelease(Objects.requireNonNull(handle.receiverType.cast(holder)),
278 handle.fieldOffset,
279 value);
280 }
281
282 @ForceInline
283 static int getAndBitwiseXorAcquire(FieldInstanceReadWrite handle, Object holder, int value) {
284 return UNSAFE.getAndBitwiseXorIntAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
285 handle.fieldOffset,
286 value);
287 }
288
289 static final VarForm FORM = new VarForm(FieldInstanceReadWrite.class, Object.class, int.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, int.class);
311 }
312
313 @ForceInline
314 static int get(FieldStaticReadOnly handle) {
315 return UNSAFE.getInt(handle.base,
316 handle.fieldOffset);
317 }
318
319 @ForceInline
320 static int getVolatile(FieldStaticReadOnly handle) {
321 return UNSAFE.getIntVolatile(handle.base,
322 handle.fieldOffset);
323 }
324
325 @ForceInline
326 static int getOpaque(FieldStaticReadOnly handle) {
327 return UNSAFE.getIntOpaque(handle.base,
328 handle.fieldOffset);
329 }
330
331 @ForceInline
332 static int getAcquire(FieldStaticReadOnly handle) {
333 return UNSAFE.getIntAcquire(handle.base,
334 handle.fieldOffset);
335 }
336
337 static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, int.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, int value) {
348 UNSAFE.putInt(handle.base,
349 handle.fieldOffset,
350 value);
351 }
352
353 @ForceInline
354 static void setVolatile(FieldStaticReadWrite handle, int value) {
355 UNSAFE.putIntVolatile(handle.base,
356 handle.fieldOffset,
357 value);
358 }
359
360 @ForceInline
361 static void setOpaque(FieldStaticReadWrite handle, int value) {
362 UNSAFE.putIntOpaque(handle.base,
363 handle.fieldOffset,
364 value);
365 }
366
367 @ForceInline
368 static void setRelease(FieldStaticReadWrite handle, int value) {
369 UNSAFE.putIntRelease(handle.base,
370 handle.fieldOffset,
371 value);
372 }
373
374 @ForceInline
375 static boolean compareAndSet(FieldStaticReadWrite handle, int expected, int value) {
376 return UNSAFE.compareAndSetInt(handle.base,
377 handle.fieldOffset,
378 expected,
379 value);
380 }
381
382
383 @ForceInline
384 static int compareAndExchange(FieldStaticReadWrite handle, int expected, int value) {
385 return UNSAFE.compareAndExchangeInt(handle.base,
386 handle.fieldOffset,
387 expected,
388 value);
389 }
390
391 @ForceInline
392 static int compareAndExchangeAcquire(FieldStaticReadWrite handle, int expected, int value) {
393 return UNSAFE.compareAndExchangeIntAcquire(handle.base,
394 handle.fieldOffset,
395 expected,
396 value);
397 }
398
399 @ForceInline
400 static int compareAndExchangeRelease(FieldStaticReadWrite handle, int expected, int value) {
401 return UNSAFE.compareAndExchangeIntRelease(handle.base,
402 handle.fieldOffset,
403 expected,
404 value);
405 }
406
407 @ForceInline
408 static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, int expected, int value) {
409 return UNSAFE.weakCompareAndSetIntPlain(handle.base,
410 handle.fieldOffset,
411 expected,
412 value);
413 }
414
415 @ForceInline
416 static boolean weakCompareAndSet(FieldStaticReadWrite handle, int expected, int value) {
417 return UNSAFE.weakCompareAndSetInt(handle.base,
418 handle.fieldOffset,
419 expected,
420 value);
421 }
422
423 @ForceInline
424 static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, int expected, int value) {
425 return UNSAFE.weakCompareAndSetIntAcquire(handle.base,
426 handle.fieldOffset,
427 expected,
428 value);
429 }
430
431 @ForceInline
432 static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, int expected, int value) {
433 return UNSAFE.weakCompareAndSetIntRelease(handle.base,
434 handle.fieldOffset,
435 expected,
436 value);
437 }
438
439 @ForceInline
440 static int getAndSet(FieldStaticReadWrite handle, int value) {
441 return UNSAFE.getAndSetInt(handle.base,
442 handle.fieldOffset,
443 value);
444 }
445
446 @ForceInline
447 static int getAndSetAcquire(FieldStaticReadWrite handle, int value) {
448 return UNSAFE.getAndSetIntAcquire(handle.base,
449 handle.fieldOffset,
450 value);
451 }
452
453 @ForceInline
454 static int getAndSetRelease(FieldStaticReadWrite handle, int value) {
455 return UNSAFE.getAndSetIntRelease(handle.base,
456 handle.fieldOffset,
457 value);
458 }
459
460 @ForceInline
461 static int getAndAdd(FieldStaticReadWrite handle, int value) {
462 return UNSAFE.getAndAddInt(handle.base,
463 handle.fieldOffset,
464 value);
465 }
466
467 @ForceInline
468 static int getAndAddAcquire(FieldStaticReadWrite handle, int value) {
469 return UNSAFE.getAndAddIntAcquire(handle.base,
470 handle.fieldOffset,
471 value);
472 }
473
474 @ForceInline
475 static int getAndAddRelease(FieldStaticReadWrite handle, int value) {
476 return UNSAFE.getAndAddIntRelease(handle.base,
477 handle.fieldOffset,
478 value);
479 }
480
481 @ForceInline
482 static int getAndBitwiseOr(FieldStaticReadWrite handle, int value) {
483 return UNSAFE.getAndBitwiseOrInt(handle.base,
484 handle.fieldOffset,
485 value);
486 }
487
488 @ForceInline
489 static int getAndBitwiseOrRelease(FieldStaticReadWrite handle, int value) {
490 return UNSAFE.getAndBitwiseOrIntRelease(handle.base,
491 handle.fieldOffset,
492 value);
493 }
494
495 @ForceInline
496 static int getAndBitwiseOrAcquire(FieldStaticReadWrite handle, int value) {
497 return UNSAFE.getAndBitwiseOrIntAcquire(handle.base,
498 handle.fieldOffset,
499 value);
500 }
501
502 @ForceInline
503 static int getAndBitwiseAnd(FieldStaticReadWrite handle, int value) {
504 return UNSAFE.getAndBitwiseAndInt(handle.base,
505 handle.fieldOffset,
506 value);
507 }
508
509 @ForceInline
510 static int getAndBitwiseAndRelease(FieldStaticReadWrite handle, int value) {
511 return UNSAFE.getAndBitwiseAndIntRelease(handle.base,
512 handle.fieldOffset,
513 value);
514 }
515
516 @ForceInline
517 static int getAndBitwiseAndAcquire(FieldStaticReadWrite handle, int value) {
518 return UNSAFE.getAndBitwiseAndIntAcquire(handle.base,
519 handle.fieldOffset,
520 value);
521 }
522
523 @ForceInline
524 static int getAndBitwiseXor(FieldStaticReadWrite handle, int value) {
525 return UNSAFE.getAndBitwiseXorInt(handle.base,
526 handle.fieldOffset,
527 value);
528 }
529
530 @ForceInline
531 static int getAndBitwiseXorRelease(FieldStaticReadWrite handle, int value) {
532 return UNSAFE.getAndBitwiseXorIntRelease(handle.base,
533 handle.fieldOffset,
534 value);
535 }
536
537 @ForceInline
538 static int getAndBitwiseXorAcquire(FieldStaticReadWrite handle, int value) {
539 return UNSAFE.getAndBitwiseXorIntAcquire(handle.base,
540 handle.fieldOffset,
541 value);
542 }
543
544 static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, int.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(int[].class, int.class, int.class);
561 }
562
563
564 @ForceInline
565 static int get(Array handle, Object oarray, int index) {
566 int[] array = (int[]) oarray;
567 return array[index];
568 }
569
570 @ForceInline
571 static void set(Array handle, Object oarray, int index, int value) {
572 int[] array = (int[]) oarray;
573 array[index] = value;
574 }
575
576 @ForceInline
577 static int getVolatile(Array handle, Object oarray, int index) {
578 int[] array = (int[]) oarray;
579 return UNSAFE.getIntVolatile(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, int value) {
585 int[] array = (int[]) oarray;
586 UNSAFE.putIntVolatile(array,
587 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
588 value);
589 }
590
591 @ForceInline
592 static int getOpaque(Array handle, Object oarray, int index) {
593 int[] array = (int[]) oarray;
594 return UNSAFE.getIntOpaque(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, int value) {
600 int[] array = (int[]) oarray;
601 UNSAFE.putIntOpaque(array,
602 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
603 value);
604 }
605
606 @ForceInline
607 static int getAcquire(Array handle, Object oarray, int index) {
608 int[] array = (int[]) oarray;
609 return UNSAFE.getIntAcquire(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, int value) {
615 int[] array = (int[]) oarray;
616 UNSAFE.putIntRelease(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, int expected, int value) {
623 int[] array = (int[]) oarray;
624 return UNSAFE.compareAndSetInt(array,
625 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
626 expected,
627 value);
628 }
629
630 @ForceInline
631 static int compareAndExchange(Array handle, Object oarray, int index, int expected, int value) {
632 int[] array = (int[]) oarray;
633 return UNSAFE.compareAndExchangeInt(array,
634 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
635 expected,
636 value);
637 }
638
639 @ForceInline
640 static int compareAndExchangeAcquire(Array handle, Object oarray, int index, int expected, int value) {
641 int[] array = (int[]) oarray;
642 return UNSAFE.compareAndExchangeIntAcquire(array,
643 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
644 expected,
645 value);
646 }
647
648 @ForceInline
649 static int compareAndExchangeRelease(Array handle, Object oarray, int index, int expected, int value) {
650 int[] array = (int[]) oarray;
651 return UNSAFE.compareAndExchangeIntRelease(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, int expected, int value) {
659 int[] array = (int[]) oarray;
660 return UNSAFE.weakCompareAndSetIntPlain(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, int expected, int value) {
668 int[] array = (int[]) oarray;
669 return UNSAFE.weakCompareAndSetInt(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, int expected, int value) {
677 int[] array = (int[]) oarray;
678 return UNSAFE.weakCompareAndSetIntAcquire(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, int expected, int value) {
686 int[] array = (int[]) oarray;
687 return UNSAFE.weakCompareAndSetIntRelease(array,
688 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
689 expected,
690 value);
691 }
692
693 @ForceInline
694 static int getAndSet(Array handle, Object oarray, int index, int value) {
695 int[] array = (int[]) oarray;
696 return UNSAFE.getAndSetInt(array,
697 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
698 value);
699 }
700
701 @ForceInline
702 static int getAndSetAcquire(Array handle, Object oarray, int index, int value) {
703 int[] array = (int[]) oarray;
704 return UNSAFE.getAndSetIntAcquire(array,
705 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
706 value);
707 }
708
709 @ForceInline
710 static int getAndSetRelease(Array handle, Object oarray, int index, int value) {
711 int[] array = (int[]) oarray;
712 return UNSAFE.getAndSetIntRelease(array,
713 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
714 value);
715 }
716
717 @ForceInline
718 static int getAndAdd(Array handle, Object oarray, int index, int value) {
719 int[] array = (int[]) oarray;
720 return UNSAFE.getAndAddInt(array,
721 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
722 value);
723 }
724
725 @ForceInline
726 static int getAndAddAcquire(Array handle, Object oarray, int index, int value) {
727 int[] array = (int[]) oarray;
728 return UNSAFE.getAndAddIntAcquire(array,
729 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
730 value);
731 }
732
733 @ForceInline
734 static int getAndAddRelease(Array handle, Object oarray, int index, int value) {
735 int[] array = (int[]) oarray;
736 return UNSAFE.getAndAddIntRelease(array,
737 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
738 value);
739 }
740
741 @ForceInline
742 static int getAndBitwiseOr(Array handle, Object oarray, int index, int value) {
743 int[] array = (int[]) oarray;
744 return UNSAFE.getAndBitwiseOrInt(array,
745 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
746 value);
747 }
748
749 @ForceInline
750 static int getAndBitwiseOrRelease(Array handle, Object oarray, int index, int value) {
751 int[] array = (int[]) oarray;
752 return UNSAFE.getAndBitwiseOrIntRelease(array,
753 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
754 value);
755 }
756
757 @ForceInline
758 static int getAndBitwiseOrAcquire(Array handle, Object oarray, int index, int value) {
759 int[] array = (int[]) oarray;
760 return UNSAFE.getAndBitwiseOrIntAcquire(array,
761 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
762 value);
763 }
764
765 @ForceInline
766 static int getAndBitwiseAnd(Array handle, Object oarray, int index, int value) {
767 int[] array = (int[]) oarray;
768 return UNSAFE.getAndBitwiseAndInt(array,
769 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
770 value);
771 }
772
773 @ForceInline
774 static int getAndBitwiseAndRelease(Array handle, Object oarray, int index, int value) {
775 int[] array = (int[]) oarray;
776 return UNSAFE.getAndBitwiseAndIntRelease(array,
777 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
778 value);
779 }
780
781 @ForceInline
782 static int getAndBitwiseAndAcquire(Array handle, Object oarray, int index, int value) {
783 int[] array = (int[]) oarray;
784 return UNSAFE.getAndBitwiseAndIntAcquire(array,
785 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
786 value);
787 }
788
789 @ForceInline
790 static int getAndBitwiseXor(Array handle, Object oarray, int index, int value) {
791 int[] array = (int[]) oarray;
792 return UNSAFE.getAndBitwiseXorInt(array,
793 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
794 value);
795 }
796
797 @ForceInline
798 static int getAndBitwiseXorRelease(Array handle, Object oarray, int index, int value) {
799 int[] array = (int[]) oarray;
800 return UNSAFE.getAndBitwiseXorIntRelease(array,
801 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
802 value);
803 }
804
805 @ForceInline
806 static int getAndBitwiseXorAcquire(Array handle, Object oarray, int index, int value) {
807 int[] array = (int[]) oarray;
808 return UNSAFE.getAndBitwiseXorIntAcquire(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, int[].class, int.class, int.class);
814 }
815 }
816