< prev index next >

src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template

Print this page
rev 14353 : 8155258: VarHandle implementation improvements
Reviewed-by:
rev 14354 : 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
Reviewed-by:


   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.FORM);
  45         }
  46 
  47         protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
  48                                         VarForm form) {
  49             super(form);


 438         }
 439 
 440         @ForceInline
 441         static void set(Array handle, Object oarray, int index, $type$ value) {
 442 #if[Object]
 443             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 444 #else[Object]
 445             $type$[] array = ($type$[]) oarray;
 446 #end[Object]
 447             array[index] = {#if[Object]?handle.componentType.cast(value):value};
 448         }
 449 
 450         @ForceInline
 451         static $type$ getVolatile(Array handle, Object oarray, int index) {
 452 #if[Object]
 453             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 454 #else[Object]
 455             $type$[] array = ($type$[]) oarray;
 456 #end[Object]
 457             return UNSAFE.get$Type$Volatile(array,
 458                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 459         }
 460 
 461         @ForceInline
 462         static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
 463 #if[Object]
 464             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 465 #else[Object]
 466             $type$[] array = ($type$[]) oarray;
 467 #end[Object]
 468             UNSAFE.put$Type$Volatile(array,
 469                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 470                     {#if[Object]?handle.componentType.cast(value):value});
 471         }
 472 
 473         @ForceInline
 474         static $type$ getOpaque(Array handle, Object oarray, int index) {
 475 #if[Object]
 476             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 477 #else[Object]
 478             $type$[] array = ($type$[]) oarray;
 479 #end[Object]
 480             return UNSAFE.get$Type$Opaque(array,
 481                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 482         }
 483 
 484         @ForceInline
 485         static void setOpaque(Array handle, Object oarray, int index, $type$ value) {
 486 #if[Object]
 487             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 488 #else[Object]
 489             $type$[] array = ($type$[]) oarray;
 490 #end[Object]
 491             UNSAFE.put$Type$Opaque(array,
 492                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 493                     {#if[Object]?handle.componentType.cast(value):value});
 494         }
 495 
 496         @ForceInline
 497         static $type$ getAcquire(Array handle, Object oarray, int index) {
 498 #if[Object]
 499             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 500 #else[Object]
 501             $type$[] array = ($type$[]) oarray;
 502 #end[Object]
 503             return UNSAFE.get$Type$Acquire(array,
 504                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 505         }
 506 
 507         @ForceInline
 508         static void setRelease(Array handle, Object oarray, int index, $type$ value) {
 509 #if[Object]
 510             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 511 #else[Object]
 512             $type$[] array = ($type$[]) oarray;
 513 #end[Object]
 514             UNSAFE.put$Type$Release(array,
 515                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 516                     {#if[Object]?handle.componentType.cast(value):value});
 517         }
 518 #if[CAS]
 519 
 520         @ForceInline
 521         static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 522 #if[Object]
 523             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 524 #else[Object]
 525             $type$[] array = ($type$[]) oarray;
 526 #end[Object]
 527             return UNSAFE.compareAndSwap$Type$(array,
 528                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 529                     {#if[Object]?handle.componentType.cast(expected):expected},
 530                     {#if[Object]?handle.componentType.cast(value):value});
 531         }
 532 
 533         @ForceInline
 534         static $type$ compareAndExchangeVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 535 #if[Object]
 536             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 537 #else[Object]
 538             $type$[] array = ($type$[]) oarray;
 539 #end[Object]
 540             return UNSAFE.compareAndExchange$Type$Volatile(array,
 541                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 542                     {#if[Object]?handle.componentType.cast(expected):expected},
 543                     {#if[Object]?handle.componentType.cast(value):value});
 544         }
 545 
 546         @ForceInline
 547         static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 548 #if[Object]
 549             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 550 #else[Object]
 551             $type$[] array = ($type$[]) oarray;
 552 #end[Object]
 553             return UNSAFE.compareAndExchange$Type$Acquire(array,
 554                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 555                     {#if[Object]?handle.componentType.cast(expected):expected},
 556                     {#if[Object]?handle.componentType.cast(value):value});
 557         }
 558 
 559         @ForceInline
 560         static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 561 #if[Object]
 562             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 563 #else[Object]
 564             $type$[] array = ($type$[]) oarray;
 565 #end[Object]
 566             return UNSAFE.compareAndExchange$Type$Release(array,
 567                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 568                     {#if[Object]?handle.componentType.cast(expected):expected},
 569                     {#if[Object]?handle.componentType.cast(value):value});
 570         }
 571 
 572         @ForceInline
 573         static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 574 #if[Object]
 575             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 576 #else[Object]
 577             $type$[] array = ($type$[]) oarray;
 578 #end[Object]
 579             return UNSAFE.weakCompareAndSwap$Type$(array,
 580                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 581                     {#if[Object]?handle.componentType.cast(expected):expected},
 582                     {#if[Object]?handle.componentType.cast(value):value});
 583         }
 584 
 585         @ForceInline
 586         static boolean weakCompareAndSetVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 587 #if[Object]
 588             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 589 #else[Object]
 590             $type$[] array = ($type$[]) oarray;
 591 #end[Object]
 592             // TODO defer to strong form until new Unsafe method is added
 593             return UNSAFE.compareAndSwap$Type$(array,
 594                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 595                     {#if[Object]?handle.componentType.cast(expected):expected},
 596                     {#if[Object]?handle.componentType.cast(value):value});
 597         }
 598 
 599         @ForceInline
 600         static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 601 #if[Object]
 602             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 603 #else[Object]
 604             $type$[] array = ($type$[]) oarray;
 605 #end[Object]
 606             return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
 607                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 608                     {#if[Object]?handle.componentType.cast(expected):expected},
 609                     {#if[Object]?handle.componentType.cast(value):value});
 610         }
 611 
 612         @ForceInline
 613         static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 614 #if[Object]
 615             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 616 #else[Object]
 617             $type$[] array = ($type$[]) oarray;
 618 #end[Object]
 619             return UNSAFE.weakCompareAndSwap$Type$Release(array,
 620                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 621                     {#if[Object]?handle.componentType.cast(expected):expected},
 622                     {#if[Object]?handle.componentType.cast(value):value});
 623         }
 624 
 625         @ForceInline
 626         static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
 627 #if[Object]
 628             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 629 #else[Object]
 630             $type$[] array = ($type$[]) oarray;
 631 #end[Object]
 632             return UNSAFE.getAndSet$Type$(array,
 633                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 634                     {#if[Object]?handle.componentType.cast(value):value});
 635         }
 636 #end[CAS]
 637 #if[AtomicAdd]
 638 
 639         @ForceInline
 640         static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
 641 #if[Object]
 642             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 643 #else[Object]
 644             $type$[] array = ($type$[]) oarray;
 645 #end[Object]
 646             return UNSAFE.getAndAdd$Type$(array,
 647                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 648                     value);
 649         }
 650 
 651         @ForceInline
 652         static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) {
 653 #if[Object]
 654             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 655 #else[Object]
 656             $type$[] array = ($type$[]) oarray;
 657 #end[Object]
 658             return UNSAFE.getAndAdd$Type$(array,
 659                     (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 660                     value) + value;
 661         }
 662 #end[AtomicAdd]
 663 
 664         static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class);
 665     }
 666 }


   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 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 #warn
  35 
  36 final class VarHandle$Type$s {
  37 
  38     static class FieldInstanceReadOnly extends VarHandle {
  39         final long fieldOffset;
  40         final Class<?> receiverType;
  41 #if[Object]
  42         final Class<?> fieldType;
  43 #end[Object]
  44 
  45         FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
  46             this(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadOnly.FORM);
  47         }
  48 
  49         protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
  50                                         VarForm form) {
  51             super(form);


 440         }
 441 
 442         @ForceInline
 443         static void set(Array handle, Object oarray, int index, $type$ value) {
 444 #if[Object]
 445             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 446 #else[Object]
 447             $type$[] array = ($type$[]) oarray;
 448 #end[Object]
 449             array[index] = {#if[Object]?handle.componentType.cast(value):value};
 450         }
 451 
 452         @ForceInline
 453         static $type$ getVolatile(Array handle, Object oarray, int index) {
 454 #if[Object]
 455             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 456 #else[Object]
 457             $type$[] array = ($type$[]) oarray;
 458 #end[Object]
 459             return UNSAFE.get$Type$Volatile(array,
 460                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 461         }
 462 
 463         @ForceInline
 464         static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
 465 #if[Object]
 466             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 467 #else[Object]
 468             $type$[] array = ($type$[]) oarray;
 469 #end[Object]
 470             UNSAFE.put$Type$Volatile(array,
 471                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 472                     {#if[Object]?handle.componentType.cast(value):value});
 473         }
 474 
 475         @ForceInline
 476         static $type$ getOpaque(Array handle, Object oarray, int index) {
 477 #if[Object]
 478             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 479 #else[Object]
 480             $type$[] array = ($type$[]) oarray;
 481 #end[Object]
 482             return UNSAFE.get$Type$Opaque(array,
 483                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 484         }
 485 
 486         @ForceInline
 487         static void setOpaque(Array handle, Object oarray, int index, $type$ value) {
 488 #if[Object]
 489             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 490 #else[Object]
 491             $type$[] array = ($type$[]) oarray;
 492 #end[Object]
 493             UNSAFE.put$Type$Opaque(array,
 494                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 495                     {#if[Object]?handle.componentType.cast(value):value});
 496         }
 497 
 498         @ForceInline
 499         static $type$ getAcquire(Array handle, Object oarray, int index) {
 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.get$Type$Acquire(array,
 506                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 507         }
 508 
 509         @ForceInline
 510         static void setRelease(Array handle, Object oarray, int index, $type$ value) {
 511 #if[Object]
 512             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 513 #else[Object]
 514             $type$[] array = ($type$[]) oarray;
 515 #end[Object]
 516             UNSAFE.put$Type$Release(array,
 517                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 518                     {#if[Object]?handle.componentType.cast(value):value});
 519         }
 520 #if[CAS]
 521 
 522         @ForceInline
 523         static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 524 #if[Object]
 525             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 526 #else[Object]
 527             $type$[] array = ($type$[]) oarray;
 528 #end[Object]
 529             return UNSAFE.compareAndSwap$Type$(array,
 530                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 531                     {#if[Object]?handle.componentType.cast(expected):expected},
 532                     {#if[Object]?handle.componentType.cast(value):value});
 533         }
 534 
 535         @ForceInline
 536         static $type$ compareAndExchangeVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 537 #if[Object]
 538             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 539 #else[Object]
 540             $type$[] array = ($type$[]) oarray;
 541 #end[Object]
 542             return UNSAFE.compareAndExchange$Type$Volatile(array,
 543                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 544                     {#if[Object]?handle.componentType.cast(expected):expected},
 545                     {#if[Object]?handle.componentType.cast(value):value});
 546         }
 547 
 548         @ForceInline
 549         static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 550 #if[Object]
 551             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 552 #else[Object]
 553             $type$[] array = ($type$[]) oarray;
 554 #end[Object]
 555             return UNSAFE.compareAndExchange$Type$Acquire(array,
 556                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 557                     {#if[Object]?handle.componentType.cast(expected):expected},
 558                     {#if[Object]?handle.componentType.cast(value):value});
 559         }
 560 
 561         @ForceInline
 562         static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 563 #if[Object]
 564             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 565 #else[Object]
 566             $type$[] array = ($type$[]) oarray;
 567 #end[Object]
 568             return UNSAFE.compareAndExchange$Type$Release(array,
 569                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 570                     {#if[Object]?handle.componentType.cast(expected):expected},
 571                     {#if[Object]?handle.componentType.cast(value):value});
 572         }
 573 
 574         @ForceInline
 575         static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 576 #if[Object]
 577             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 578 #else[Object]
 579             $type$[] array = ($type$[]) oarray;
 580 #end[Object]
 581             return UNSAFE.weakCompareAndSwap$Type$(array,
 582                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 583                     {#if[Object]?handle.componentType.cast(expected):expected},
 584                     {#if[Object]?handle.componentType.cast(value):value});
 585         }
 586 
 587         @ForceInline
 588         static boolean weakCompareAndSetVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 589 #if[Object]
 590             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 591 #else[Object]
 592             $type$[] array = ($type$[]) oarray;
 593 #end[Object]
 594             // TODO defer to strong form until new Unsafe method is added
 595             return UNSAFE.compareAndSwap$Type$(array,
 596                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 597                     {#if[Object]?handle.componentType.cast(expected):expected},
 598                     {#if[Object]?handle.componentType.cast(value):value});
 599         }
 600 
 601         @ForceInline
 602         static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 603 #if[Object]
 604             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 605 #else[Object]
 606             $type$[] array = ($type$[]) oarray;
 607 #end[Object]
 608             return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
 609                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 610                     {#if[Object]?handle.componentType.cast(expected):expected},
 611                     {#if[Object]?handle.componentType.cast(value):value});
 612         }
 613 
 614         @ForceInline
 615         static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 616 #if[Object]
 617             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 618 #else[Object]
 619             $type$[] array = ($type$[]) oarray;
 620 #end[Object]
 621             return UNSAFE.weakCompareAndSwap$Type$Release(array,
 622                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 623                     {#if[Object]?handle.componentType.cast(expected):expected},
 624                     {#if[Object]?handle.componentType.cast(value):value});
 625         }
 626 
 627         @ForceInline
 628         static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
 629 #if[Object]
 630             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 631 #else[Object]
 632             $type$[] array = ($type$[]) oarray;
 633 #end[Object]
 634             return UNSAFE.getAndSet$Type$(array,
 635                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 636                     {#if[Object]?handle.componentType.cast(value):value});
 637         }
 638 #end[CAS]
 639 #if[AtomicAdd]
 640 
 641         @ForceInline
 642         static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
 643 #if[Object]
 644             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 645 #else[Object]
 646             $type$[] array = ($type$[]) oarray;
 647 #end[Object]
 648             return UNSAFE.getAndAdd$Type$(array,
 649                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 650                     value);
 651         }
 652 
 653         @ForceInline
 654         static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) {
 655 #if[Object]
 656             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 657 #else[Object]
 658             $type$[] array = ($type$[]) oarray;
 659 #end[Object]
 660             return UNSAFE.getAndAdd$Type$(array,
 661                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 662                     value) + value;
 663         }
 664 #end[AtomicAdd]
 665 
 666         static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class);
 667     }
 668 }
< prev index next >