/* * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package java.lang.invoke; import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.ForceInline; import java.util.Objects; import static java.lang.invoke.MethodHandleStatics.UNSAFE; #warn final class VarHandle$Type$s { static class FieldInstanceReadOnly extends VarHandle { final long fieldOffset; final Class receiverType; #if[Object] final Class fieldType; #end[Object] FieldInstanceReadOnly(Class receiverType, long fieldOffset{#if[Object]?, Class fieldType}) { this(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadOnly.FORM); } protected FieldInstanceReadOnly(Class receiverType, long fieldOffset{#if[Object]?, Class fieldType}, VarForm form) { super(form); this.fieldOffset = fieldOffset; this.receiverType = receiverType; #if[Object] this.fieldType = fieldType; #end[Object] } @Override final MethodType accessModeTypeUncached(AccessMode accessMode) { return accessMode.at.accessModeType(receiverType, {#if[Object]?fieldType:$type$.class}); } @ForceInline static $type$ get(FieldInstanceReadOnly handle, Object holder) { return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset); } @ForceInline static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) { return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset); } @ForceInline static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) { return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset); } @ForceInline static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) { return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset); } static final VarForm FORM = new VarForm(FieldInstanceReadOnly.class, Object.class, $type$.class); } static final class FieldInstanceReadWrite extends FieldInstanceReadOnly { #if[Object] final boolean needsNullCheck; #end[Object] FieldInstanceReadWrite(Class receiverType, long fieldOffset{#if[Object]?, Class fieldType, boolean canBeNull}) { super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.FORM); #if[Object] this.needsNullCheck = !canBeNull; #end[Object] } #if[Object] @ForceInline static Object checkCast(FieldInstanceReadWrite handle, $type$ value) { if (handle.needsNullCheck) Objects.requireNonNull(value); return handle.fieldType.cast(value); } #end[Object] @ForceInline static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) { UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) { UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) { UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } #if[CAS] @ForceInline static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ getAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } #end[CAS] #if[AtomicAdd] @ForceInline static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndAddRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndAdd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } #end[AtomicAdd] #if[Bitwise] @ForceInline static $type$ getAndBitwiseOr(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseOr$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseOrRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseOr$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseOrAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseOr$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseAnd(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseAnd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseAndRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseAnd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseAndAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseAnd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseXorRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseXorAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, value); } #end[Bitwise] static final VarForm FORM = new VarForm(FieldInstanceReadWrite.class, Object.class, $type$.class); } static class FieldStaticReadOnly extends VarHandle { final Object base; final long fieldOffset; #if[Object] final Class fieldType; #end[Object] FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class fieldType}) { this(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.FORM); } protected FieldStaticReadOnly(Object base, long fieldOffset{#if[Object]?, Class fieldType}, VarForm form) { super(form); this.base = base; this.fieldOffset = fieldOffset; #if[Object] this.fieldType = fieldType; #end[Object] } @Override final MethodType accessModeTypeUncached(AccessMode accessMode) { return accessMode.at.accessModeType(null, {#if[Object]?fieldType:$type$.class}); } @ForceInline static $type$ get(FieldStaticReadOnly handle) { return UNSAFE.get$Type$(handle.base, handle.fieldOffset); } @ForceInline static $type$ getVolatile(FieldStaticReadOnly handle) { return UNSAFE.get$Type$Volatile(handle.base, handle.fieldOffset); } @ForceInline static $type$ getOpaque(FieldStaticReadOnly handle) { return UNSAFE.get$Type$Opaque(handle.base, handle.fieldOffset); } @ForceInline static $type$ getAcquire(FieldStaticReadOnly handle) { return UNSAFE.get$Type$Acquire(handle.base, handle.fieldOffset); } static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, $type$.class); } static final class FieldStaticReadWrite extends FieldStaticReadOnly { #if[Object] final boolean needsNullCheck; #end[Object] FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class fieldType, boolean canBeNull}) { super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM); #if[Object] this.needsNullCheck = !canBeNull; #end[Object] } #if[Object] static Object checkCast(FieldStaticReadWrite handle, $type$ value) { if (handle.needsNullCheck) Objects.requireNonNull(value); return handle.fieldType.cast(value); } #end[Object] @ForceInline static void set(FieldStaticReadWrite handle, $type$ value) { UNSAFE.put$Type$(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static void setVolatile(FieldStaticReadWrite handle, $type$ value) { UNSAFE.put$Type$Volatile(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static void setOpaque(FieldStaticReadWrite handle, $type$ value) { UNSAFE.put$Type$Opaque(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static void setRelease(FieldStaticReadWrite handle, $type$ value) { UNSAFE.put$Type$Release(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } #if[CAS] @ForceInline static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.compareAndSet$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.compareAndExchange$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.compareAndExchange$Type$Acquire(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.compareAndExchange$Type$Release(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$Plain(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSet$Type$Release(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndSet$Type$(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ getAndSetAcquire(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndSet$Type$Acquire(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } @ForceInline static $type$ getAndSetRelease(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndSet$Type$Release(handle.base, handle.fieldOffset, {#if[Object]?checkCast(handle, value):value}); } #end[CAS] #if[AtomicAdd] @ForceInline static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndAdd$Type$(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndAddAcquire(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndAdd$Type$Acquire(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndAddRelease(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndAdd$Type$Release(handle.base, handle.fieldOffset, value); } #end[AtomicAdd] #if[Bitwise] @ForceInline static $type$ getAndBitwiseOr(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseOr$Type$(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseOrRelease(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseOr$Type$Release(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseOrAcquire(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseOr$Type$Acquire(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseAnd(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseAnd$Type$(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseAndRelease(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseAnd$Type$Release(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseAndAcquire(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseAnd$Type$Acquire(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseXor(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseXorRelease(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$Release(handle.base, handle.fieldOffset, value); } @ForceInline static $type$ getAndBitwiseXorAcquire(FieldStaticReadWrite handle, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base, handle.fieldOffset, value); } #end[Bitwise] static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class); } #if[Object] static class FlatValueFieldInstanceReadOnly extends VarHandle { final long fieldOffset; final Class receiverType; final Class fieldType; FlatValueFieldInstanceReadOnly(Class receiverType, long fieldOffset, Class fieldType) { this(receiverType, fieldOffset, fieldType, FlatValueFieldInstanceReadOnly.FORM); } protected FlatValueFieldInstanceReadOnly(Class receiverType, long fieldOffset, Class fieldType, VarForm form) { super(form); this.fieldOffset = fieldOffset; this.receiverType = receiverType; this.fieldType = fieldType; } @Override final MethodType accessModeTypeUncached(AccessMode accessMode) { return accessMode.at.accessModeType(receiverType, fieldType); } @ForceInline static Object get(FlatValueFieldInstanceReadOnly handle, Object holder) { return UNSAFE.getValue(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType); } @ForceInline static Object getVolatile(FlatValueFieldInstanceReadOnly handle, Object holder) { return UNSAFE.getValueVolatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType); } @ForceInline static Object getOpaque(FlatValueFieldInstanceReadOnly handle, Object holder) { return UNSAFE.getValueOpaque(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType); } @ForceInline static Object getAcquire(FlatValueFieldInstanceReadOnly handle, Object holder) { return UNSAFE.getValueAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType); } static final VarForm FORM = new VarForm(FlatValueFieldInstanceReadOnly.class, Object.class, Object.class); } static final class FlatValueFieldInstanceReadWrite extends FlatValueFieldInstanceReadOnly { FlatValueFieldInstanceReadWrite(Class receiverType, long fieldOffset, Class fieldType) { super(receiverType, fieldOffset, fieldType, FlatValueFieldInstanceReadWrite.FORM); } @ForceInline static void set(FlatValueFieldInstanceReadWrite handle, Object holder, Object value) { UNSAFE.putValue(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static void setVolatile(FlatValueFieldInstanceReadWrite handle, Object holder, Object value) { UNSAFE.putValueVolatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static void setOpaque(FlatValueFieldInstanceReadWrite handle, Object holder, Object value) { UNSAFE.putValueOpaque(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static void setRelease(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ value) { UNSAFE.putValueRelease(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } #if[CAS] @ForceInline static boolean compareAndSet(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndSetValue(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static $type$ compareAndExchange(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndExchangeValue(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static $type$ compareAndExchangeAcquire(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndExchangeValueAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static $type$ compareAndExchangeRelease(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.compareAndExchangeValueRelease(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static boolean weakCompareAndSetPlain(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSetValuePlain(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static boolean weakCompareAndSet(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSetValue(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static boolean weakCompareAndSetAcquire(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSetValueAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static boolean weakCompareAndSetRelease(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSetValueRelease(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(expected)), handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static $type$ getAndSet(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndSetValue(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static $type$ getAndSetAcquire(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndSetValueAcquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } @ForceInline static $type$ getAndSetRelease(FlatValueFieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndSetValueRelease(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, handle.fieldType, handle.fieldType.cast(Objects.requireNonNull(value))); } #end[CAS] static final VarForm FORM = new VarForm(FlatValueFieldInstanceReadWrite.class, Object.class, Object.class); } #end[Object] static final class Array extends VarHandle { final int abase; final int ashift; #if[Object] final Class<{#if[Object]??:$type$[]}> arrayType; final Class componentType; #end[Object] Array(int abase, int ashift{#if[Object]?, Class arrayType}) { super(Array.FORM); this.abase = abase; this.ashift = ashift; #if[Object] this.arrayType = {#if[Object]?arrayType:$type$[].class}; this.componentType = arrayType.getComponentType(); #end[Object] } @Override final MethodType accessModeTypeUncached(AccessMode accessMode) { return accessMode.at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class); } #if[Object] @ForceInline static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) { if (handle.arrayType == oarray.getClass()) { // Fast path: static array type same as argument array type return handle.componentType.cast(value); } else { // Slow path: check value against argument array component type return reflectiveTypeCheck(oarray, value); } } @ForceInline static Object reflectiveTypeCheck(Object[] oarray, Object value) { try { return oarray.getClass().getComponentType().cast(value); } catch (ClassCastException e) { throw new ArrayStoreException(); } } #end[Object] @ForceInline static $type$ get(Array handle, Object oarray, int index) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return array[index]; } @ForceInline static void set(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] array[index] = {#if[Object]?handle.componentType.cast(value):value}; } @ForceInline static $type$ getVolatile(Array handle, Object oarray, int index) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.get$Type$Volatile(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); } @ForceInline static void setVolatile(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] UNSAFE.put$Type$Volatile(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ getOpaque(Array handle, Object oarray, int index) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.get$Type$Opaque(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); } @ForceInline static void setOpaque(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] UNSAFE.put$Type$Opaque(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ getAcquire(Array handle, Object oarray, int index) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.get$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); } @ForceInline static void setRelease(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] UNSAFE.put$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } #if[CAS] @ForceInline static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndSet$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ compareAndExchange(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndExchange$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndExchange$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndExchange$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSet$Type$Plain(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSet$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSet$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSet$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.getAndSet$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ getAndSetAcquire(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.getAndSet$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } @ForceInline static $type$ getAndSetRelease(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.getAndSet$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?runtimeTypeCheck(handle, array, value):value}); } #end[CAS] #if[AtomicAdd] @ForceInline static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndAdd$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndAddAcquire(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndAdd$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndAddRelease(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndAdd$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } #end[AtomicAdd] #if[Bitwise] @ForceInline static $type$ getAndBitwiseOr(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseOr$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseOrRelease(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseOr$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseOrAcquire(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseOr$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseAnd(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseAnd$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseAndRelease(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseAnd$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseAndAcquire(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseAnd$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseXor$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseXorRelease(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseXor$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline static $type$ getAndBitwiseXorAcquire(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; return UNSAFE.getAndBitwiseXor$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } #end[Bitwise] static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); } #if[Object] static final class ValueArray extends VarHandle { final int abase; final int ashift; final Class arrayType; final Class componentType; ValueArray(int abase, int ashift, Class arrayType) { super(ValueArray.FORM); this.abase = abase; this.ashift = ashift; this.arrayType = arrayType; this.componentType = arrayType.getComponentType(); } @Override final MethodType accessModeTypeUncached(AccessMode accessMode) { return accessMode.at.accessModeType(arrayType, arrayType.getComponentType(), int.class); } @ForceInline static Object runtimeTypeCheck(ValueArray handle, Object[] oarray, Object value) { if (handle.arrayType == oarray.getClass()) { // Fast path: static array type same as argument array type return handle.componentType.cast(Objects.requireNonNull(value)); } else { // Slow path: check value against argument array component type return reflectiveTypeCheck(oarray, value); } } @ForceInline static Object reflectiveTypeCheck(Object[] oarray, Object value) { try { return oarray.getClass().getComponentType().cast(Objects.requireNonNull(value)); } catch (ClassCastException e) { throw new ArrayStoreException(); } } @ForceInline static $type$ get(ValueArray handle, Object oarray, int index) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return array[index]; } @ForceInline static void set(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); array[index] = handle.componentType.cast(Objects.requireNonNull(value)); } @ForceInline static $type$ getVolatile(ValueArray handle, Object oarray, int index) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.getValueVolatile(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType); } @ForceInline static void setVolatile(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); UNSAFE.putValueVolatile(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ getOpaque(ValueArray handle, Object oarray, int index) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.getValueOpaque(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType); } @ForceInline static void setOpaque(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); UNSAFE.putValueOpaque(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ getAcquire(ValueArray handle, Object oarray, int index) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.getValueAcquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType); } @ForceInline static void setRelease(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); UNSAFE.putValueRelease(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, runtimeTypeCheck(handle, array, value)); } #if[CAS] @ForceInline static boolean compareAndSet(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.compareAndSetValue(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ compareAndExchange(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.compareAndExchangeValue(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ compareAndExchangeAcquire(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.compareAndExchangeValueAcquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ compareAndExchangeRelease(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.compareAndExchangeValueRelease(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static boolean weakCompareAndSetPlain(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.weakCompareAndSetValuePlain(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static boolean weakCompareAndSet(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.weakCompareAndSetValue(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static boolean weakCompareAndSetAcquire(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.weakCompareAndSetValueAcquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static boolean weakCompareAndSetRelease(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.weakCompareAndSetValueRelease(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, handle.componentType.cast(Objects.requireNonNull(expected)), runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ getAndSet(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.getAndSetValue(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ getAndSetAcquire(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.getAndSetValueAcquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, runtimeTypeCheck(handle, array, value)); } @ForceInline static $type$ getAndSetRelease(ValueArray handle, Object oarray, int index, $type$ value) { Object[] array = (Object[]) handle.arrayType.cast(oarray); return UNSAFE.getAndSetValueRelease(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, handle.componentType, runtimeTypeCheck(handle, array, value)); } #end[CAS] static final VarForm FORM = new VarForm(ValueArray.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); } #end[Object] }