jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
author psandoz
Thu, 05 May 2016 18:14:47 -0700
changeset 38356 1e4ecca97792
parent 36934 590fc47a0aeb
child 38358 cb99c6d2af1b
permissions -rw-r--r--
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package Reviewed-by: chegar, shade, forax, vlivanov
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
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
    27
import jdk.internal.util.Preconditions;
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
    28
import jdk.internal.vm.annotation.ForceInline;
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
    29
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    30
import java.util.Objects;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    31
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    32
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    33
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    34
#warn
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    35
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    36
final class VarHandle$Type$s {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    37
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    38
    static class FieldInstanceReadOnly extends VarHandle {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    39
        final long fieldOffset;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    40
        final Class<?> receiverType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    41
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    42
        final Class<?> fieldType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    43
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    44
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    45
        FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    46
            this(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadOnly.class);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    47
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    48
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    49
        protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    50
                                        Class<? extends FieldInstanceReadOnly> handle) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    51
            super(VarForm.createFromStatic(handle), receiverType, {#if[Object]?fieldType:$type$.class});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    52
            this.fieldOffset = fieldOffset;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    53
            this.receiverType = receiverType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    54
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    55
            this.fieldType = fieldType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    56
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    57
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    58
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    59
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    60
        static $type$ get(FieldInstanceReadOnly handle, Object holder) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    61
            return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    62
                                 handle.fieldOffset);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    63
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    64
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    65
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    66
        static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    67
            return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    68
                                 handle.fieldOffset);
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
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    72
        static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    73
            return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    74
                                 handle.fieldOffset);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    75
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    76
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    77
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    78
        static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    79
            return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    80
                                 handle.fieldOffset);
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
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    84
    static class FieldInstanceReadWrite extends FieldInstanceReadOnly {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    85
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    86
        FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    87
            super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.class);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    88
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    89
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    90
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    91
        static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    92
            UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    93
                             handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    94
                             {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    95
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    96
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    97
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    98
        static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    99
            UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   100
                                     handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   101
                                     {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   102
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   103
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   104
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   105
        static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   106
            UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   107
                                   handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   108
                                   {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   109
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   110
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   111
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   112
        static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   113
            UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   114
                                    handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   115
                                    {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   116
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   117
#if[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   118
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   119
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   120
        static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   121
            return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   122
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   123
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   124
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   125
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   126
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   127
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   128
        static $type$ compareAndExchangeVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   129
            return UNSAFE.compareAndExchange$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   130
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   131
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   132
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   133
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   134
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   135
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   136
        static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   137
            return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   138
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   139
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   140
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   141
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   142
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   143
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   144
        static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   145
            return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   146
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   147
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   148
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   149
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   150
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   151
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   152
        static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   153
            return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   154
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   155
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   156
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   157
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   158
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   159
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   160
        static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   161
            return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   162
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   163
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   164
                                               {#if[Object]?handle.fieldType.cast(value):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 boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   169
            return UNSAFE.weakCompareAndSwap$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   170
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   171
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   172
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   173
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   174
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   175
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   176
        static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   177
            return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   178
                                          handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   179
                                          {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   180
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   181
#end[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   182
#if[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   183
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   184
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   185
        static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   186
            return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   187
                                       handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   188
                                       value);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   189
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   190
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   191
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   192
        static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   193
            return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   194
                                       handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   195
                                       value) + value;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   196
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   197
#end[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   198
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   199
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   200
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   201
    static class FieldStaticReadOnly extends VarHandle {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   202
        final Object base;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   203
        final long fieldOffset;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   204
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   205
        final Class<?> fieldType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   206
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   207
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   208
        FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   209
            this(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.class);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   210
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   211
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   212
        protected FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   213
                                      Class<? extends FieldStaticReadOnly> handle) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   214
            super(VarForm.createFromStatic(handle), null, {#if[Object]?fieldType:$type$.class});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   215
            this.base = base;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   216
            this.fieldOffset = fieldOffset;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   217
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   218
            this.fieldType = fieldType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   219
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   220
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   221
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   222
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   223
        static $type$ get(FieldStaticReadOnly handle) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   224
            return UNSAFE.get$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   225
                                 handle.fieldOffset);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   226
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   227
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   228
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   229
        static $type$ getVolatile(FieldStaticReadOnly handle) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   230
            return UNSAFE.get$Type$Volatile(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   231
                                 handle.fieldOffset);
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
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   235
        static $type$ getOpaque(FieldStaticReadOnly handle) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   236
            return UNSAFE.get$Type$Opaque(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   237
                                 handle.fieldOffset);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   238
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   239
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   240
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   241
        static $type$ getAcquire(FieldStaticReadOnly handle) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   242
            return UNSAFE.get$Type$Acquire(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   243
                                 handle.fieldOffset);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   244
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   245
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   246
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   247
    static class FieldStaticReadWrite extends FieldStaticReadOnly {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   248
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   249
        FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   250
            super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.class);
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 void set(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   255
            UNSAFE.put$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   256
                             handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   257
                             {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   258
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   259
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   260
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   261
        static void setVolatile(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   262
            UNSAFE.put$Type$Volatile(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   263
                                     handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   264
                                     {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   265
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   266
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   267
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   268
        static void setOpaque(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   269
            UNSAFE.put$Type$Opaque(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   270
                                   handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   271
                                   {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   272
        }
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 void setRelease(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   276
            UNSAFE.put$Type$Release(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   277
                                    handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   278
                                    {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   279
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   280
#if[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   281
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   282
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   283
        static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   284
            return UNSAFE.compareAndSwap$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   285
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   286
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   287
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   288
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   289
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   290
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   291
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   292
        static $type$ compareAndExchangeVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   293
            return UNSAFE.compareAndExchange$Type$Volatile(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   294
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   295
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   296
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   297
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   298
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   299
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   300
        static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   301
            return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   302
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   303
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   304
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   305
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   306
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   307
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   308
        static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   309
            return UNSAFE.compareAndExchange$Type$Release(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   310
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   311
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   312
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   313
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   314
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   315
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   316
        static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   317
            return UNSAFE.weakCompareAndSwap$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   318
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   319
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   320
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   321
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   322
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   323
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   324
        static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   325
            return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   326
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   327
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   328
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   329
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   330
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   331
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   332
        static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   333
            return UNSAFE.weakCompareAndSwap$Type$Release(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   334
                                               handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   335
                                               {#if[Object]?handle.fieldType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   336
                                               {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   337
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   338
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   339
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   340
        static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   341
            return UNSAFE.getAndSet$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   342
                                          handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   343
                                          {#if[Object]?handle.fieldType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   344
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   345
#end[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   346
#if[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   347
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   348
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   349
        static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   350
            return UNSAFE.getAndAdd$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   351
                                       handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   352
                                       value);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   353
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   354
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   355
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   356
        static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   357
            return UNSAFE.getAndAdd$Type$(handle.base,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   358
                                       handle.fieldOffset,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   359
                                       value) + value;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   360
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   361
#end[AtomicAdd]
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
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   365
    static final class Array extends VarHandle {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   366
        final int abase;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   367
        final int ashift;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   368
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   369
        final Class<{#if[Object]??:$type$[]}> arrayType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   370
        final Class<?> componentType;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   371
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   372
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   373
        Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   374
            super(VarForm.createFromStatic(Array.class),
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   375
                  {#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   376
            this.abase = abase;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   377
            this.ashift = ashift;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   378
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   379
            this.arrayType = {#if[Object]?arrayType:$type$[].class};
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   380
            this.componentType = arrayType.getComponentType();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   381
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   382
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   383
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   384
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   385
        static $type$ get(Array handle, Object oarray, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   386
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   387
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   388
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   389
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   390
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   391
            return array[index];
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   392
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   393
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   394
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   395
        static void set(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   396
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   397
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   398
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   399
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   400
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   401
            array[index] = {#if[Object]?handle.componentType.cast(value):value};
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   402
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   403
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   404
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   405
        static $type$ getVolatile(Array handle, Object oarray, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   406
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   407
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   408
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   409
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   410
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   411
            return UNSAFE.get$Type$Volatile(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   412
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   413
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   414
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   415
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   416
        static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   417
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   418
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   419
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   420
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   421
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   422
            UNSAFE.put$Type$Volatile(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   423
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   424
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   425
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   426
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   427
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   428
        static $type$ getOpaque(Array handle, Object oarray, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   429
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   430
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   431
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   432
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   433
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   434
            return UNSAFE.get$Type$Opaque(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   435
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
36934
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 void setOpaque(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   440
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   441
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   442
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   443
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   444
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   445
            UNSAFE.put$Type$Opaque(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   446
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   447
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   448
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   449
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   450
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   451
        static $type$ getAcquire(Array handle, Object oarray, int index) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   452
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   453
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   454
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   455
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   456
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   457
            return UNSAFE.get$Type$Acquire(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   458
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   459
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   460
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   461
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   462
        static void setRelease(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   463
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   464
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   465
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   466
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   467
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   468
            UNSAFE.put$Type$Release(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   469
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   470
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   471
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   472
#if[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   473
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   474
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   475
        static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   476
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   477
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   478
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   479
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   480
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   481
            return UNSAFE.compareAndSwap$Type$(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   482
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   483
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   484
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   485
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   486
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   487
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   488
        static $type$ compareAndExchangeVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   489
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   490
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   491
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   492
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   493
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   494
            return UNSAFE.compareAndExchange$Type$Volatile(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   495
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   496
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   497
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   498
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   499
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   500
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   501
        static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   502
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   503
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   504
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   505
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   506
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   507
            return UNSAFE.compareAndExchange$Type$Acquire(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   508
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   509
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   510
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   511
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   512
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   513
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   514
        static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   515
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   516
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   517
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   518
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   519
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   520
            return UNSAFE.compareAndExchange$Type$Release(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   521
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   522
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   523
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   524
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   525
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   526
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   527
        static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   528
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   529
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   530
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   531
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   532
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   533
            return UNSAFE.weakCompareAndSwap$Type$(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   534
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   535
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   536
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   537
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   538
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   539
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   540
        static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   541
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   542
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   543
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   544
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   545
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   546
            return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   547
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   548
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   549
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   550
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   551
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   552
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   553
        static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   554
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   555
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   556
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   557
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   558
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   559
            return UNSAFE.weakCompareAndSwap$Type$Release(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   560
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   561
                    {#if[Object]?handle.componentType.cast(expected):expected},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   562
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   563
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   564
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   565
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   566
        static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   567
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   568
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   569
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   570
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   571
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   572
            return UNSAFE.getAndSet$Type$(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   573
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   574
                    {#if[Object]?handle.componentType.cast(value):value});
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   575
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   576
#end[CAS]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   577
#if[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   578
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   579
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   580
        static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   581
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   582
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   583
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   584
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   585
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   586
            return UNSAFE.getAndAdd$Type$(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   587
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   588
                    value);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   589
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   590
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   591
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   592
        static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   593
#if[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   594
            Object[] array = (Object[]) handle.arrayType.cast(oarray);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   595
#else[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   596
            $type$[] array = ($type$[]) oarray;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   597
#end[Object]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   598
            return UNSAFE.getAndAdd$Type$(array,
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 36934
diff changeset
   599
                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   600
                    value) + value;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   601
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   602
#end[AtomicAdd]
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   603
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   604
}