src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
changeset 52220 9c260a6b6471
parent 48710 38872bed90e0
child 52914 4fa75d8ad418
equal deleted inserted replaced
52219:151b990e3764 52220:9c260a6b6471
   184 #if[CAS]
   184 #if[CAS]
   185 
   185 
   186         @ForceInline
   186         @ForceInline
   187         static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
   187         static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
   188             byte[] ba = (byte[]) oba;
   188             byte[] ba = (byte[]) oba;
       
   189 #if[Object]
       
   190             return UNSAFE.compareAndSetReference(
       
   191                     ba,
       
   192                     address(ba, index(ba, index)),
       
   193                     convEndian(handle.be, expected), convEndian(handle.be, value));
       
   194 #else[Object]
   189             return UNSAFE.compareAndSet$RawType$(
   195             return UNSAFE.compareAndSet$RawType$(
   190                     ba,
   196                     ba,
   191                     address(ba, index(ba, index)),
   197                     address(ba, index(ba, index)),
   192                     convEndian(handle.be, expected), convEndian(handle.be, value));
   198                     convEndian(handle.be, expected), convEndian(handle.be, value));
       
   199 #end[Object]
   193         }
   200         }
   194 
   201 
   195         @ForceInline
   202         @ForceInline
   196         static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
   203         static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
   197             byte[] ba = (byte[]) oba;
   204             byte[] ba = (byte[]) oba;
   259         }
   266         }
   260 
   267 
   261         @ForceInline
   268         @ForceInline
   262         static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) {
   269         static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) {
   263             byte[] ba = (byte[]) oba;
   270             byte[] ba = (byte[]) oba;
       
   271 #if[Object]
       
   272             return convEndian(handle.be,
       
   273                               UNSAFE.getAndSetReference(
       
   274                                       ba,
       
   275                                       address(ba, index(ba, index)),
       
   276                                       convEndian(handle.be, value)));
       
   277 #else[Object]
   264             return convEndian(handle.be,
   278             return convEndian(handle.be,
   265                               UNSAFE.getAndSet$RawType$(
   279                               UNSAFE.getAndSet$RawType$(
   266                                       ba,
   280                                       ba,
   267                                       address(ba, index(ba, index)),
   281                                       address(ba, index(ba, index)),
   268                                       convEndian(handle.be, value)));
   282                                       convEndian(handle.be, value)));
       
   283 #end[Object]
   269         }
   284         }
   270 
   285 
   271         @ForceInline
   286         @ForceInline
   272         static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
   287         static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
   273             byte[] ba = (byte[]) oba;
   288             byte[] ba = (byte[]) oba;
   535         @ForceInline
   550         @ForceInline
   536         static $type$ get(ByteBufferHandle handle, Object obb, int index) {
   551         static $type$ get(ByteBufferHandle handle, Object obb, int index) {
   537             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   552             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   538 #if[floatingPoint]
   553 #if[floatingPoint]
   539             $rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
   554             $rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
   540                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   555                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   541                     ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   556                     ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   542                     handle.be);
   557                     handle.be);
   543             return $Type$.$rawType$BitsTo$Type$(rawValue);
   558             return $Type$.$rawType$BitsTo$Type$(rawValue);
   544 #else[floatingPoint]
   559 #else[floatingPoint]
   545             return UNSAFE.get$Type$Unaligned(
   560             return UNSAFE.get$Type$Unaligned(
   546                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   561                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   547                     ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   562                     ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   548                     handle.be);
   563                     handle.be);
   549 #end[floatingPoint]
   564 #end[floatingPoint]
   550         }
   565         }
   551 
   566 
   552         @ForceInline
   567         @ForceInline
   553         static void set(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   568         static void set(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   554             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   569             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   555 #if[floatingPoint]
   570 #if[floatingPoint]
   556             UNSAFE.put$RawType$Unaligned(
   571             UNSAFE.put$RawType$Unaligned(
   557                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   572                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   558                     ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   573                     ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   559                     $Type$.$type$ToRaw$RawType$Bits(value),
   574                     $Type$.$type$ToRaw$RawType$Bits(value),
   560                     handle.be);
   575                     handle.be);
   561 #else[floatingPoint]
   576 #else[floatingPoint]
   562             UNSAFE.put$Type$Unaligned(
   577             UNSAFE.put$Type$Unaligned(
   563                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   578                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   564                     ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   579                     ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
   565                     value,
   580                     value,
   566                     handle.be);
   581                     handle.be);
   567 #end[floatingPoint]
   582 #end[floatingPoint]
   568         }
   583         }
   570         @ForceInline
   585         @ForceInline
   571         static $type$ getVolatile(ByteBufferHandle handle, Object obb, int index) {
   586         static $type$ getVolatile(ByteBufferHandle handle, Object obb, int index) {
   572             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   587             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   573             return convEndian(handle.be,
   588             return convEndian(handle.be,
   574                               UNSAFE.get$RawType$Volatile(
   589                               UNSAFE.get$RawType$Volatile(
   575                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   590                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   576                                       address(bb, index(bb, index))));
   591                                       address(bb, index(bb, index))));
   577         }
   592         }
   578 
   593 
   579         @ForceInline
   594         @ForceInline
   580         static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   595         static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   581             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   596             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   582             UNSAFE.put$RawType$Volatile(
   597             UNSAFE.put$RawType$Volatile(
   583                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   598                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   584                     address(bb, indexRO(bb, index)),
   599                     address(bb, indexRO(bb, index)),
   585                     convEndian(handle.be, value));
   600                     convEndian(handle.be, value));
   586         }
   601         }
   587 
   602 
   588         @ForceInline
   603         @ForceInline
   589         static $type$ getAcquire(ByteBufferHandle handle, Object obb, int index) {
   604         static $type$ getAcquire(ByteBufferHandle handle, Object obb, int index) {
   590             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   605             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   591             return convEndian(handle.be,
   606             return convEndian(handle.be,
   592                               UNSAFE.get$RawType$Acquire(
   607                               UNSAFE.get$RawType$Acquire(
   593                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   608                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   594                                       address(bb, index(bb, index))));
   609                                       address(bb, index(bb, index))));
   595         }
   610         }
   596 
   611 
   597         @ForceInline
   612         @ForceInline
   598         static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   613         static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   599             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   614             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   600             UNSAFE.put$RawType$Release(
   615             UNSAFE.put$RawType$Release(
   601                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   616                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   602                     address(bb, indexRO(bb, index)),
   617                     address(bb, indexRO(bb, index)),
   603                     convEndian(handle.be, value));
   618                     convEndian(handle.be, value));
   604         }
   619         }
   605 
   620 
   606         @ForceInline
   621         @ForceInline
   607         static $type$ getOpaque(ByteBufferHandle handle, Object obb, int index) {
   622         static $type$ getOpaque(ByteBufferHandle handle, Object obb, int index) {
   608             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   623             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   609             return convEndian(handle.be,
   624             return convEndian(handle.be,
   610                               UNSAFE.get$RawType$Opaque(
   625                               UNSAFE.get$RawType$Opaque(
   611                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   626                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   612                                       address(bb, index(bb, index))));
   627                                       address(bb, index(bb, index))));
   613         }
   628         }
   614 
   629 
   615         @ForceInline
   630         @ForceInline
   616         static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   631         static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   617             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   632             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   618             UNSAFE.put$RawType$Opaque(
   633             UNSAFE.put$RawType$Opaque(
   619                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   634                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   620                     address(bb, indexRO(bb, index)),
   635                     address(bb, indexRO(bb, index)),
   621                     convEndian(handle.be, value));
   636                     convEndian(handle.be, value));
   622         }
   637         }
   623 #if[CAS]
   638 #if[CAS]
   624 
   639 
   625         @ForceInline
   640         @ForceInline
   626         static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   641         static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   627             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   642             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
       
   643 #if[Object]
       
   644             return UNSAFE.compareAndSetReference(
       
   645                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
       
   646                     address(bb, indexRO(bb, index)),
       
   647                     convEndian(handle.be, expected), convEndian(handle.be, value));
       
   648 #else[Object]
   628             return UNSAFE.compareAndSet$RawType$(
   649             return UNSAFE.compareAndSet$RawType$(
   629                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   650                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   630                     address(bb, indexRO(bb, index)),
   651                     address(bb, indexRO(bb, index)),
   631                     convEndian(handle.be, expected), convEndian(handle.be, value));
   652                     convEndian(handle.be, expected), convEndian(handle.be, value));
       
   653 #end[Object]
   632         }
   654         }
   633 
   655 
   634         @ForceInline
   656         @ForceInline
   635         static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   657         static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   636             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   658             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   637             return convEndian(handle.be,
   659             return convEndian(handle.be,
   638                               UNSAFE.compareAndExchange$RawType$(
   660                               UNSAFE.compareAndExchange$RawType$(
   639                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   661                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   640                                       address(bb, indexRO(bb, index)),
   662                                       address(bb, indexRO(bb, index)),
   641                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
   663                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
   642         }
   664         }
   643 
   665 
   644         @ForceInline
   666         @ForceInline
   645         static $type$ compareAndExchangeAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   667         static $type$ compareAndExchangeAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   646             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   668             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   647             return convEndian(handle.be,
   669             return convEndian(handle.be,
   648                               UNSAFE.compareAndExchange$RawType$Acquire(
   670                               UNSAFE.compareAndExchange$RawType$Acquire(
   649                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   671                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   650                                       address(bb, indexRO(bb, index)),
   672                                       address(bb, indexRO(bb, index)),
   651                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
   673                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
   652         }
   674         }
   653 
   675 
   654         @ForceInline
   676         @ForceInline
   655         static $type$ compareAndExchangeRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   677         static $type$ compareAndExchangeRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   656             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   678             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   657             return convEndian(handle.be,
   679             return convEndian(handle.be,
   658                               UNSAFE.compareAndExchange$RawType$Release(
   680                               UNSAFE.compareAndExchange$RawType$Release(
   659                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   681                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   660                                       address(bb, indexRO(bb, index)),
   682                                       address(bb, indexRO(bb, index)),
   661                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
   683                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
   662         }
   684         }
   663 
   685 
   664         @ForceInline
   686         @ForceInline
   665         static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   687         static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   666             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   688             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   667             return UNSAFE.weakCompareAndSet$RawType$Plain(
   689             return UNSAFE.weakCompareAndSet$RawType$Plain(
   668                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   690                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   669                     address(bb, indexRO(bb, index)),
   691                     address(bb, indexRO(bb, index)),
   670                     convEndian(handle.be, expected), convEndian(handle.be, value));
   692                     convEndian(handle.be, expected), convEndian(handle.be, value));
   671         }
   693         }
   672 
   694 
   673         @ForceInline
   695         @ForceInline
   674         static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   696         static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   675             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   697             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   676             return UNSAFE.weakCompareAndSet$RawType$(
   698             return UNSAFE.weakCompareAndSet$RawType$(
   677                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   699                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   678                     address(bb, indexRO(bb, index)),
   700                     address(bb, indexRO(bb, index)),
   679                     convEndian(handle.be, expected), convEndian(handle.be, value));
   701                     convEndian(handle.be, expected), convEndian(handle.be, value));
   680         }
   702         }
   681 
   703 
   682         @ForceInline
   704         @ForceInline
   683         static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   705         static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   684             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   706             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   685             return UNSAFE.weakCompareAndSet$RawType$Acquire(
   707             return UNSAFE.weakCompareAndSet$RawType$Acquire(
   686                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   708                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   687                     address(bb, indexRO(bb, index)),
   709                     address(bb, indexRO(bb, index)),
   688                     convEndian(handle.be, expected), convEndian(handle.be, value));
   710                     convEndian(handle.be, expected), convEndian(handle.be, value));
   689         }
   711         }
   690 
   712 
   691         @ForceInline
   713         @ForceInline
   692         static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   714         static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
   693             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   715             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   694             return UNSAFE.weakCompareAndSet$RawType$Release(
   716             return UNSAFE.weakCompareAndSet$RawType$Release(
   695                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   717                     UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   696                     address(bb, indexRO(bb, index)),
   718                     address(bb, indexRO(bb, index)),
   697                     convEndian(handle.be, expected), convEndian(handle.be, value));
   719                     convEndian(handle.be, expected), convEndian(handle.be, value));
   698         }
   720         }
   699 
   721 
   700         @ForceInline
   722         @ForceInline
   701         static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   723         static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   702             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   724             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   703             return convEndian(handle.be,
   725 #if[Object]
   704                               UNSAFE.getAndSet$RawType$(
   726             return convEndian(handle.be,
   705                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   727                               UNSAFE.getAndSetReference(
       
   728                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   706                                       address(bb, indexRO(bb, index)),
   729                                       address(bb, indexRO(bb, index)),
   707                                       convEndian(handle.be, value)));
   730                                       convEndian(handle.be, value)));
   708         }
   731 #else[Object]
   709 
   732             return convEndian(handle.be,
   710         @ForceInline
   733                               UNSAFE.getAndSet$RawType$(
   711         static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   734                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   712             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
       
   713             return convEndian(handle.be,
       
   714                               UNSAFE.getAndSet$RawType$Acquire(
       
   715                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
       
   716                                       address(bb, indexRO(bb, index)),
   735                                       address(bb, indexRO(bb, index)),
   717                                       convEndian(handle.be, value)));
   736                                       convEndian(handle.be, value)));
   718         }
   737 #end[Object]
   719 
   738         }
   720         @ForceInline
   739 
   721         static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   740         @ForceInline
   722             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   741         static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   723             return convEndian(handle.be,
   742             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   724                               UNSAFE.getAndSet$RawType$Release(
   743             return convEndian(handle.be,
   725                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   744                               UNSAFE.getAndSet$RawType$Acquire(
       
   745                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   726                                       address(bb, indexRO(bb, index)),
   746                                       address(bb, indexRO(bb, index)),
   727                                       convEndian(handle.be, value)));
   747                                       convEndian(handle.be, value)));
   728         }
   748         }
       
   749 
       
   750         @ForceInline
       
   751         static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
       
   752             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
       
   753             return convEndian(handle.be,
       
   754                               UNSAFE.getAndSet$RawType$Release(
       
   755                                       UNSAFE.getReference(bb, BYTE_BUFFER_HB),
       
   756                                       address(bb, indexRO(bb, index)),
       
   757                                       convEndian(handle.be, value)));
       
   758         }
   729 #end[CAS]
   759 #end[CAS]
   730 #if[AtomicAdd]
   760 #if[AtomicAdd]
   731 
   761 
   732         @ForceInline
   762         @ForceInline
   733         static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
   763         static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
   734             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   764             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   735             if (handle.be == BE) {
   765             if (handle.be == BE) {
   736                 return UNSAFE.getAndAdd$RawType$(
   766                 return UNSAFE.getAndAdd$RawType$(
   737                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   767                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   738                         address(bb, indexRO(bb, index)),
   768                         address(bb, indexRO(bb, index)),
   739                         delta);
   769                         delta);
   740             } else {
   770             } else {
   741                 return getAndAddConvEndianWithCAS(bb, index, delta);
   771                 return getAndAddConvEndianWithCAS(bb, index, delta);
   742             }
   772             }
   745         @ForceInline
   775         @ForceInline
   746         static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
   776         static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
   747             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   777             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   748             if (handle.be == BE) {
   778             if (handle.be == BE) {
   749                 return UNSAFE.getAndAdd$RawType$Acquire(
   779                 return UNSAFE.getAndAdd$RawType$Acquire(
   750                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   780                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   751                         address(bb, indexRO(bb, index)),
   781                         address(bb, indexRO(bb, index)),
   752                         delta);
   782                         delta);
   753             } else {
   783             } else {
   754                 return getAndAddConvEndianWithCAS(bb, index, delta);
   784                 return getAndAddConvEndianWithCAS(bb, index, delta);
   755             }
   785             }
   758         @ForceInline
   788         @ForceInline
   759         static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
   789         static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
   760             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   790             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   761             if (handle.be == BE) {
   791             if (handle.be == BE) {
   762                 return UNSAFE.getAndAdd$RawType$Release(
   792                 return UNSAFE.getAndAdd$RawType$Release(
   763                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   793                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   764                         address(bb, indexRO(bb, index)),
   794                         address(bb, indexRO(bb, index)),
   765                         delta);
   795                         delta);
   766             } else {
   796             } else {
   767                 return getAndAddConvEndianWithCAS(bb, index, delta);
   797                 return getAndAddConvEndianWithCAS(bb, index, delta);
   768             }
   798             }
   769         }
   799         }
   770 
   800 
   771         @ForceInline
   801         @ForceInline
   772         static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) {
   802         static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) {
   773             $type$ nativeExpectedValue, expectedValue;
   803             $type$ nativeExpectedValue, expectedValue;
   774             Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
   804             Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
   775             long offset = address(bb, indexRO(bb, index));
   805             long offset = address(bb, indexRO(bb, index));
   776             do {
   806             do {
   777                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   807                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   778                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   808                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   779             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   809             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   786         @ForceInline
   816         @ForceInline
   787         static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   817         static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   788             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   818             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   789             if (handle.be == BE) {
   819             if (handle.be == BE) {
   790                 return UNSAFE.getAndBitwiseOr$RawType$(
   820                 return UNSAFE.getAndBitwiseOr$RawType$(
   791                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   821                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   792                         address(bb, indexRO(bb, index)),
   822                         address(bb, indexRO(bb, index)),
   793                         value);
   823                         value);
   794             } else {
   824             } else {
   795                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
   825                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
   796             }
   826             }
   799         @ForceInline
   829         @ForceInline
   800         static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   830         static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   801             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   831             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   802             if (handle.be == BE) {
   832             if (handle.be == BE) {
   803                 return UNSAFE.getAndBitwiseOr$RawType$Release(
   833                 return UNSAFE.getAndBitwiseOr$RawType$Release(
   804                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   834                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   805                         address(bb, indexRO(bb, index)),
   835                         address(bb, indexRO(bb, index)),
   806                         value);
   836                         value);
   807             } else {
   837             } else {
   808                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
   838                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
   809             }
   839             }
   812         @ForceInline
   842         @ForceInline
   813         static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   843         static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   814             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   844             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   815             if (handle.be == BE) {
   845             if (handle.be == BE) {
   816                 return UNSAFE.getAndBitwiseOr$RawType$Acquire(
   846                 return UNSAFE.getAndBitwiseOr$RawType$Acquire(
   817                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   847                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   818                         address(bb, indexRO(bb, index)),
   848                         address(bb, indexRO(bb, index)),
   819                         value);
   849                         value);
   820             } else {
   850             } else {
   821                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
   851                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
   822             }
   852             }
   823         }
   853         }
   824 
   854 
   825         @ForceInline
   855         @ForceInline
   826         static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
   856         static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
   827             $type$ nativeExpectedValue, expectedValue;
   857             $type$ nativeExpectedValue, expectedValue;
   828             Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
   858             Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
   829             long offset = address(bb, indexRO(bb, index));
   859             long offset = address(bb, indexRO(bb, index));
   830             do {
   860             do {
   831                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   861                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   832                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   862                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   833             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   863             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   838         @ForceInline
   868         @ForceInline
   839         static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   869         static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   840             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   870             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   841             if (handle.be == BE) {
   871             if (handle.be == BE) {
   842                 return UNSAFE.getAndBitwiseAnd$RawType$(
   872                 return UNSAFE.getAndBitwiseAnd$RawType$(
   843                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   873                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   844                         address(bb, indexRO(bb, index)),
   874                         address(bb, indexRO(bb, index)),
   845                         value);
   875                         value);
   846             } else {
   876             } else {
   847                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
   877                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
   848             }
   878             }
   851         @ForceInline
   881         @ForceInline
   852         static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   882         static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   853             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   883             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   854             if (handle.be == BE) {
   884             if (handle.be == BE) {
   855                 return UNSAFE.getAndBitwiseAnd$RawType$Release(
   885                 return UNSAFE.getAndBitwiseAnd$RawType$Release(
   856                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   886                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   857                         address(bb, indexRO(bb, index)),
   887                         address(bb, indexRO(bb, index)),
   858                         value);
   888                         value);
   859             } else {
   889             } else {
   860                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
   890                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
   861             }
   891             }
   864         @ForceInline
   894         @ForceInline
   865         static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   895         static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   866             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   896             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   867             if (handle.be == BE) {
   897             if (handle.be == BE) {
   868                 return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
   898                 return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
   869                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   899                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   870                         address(bb, indexRO(bb, index)),
   900                         address(bb, indexRO(bb, index)),
   871                         value);
   901                         value);
   872             } else {
   902             } else {
   873                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
   903                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
   874             }
   904             }
   875         }
   905         }
   876 
   906 
   877         @ForceInline
   907         @ForceInline
   878         static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
   908         static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
   879             $type$ nativeExpectedValue, expectedValue;
   909             $type$ nativeExpectedValue, expectedValue;
   880             Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
   910             Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
   881             long offset = address(bb, indexRO(bb, index));
   911             long offset = address(bb, indexRO(bb, index));
   882             do {
   912             do {
   883                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   913                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   884                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   914                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   885             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   915             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   891         @ForceInline
   921         @ForceInline
   892         static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   922         static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   893             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   923             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   894             if (handle.be == BE) {
   924             if (handle.be == BE) {
   895                 return UNSAFE.getAndBitwiseXor$RawType$(
   925                 return UNSAFE.getAndBitwiseXor$RawType$(
   896                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   926                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   897                         address(bb, indexRO(bb, index)),
   927                         address(bb, indexRO(bb, index)),
   898                         value);
   928                         value);
   899             } else {
   929             } else {
   900                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
   930                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
   901             }
   931             }
   904         @ForceInline
   934         @ForceInline
   905         static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   935         static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   906             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   936             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   907             if (handle.be == BE) {
   937             if (handle.be == BE) {
   908                 return UNSAFE.getAndBitwiseXor$RawType$Release(
   938                 return UNSAFE.getAndBitwiseXor$RawType$Release(
   909                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   939                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   910                         address(bb, indexRO(bb, index)),
   940                         address(bb, indexRO(bb, index)),
   911                         value);
   941                         value);
   912             } else {
   942             } else {
   913                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
   943                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
   914             }
   944             }
   917         @ForceInline
   947         @ForceInline
   918         static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   948         static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
   919             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   949             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
   920             if (handle.be == BE) {
   950             if (handle.be == BE) {
   921                 return UNSAFE.getAndBitwiseXor$RawType$Acquire(
   951                 return UNSAFE.getAndBitwiseXor$RawType$Acquire(
   922                         UNSAFE.getObject(bb, BYTE_BUFFER_HB),
   952                         UNSAFE.getReference(bb, BYTE_BUFFER_HB),
   923                         address(bb, indexRO(bb, index)),
   953                         address(bb, indexRO(bb, index)),
   924                         value);
   954                         value);
   925             } else {
   955             } else {
   926                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
   956                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
   927             }
   957             }
   928         }
   958         }
   929 
   959 
   930         @ForceInline
   960         @ForceInline
   931         static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
   961         static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
   932             $type$ nativeExpectedValue, expectedValue;
   962             $type$ nativeExpectedValue, expectedValue;
   933             Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
   963             Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
   934             long offset = address(bb, indexRO(bb, index));
   964             long offset = address(bb, indexRO(bb, index));
   935             do {
   965             do {
   936                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   966                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
   937                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   967                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
   938             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
   968             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,