22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package java.lang.invoke; |
25 package java.lang.invoke; |
26 |
26 |
|
27 import jdk.internal.util.Preconditions; |
|
28 import jdk.internal.vm.annotation.ForceInline; |
|
29 |
27 import java.util.Objects; |
30 import java.util.Objects; |
28 import jdk.internal.vm.annotation.ForceInline; |
|
29 |
31 |
30 import static java.lang.invoke.MethodHandleStatics.UNSAFE; |
32 import static java.lang.invoke.MethodHandleStatics.UNSAFE; |
31 |
33 |
32 #warn |
34 #warn |
33 |
35 |
405 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
407 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
406 #else[Object] |
408 #else[Object] |
407 $type$[] array = ($type$[]) oarray; |
409 $type$[] array = ($type$[]) oarray; |
408 #end[Object] |
410 #end[Object] |
409 return UNSAFE.get$Type$Volatile(array, |
411 return UNSAFE.get$Type$Volatile(array, |
410 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
412 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
411 } |
413 } |
412 |
414 |
413 @ForceInline |
415 @ForceInline |
414 static void setVolatile(Array handle, Object oarray, int index, $type$ value) { |
416 static void setVolatile(Array handle, Object oarray, int index, $type$ value) { |
415 #if[Object] |
417 #if[Object] |
416 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
418 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
417 #else[Object] |
419 #else[Object] |
418 $type$[] array = ($type$[]) oarray; |
420 $type$[] array = ($type$[]) oarray; |
419 #end[Object] |
421 #end[Object] |
420 UNSAFE.put$Type$Volatile(array, |
422 UNSAFE.put$Type$Volatile(array, |
421 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
423 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
422 {#if[Object]?handle.componentType.cast(value):value}); |
424 {#if[Object]?handle.componentType.cast(value):value}); |
423 } |
425 } |
424 |
426 |
425 @ForceInline |
427 @ForceInline |
426 static $type$ getOpaque(Array handle, Object oarray, int index) { |
428 static $type$ getOpaque(Array handle, Object oarray, int index) { |
428 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
430 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
429 #else[Object] |
431 #else[Object] |
430 $type$[] array = ($type$[]) oarray; |
432 $type$[] array = ($type$[]) oarray; |
431 #end[Object] |
433 #end[Object] |
432 return UNSAFE.get$Type$Opaque(array, |
434 return UNSAFE.get$Type$Opaque(array, |
433 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
435 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
434 } |
436 } |
435 |
437 |
436 @ForceInline |
438 @ForceInline |
437 static void setOpaque(Array handle, Object oarray, int index, $type$ value) { |
439 static void setOpaque(Array handle, Object oarray, int index, $type$ value) { |
438 #if[Object] |
440 #if[Object] |
439 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
441 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
440 #else[Object] |
442 #else[Object] |
441 $type$[] array = ($type$[]) oarray; |
443 $type$[] array = ($type$[]) oarray; |
442 #end[Object] |
444 #end[Object] |
443 UNSAFE.put$Type$Opaque(array, |
445 UNSAFE.put$Type$Opaque(array, |
444 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
446 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
445 {#if[Object]?handle.componentType.cast(value):value}); |
447 {#if[Object]?handle.componentType.cast(value):value}); |
446 } |
448 } |
447 |
449 |
448 @ForceInline |
450 @ForceInline |
449 static $type$ getAcquire(Array handle, Object oarray, int index) { |
451 static $type$ getAcquire(Array handle, Object oarray, int index) { |
451 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
453 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
452 #else[Object] |
454 #else[Object] |
453 $type$[] array = ($type$[]) oarray; |
455 $type$[] array = ($type$[]) oarray; |
454 #end[Object] |
456 #end[Object] |
455 return UNSAFE.get$Type$Acquire(array, |
457 return UNSAFE.get$Type$Acquire(array, |
456 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
458 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); |
457 } |
459 } |
458 |
460 |
459 @ForceInline |
461 @ForceInline |
460 static void setRelease(Array handle, Object oarray, int index, $type$ value) { |
462 static void setRelease(Array handle, Object oarray, int index, $type$ value) { |
461 #if[Object] |
463 #if[Object] |
462 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
464 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
463 #else[Object] |
465 #else[Object] |
464 $type$[] array = ($type$[]) oarray; |
466 $type$[] array = ($type$[]) oarray; |
465 #end[Object] |
467 #end[Object] |
466 UNSAFE.put$Type$Release(array, |
468 UNSAFE.put$Type$Release(array, |
467 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
469 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
468 {#if[Object]?handle.componentType.cast(value):value}); |
470 {#if[Object]?handle.componentType.cast(value):value}); |
469 } |
471 } |
470 #if[CAS] |
472 #if[CAS] |
471 |
473 |
472 @ForceInline |
474 @ForceInline |
475 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
477 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
476 #else[Object] |
478 #else[Object] |
477 $type$[] array = ($type$[]) oarray; |
479 $type$[] array = ($type$[]) oarray; |
478 #end[Object] |
480 #end[Object] |
479 return UNSAFE.compareAndSwap$Type$(array, |
481 return UNSAFE.compareAndSwap$Type$(array, |
480 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
482 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
481 {#if[Object]?handle.componentType.cast(expected):expected}, |
483 {#if[Object]?handle.componentType.cast(expected):expected}, |
482 {#if[Object]?handle.componentType.cast(value):value}); |
484 {#if[Object]?handle.componentType.cast(value):value}); |
483 } |
485 } |
484 |
486 |
485 @ForceInline |
487 @ForceInline |
488 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
490 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
489 #else[Object] |
491 #else[Object] |
490 $type$[] array = ($type$[]) oarray; |
492 $type$[] array = ($type$[]) oarray; |
491 #end[Object] |
493 #end[Object] |
492 return UNSAFE.compareAndExchange$Type$Volatile(array, |
494 return UNSAFE.compareAndExchange$Type$Volatile(array, |
493 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
495 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
494 {#if[Object]?handle.componentType.cast(expected):expected}, |
496 {#if[Object]?handle.componentType.cast(expected):expected}, |
495 {#if[Object]?handle.componentType.cast(value):value}); |
497 {#if[Object]?handle.componentType.cast(value):value}); |
496 } |
498 } |
497 |
499 |
498 @ForceInline |
500 @ForceInline |
501 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
503 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
502 #else[Object] |
504 #else[Object] |
503 $type$[] array = ($type$[]) oarray; |
505 $type$[] array = ($type$[]) oarray; |
504 #end[Object] |
506 #end[Object] |
505 return UNSAFE.compareAndExchange$Type$Acquire(array, |
507 return UNSAFE.compareAndExchange$Type$Acquire(array, |
506 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
508 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
507 {#if[Object]?handle.componentType.cast(expected):expected}, |
509 {#if[Object]?handle.componentType.cast(expected):expected}, |
508 {#if[Object]?handle.componentType.cast(value):value}); |
510 {#if[Object]?handle.componentType.cast(value):value}); |
509 } |
511 } |
510 |
512 |
511 @ForceInline |
513 @ForceInline |
514 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
516 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
515 #else[Object] |
517 #else[Object] |
516 $type$[] array = ($type$[]) oarray; |
518 $type$[] array = ($type$[]) oarray; |
517 #end[Object] |
519 #end[Object] |
518 return UNSAFE.compareAndExchange$Type$Release(array, |
520 return UNSAFE.compareAndExchange$Type$Release(array, |
519 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
521 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
520 {#if[Object]?handle.componentType.cast(expected):expected}, |
522 {#if[Object]?handle.componentType.cast(expected):expected}, |
521 {#if[Object]?handle.componentType.cast(value):value}); |
523 {#if[Object]?handle.componentType.cast(value):value}); |
522 } |
524 } |
523 |
525 |
524 @ForceInline |
526 @ForceInline |
527 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
529 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
528 #else[Object] |
530 #else[Object] |
529 $type$[] array = ($type$[]) oarray; |
531 $type$[] array = ($type$[]) oarray; |
530 #end[Object] |
532 #end[Object] |
531 return UNSAFE.weakCompareAndSwap$Type$(array, |
533 return UNSAFE.weakCompareAndSwap$Type$(array, |
532 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
534 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
533 {#if[Object]?handle.componentType.cast(expected):expected}, |
535 {#if[Object]?handle.componentType.cast(expected):expected}, |
534 {#if[Object]?handle.componentType.cast(value):value}); |
536 {#if[Object]?handle.componentType.cast(value):value}); |
535 } |
537 } |
536 |
538 |
537 @ForceInline |
539 @ForceInline |
540 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
542 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
541 #else[Object] |
543 #else[Object] |
542 $type$[] array = ($type$[]) oarray; |
544 $type$[] array = ($type$[]) oarray; |
543 #end[Object] |
545 #end[Object] |
544 return UNSAFE.weakCompareAndSwap$Type$Acquire(array, |
546 return UNSAFE.weakCompareAndSwap$Type$Acquire(array, |
545 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
547 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
546 {#if[Object]?handle.componentType.cast(expected):expected}, |
548 {#if[Object]?handle.componentType.cast(expected):expected}, |
547 {#if[Object]?handle.componentType.cast(value):value}); |
549 {#if[Object]?handle.componentType.cast(value):value}); |
548 } |
550 } |
549 |
551 |
550 @ForceInline |
552 @ForceInline |
553 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
555 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
554 #else[Object] |
556 #else[Object] |
555 $type$[] array = ($type$[]) oarray; |
557 $type$[] array = ($type$[]) oarray; |
556 #end[Object] |
558 #end[Object] |
557 return UNSAFE.weakCompareAndSwap$Type$Release(array, |
559 return UNSAFE.weakCompareAndSwap$Type$Release(array, |
558 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
560 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
559 {#if[Object]?handle.componentType.cast(expected):expected}, |
561 {#if[Object]?handle.componentType.cast(expected):expected}, |
560 {#if[Object]?handle.componentType.cast(value):value}); |
562 {#if[Object]?handle.componentType.cast(value):value}); |
561 } |
563 } |
562 |
564 |
563 @ForceInline |
565 @ForceInline |
566 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
568 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
567 #else[Object] |
569 #else[Object] |
568 $type$[] array = ($type$[]) oarray; |
570 $type$[] array = ($type$[]) oarray; |
569 #end[Object] |
571 #end[Object] |
570 return UNSAFE.getAndSet$Type$(array, |
572 return UNSAFE.getAndSet$Type$(array, |
571 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
573 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
572 {#if[Object]?handle.componentType.cast(value):value}); |
574 {#if[Object]?handle.componentType.cast(value):value}); |
573 } |
575 } |
574 #end[CAS] |
576 #end[CAS] |
575 #if[AtomicAdd] |
577 #if[AtomicAdd] |
576 |
578 |
580 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
582 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
581 #else[Object] |
583 #else[Object] |
582 $type$[] array = ($type$[]) oarray; |
584 $type$[] array = ($type$[]) oarray; |
583 #end[Object] |
585 #end[Object] |
584 return UNSAFE.getAndAdd$Type$(array, |
586 return UNSAFE.getAndAdd$Type$(array, |
585 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
587 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
586 value); |
588 value); |
587 } |
589 } |
588 |
590 |
589 @ForceInline |
591 @ForceInline |
590 static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { |
592 static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { |
592 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
594 Object[] array = (Object[]) handle.arrayType.cast(oarray); |
593 #else[Object] |
595 #else[Object] |
594 $type$[] array = ($type$[]) oarray; |
596 $type$[] array = ($type$[]) oarray; |
595 #end[Object] |
597 #end[Object] |
596 return UNSAFE.getAndAdd$Type$(array, |
598 return UNSAFE.getAndAdd$Type$(array, |
597 (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
599 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, |
598 value) + value; |
600 value) + value; |
599 } |
601 } |
600 #end[AtomicAdd] |
602 #end[AtomicAdd] |
601 } |
603 } |
602 } |
604 } |