jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
author amurillo
Sat, 14 May 2016 09:11:07 -0700
changeset 38367 21801e8e9344
parent 37792 dd626e6f5967
parent 38358 cb99c6d2af1b
child 38372 017d7578731c
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     1
/*
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     4
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    10
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    15
 * accompanied this code).
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    16
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    20
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    23
 * questions.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    24
 */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    25
package java.lang.invoke;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    26
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    27
import jdk.internal.misc.Unsafe;
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
    28
import jdk.internal.util.Preconditions;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    29
import jdk.internal.vm.annotation.ForceInline;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    30
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    31
import java.nio.ByteBuffer;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    32
import java.nio.ReadOnlyBufferException;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    33
import java.util.Objects;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    34
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    35
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    36
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    37
#warn
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    38
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    39
final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    40
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    41
    static final int ALIGN = $BoxType$.BYTES - 1;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    42
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    43
#if[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    44
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    45
    static $rawType$ convEndian(boolean big, $type$ v) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    46
        $rawType$ rv = $Type$.$type$ToRaw$RawType$Bits(v);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    47
        return big == BE ? rv : $RawBoxType$.reverseBytes(rv);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    48
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    49
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    50
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    51
    static $type$ convEndian(boolean big, $rawType$ rv) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    52
        rv = big == BE ? rv : $RawBoxType$.reverseBytes(rv);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    53
        return $Type$.$rawType$BitsTo$Type$(rv);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    54
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    55
#else[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    56
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    57
    static $type$ convEndian(boolean big, $type$ n) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    58
        return big == BE ? n : $BoxType$.reverseBytes(n);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    59
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    60
#end[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    61
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    62
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    63
    private static abstract class ByteArrayViewVarHandle extends VarHandle {
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    64
        final boolean be;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    65
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    66
        ByteArrayViewVarHandle(VarForm form, boolean be) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    67
            super(form);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    68
            this.be = be;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    69
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    70
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    71
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    72
    static final class ArrayHandle extends ByteArrayViewVarHandle {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    73
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    74
        ArrayHandle(boolean be) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    75
            super(ArrayHandle.FORM, be);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    76
        }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    77
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    78
        @Override
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    79
        final MethodType accessModeTypeUncached(AccessMode accessMode) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    80
            return accessMode.at.accessModeType(byte[].class, $type$.class, int.class);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    81
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    82
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    83
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    84
        static int index(byte[] ba, int index) {
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
    85
            return Preconditions.checkIndex(index, ba.length - ALIGN, null);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    86
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    87
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    88
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    89
        static long address(byte[] ba, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    90
            long address = ((long) index) + Unsafe.ARRAY_BYTE_BASE_OFFSET;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    91
            if ((address & ALIGN) != 0)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    92
                throw newIllegalStateExceptionForMisalignedAccess(index);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    93
            return address;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    94
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    95
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    96
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    97
        static $type$ get(ArrayHandle handle, Object oba, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    98
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    99
#if[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   100
            $rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   101
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   102
                    ((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   103
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   104
            return $Type$.$rawType$BitsTo$Type$(rawValue);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   105
#else[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   106
            return UNSAFE.get$Type$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   107
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   108
                    ((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   109
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   110
#end[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   111
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   112
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   113
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   114
        static void set(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   115
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   116
#if[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   117
            UNSAFE.put$RawType$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   118
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   119
                    ((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   120
                    $Type$.$type$ToRaw$RawType$Bits(value),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   121
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   122
#else[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   123
            UNSAFE.put$RawType$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   124
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   125
                    ((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   126
                    value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   127
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   128
#end[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   129
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   130
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   131
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   132
        static $type$ getVolatile(ArrayHandle handle, Object oba, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   133
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   134
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   135
                              UNSAFE.get$RawType$Volatile(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   136
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   137
                                      address(ba, index(ba, index))));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   138
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   139
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   140
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   141
        static void setVolatile(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   142
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   143
            UNSAFE.put$RawType$Volatile(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   144
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   145
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   146
                    convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   147
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   148
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   149
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   150
        static $type$ getAcquire(ArrayHandle handle, Object oba, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   151
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   152
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   153
                              UNSAFE.get$RawType$Acquire(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   154
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   155
                                      address(ba, index(ba, index))));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   156
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   157
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   158
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   159
        static void setRelease(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   160
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   161
            UNSAFE.put$RawType$Release(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   162
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   163
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   164
                    convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   165
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   166
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   167
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   168
        static $type$ getOpaque(ArrayHandle handle, Object oba, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   169
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   170
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   171
                              UNSAFE.get$RawType$Opaque(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   172
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   173
                                      address(ba, index(ba, index))));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   174
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   175
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   176
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   177
        static void setOpaque(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   178
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   179
            UNSAFE.put$RawType$Opaque(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   180
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   181
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   182
                    convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   183
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   184
#if[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   185
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   186
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   187
        static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   188
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   189
            return UNSAFE.compareAndSwap$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   190
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   191
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   192
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   193
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   194
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   195
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   196
        static $type$ compareAndExchangeVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   197
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   198
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   199
                              UNSAFE.compareAndExchange$RawType$Volatile(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   200
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   201
                                      address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   202
                                      convEndian(handle.be, expected), convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   203
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   204
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   205
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   206
        static $type$ compareAndExchangeAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   207
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   208
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   209
                              UNSAFE.compareAndExchange$RawType$Acquire(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   210
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   211
                                      address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   212
                                      convEndian(handle.be, expected), convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   213
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   214
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   215
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   216
        static $type$ compareAndExchangeRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   217
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   218
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   219
                              UNSAFE.compareAndExchange$RawType$Release(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   220
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   221
                                      address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   222
                                      convEndian(handle.be, expected), convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   223
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   224
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   225
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   226
        static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   227
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   228
            return UNSAFE.weakCompareAndSwap$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   229
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   230
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   231
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   232
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   233
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   234
        @ForceInline
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   235
        static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   236
            byte[] ba = (byte[]) oba;
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   237
            // TODO defer to strong form until new Unsafe method is added
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   238
            return UNSAFE.compareAndSwap$RawType$(
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   239
                    ba,
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   240
                    address(ba, index(ba, index)),
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   241
                    convEndian(handle.be, expected), convEndian(handle.be, value));
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   242
        }
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   243
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   244
        @ForceInline
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   245
        static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   246
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   247
            return UNSAFE.weakCompareAndSwap$RawType$Acquire(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   248
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   249
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   250
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   251
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   252
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   253
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   254
        static boolean weakCompareAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   255
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   256
            return UNSAFE.weakCompareAndSwap$RawType$Release(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   257
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   258
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   259
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   260
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   261
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   262
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   263
        static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   264
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   265
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   266
                              UNSAFE.getAndSet$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   267
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   268
                                      address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   269
                                      convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   270
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   271
#end[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   272
#if[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   273
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   274
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   275
        static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   276
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   277
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   278
                              UNSAFE.getAndAdd$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   279
                                      ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   280
                                      address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   281
                                      convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   282
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   283
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   284
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   285
        static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   286
            byte[] ba = (byte[]) oba;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   287
            return convEndian(handle.be, UNSAFE.getAndAdd$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   288
                    ba,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   289
                    address(ba, index(ba, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   290
                    convEndian(handle.be, value))) + value;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   291
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   292
#end[AtomicAdd]
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   293
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   294
        static final VarForm FORM = new VarForm(ArrayHandle.class, byte[].class, $type$.class, int.class);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   295
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   296
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   297
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   298
    static final class ByteBufferHandle extends ByteArrayViewVarHandle {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   299
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   300
        ByteBufferHandle(boolean be) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   301
            super(ByteBufferHandle.FORM, be);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   302
        }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   303
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   304
        @Override
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   305
        final MethodType accessModeTypeUncached(AccessMode accessMode) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   306
            return accessMode.at.accessModeType(ByteBuffer.class, $type$.class, int.class);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   307
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   308
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   309
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   310
        static int index(ByteBuffer bb, int index) {
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   311
            return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   312
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   313
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   314
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   315
        static int indexRO(ByteBuffer bb, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   316
            if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY))
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   317
                throw new ReadOnlyBufferException();
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   318
            return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   319
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   320
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   321
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   322
        static long address(ByteBuffer bb, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   323
            long address = ((long) index) + UNSAFE.getLong(bb, BUFFER_ADDRESS);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   324
            if ((address & ALIGN) != 0)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   325
                throw newIllegalStateExceptionForMisalignedAccess(index);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   326
            return address;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   327
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   328
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   329
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   330
        static $type$ get(ByteBufferHandle handle, Object obb, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   331
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   332
#if[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   333
            $rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   334
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   335
                    ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   336
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   337
            return $Type$.$rawType$BitsTo$Type$(rawValue);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   338
#else[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   339
            return UNSAFE.get$Type$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   340
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   341
                    ((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   342
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   343
#end[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   344
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   345
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   346
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   347
        static void set(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   348
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   349
#if[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   350
            UNSAFE.put$RawType$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   351
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   352
                    ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   353
                    $Type$.$type$ToRaw$RawType$Bits(value),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   354
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   355
#else[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   356
            UNSAFE.put$Type$Unaligned(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   357
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   358
                    ((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   359
                    value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   360
                    handle.be);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   361
#end[floatingPoint]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   362
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   363
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   364
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   365
        static $type$ getVolatile(ByteBufferHandle handle, Object obb, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   366
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   367
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   368
                              UNSAFE.get$RawType$Volatile(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   369
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   370
                                      address(bb, index(bb, index))));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   371
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   372
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   373
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   374
        static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   375
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   376
            UNSAFE.put$RawType$Volatile(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   377
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   378
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   379
                    convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   380
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   381
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   382
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   383
        static $type$ getAcquire(ByteBufferHandle handle, Object obb, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   384
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   385
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   386
                              UNSAFE.get$RawType$Acquire(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   387
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   388
                                      address(bb, index(bb, index))));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   389
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   390
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   391
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   392
        static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   393
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   394
            UNSAFE.put$RawType$Release(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   395
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   396
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   397
                    convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   398
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   399
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   400
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   401
        static $type$ getOpaque(ByteBufferHandle handle, Object obb, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   402
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   403
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   404
                              UNSAFE.get$RawType$Opaque(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   405
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   406
                                      address(bb, index(bb, index))));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   407
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   408
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   409
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   410
        static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   411
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   412
            UNSAFE.put$RawType$Opaque(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   413
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   414
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   415
                    convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   416
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   417
#if[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   418
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   419
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   420
        static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   421
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   422
            return UNSAFE.compareAndSwap$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   423
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   424
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   425
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   426
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   427
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   428
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   429
        static $type$ compareAndExchangeVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   430
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   431
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   432
                              UNSAFE.compareAndExchange$RawType$Volatile(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   433
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   434
                                      address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   435
                                      convEndian(handle.be, expected), convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   436
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   437
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   438
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   439
        static $type$ compareAndExchangeAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   440
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   441
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   442
                              UNSAFE.compareAndExchange$RawType$Acquire(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   443
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   444
                                      address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   445
                                      convEndian(handle.be, expected), convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   446
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   447
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   448
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   449
        static $type$ compareAndExchangeRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   450
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   451
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   452
                              UNSAFE.compareAndExchange$RawType$Release(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   453
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   454
                                      address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   455
                                      convEndian(handle.be, expected), convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   456
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   457
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   458
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   459
        static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   460
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   461
            return UNSAFE.weakCompareAndSwap$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   462
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   463
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   464
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   465
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   466
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   467
        @ForceInline
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   468
        static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   469
            ByteBuffer bb = (ByteBuffer) obb;
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   470
            // TODO defer to strong form until new Unsafe method is added
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   471
            return UNSAFE.compareAndSwap$RawType$(
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   472
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   473
                    address(bb, indexRO(bb, index)),
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   474
                    convEndian(handle.be, expected), convEndian(handle.be, value));
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   475
        }
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   476
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 36934
diff changeset
   477
        @ForceInline
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   478
        static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   479
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   480
            return UNSAFE.weakCompareAndSwap$RawType$Acquire(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   481
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   482
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   483
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   484
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   485
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   486
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   487
        static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   488
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   489
            return UNSAFE.weakCompareAndSwap$RawType$Release(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   490
                    UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   491
                    address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   492
                    convEndian(handle.be, expected), convEndian(handle.be, value));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   493
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   494
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   495
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   496
        static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   497
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   498
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   499
                              UNSAFE.getAndSet$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   500
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   501
                                      address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   502
                                      convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   503
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   504
#end[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   505
#if[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   506
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   507
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   508
        static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   509
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   510
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   511
                              UNSAFE.getAndAdd$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   512
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   513
                                      address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   514
                                      convEndian(handle.be, value)));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   515
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   516
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   517
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   518
        static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   519
            ByteBuffer bb = (ByteBuffer) obb;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   520
            return convEndian(handle.be,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   521
                              UNSAFE.getAndAdd$RawType$(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   522
                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   523
                                      address(bb, indexRO(bb, index)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   524
                                      convEndian(handle.be, value))) + value;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   525
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   526
#end[AtomicAdd]
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   527
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   528
        static final VarForm FORM = new VarForm(ByteBufferHandle.class, ByteBuffer.class, $type$.class, int.class);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   529
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   530
}