< prev index next >

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

Print this page

        

@@ -184,14 +184,21 @@
 #if[CAS]
 
         @ForceInline
         static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
+#if[Object]
+            return UNSAFE.compareAndSetReference(
+                    ba,
+                    address(ba, index(ba, index)),
+                    convEndian(handle.be, expected), convEndian(handle.be, value));
+#else[Object]
             return UNSAFE.compareAndSet$RawType$(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
+#end[Object]
         }
 
         @ForceInline
         static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;

@@ -259,15 +266,23 @@
         }
 
         @ForceInline
         static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) {
             byte[] ba = (byte[]) oba;
+#if[Object]
+            return convEndian(handle.be,
+                              UNSAFE.getAndSetReference(
+                                      ba,
+                                      address(ba, index(ba, index)),
+                                      convEndian(handle.be, value)));
+#else[Object]
             return convEndian(handle.be,
                               UNSAFE.getAndSet$RawType$(
                                       ba,
                                       address(ba, index(ba, index)),
                                       convEndian(handle.be, value)));
+#end[Object]
         }
 
         @ForceInline
         static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
             byte[] ba = (byte[]) oba;

@@ -535,34 +550,34 @@
         @ForceInline
         static $type$ get(ByteBufferHandle handle, Object obb, int index) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
 #if[floatingPoint]
             $rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
                     handle.be);
             return $Type$.$rawType$BitsTo$Type$(rawValue);
 #else[floatingPoint]
             return UNSAFE.get$Type$Unaligned(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
                     handle.be);
 #end[floatingPoint]
         }
 
         @ForceInline
         static void set(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
 #if[floatingPoint]
             UNSAFE.put$RawType$Unaligned(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
                     $Type$.$type$ToRaw$RawType$Bits(value),
                     handle.be);
 #else[floatingPoint]
             UNSAFE.put$Type$Unaligned(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
                     value,
                     handle.be);
 #end[floatingPoint]
         }

@@ -570,161 +585,176 @@
         @ForceInline
         static $type$ getVolatile(ByteBufferHandle handle, Object obb, int index) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.get$RawType$Volatile(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, index(bb, index))));
         }
 
         @ForceInline
         static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             UNSAFE.put$RawType$Volatile(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, value));
         }
 
         @ForceInline
         static $type$ getAcquire(ByteBufferHandle handle, Object obb, int index) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.get$RawType$Acquire(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, index(bb, index))));
         }
 
         @ForceInline
         static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             UNSAFE.put$RawType$Release(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, value));
         }
 
         @ForceInline
         static $type$ getOpaque(ByteBufferHandle handle, Object obb, int index) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.get$RawType$Opaque(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, index(bb, index))));
         }
 
         @ForceInline
         static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             UNSAFE.put$RawType$Opaque(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, value));
         }
 #if[CAS]
 
         @ForceInline
         static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
+#if[Object]
+            return UNSAFE.compareAndSetReference(
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
+                    address(bb, indexRO(bb, index)),
+                    convEndian(handle.be, expected), convEndian(handle.be, value));
+#else[Object]
             return UNSAFE.compareAndSet$RawType$(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
+#end[Object]
         }
 
         @ForceInline
         static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.compareAndExchange$RawType$(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
         }
 
         @ForceInline
         static $type$ compareAndExchangeAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.compareAndExchange$RawType$Acquire(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
         }
 
         @ForceInline
         static $type$ compareAndExchangeRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.compareAndExchange$RawType$Release(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
         }
 
         @ForceInline
         static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return UNSAFE.weakCompareAndSet$RawType$Plain(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
         }
 
         @ForceInline
         static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return UNSAFE.weakCompareAndSet$RawType$(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
         }
 
         @ForceInline
         static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return UNSAFE.weakCompareAndSet$RawType$Acquire(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
         }
 
         @ForceInline
         static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return UNSAFE.weakCompareAndSet$RawType$Release(
-                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                    UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
         }
 
         @ForceInline
         static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
+#if[Object]
+            return convEndian(handle.be,
+                              UNSAFE.getAndSetReference(
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
+                                      address(bb, indexRO(bb, index)),
+                                      convEndian(handle.be, value)));
+#else[Object]
             return convEndian(handle.be,
                               UNSAFE.getAndSet$RawType$(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, value)));
+#end[Object]
         }
 
         @ForceInline
         static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.getAndSet$RawType$Acquire(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, value)));
         }
 
         @ForceInline
         static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             return convEndian(handle.be,
                               UNSAFE.getAndSet$RawType$Release(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                                      UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, value)));
         }
 #end[CAS]
 #if[AtomicAdd]

@@ -732,11 +762,11 @@
         @ForceInline
         static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndAdd$RawType$(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         delta);
             } else {
                 return getAndAddConvEndianWithCAS(bb, index, delta);
             }

@@ -745,11 +775,11 @@
         @ForceInline
         static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndAdd$RawType$Acquire(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         delta);
             } else {
                 return getAndAddConvEndianWithCAS(bb, index, delta);
             }

@@ -758,22 +788,22 @@
         @ForceInline
         static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndAdd$RawType$Release(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         delta);
             } else {
                 return getAndAddConvEndianWithCAS(bb, index, delta);
             }
         }
 
         @ForceInline
         static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) {
             $type$ nativeExpectedValue, expectedValue;
-            Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
+            Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
             long offset = address(bb, indexRO(bb, index));
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,

@@ -786,11 +816,11 @@
         @ForceInline
         static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseOr$RawType$(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
             }

@@ -799,11 +829,11 @@
         @ForceInline
         static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseOr$RawType$Release(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
             }

@@ -812,22 +842,22 @@
         @ForceInline
         static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseOr$RawType$Acquire(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseOrConvEndianWithCAS(bb, index, value);
             }
         }
 
         @ForceInline
         static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
             $type$ nativeExpectedValue, expectedValue;
-            Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
+            Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
             long offset = address(bb, indexRO(bb, index));
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,

@@ -838,11 +868,11 @@
         @ForceInline
         static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseAnd$RawType$(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
             }

@@ -851,11 +881,11 @@
         @ForceInline
         static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseAnd$RawType$Release(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
             }

@@ -864,22 +894,22 @@
         @ForceInline
         static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseAndConvEndianWithCAS(bb, index, value);
             }
         }
 
         @ForceInline
         static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
             $type$ nativeExpectedValue, expectedValue;
-            Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
+            Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
             long offset = address(bb, indexRO(bb, index));
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,

@@ -891,11 +921,11 @@
         @ForceInline
         static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseXor$RawType$(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
             }

@@ -904,11 +934,11 @@
         @ForceInline
         static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseXor$RawType$Release(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
             }

@@ -917,22 +947,22 @@
         @ForceInline
         static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
             if (handle.be == BE) {
                 return UNSAFE.getAndBitwiseXor$RawType$Acquire(
-                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        UNSAFE.getReference(bb, BYTE_BUFFER_HB),
                         address(bb, indexRO(bb, index)),
                         value);
             } else {
                 return getAndBitwiseXorConvEndianWithCAS(bb, index, value);
             }
         }
 
         @ForceInline
         static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
             $type$ nativeExpectedValue, expectedValue;
-            Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
+            Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
             long offset = address(bb, indexRO(bb, index));
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
             } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
< prev index next >