8243491: Implementation of Foreign-Memory Access API (Second Incubator)

Upstream latest changes of the Foreign-Memory Access API

Co-authored-by: Jorn Vernee <jorn.vernee@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Paul Sandoz <paul.sandoz@oracle.com>
Co-authored-by: Peter Levart <peter.levart@gmail.com>
Reviewed-by: chegar, psandoz
This commit is contained in:
Chris Hegarty 2020-05-25 10:54:39 +01:00 committed by Maurizio Cimadamore
parent 9b94b9d1a1
commit f3eb44a94d
94 changed files with 7496 additions and 1388 deletions

View file

@ -0,0 +1,108 @@
/*
* Copyright (c) 2020, 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.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.Stable;
import java.util.List;
import java.util.function.BiFunction;
/**
* An indirect var handle can be thought of as an aggregate of the method handles implementing its supported access modes.
* Its varform contains no method name table (given that some of the method handles composing a bound var handle might
* not be direct). The set of method handles constituting an inditrect var handle are retrieved lazily, to minimize
* code spinning (since not all the access modes will be used anyway).
* Indirect var handles are useful when constructing var handle adapters - that is, an adapter var handle
* can be constructed by extracting the method handles constituting the target var handle, adapting them
* (using the method handle combinator API) and then repackaging the adapted method handles into a new, indirect
* var handle.
*/
/* package */ class IndirectVarHandle extends VarHandle {
@Stable
private final MethodHandle[] handleMap = new MethodHandle[AccessMode.values().length];
private final VarHandle directTarget; // cache, for performance reasons
private final VarHandle target;
private final BiFunction<AccessMode, MethodHandle, MethodHandle> handleFactory;
private final Class<?> value;
private final Class<?>[] coordinates;
IndirectVarHandle(VarHandle target, Class<?> value, Class<?>[] coordinates, BiFunction<AccessMode, MethodHandle, MethodHandle> handleFactory) {
super(new VarForm(value, coordinates));
this.handleFactory = handleFactory;
this.target = target;
this.directTarget = target.asDirect();
this.value = value;
this.coordinates = coordinates;
}
@Override
public Class<?> varType() {
return value;
}
@Override
public List<Class<?>> coordinateTypes() {
return List.of(coordinates);
}
@Override
MethodType accessModeTypeUncached(AccessMode accessMode) {
return accessMode.at.accessModeType(directTarget.getClass(), value, coordinates);
}
@Override
boolean isDirect() {
return false;
}
@Override
VarHandle asDirect() {
return directTarget;
}
VarHandle target() {
return target;
}
@Override
@ForceInline
MethodHandle getMethodHandle(int mode) {
MethodHandle handle = handleMap[mode];
if (handle == null) {
MethodHandle targetHandle = target.getMethodHandle(mode); // might throw UOE of access mode is not supported, which is ok
handle = handleMap[mode] = handleFactory.apply(AccessMode.values()[mode], targetHandle);
}
return handle;
}
@Override
public MethodHandle toMethodHandle(AccessMode accessMode) {
return getMethodHandle(accessMode.ordinal()).bindTo(directTarget);
}
}

View file

@ -365,6 +365,7 @@ class Invokers {
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
int nameCursor = ARG_LIMIT;
final int VAD_ARG = nameCursor++;
final int UNBOUND_VH = nameCursor++;
final int CHECK_TYPE = nameCursor++;
final int CHECK_CUSTOM = (CUSTOMIZE_THRESHOLD >= 0) ? nameCursor++ : -1;
final int LINKER_CALL = nameCursor++;
@ -376,11 +377,14 @@ class Invokers {
}
names[VAD_ARG] = new Name(ARG_LIMIT, BasicType.basicType(Object.class));
names[UNBOUND_VH] = new Name(getFunction(NF_directVarHandleTarget), names[THIS_VH]);
names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[THIS_VH], names[VAD_ARG]);
Object[] outArgs = new Object[ARG_LIMIT + 1];
outArgs[0] = names[CHECK_TYPE];
for (int i = 0; i < ARG_LIMIT; i++) {
outArgs[1] = names[UNBOUND_VH];
for (int i = 1; i < ARG_LIMIT; i++) {
outArgs[i + 1] = names[i];
}
@ -411,6 +415,7 @@ class Invokers {
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
int nameCursor = ARG_LIMIT;
final int VAD_ARG = nameCursor++;
final int UNBOUND_VH = nameCursor++;
final int CHECK_TYPE = nameCursor++;
final int LINKER_CALL = nameCursor++;
@ -427,6 +432,8 @@ class Invokers {
NamedFunction getter = speciesData.getterFunction(0);
names[VAD_ARG] = new Name(getter, names[THIS_MH]);
names[UNBOUND_VH] = new Name(getFunction(NF_directVarHandleTarget), names[CALL_VH]);
if (isExact) {
names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleExactType), names[CALL_VH], names[VAD_ARG]);
} else {
@ -434,7 +441,8 @@ class Invokers {
}
Object[] outArgs = new Object[ARG_LIMIT];
outArgs[0] = names[CHECK_TYPE];
for (int i = 1; i < ARG_LIMIT; i++) {
outArgs[1] = names[UNBOUND_VH];
for (int i = 2; i < ARG_LIMIT; i++) {
outArgs[i] = names[i];
}
@ -520,6 +528,12 @@ class Invokers {
*/
}
@ForceInline
/*non-public*/
static VarHandle directVarHandleTarget(VarHandle handle) {
return handle.asDirect();
}
static MemberName linkToCallSiteMethod(MethodType mtype) {
LambdaForm lform = callSiteForm(mtype, false);
return lform.vmentry;
@ -600,7 +614,8 @@ class Invokers {
NF_checkCustomized = 3,
NF_checkVarHandleGenericType = 4,
NF_checkVarHandleExactType = 5,
NF_LIMIT = 6;
NF_directVarHandleTarget = 6,
NF_LIMIT = 7;
private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
@ -630,6 +645,8 @@ class Invokers {
return getNamedFunction("checkVarHandleGenericType", MethodType.methodType(MethodHandle.class, VarHandle.class, VarHandle.AccessDescriptor.class));
case NF_checkVarHandleExactType:
return getNamedFunction("checkVarHandleExactType", MethodType.methodType(MethodHandle.class, VarHandle.class, VarHandle.AccessDescriptor.class));
case NF_directVarHandleTarget:
return getNamedFunction("directVarHandleTarget", MethodType.methodType(VarHandle.class, VarHandle.class));
default:
throw newInternalError("Unknown function: " + func);
}

View file

@ -28,7 +28,7 @@ package java.lang.invoke;
/**
* Base class for memory access var handle implementations.
*/
abstract class VarHandleMemoryAddressBase extends VarHandle {
abstract class MemoryAccessVarHandleBase extends VarHandle {
/** endianness **/
final boolean be;
@ -42,7 +42,7 @@ abstract class VarHandleMemoryAddressBase extends VarHandle {
/** alignment constraint (in bytes, expressed as a bit mask) **/
final long alignmentMask;
VarHandleMemoryAddressBase(VarForm form, boolean be, long length, long offset, long alignmentMask) {
MemoryAccessVarHandleBase(VarForm form, boolean be, long length, long offset, long alignmentMask) {
super(form);
this.be = be;
this.length = length;

View file

@ -26,9 +26,10 @@
package java.lang.invoke;
import jdk.internal.access.foreign.MemoryAddressProxy;
import jdk.internal.misc.Unsafe;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.ConstantDynamic;
import jdk.internal.org.objectweb.asm.Handle;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.internal.org.objectweb.asm.Type;
@ -42,10 +43,10 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import static jdk.internal.org.objectweb.asm.Opcodes.AALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
@ -53,51 +54,65 @@ import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.ARETURN;
import static jdk.internal.org.objectweb.asm.Opcodes.ASTORE;
import static jdk.internal.org.objectweb.asm.Opcodes.BIPUSH;
import static jdk.internal.org.objectweb.asm.Opcodes.CHECKCAST;
import static jdk.internal.org.objectweb.asm.Opcodes.GETFIELD;
import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_0;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_1;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_2;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_3;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_4;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_5;
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_M1;
import static jdk.internal.org.objectweb.asm.Opcodes.ILOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
import static jdk.internal.org.objectweb.asm.Opcodes.LADD;
import static jdk.internal.org.objectweb.asm.Opcodes.LALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.LASTORE;
import static jdk.internal.org.objectweb.asm.Opcodes.LLOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.LMUL;
import static jdk.internal.org.objectweb.asm.Opcodes.NEWARRAY;
import static jdk.internal.org.objectweb.asm.Opcodes.PUTFIELD;
import static jdk.internal.org.objectweb.asm.Opcodes.PUTSTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.RETURN;
import static jdk.internal.org.objectweb.asm.Opcodes.DUP;
import static jdk.internal.org.objectweb.asm.Opcodes.SIPUSH;
import static jdk.internal.org.objectweb.asm.Opcodes.T_LONG;
import static jdk.internal.org.objectweb.asm.Opcodes.V14;
class AddressVarHandleGenerator {
class MemoryAccessVarHandleGenerator {
private static final String DEBUG_DUMP_CLASSES_DIR_PROPERTY = "jdk.internal.foreign.ClassGenerator.DEBUG_DUMP_CLASSES_DIR";
private static final boolean DEBUG =
GetBooleanAction.privilegedGetProperty("jdk.internal.foreign.ClassGenerator.DEBUG");
private static final Class<?> BASE_CLASS = VarHandleMemoryAddressBase.class;
private static final Class<?> BASE_CLASS = MemoryAccessVarHandleBase.class;
private static final HashMap<Class<?>, Class<?>> helperClassCache;
private final static MethodType OFFSET_OP_TYPE;
private final static MethodHandle ADD_OFFSETS_HANDLE;
private final static MethodHandle MUL_OFFSETS_HANDLE;
static {
helperClassCache = new HashMap<>();
helperClassCache.put(byte.class, VarHandleMemoryAddressAsBytes.class);
helperClassCache.put(short.class, VarHandleMemoryAddressAsShorts.class);
helperClassCache.put(char.class, VarHandleMemoryAddressAsChars.class);
helperClassCache.put(int.class, VarHandleMemoryAddressAsInts.class);
helperClassCache.put(long.class, VarHandleMemoryAddressAsLongs.class);
helperClassCache.put(float.class, VarHandleMemoryAddressAsFloats.class);
helperClassCache.put(double.class, VarHandleMemoryAddressAsDoubles.class);
helperClassCache.put(byte.class, MemoryAccessVarHandleByteHelper.class);
helperClassCache.put(short.class, MemoryAccessVarHandleShortHelper.class);
helperClassCache.put(char.class, MemoryAccessVarHandleCharHelper.class);
helperClassCache.put(int.class, MemoryAccessVarHandleIntHelper.class);
helperClassCache.put(long.class, MemoryAccessVarHandleLongHelper.class);
helperClassCache.put(float.class, MemoryAccessVarHandleFloatHelper.class);
helperClassCache.put(double.class, MemoryAccessVarHandleDoubleHelper.class);
OFFSET_OP_TYPE = MethodType.methodType(long.class, long.class, long.class, MemoryAddressProxy.class);
try {
ADD_OFFSETS_HANDLE = MethodHandles.Lookup.IMPL_LOOKUP.findStatic(MemoryAddressProxy.class, "addOffsets", OFFSET_OP_TYPE);
MUL_OFFSETS_HANDLE = MethodHandles.Lookup.IMPL_LOOKUP.findStatic(MemoryAddressProxy.class, "multiplyOffsets", OFFSET_OP_TYPE);
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
private static final File DEBUG_DUMP_CLASSES_DIR;
@ -111,15 +126,14 @@ class AddressVarHandleGenerator {
}
}
private static final Unsafe U = Unsafe.getUnsafe();
private final String implClassName;
private final int dimensions;
private final Class<?> carrier;
private final Class<?> helperClass;
private final VarForm form;
private final Object[] classData;
AddressVarHandleGenerator(Class<?> carrier, int dims) {
MemoryAccessVarHandleGenerator(Class<?> carrier, int dims) {
this.dimensions = dims;
this.carrier = carrier;
Class<?>[] components = new Class<?>[dimensions];
@ -127,6 +141,10 @@ class AddressVarHandleGenerator {
this.form = new VarForm(BASE_CLASS, MemoryAddressProxy.class, carrier, components);
this.helperClass = helperClassCache.get(carrier);
this.implClassName = helperClass.getName().replace('.', '/') + dimensions;
// live constants
Class<?>[] intermediate = new Class<?>[dimensions];
Arrays.fill(intermediate, long.class);
this.classData = new Object[] { carrier, intermediate, ADD_OFFSETS_HANDLE, MUL_OFFSETS_HANDLE };
}
/*
@ -134,18 +152,24 @@ class AddressVarHandleGenerator {
* The factory has type (ZJJ[J)VarHandle.
*/
MethodHandle generateHandleFactory() {
Class<?> implCls = generateClass();
byte[] classBytes = generateClassBytes();
if (DEBUG_DUMP_CLASSES_DIR != null) {
debugWriteClassToFile(classBytes);
}
try {
MethodHandles.Lookup lookup = MethodHandles.lookup().defineHiddenClassWithClassData(classBytes, classData);
Class<?> implCls = lookup.lookupClass();
Class<?>[] components = new Class<?>[dimensions];
Arrays.fill(components, long.class);
VarForm form = new VarForm(implCls, MemoryAddressProxy.class, carrier, components);
MethodType constrType = MethodType.methodType(void.class, VarForm.class, boolean.class, long.class, long.class, long.class, long[].class);
MethodHandle constr = MethodHandles.Lookup.IMPL_LOOKUP.findConstructor(implCls, constrType);
MethodHandle constr = lookup.findConstructor(implCls, constrType);
constr = MethodHandles.insertArguments(constr, 0, form);
return constr;
} catch (Throwable ex) {
debugPrintClass(classBytes);
throw new AssertionError(ex);
}
}
@ -154,20 +178,22 @@ class AddressVarHandleGenerator {
* Generate a specialized VarHandle class for given carrier
* and access coordinates.
*/
Class<?> generateClass() {
BinderClassWriter cw = new BinderClassWriter();
byte[] generateClassBytes() {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
if (DEBUG) {
System.out.println("Generating header implementation class");
}
cw.visit(52, ACC_PUBLIC | ACC_SUPER, implClassName, null, Type.getInternalName(BASE_CLASS), null);
cw.visit(V14, ACC_PUBLIC | ACC_SUPER, implClassName, null, Type.getInternalName(BASE_CLASS), null);
//add dimension fields
for (int i = 0; i < dimensions; i++) {
cw.visitField(ACC_PRIVATE | ACC_FINAL, "dim" + i, "J", null, null);
}
addStaticInitializer(cw);
addConstructor(cw);
addAccessModeTypeMethod(cw);
@ -180,13 +206,53 @@ class AddressVarHandleGenerator {
addAccessModeMethodIfNeeded(mode, cw);
}
cw.visitEnd();
byte[] classBytes = cw.toByteArray();
return defineClass(cw, classBytes);
return cw.toByteArray();
}
void addConstructor(BinderClassWriter cw) {
void addStaticInitializer(ClassWriter cw) {
// carrier and intermediate
cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, "carrier", Class.class.descriptorString(), null, null);
cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, "intermediate", Class[].class.descriptorString(), null, null);
cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, "addHandle", MethodHandle.class.descriptorString(), null, null);
cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, "mulHandle", MethodHandle.class.descriptorString(), null, null);
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
mv.visitCode();
// extract class data in static final fields
MethodType mtype = MethodType.methodType(Object.class, MethodHandles.Lookup.class, String.class, Class.class);
Handle bsm = new Handle(H_INVOKESTATIC, Type.getInternalName(MethodHandles.class), "classData",
mtype.descriptorString(), false);
ConstantDynamic dynamic = new ConstantDynamic("classData", Object[].class.descriptorString(), bsm);
mv.visitLdcInsn(dynamic);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Object[].class));
mv.visitVarInsn(ASTORE, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_0);
mv.visitInsn(AALOAD);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Class.class));
mv.visitFieldInsn(PUTSTATIC, implClassName, "carrier", Class.class.descriptorString());
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_1);
mv.visitInsn(AALOAD);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Class[].class));
mv.visitFieldInsn(PUTSTATIC, implClassName, "intermediate", Class[].class.descriptorString());
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_2);
mv.visitInsn(AALOAD);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(MethodHandle.class));
mv.visitFieldInsn(PUTSTATIC, implClassName, "addHandle", MethodHandle.class.descriptorString());
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_3);
mv.visitInsn(AALOAD);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(MethodHandle.class));
mv.visitFieldInsn(PUTSTATIC, implClassName, "mulHandle", MethodHandle.class.descriptorString());
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
void addConstructor(ClassWriter cw) {
MethodType constrType = MethodType.methodType(void.class, VarForm.class, boolean.class, long.class, long.class, long.class, long[].class);
MethodVisitor mv = cw.visitMethod(0, "<init>", constrType.toMethodDescriptorString(), null, null);
mv.visitCode();
@ -213,21 +279,16 @@ class AddressVarHandleGenerator {
mv.visitEnd();
}
void addAccessModeTypeMethod(BinderClassWriter cw) {
void addAccessModeTypeMethod(ClassWriter cw) {
MethodType modeMethType = MethodType.methodType(MethodType.class, VarHandle.AccessMode.class);
MethodVisitor mv = cw.visitMethod(ACC_FINAL, "accessModeTypeUncached", modeMethType.toMethodDescriptorString(), null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(GETFIELD, Type.getInternalName(VarHandle.AccessMode.class), "at", Type.getDescriptor(VarHandle.AccessType.class));
mv.visitLdcInsn(cw.makeConstantPoolPatch(MemoryAddressProxy.class));
mv.visitFieldInsn(GETFIELD, Type.getInternalName(VarHandle.AccessMode.class), "at", VarHandle.AccessType.class.descriptorString());
mv.visitLdcInsn(Type.getType(MemoryAddressProxy.class));
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Class.class));
mv.visitLdcInsn(cw.makeConstantPoolPatch(carrier));
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Class.class));
Class<?>[] dims = new Class<?>[dimensions];
Arrays.fill(dims, long.class);
mv.visitLdcInsn(cw.makeConstantPoolPatch(dims));
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Class[].class));
mv.visitFieldInsn(GETSTATIC, implClassName, "carrier", Class.class.descriptorString());
mv.visitFieldInsn(GETSTATIC, implClassName, "intermediate", Class[].class.descriptorString());
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(VarHandle.AccessType.class),
"accessModeType", MethodType.methodType(MethodType.class, Class.class, Class.class, Class[].class).toMethodDescriptorString(), false);
@ -238,10 +299,10 @@ class AddressVarHandleGenerator {
mv.visitEnd();
}
void addAccessModeMethodIfNeeded(VarHandle.AccessMode mode, BinderClassWriter cw) {
void addAccessModeMethodIfNeeded(VarHandle.AccessMode mode, ClassWriter cw) {
String methName = mode.methodName();
MethodType methType = form.getMethodType(mode.at.ordinal())
.insertParameterTypes(0, BASE_CLASS);
.insertParameterTypes(0, VarHandle.class);
try {
MethodType helperType = methType.insertParameterTypes(2, long.class);
@ -266,14 +327,38 @@ class AddressVarHandleGenerator {
// offset calculation
int slot = 2;
mv.visitVarInsn(ALOAD, 0); // load recv
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(BASE_CLASS));
mv.visitFieldInsn(GETFIELD, Type.getInternalName(BASE_CLASS), "offset", "J");
for (int i = 0 ; i < dimensions ; i++) {
// load ADD MH
mv.visitFieldInsn(GETSTATIC, implClassName, "addHandle", MethodHandle.class.descriptorString());
//fixup stack so that ADD MH ends up bottom
mv.visitInsn(Opcodes.DUP_X2);
mv.visitInsn(Opcodes.POP);
// load MUL MH
mv.visitFieldInsn(GETSTATIC, implClassName, "mulHandle", MethodHandle.class.descriptorString());
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(MethodHandle.class));
mv.visitVarInsn(ALOAD, 0); // load recv
mv.visitTypeInsn(CHECKCAST, implClassName);
mv.visitFieldInsn(GETFIELD, implClassName, "dim" + i, "J");
mv.visitVarInsn(LLOAD, slot);
mv.visitInsn(LMUL);
mv.visitInsn(LADD);
mv.visitVarInsn(ALOAD, 1); // receiver
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(MemoryAddressProxy.class));
//MUL
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(MethodHandle.class), "invokeExact",
OFFSET_OP_TYPE.toMethodDescriptorString(), false);
mv.visitVarInsn(ALOAD, 1); // receiver
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(MemoryAddressProxy.class));
//ADD
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(MethodHandle.class), "invokeExact",
OFFSET_OP_TYPE.toMethodDescriptorString(), false);
slot += 2;
}
@ -296,7 +381,7 @@ class AddressVarHandleGenerator {
}
}
void addStridesAccessor(BinderClassWriter cw) {
void addStridesAccessor(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_FINAL, "strides", "()[J", null, null);
mv.visitCode();
iConstInsn(mv, dimensions);
@ -315,31 +400,15 @@ class AddressVarHandleGenerator {
mv.visitEnd();
}
void addCarrierAccessor(BinderClassWriter cw) {
void addCarrierAccessor(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_FINAL, "carrier", "()Ljava/lang/Class;", null, null);
mv.visitCode();
mv.visitLdcInsn(cw.makeConstantPoolPatch(carrier));
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Class.class));
mv.visitFieldInsn(GETSTATIC, implClassName, "carrier", Class.class.descriptorString());
mv.visitInsn(ARETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
//where
private Class<?> defineClass(BinderClassWriter cw, byte[] classBytes) {
try {
if (DEBUG_DUMP_CLASSES_DIR != null) {
debugWriteClassToFile(classBytes);
}
Object[] patches = cw.resolvePatches(classBytes);
Class<?> c = U.defineAnonymousClass(BASE_CLASS, classBytes, patches);
return c;
} catch (Throwable e) {
debugPrintClass(classBytes);
throw e;
}
}
// shared code generation helpers
private static int getSlotsForType(Class<?> c) {
@ -438,57 +507,4 @@ class AddressVarHandleGenerator {
throw new RuntimeException("Failed to write class " + implClassName + " to file " + file);
}
}
static class BinderClassWriter extends ClassWriter {
private final ArrayList<ConstantPoolPatch> cpPatches = new ArrayList<>();
private int curUniquePatchIndex = 0;
BinderClassWriter() {
super(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
}
public String makeConstantPoolPatch(Object o) {
int myUniqueIndex = curUniquePatchIndex++;
String cpPlaceholder = "CONSTANT_PLACEHOLDER_" + myUniqueIndex;
int index = newConst(cpPlaceholder);
cpPatches.add(new ConstantPoolPatch(index, cpPlaceholder, o));
return cpPlaceholder;
}
public Object[] resolvePatches(byte[] classFile) {
if (cpPatches.isEmpty()) {
return null;
}
int size = ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF);
Object[] patches = new Object[size];
for (ConstantPoolPatch p : cpPatches) {
if (p.index >= size) {
throw new InternalError("Failed to resolve constant pool patch entries");
}
patches[p.index] = p.value;
}
return patches;
}
static class ConstantPoolPatch {
final int index;
final String placeholder;
final Object value;
ConstantPoolPatch(int index, String placeholder, Object value) {
this.index = index;
this.placeholder = placeholder;
this.value = value;
}
@Override
public String toString() {
return "CpPatch/index="+index+",placeholder="+placeholder+",value="+value;
}
}
}
}

View file

@ -1802,42 +1802,90 @@ abstract class MethodHandleImpl {
}
@Override
public VarHandle memoryAddressViewVarHandle(Class<?> carrier, long alignmentMask,
ByteOrder order, long offset, long[] strides) {
public VarHandle memoryAccessVarHandle(Class<?> carrier, long alignmentMask,
ByteOrder order, long offset, long[] strides) {
return VarHandles.makeMemoryAddressViewHandle(carrier, alignmentMask, order, offset, strides);
}
@Override
public Class<?> memoryAddressCarrier(VarHandle handle) {
return checkMemAccessHandle(handle).carrier();
return checkMemoryAccessHandle(handle).carrier();
}
@Override
public long memoryAddressAlignmentMask(VarHandle handle) {
return checkMemAccessHandle(handle).alignmentMask;
return checkMemoryAccessHandle(handle).alignmentMask;
}
@Override
public ByteOrder memoryAddressByteOrder(VarHandle handle) {
return checkMemAccessHandle(handle).be ?
return checkMemoryAccessHandle(handle).be ?
ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
}
@Override
public long memoryAddressOffset(VarHandle handle) {
return checkMemAccessHandle(handle).offset;
return checkMemoryAccessHandle(handle).offset;
}
@Override
public long[] memoryAddressStrides(VarHandle handle) {
return checkMemAccessHandle(handle).strides();
return checkMemoryAccessHandle(handle).strides();
}
private VarHandleMemoryAddressBase checkMemAccessHandle(VarHandle handle) {
if (!(handle instanceof VarHandleMemoryAddressBase)) {
@Override
public boolean isMemoryAccessVarHandle(VarHandle handle) {
return asMemoryAccessVarHandle(handle) != null;
}
@Override
public VarHandle filterValue(VarHandle target, MethodHandle filterToTarget, MethodHandle filterFromTarget) {
return VarHandles.filterValue(target, filterToTarget, filterFromTarget);
}
@Override
public VarHandle filterCoordinates(VarHandle target, int pos, MethodHandle... filters) {
return VarHandles.filterCoordinates(target, pos, filters);
}
@Override
public VarHandle dropCoordinates(VarHandle target, int pos, Class<?>... valueTypes) {
return VarHandles.dropCoordinates(target, pos, valueTypes);
}
@Override
public VarHandle permuteCoordinates(VarHandle target, List<Class<?>> newCoordinates, int... reorder) {
return VarHandles.permuteCoordinates(target, newCoordinates, reorder);
}
@Override
public VarHandle collectCoordinates(VarHandle target, int pos, MethodHandle filter) {
return VarHandles.collectCoordinates(target, pos, filter);
}
@Override
public VarHandle insertCoordinates(VarHandle target, int pos, Object... values) {
return VarHandles.insertCoordinates(target, pos, values);
}
private MemoryAccessVarHandleBase asMemoryAccessVarHandle(VarHandle handle) {
if (handle instanceof MemoryAccessVarHandleBase) {
return (MemoryAccessVarHandleBase)handle;
} else if (handle.target() instanceof MemoryAccessVarHandleBase) {
// skip first adaptation, since we have to step over MemoryAddressProxy
// see JDK-8237349
return (MemoryAccessVarHandleBase)handle.target();
} else {
return null;
}
}
private MemoryAccessVarHandleBase checkMemoryAccessHandle(VarHandle handle) {
MemoryAccessVarHandleBase base = asMemoryAccessVarHandle(handle);
if (base == null) {
throw new IllegalArgumentException("Not a memory access varhandle: " + handle);
}
return (VarHandleMemoryAddressBase) handle;
return base;
}
});
}

View file

@ -56,6 +56,7 @@ class MethodHandleStatics {
static final int CUSTOMIZE_THRESHOLD;
static final boolean VAR_HANDLE_GUARDS;
static final int MAX_ARITY;
static final boolean VAR_HANDLE_IDENTITY_ADAPT;
static {
Properties props = GetPropertyAction.privilegedGetProperties();
@ -83,6 +84,8 @@ class MethodHandleStatics {
props.getProperty("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", "127"));
VAR_HANDLE_GUARDS = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true"));
VAR_HANDLE_IDENTITY_ADAPT = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT", "false"));
// Do not adjust this except for special platforms:
MAX_ARITY = Integer.parseInt(

View file

@ -4609,7 +4609,7 @@ assert((int)twice.invokeExact(21) == 42);
}
}
private static boolean permuteArgumentChecks(int[] reorder, MethodType newType, MethodType oldType) {
static boolean permuteArgumentChecks(int[] reorder, MethodType newType, MethodType oldType) {
if (newType.returnType() != oldType.returnType())
throw newIllegalArgumentException("return types do not match",
oldType, newType);

View file

@ -45,38 +45,45 @@ final class VarForm {
VarForm(Class<?> implClass, Class<?> receiver, Class<?> value, Class<?>... intermediate) {
this.methodType_table = new MethodType[VarHandle.AccessType.values().length];
if (receiver == null) {
initMethodTypes(value, intermediate);
} else {
Class<?>[] coordinates = new Class<?>[intermediate.length + 1];
coordinates[0] = receiver;
System.arraycopy(intermediate, 0, coordinates, 1, intermediate.length);
initMethodTypes(value, coordinates);
}
// TODO lazily calculate
this.memberName_table = linkFromStatic(implClass);
}
// (Receiver, <Intermediates>)
List<Class<?>> l = new ArrayList<>();
if (receiver != null)
l.add(receiver);
for (Class<?> c : intermediate)
l.add(c);
VarForm(Class<?> value, Class<?>[] coordinates) {
this.methodType_table = new MethodType[VarHandle.AccessType.values().length];
this.memberName_table = null;
initMethodTypes(value, coordinates);
}
void initMethodTypes(Class<?> value, Class<?>... coordinates) {
// (Receiver, <Intermediates>)Value
methodType_table[VarHandle.AccessType.GET.ordinal()] =
MethodType.methodType(value, l).erase();
MethodType.methodType(value, coordinates).erase();
// (Receiver, <Intermediates>, Value)void
l.add(value);
methodType_table[VarHandle.AccessType.SET.ordinal()] =
MethodType.methodType(void.class, l).erase();
MethodType.methodType(void.class, coordinates).appendParameterTypes(value).erase();
// (Receiver, <Intermediates>, Value)Value
methodType_table[VarHandle.AccessType.GET_AND_UPDATE.ordinal()] =
MethodType.methodType(value, l).erase();
MethodType.methodType(value, coordinates).appendParameterTypes(value).erase();
// (Receiver, <Intermediates>, Value, Value)boolean
l.add(value);
methodType_table[VarHandle.AccessType.COMPARE_AND_SET.ordinal()] =
MethodType.methodType(boolean.class, l).erase();
MethodType.methodType(boolean.class, coordinates).appendParameterTypes(value, value).erase();
// (Receiver, <Intermediates>, Value, Value)Value
methodType_table[VarHandle.AccessType.COMPARE_AND_EXCHANGE.ordinal()] =
MethodType.methodType(value, l).erase();
MethodType.methodType(value, coordinates).appendParameterTypes(value, value).erase();
}
@ForceInline

View file

@ -455,6 +455,16 @@ public abstract class VarHandle implements Constable {
return new UnsupportedOperationException();
}
boolean isDirect() {
return true;
}
VarHandle asDirect() {
return this;
}
VarHandle target() { return null; }
// Plain accessors
/**
@ -1882,7 +1892,7 @@ public abstract class VarHandle implements Constable {
*
* @return the variable type of variables referenced by this VarHandle
*/
public final Class<?> varType() {
public Class<?> varType() {
MethodType typeSet = accessModeType(AccessMode.SET);
return typeSet.parameterType(typeSet.parameterCount() - 1);
}
@ -1893,7 +1903,7 @@ public abstract class VarHandle implements Constable {
* @return the coordinate types for this VarHandle. The returned
* list is unmodifiable
*/
public final List<Class<?>> coordinateTypes() {
public List<Class<?>> coordinateTypes() {
MethodType typeGet = accessModeType(AccessMode.GET);
return typeGet.parameterList();
}
@ -1958,7 +1968,7 @@ public abstract class VarHandle implements Constable {
* signature-polymorphic method of the same name
* @return a method handle bound to this VarHandle and the given access mode
*/
public final MethodHandle toMethodHandle(AccessMode accessMode) {
public MethodHandle toMethodHandle(AccessMode accessMode) {
MemberName mn = AccessMode.getMemberName(accessMode.ordinal(), vform);
if (mn != null) {
MethodHandle mh = getMethodHandle(accessMode.ordinal());
@ -2008,7 +2018,7 @@ public abstract class VarHandle implements Constable {
}
@ForceInline
final MethodHandle getMethodHandle(int mode) {
MethodHandle getMethodHandle(int mode) {
TypesAndInvokers tis = getTypesAndInvokers();
MethodHandle mh = tis.methodHandle_table[mode];
if (mh == null) {

View file

@ -27,14 +27,22 @@ package java.lang.invoke;
import sun.invoke.util.Wrapper;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Stream;
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
import static java.lang.invoke.MethodHandleStatics.VAR_HANDLE_IDENTITY_ADAPT;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
final class VarHandles {
@ -49,49 +57,49 @@ final class VarHandles {
if (!f.isStatic()) {
long foffset = MethodHandleNatives.objectFieldOffset(f);
if (!type.isPrimitive()) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleReferences.FieldInstanceReadOnly(refc, foffset, type)
: new VarHandleReferences.FieldInstanceReadWrite(refc, foffset, type);
: new VarHandleReferences.FieldInstanceReadWrite(refc, foffset, type));
}
else if (type == boolean.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleBooleans.FieldInstanceReadOnly(refc, foffset)
: new VarHandleBooleans.FieldInstanceReadWrite(refc, foffset);
: new VarHandleBooleans.FieldInstanceReadWrite(refc, foffset));
}
else if (type == byte.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleBytes.FieldInstanceReadOnly(refc, foffset)
: new VarHandleBytes.FieldInstanceReadWrite(refc, foffset);
: new VarHandleBytes.FieldInstanceReadWrite(refc, foffset));
}
else if (type == short.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleShorts.FieldInstanceReadOnly(refc, foffset)
: new VarHandleShorts.FieldInstanceReadWrite(refc, foffset);
: new VarHandleShorts.FieldInstanceReadWrite(refc, foffset));
}
else if (type == char.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleChars.FieldInstanceReadOnly(refc, foffset)
: new VarHandleChars.FieldInstanceReadWrite(refc, foffset);
: new VarHandleChars.FieldInstanceReadWrite(refc, foffset));
}
else if (type == int.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleInts.FieldInstanceReadOnly(refc, foffset)
: new VarHandleInts.FieldInstanceReadWrite(refc, foffset);
: new VarHandleInts.FieldInstanceReadWrite(refc, foffset));
}
else if (type == long.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleLongs.FieldInstanceReadOnly(refc, foffset)
: new VarHandleLongs.FieldInstanceReadWrite(refc, foffset);
: new VarHandleLongs.FieldInstanceReadWrite(refc, foffset));
}
else if (type == float.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleFloats.FieldInstanceReadOnly(refc, foffset)
: new VarHandleFloats.FieldInstanceReadWrite(refc, foffset);
: new VarHandleFloats.FieldInstanceReadWrite(refc, foffset));
}
else if (type == double.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleDoubles.FieldInstanceReadOnly(refc, foffset)
: new VarHandleDoubles.FieldInstanceReadWrite(refc, foffset);
: new VarHandleDoubles.FieldInstanceReadWrite(refc, foffset));
}
else {
throw new UnsupportedOperationException();
@ -110,49 +118,49 @@ final class VarHandles {
Object base = MethodHandleNatives.staticFieldBase(f);
long foffset = MethodHandleNatives.staticFieldOffset(f);
if (!type.isPrimitive()) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleReferences.FieldStaticReadOnly(base, foffset, type)
: new VarHandleReferences.FieldStaticReadWrite(base, foffset, type);
: new VarHandleReferences.FieldStaticReadWrite(base, foffset, type));
}
else if (type == boolean.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleBooleans.FieldStaticReadOnly(base, foffset)
: new VarHandleBooleans.FieldStaticReadWrite(base, foffset);
: new VarHandleBooleans.FieldStaticReadWrite(base, foffset));
}
else if (type == byte.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleBytes.FieldStaticReadOnly(base, foffset)
: new VarHandleBytes.FieldStaticReadWrite(base, foffset);
: new VarHandleBytes.FieldStaticReadWrite(base, foffset));
}
else if (type == short.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleShorts.FieldStaticReadOnly(base, foffset)
: new VarHandleShorts.FieldStaticReadWrite(base, foffset);
: new VarHandleShorts.FieldStaticReadWrite(base, foffset));
}
else if (type == char.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleChars.FieldStaticReadOnly(base, foffset)
: new VarHandleChars.FieldStaticReadWrite(base, foffset);
: new VarHandleChars.FieldStaticReadWrite(base, foffset));
}
else if (type == int.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleInts.FieldStaticReadOnly(base, foffset)
: new VarHandleInts.FieldStaticReadWrite(base, foffset);
: new VarHandleInts.FieldStaticReadWrite(base, foffset));
}
else if (type == long.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleLongs.FieldStaticReadOnly(base, foffset)
: new VarHandleLongs.FieldStaticReadWrite(base, foffset);
: new VarHandleLongs.FieldStaticReadWrite(base, foffset));
}
else if (type == float.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleFloats.FieldStaticReadOnly(base, foffset)
: new VarHandleFloats.FieldStaticReadWrite(base, foffset);
: new VarHandleFloats.FieldStaticReadWrite(base, foffset));
}
else if (type == double.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleDoubles.FieldStaticReadOnly(base, foffset)
: new VarHandleDoubles.FieldStaticReadWrite(base, foffset);
: new VarHandleDoubles.FieldStaticReadWrite(base, foffset));
}
else {
throw new UnsupportedOperationException();
@ -203,31 +211,31 @@ final class VarHandles {
int ashift = 31 - Integer.numberOfLeadingZeros(ascale);
if (!componentType.isPrimitive()) {
return new VarHandleReferences.Array(aoffset, ashift, arrayClass);
return maybeAdapt(new VarHandleReferences.Array(aoffset, ashift, arrayClass));
}
else if (componentType == boolean.class) {
return new VarHandleBooleans.Array(aoffset, ashift);
return maybeAdapt(new VarHandleBooleans.Array(aoffset, ashift));
}
else if (componentType == byte.class) {
return new VarHandleBytes.Array(aoffset, ashift);
return maybeAdapt(new VarHandleBytes.Array(aoffset, ashift));
}
else if (componentType == short.class) {
return new VarHandleShorts.Array(aoffset, ashift);
return maybeAdapt(new VarHandleShorts.Array(aoffset, ashift));
}
else if (componentType == char.class) {
return new VarHandleChars.Array(aoffset, ashift);
return maybeAdapt(new VarHandleChars.Array(aoffset, ashift));
}
else if (componentType == int.class) {
return new VarHandleInts.Array(aoffset, ashift);
return maybeAdapt(new VarHandleInts.Array(aoffset, ashift));
}
else if (componentType == long.class) {
return new VarHandleLongs.Array(aoffset, ashift);
return maybeAdapt(new VarHandleLongs.Array(aoffset, ashift));
}
else if (componentType == float.class) {
return new VarHandleFloats.Array(aoffset, ashift);
return maybeAdapt(new VarHandleFloats.Array(aoffset, ashift));
}
else if (componentType == double.class) {
return new VarHandleDoubles.Array(aoffset, ashift);
return maybeAdapt(new VarHandleDoubles.Array(aoffset, ashift));
}
else {
throw new UnsupportedOperationException();
@ -242,22 +250,22 @@ final class VarHandles {
Class<?> viewComponentType = viewArrayClass.getComponentType();
if (viewComponentType == long.class) {
return new VarHandleByteArrayAsLongs.ArrayHandle(be);
return maybeAdapt(new VarHandleByteArrayAsLongs.ArrayHandle(be));
}
else if (viewComponentType == int.class) {
return new VarHandleByteArrayAsInts.ArrayHandle(be);
return maybeAdapt(new VarHandleByteArrayAsInts.ArrayHandle(be));
}
else if (viewComponentType == short.class) {
return new VarHandleByteArrayAsShorts.ArrayHandle(be);
return maybeAdapt(new VarHandleByteArrayAsShorts.ArrayHandle(be));
}
else if (viewComponentType == char.class) {
return new VarHandleByteArrayAsChars.ArrayHandle(be);
return maybeAdapt(new VarHandleByteArrayAsChars.ArrayHandle(be));
}
else if (viewComponentType == double.class) {
return new VarHandleByteArrayAsDoubles.ArrayHandle(be);
return maybeAdapt(new VarHandleByteArrayAsDoubles.ArrayHandle(be));
}
else if (viewComponentType == float.class) {
return new VarHandleByteArrayAsFloats.ArrayHandle(be);
return maybeAdapt(new VarHandleByteArrayAsFloats.ArrayHandle(be));
}
throw new UnsupportedOperationException();
@ -271,22 +279,22 @@ final class VarHandles {
Class<?> viewComponentType = viewArrayClass.getComponentType();
if (viewComponentType == long.class) {
return new VarHandleByteArrayAsLongs.ByteBufferHandle(be);
return maybeAdapt(new VarHandleByteArrayAsLongs.ByteBufferHandle(be));
}
else if (viewComponentType == int.class) {
return new VarHandleByteArrayAsInts.ByteBufferHandle(be);
return maybeAdapt(new VarHandleByteArrayAsInts.ByteBufferHandle(be));
}
else if (viewComponentType == short.class) {
return new VarHandleByteArrayAsShorts.ByteBufferHandle(be);
return maybeAdapt(new VarHandleByteArrayAsShorts.ByteBufferHandle(be));
}
else if (viewComponentType == char.class) {
return new VarHandleByteArrayAsChars.ByteBufferHandle(be);
return maybeAdapt(new VarHandleByteArrayAsChars.ByteBufferHandle(be));
}
else if (viewComponentType == double.class) {
return new VarHandleByteArrayAsDoubles.ByteBufferHandle(be);
return maybeAdapt(new VarHandleByteArrayAsDoubles.ByteBufferHandle(be));
}
else if (viewComponentType == float.class) {
return new VarHandleByteArrayAsFloats.ByteBufferHandle(be);
return maybeAdapt(new VarHandleByteArrayAsFloats.ByteBufferHandle(be));
}
throw new UnsupportedOperationException();
@ -319,16 +327,257 @@ final class VarHandles {
Map<Integer, MethodHandle> carrierFactory = ADDRESS_FACTORIES.get(carrier);
MethodHandle fac = carrierFactory.computeIfAbsent(strides.length,
dims -> new AddressVarHandleGenerator(carrier, dims)
dims -> new MemoryAccessVarHandleGenerator(carrier, dims)
.generateHandleFactory());
try {
return (VarHandle)fac.invoke(be, size, offset, alignmentMask, strides);
return maybeAdapt((VarHandle)fac.invoke(be, size, offset, alignmentMask, strides));
} catch (Throwable ex) {
throw new IllegalStateException(ex);
}
}
private static VarHandle maybeAdapt(VarHandle target) {
if (!VAR_HANDLE_IDENTITY_ADAPT) return target;
target = filterValue(target,
MethodHandles.identity(target.varType()), MethodHandles.identity(target.varType()));
MethodType mtype = target.accessModeType(VarHandle.AccessMode.GET).dropParameterTypes(0, 1);
for (int i = 0 ; i < mtype.parameterCount() ; i++) {
target = filterCoordinates(target, i, MethodHandles.identity(mtype.parameterType(i)));
}
return target;
}
public static VarHandle filterValue(VarHandle target, MethodHandle filterToTarget, MethodHandle filterFromTarget) {
Objects.nonNull(target);
Objects.nonNull(filterToTarget);
Objects.nonNull(filterFromTarget);
//check that from/to filters do not throw checked exceptions
noCheckedExceptions(filterToTarget);
noCheckedExceptions(filterFromTarget);
//check that from/to filters have right signatures
if (filterFromTarget.type().parameterCount() != 1) {
throw newIllegalArgumentException("filterFromTarget filter type has wrong arity", filterFromTarget.type());
} else if (filterToTarget.type().parameterCount() != 1) {
throw newIllegalArgumentException("filterToTarget filter type has wrong arity", filterFromTarget.type());
} else if (filterFromTarget.type().parameterType(0) != filterToTarget.type().returnType() ||
filterToTarget.type().parameterType(0) != filterFromTarget.type().returnType()) {
throw newIllegalArgumentException("filterFromTarget and filterToTarget filter types do not match", filterFromTarget.type(), filterToTarget.type());
} else if (target.varType() != filterFromTarget.type().parameterType(0)) {
throw newIllegalArgumentException("filterFromTarget filter type does not match target var handle type", filterFromTarget.type(), target.varType());
} else if (target.varType() != filterToTarget.type().returnType()) {
throw newIllegalArgumentException("filterFromTarget filter type does not match target var handle type", filterToTarget.type(), target.varType());
}
return new IndirectVarHandle(target, filterFromTarget.type().returnType(), target.coordinateTypes().toArray(new Class<?>[0]),
(mode, modeHandle) -> {
int lastParameterPos = modeHandle.type().parameterCount() - 1;
return switch (mode.at) {
case GET -> MethodHandles.filterReturnValue(modeHandle, filterFromTarget);
case SET -> MethodHandles.filterArgument(modeHandle, lastParameterPos, filterToTarget);
case GET_AND_UPDATE -> {
MethodHandle adapter = MethodHandles.filterReturnValue(modeHandle, filterFromTarget);
yield MethodHandles.filterArgument(adapter, lastParameterPos, filterToTarget);
}
case COMPARE_AND_EXCHANGE -> {
MethodHandle adapter = MethodHandles.filterReturnValue(modeHandle, filterFromTarget);
adapter = MethodHandles.filterArgument(adapter, lastParameterPos, filterToTarget);
yield MethodHandles.filterArgument(adapter, lastParameterPos - 1, filterToTarget);
}
case COMPARE_AND_SET -> {
MethodHandle adapter = MethodHandles.filterArgument(modeHandle, lastParameterPos, filterToTarget);
yield MethodHandles.filterArgument(adapter, lastParameterPos - 1, filterToTarget);
}
};
});
}
public static VarHandle filterCoordinates(VarHandle target, int pos, MethodHandle... filters) {
Objects.nonNull(target);
Objects.nonNull(filters);
List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos >= targetCoordinates.size()) {
throw newIllegalArgumentException("Invalid position " + pos + " for coordinate types", targetCoordinates);
} else if (pos + filters.length > targetCoordinates.size()) {
throw new IllegalArgumentException("Too many filters");
}
if (filters.length == 0) return target;
List<Class<?>> newCoordinates = new ArrayList<>(targetCoordinates);
for (int i = 0 ; i < filters.length ; i++) {
noCheckedExceptions(filters[i]);
MethodType filterType = filters[i].type();
if (filterType.parameterCount() != 1) {
throw newIllegalArgumentException("Invalid filter type " + filterType);
} else if (newCoordinates.get(pos + i) != filterType.returnType()) {
throw newIllegalArgumentException("Invalid filter type " + filterType + " for coordinate type " + newCoordinates.get(i));
}
newCoordinates.set(pos + i, filters[i].type().parameterType(0));
}
return new IndirectVarHandle(target, target.varType(), newCoordinates.toArray(new Class<?>[0]),
(mode, modeHandle) -> MethodHandles.filterArguments(modeHandle, 1 + pos, filters));
}
public static VarHandle insertCoordinates(VarHandle target, int pos, Object... values) {
Objects.nonNull(target);
Objects.nonNull(values);
List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos >= targetCoordinates.size()) {
throw newIllegalArgumentException("Invalid position " + pos + " for coordinate types", targetCoordinates);
} else if (pos + values.length > targetCoordinates.size()) {
throw new IllegalArgumentException("Too many values");
}
if (values.length == 0) return target;
List<Class<?>> newCoordinates = new ArrayList<>(targetCoordinates);
for (int i = 0 ; i < values.length ; i++) {
Class<?> pt = newCoordinates.get(pos);
if (pt.isPrimitive()) {
Wrapper w = Wrapper.forPrimitiveType(pt);
w.convert(values[i], pt);
} else {
pt.cast(values[i]);
}
newCoordinates.remove(pos);
}
return new IndirectVarHandle(target, target.varType(), newCoordinates.toArray(new Class<?>[0]),
(mode, modeHandle) -> MethodHandles.insertArguments(modeHandle, 1 + pos, values));
}
public static VarHandle permuteCoordinates(VarHandle target, List<Class<?>> newCoordinates, int... reorder) {
Objects.nonNull(target);
Objects.nonNull(newCoordinates);
Objects.nonNull(reorder);
List<Class<?>> targetCoordinates = target.coordinateTypes();
MethodHandles.permuteArgumentChecks(reorder,
MethodType.methodType(void.class, newCoordinates),
MethodType.methodType(void.class, targetCoordinates));
return new IndirectVarHandle(target, target.varType(), newCoordinates.toArray(new Class<?>[0]),
(mode, modeHandle) ->
MethodHandles.permuteArguments(modeHandle,
methodTypeFor(mode.at, modeHandle.type(), targetCoordinates, newCoordinates),
reorderArrayFor(mode.at, newCoordinates, reorder)));
}
private static int numTrailingArgs(VarHandle.AccessType at) {
return switch (at) {
case GET -> 0;
case GET_AND_UPDATE, SET -> 1;
case COMPARE_AND_SET, COMPARE_AND_EXCHANGE -> 2;
};
}
private static int[] reorderArrayFor(VarHandle.AccessType at, List<Class<?>> newCoordinates, int[] reorder) {
int numTrailingArgs = numTrailingArgs(at);
int[] adjustedReorder = new int[reorder.length + 1 + numTrailingArgs];
adjustedReorder[0] = 0;
for (int i = 0 ; i < reorder.length ; i++) {
adjustedReorder[i + 1] = reorder[i] + 1;
}
for (int i = 0 ; i < numTrailingArgs ; i++) {
adjustedReorder[i + reorder.length + 1] = i + newCoordinates.size() + 1;
}
return adjustedReorder;
}
private static MethodType methodTypeFor(VarHandle.AccessType at, MethodType oldType, List<Class<?>> oldCoordinates, List<Class<?>> newCoordinates) {
int numTrailingArgs = numTrailingArgs(at);
MethodType adjustedType = MethodType.methodType(oldType.returnType(), oldType.parameterType(0));
adjustedType = adjustedType.appendParameterTypes(newCoordinates);
for (int i = 0 ; i < numTrailingArgs ; i++) {
adjustedType = adjustedType.appendParameterTypes(oldType.parameterType(1 + oldCoordinates.size() + i));
}
return adjustedType;
}
public static VarHandle collectCoordinates(VarHandle target, int pos, MethodHandle filter) {
Objects.nonNull(target);
Objects.nonNull(filter);
noCheckedExceptions(filter);
List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos >= targetCoordinates.size()) {
throw newIllegalArgumentException("Invalid position " + pos + " for coordinate types", targetCoordinates);
} else if (filter.type().returnType() == void.class) {
throw newIllegalArgumentException("Invalid filter type " + filter.type() + " ; filter cannot be void");
} else if (filter.type().returnType() != targetCoordinates.get(pos)) {
throw newIllegalArgumentException("Invalid filter type " + filter.type() + " for coordinate type " + targetCoordinates.get(pos));
}
List<Class<?>> newCoordinates = new ArrayList<>(targetCoordinates);
newCoordinates.remove(pos);
newCoordinates.addAll(pos, filter.type().parameterList());
return new IndirectVarHandle(target, target.varType(), newCoordinates.toArray(new Class<?>[0]),
(mode, modeHandle) -> MethodHandles.collectArguments(modeHandle, 1 + pos, filter));
}
public static VarHandle dropCoordinates(VarHandle target, int pos, Class<?>... valueTypes) {
Objects.nonNull(target);
Objects.nonNull(valueTypes);
List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos > targetCoordinates.size()) {
throw newIllegalArgumentException("Invalid position " + pos + " for coordinate types", targetCoordinates);
}
if (valueTypes.length == 0) return target;
List<Class<?>> newCoordinates = new ArrayList<>(targetCoordinates);
newCoordinates.addAll(pos, List.of(valueTypes));
return new IndirectVarHandle(target, target.varType(), newCoordinates.toArray(new Class<?>[0]),
(mode, modeHandle) -> MethodHandles.dropArguments(modeHandle, 1 + pos, valueTypes));
}
private static void noCheckedExceptions(MethodHandle handle) {
if (handle instanceof DirectMethodHandle) {
DirectMethodHandle directHandle = (DirectMethodHandle)handle;
MethodHandleInfo info = MethodHandles.Lookup.IMPL_LOOKUP.revealDirect(directHandle);
Class<?>[] exceptionTypes = switch (info.getReferenceKind()) {
case MethodHandleInfo.REF_invokeInterface, MethodHandleInfo.REF_invokeSpecial,
MethodHandleInfo.REF_invokeStatic, MethodHandleInfo.REF_invokeVirtual ->
info.reflectAs(Method.class, MethodHandles.Lookup.IMPL_LOOKUP).getExceptionTypes();
case MethodHandleInfo.REF_newInvokeSpecial ->
info.reflectAs(Constructor.class, MethodHandles.Lookup.IMPL_LOOKUP).getExceptionTypes();
case MethodHandleInfo.REF_getField, MethodHandleInfo.REF_getStatic,
MethodHandleInfo.REF_putField, MethodHandleInfo.REF_putStatic -> null;
default -> throw new AssertionError("Cannot get here");
};
if (exceptionTypes != null) {
if (Stream.of(exceptionTypes).anyMatch(VarHandles::isCheckedException)) {
throw newIllegalArgumentException("Cannot adapt a var handle with a method handle which throws checked exceptions");
}
}
} else if (handle instanceof DelegatingMethodHandle) {
noCheckedExceptions(((DelegatingMethodHandle)handle).getTarget());
} else {
//bound
BoundMethodHandle boundHandle = (BoundMethodHandle)handle;
for (int i = 0 ; i < boundHandle.fieldCount() ; i++) {
Object arg = boundHandle.arg(i);
if (arg instanceof MethodHandle){
noCheckedExceptions((MethodHandle) arg);
}
}
}
}
private static boolean isCheckedException(Class<?> clazz) {
return Throwable.class.isAssignableFrom(clazz) &&
!RuntimeException.class.isAssignableFrom(clazz) &&
!Error.class.isAssignableFrom(clazz);
}
// /**
// * A helper program to generate the VarHandleGuards class with a set of
// * static guard methods each of which corresponds to a particular shape and
@ -365,7 +614,7 @@ final class VarHandles {
// "@ForceInline\n" +
// "@LambdaForm.Compiled\n" +
// "final static <METHOD> throws Throwable {\n" +
// " if (handle.vform.methodType_table[ad.type] == ad.symbolicMethodType) {\n" +
// " if (handle.isDirect() && handle.vform.methodType_table[ad.type] == ad.symbolicMethodType) {\n" +
// " <RESULT_ERASED>MethodHandle.linkToStatic(<LINK_TO_STATIC_ARGS>);<RETURN_ERASED>\n" +
// " }\n" +
// " else {\n" +
@ -378,10 +627,10 @@ final class VarHandles {
// "@ForceInline\n" +
// "@LambdaForm.Compiled\n" +
// "final static <METHOD> throws Throwable {\n" +
// " if (handle.vform.methodType_table[ad.type] == ad.symbolicMethodType) {\n" +
// " if (handle.isDirect() && handle.vform.methodType_table[ad.type] == ad.symbolicMethodType) {\n" +
// " MethodHandle.linkToStatic(<LINK_TO_STATIC_ARGS>);\n" +
// " }\n" +
// " else if (handle.vform.getMethodType_V(ad.type) == ad.symbolicMethodType) {\n" +
// " else if (handle.isDirect() && handle.vform.getMethodType_V(ad.type) == ad.symbolicMethodType) {\n" +
// " MethodHandle.linkToStatic(<LINK_TO_STATIC_ARGS>);\n" +
// " }\n" +
// " else {\n" +

View file

@ -77,25 +77,29 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ get(FieldInstanceReadOnly handle, Object holder) {
static $type$ get(VarHandle ob, Object holder) {
FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset);
}
@ForceInline
static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) {
static $type$ getVolatile(VarHandle ob, Object holder) {
FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset);
}
@ForceInline
static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) {
static $type$ getOpaque(VarHandle ob, Object holder) {
FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset);
}
@ForceInline
static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) {
static $type$ getAcquire(VarHandle ob, Object holder) {
FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset);
}
@ -110,28 +114,32 @@ final class VarHandle$Type$s {
}
@ForceInline
static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static void set(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static void setVolatile(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static void setOpaque(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static void setRelease(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
@ -139,7 +147,8 @@ final class VarHandle$Type$s {
#if[CAS]
@ForceInline
static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static boolean compareAndSet(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -147,7 +156,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static $type$ compareAndExchange(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -155,7 +165,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static $type$ compareAndExchangeAcquire(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -163,7 +174,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static $type$ compareAndExchangeRelease(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -171,7 +183,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static boolean weakCompareAndSetPlain(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -179,7 +192,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static boolean weakCompareAndSet(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -187,7 +201,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static boolean weakCompareAndSetAcquire(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -195,7 +210,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
static boolean weakCompareAndSetRelease(VarHandle ob, Object holder, $type$ expected, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -203,21 +219,24 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndSet(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static $type$ getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndSetAcquire(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static $type$ getAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndSetRelease(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
@ -226,21 +245,24 @@ final class VarHandle$Type$s {
#if[AtomicAdd]
@ForceInline
static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndAdd(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndAddAcquire(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndAddRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndAddRelease(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndAdd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
@ -250,63 +272,72 @@ final class VarHandle$Type$s {
#if[Bitwise]
@ForceInline
static $type$ getAndBitwiseOr(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseOr(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseOr$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseOrRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseOrRelease(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseOr$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseOrAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseOr$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseAnd(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseAnd(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseAnd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseAndRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseAndRelease(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseAnd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseAndAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseAnd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseXor(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseXorRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseXorRelease(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseXor$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseXorAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object holder, $type$ value) {
FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
return UNSAFE.getAndBitwiseXor$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
value);
@ -359,25 +390,29 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ get(FieldStaticReadOnly handle) {
static $type$ get(VarHandle ob) {
FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
return UNSAFE.get$Type$(handle.base,
handle.fieldOffset);
}
@ForceInline
static $type$ getVolatile(FieldStaticReadOnly handle) {
static $type$ getVolatile(VarHandle ob) {
FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
return UNSAFE.get$Type$Volatile(handle.base,
handle.fieldOffset);
}
@ForceInline
static $type$ getOpaque(FieldStaticReadOnly handle) {
static $type$ getOpaque(VarHandle ob) {
FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
return UNSAFE.get$Type$Opaque(handle.base,
handle.fieldOffset);
}
@ForceInline
static $type$ getAcquire(FieldStaticReadOnly handle) {
static $type$ getAcquire(VarHandle ob) {
FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
return UNSAFE.get$Type$Acquire(handle.base,
handle.fieldOffset);
}
@ -392,28 +427,32 @@ final class VarHandle$Type$s {
}
@ForceInline
static void set(FieldStaticReadWrite handle, $type$ value) {
static void set(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
UNSAFE.put$Type$(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static void setVolatile(FieldStaticReadWrite handle, $type$ value) {
static void setVolatile(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
UNSAFE.put$Type$Volatile(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static void setOpaque(FieldStaticReadWrite handle, $type$ value) {
static void setOpaque(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
UNSAFE.put$Type$Opaque(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static void setRelease(FieldStaticReadWrite handle, $type$ value) {
static void setRelease(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
UNSAFE.put$Type$Release(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
@ -421,7 +460,8 @@ final class VarHandle$Type$s {
#if[CAS]
@ForceInline
static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static boolean compareAndSet(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.compareAndSet$Type$(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -430,7 +470,8 @@ final class VarHandle$Type$s {
@ForceInline
static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static $type$ compareAndExchange(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.compareAndExchange$Type$(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -438,7 +479,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static $type$ compareAndExchangeAcquire(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -446,7 +488,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static $type$ compareAndExchangeRelease(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.compareAndExchange$Type$Release(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -454,7 +497,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static boolean weakCompareAndSetPlain(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -462,7 +506,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static boolean weakCompareAndSet(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -470,7 +515,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static boolean weakCompareAndSetAcquire(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -478,7 +524,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
static boolean weakCompareAndSetRelease(VarHandle ob, $type$ expected, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(expected):expected},
@ -486,21 +533,24 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndSet(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndSet$Type$(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static $type$ getAndSetAcquire(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndSetAcquire(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndSet$Type$Acquire(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
}
@ForceInline
static $type$ getAndSetRelease(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndSetRelease(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndSet$Type$Release(handle.base,
handle.fieldOffset,
{#if[Object]?handle.fieldType.cast(value):value});
@ -509,21 +559,24 @@ final class VarHandle$Type$s {
#if[AtomicAdd]
@ForceInline
static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndAdd(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndAdd$Type$(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndAddAcquire(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndAddAcquire(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndAdd$Type$Acquire(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndAddRelease(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndAddRelease(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndAdd$Type$Release(handle.base,
handle.fieldOffset,
value);
@ -532,63 +585,72 @@ final class VarHandle$Type$s {
#if[Bitwise]
@ForceInline
static $type$ getAndBitwiseOr(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseOr(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseOr$Type$(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseOrRelease(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseOrRelease(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseOr$Type$Release(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseOrAcquire(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseOrAcquire(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseOr$Type$Acquire(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseAnd(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseAnd(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseAnd$Type$(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseAndRelease(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseAndRelease(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseAnd$Type$Release(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseAndAcquire(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseAndAcquire(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseAnd$Type$Acquire(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseXor(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseXor(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseXor$Type$(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseXorRelease(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseXorRelease(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseXor$Type$Release(handle.base,
handle.fieldOffset,
value);
}
@ForceInline
static $type$ getAndBitwiseXorAcquire(FieldStaticReadWrite handle, $type$ value) {
static $type$ getAndBitwiseXorAcquire(VarHandle ob, $type$ value) {
FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base,
handle.fieldOffset,
value);
@ -654,7 +716,8 @@ final class VarHandle$Type$s {
#end[Object]
@ForceInline
static $type$ get(Array handle, Object oarray, int index) {
static $type$ get(VarHandle ob, Object oarray, int index) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -664,7 +727,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static void set(Array handle, Object oarray, int index, $type$ value) {
static void set(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -674,7 +738,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getVolatile(Array handle, Object oarray, int index) {
static $type$ getVolatile(VarHandle ob, Object oarray, int index) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -685,7 +750,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
static void setVolatile(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -697,7 +763,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getOpaque(Array handle, Object oarray, int index) {
static $type$ getOpaque(VarHandle ob, Object oarray, int index) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -708,7 +775,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static void setOpaque(Array handle, Object oarray, int index, $type$ value) {
static void setOpaque(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -720,7 +788,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAcquire(Array handle, Object oarray, int index) {
static $type$ getAcquire(VarHandle ob, Object oarray, int index) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -731,7 +800,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static void setRelease(Array handle, Object oarray, int index, $type$ value) {
static void setRelease(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -744,7 +814,8 @@ final class VarHandle$Type$s {
#if[CAS]
@ForceInline
static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static boolean compareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -757,7 +828,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchange(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchange(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -770,7 +842,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchangeAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -783,7 +856,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchangeRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -796,7 +870,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetPlain(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -809,7 +884,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -822,7 +898,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -835,7 +912,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -848,7 +926,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndSet(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -860,7 +939,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndSetAcquire(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -872,7 +952,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndSetRelease(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndSetRelease(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
#if[Object]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
#else[Object]
@ -886,7 +967,8 @@ final class VarHandle$Type$s {
#if[AtomicAdd]
@ForceInline
static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndAdd(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndAdd$Type$(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -894,7 +976,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndAddAcquire(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndAddAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndAdd$Type$Acquire(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -902,7 +985,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndAddRelease(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndAddRelease(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndAdd$Type$Release(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -912,7 +996,8 @@ final class VarHandle$Type$s {
#if[Bitwise]
@ForceInline
static $type$ getAndBitwiseOr(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseOr(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseOr$Type$(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -920,7 +1005,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseOrRelease(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseOrRelease(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseOr$Type$Release(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -928,7 +1014,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseOrAcquire(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseOr$Type$Acquire(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -936,7 +1023,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseAnd(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseAnd(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseAnd$Type$(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -944,7 +1032,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseAndRelease(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseAndRelease(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseAnd$Type$Release(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -952,7 +1041,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseAndAcquire(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseAnd$Type$Acquire(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -960,7 +1050,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseXor(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseXor$Type$(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -968,7 +1059,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseXorRelease(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseXorRelease(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseXor$Type$Release(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
@ -976,7 +1068,8 @@ final class VarHandle$Type$s {
}
@ForceInline
static $type$ getAndBitwiseXorAcquire(Array handle, Object oarray, int index, $type$ value) {
static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
Array handle = (Array)ob;
$type$[] array = ($type$[]) oarray;
return UNSAFE.getAndBitwiseXor$Type$Acquire(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,

View file

@ -26,6 +26,7 @@ package java.lang.invoke;
import jdk.internal.access.JavaNioAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.access.foreign.MemorySegmentProxy;
import jdk.internal.misc.Unsafe;
import jdk.internal.util.Preconditions;
import jdk.internal.vm.annotation.ForceInline;
@ -98,7 +99,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ get(ArrayHandle handle, Object oba, int index) {
static $type$ get(VarHandle ob, Object oba, int index) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
#if[floatingPoint]
$rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
@ -115,7 +117,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void set(ArrayHandle handle, Object oba, int index, $type$ value) {
static void set(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
#if[floatingPoint]
UNSAFE.put$RawType$Unaligned(
@ -133,7 +136,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getVolatile(ArrayHandle handle, Object oba, int index) {
static $type$ getVolatile(VarHandle ob, Object oba, int index) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.get$RawType$Volatile(
@ -142,7 +146,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void setVolatile(ArrayHandle handle, Object oba, int index, $type$ value) {
static void setVolatile(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
UNSAFE.put$RawType$Volatile(
ba,
@ -151,7 +156,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAcquire(ArrayHandle handle, Object oba, int index) {
static $type$ getAcquire(VarHandle ob, Object oba, int index) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.get$RawType$Acquire(
@ -160,7 +166,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void setRelease(ArrayHandle handle, Object oba, int index, $type$ value) {
static void setRelease(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
UNSAFE.put$RawType$Release(
ba,
@ -169,7 +176,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getOpaque(ArrayHandle handle, Object oba, int index) {
static $type$ getOpaque(VarHandle ob, Object oba, int index) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.get$RawType$Opaque(
@ -178,7 +186,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void setOpaque(ArrayHandle handle, Object oba, int index, $type$ value) {
static void setOpaque(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
UNSAFE.put$RawType$Opaque(
ba,
@ -188,7 +197,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
#if[CAS]
@ForceInline
static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static boolean compareAndSet(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
#if[Object]
return UNSAFE.compareAndSetReference(
@ -204,7 +214,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchange(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$(
@ -214,7 +225,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ compareAndExchangeAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchangeAcquire(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Acquire(
@ -224,7 +236,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ compareAndExchangeRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchangeRelease(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Release(
@ -234,7 +247,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetPlain(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return UNSAFE.weakCompareAndSet$RawType$Plain(
ba,
@ -243,7 +257,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSet(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return UNSAFE.weakCompareAndSet$RawType$(
ba,
@ -252,7 +267,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetAcquire(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return UNSAFE.weakCompareAndSet$RawType$Acquire(
ba,
@ -261,7 +277,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetRelease(VarHandle ob, Object oba, int index, $type$ expected, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return UNSAFE.weakCompareAndSet$RawType$Release(
ba,
@ -270,7 +287,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndSet(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
#if[Object]
return convEndian(handle.be,
@ -288,7 +306,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndSetAcquire(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Acquire(
@ -298,7 +317,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndSetRelease(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Release(
@ -310,7 +330,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
#if[AtomicAdd]
@ForceInline
static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) {
static $type$ getAndAdd(VarHandle ob, Object oba, int index, $type$ delta) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$(
@ -323,7 +344,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndAddAcquire(ArrayHandle handle, Object oba, int index, $type$ delta) {
static $type$ getAndAddAcquire(VarHandle ob, Object oba, int index, $type$ delta) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Acquire(
@ -336,7 +358,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndAddRelease(ArrayHandle handle, Object oba, int index, $type$ delta) {
static $type$ getAndAddRelease(VarHandle ob, Object oba, int index, $type$ delta) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Release(
@ -363,7 +386,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
#if[Bitwise]
@ForceInline
static $type$ getAndBitwiseOr(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseOr(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$(
@ -376,7 +400,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseOrRelease(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseOrRelease(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Release(
@ -389,7 +414,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseOrAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Acquire(
@ -414,7 +440,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseAnd(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseAnd(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$(
@ -427,7 +454,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseAndRelease(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseAndRelease(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Release(
@ -440,7 +468,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseAndAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
@ -465,7 +494,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseXor(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseXor(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$(
@ -478,7 +508,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseXorRelease(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseXorRelease(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Release(
@ -491,7 +522,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseXorAcquire(ArrayHandle handle, Object oba, int index, $type$ value) {
static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object oba, int index, $type$ value) {
ArrayHandle handle = (ArrayHandle)ob;
byte[] ba = (byte[]) oba;
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Acquire(
@ -533,7 +565,10 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static int index(ByteBuffer bb, int index) {
nioAccess.checkSegment(bb);
MemorySegmentProxy segmentProxy = nioAccess.bufferSegment(bb);
if (segmentProxy != null) {
segmentProxy.checkValidState();
}
return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
}
@ -553,7 +588,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ get(ByteBufferHandle handle, Object obb, int index) {
static $type$ get(VarHandle ob, Object obb, int index) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[floatingPoint]
$rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
@ -570,7 +606,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void set(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static void set(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[floatingPoint]
UNSAFE.put$RawType$Unaligned(
@ -588,7 +625,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getVolatile(ByteBufferHandle handle, Object obb, int index) {
static $type$ getVolatile(VarHandle ob, Object obb, int index) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.get$RawType$Volatile(
@ -597,7 +635,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static void setVolatile(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
UNSAFE.put$RawType$Volatile(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -606,7 +645,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAcquire(ByteBufferHandle handle, Object obb, int index) {
static $type$ getAcquire(VarHandle ob, Object obb, int index) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.get$RawType$Acquire(
@ -615,7 +655,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static void setRelease(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
UNSAFE.put$RawType$Release(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -624,7 +665,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getOpaque(ByteBufferHandle handle, Object obb, int index) {
static $type$ getOpaque(VarHandle ob, Object obb, int index) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.get$RawType$Opaque(
@ -633,7 +675,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static void setOpaque(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
UNSAFE.put$RawType$Opaque(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -643,7 +686,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
#if[CAS]
@ForceInline
static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static boolean compareAndSet(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[Object]
return UNSAFE.compareAndSetReference(
@ -659,7 +703,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchange(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$(
@ -669,7 +714,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ compareAndExchangeAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchangeAcquire(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Acquire(
@ -679,7 +725,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ compareAndExchangeRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static $type$ compareAndExchangeRelease(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Release(
@ -689,7 +736,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetPlain(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$Plain(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -698,7 +746,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSet(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -707,7 +756,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetAcquire(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$Acquire(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -716,7 +766,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
static boolean weakCompareAndSetRelease(VarHandle ob, Object obb, int index, $type$ expected, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$Release(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
@ -725,7 +776,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndSet(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[Object]
return convEndian(handle.be,
@ -743,7 +795,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndSetAcquire(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Acquire(
@ -753,7 +806,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndSetRelease(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Release(
@ -765,7 +819,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
#if[AtomicAdd]
@ForceInline
static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
static $type$ getAndAdd(VarHandle ob, Object obb, int index, $type$ delta) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$(
@ -778,7 +833,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
static $type$ getAndAddAcquire(VarHandle ob, Object obb, int index, $type$ delta) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Acquire(
@ -791,7 +847,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
static $type$ getAndAddRelease(VarHandle ob, Object obb, int index, $type$ delta) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Release(
@ -819,7 +876,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
#if[Bitwise]
@ForceInline
static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseOr(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$(
@ -832,7 +890,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseOrRelease(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Release(
@ -845,7 +904,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Acquire(
@ -871,7 +931,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseAnd(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$(
@ -884,7 +945,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseAndRelease(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Release(
@ -897,7 +959,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
@ -924,7 +987,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseXor(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$(
@ -937,7 +1001,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseXorRelease(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Release(
@ -950,7 +1015,8 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
}
@ForceInline
static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) {
static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object obb, int index, $type$ value) {
ByteBufferHandle handle = (ByteBufferHandle)ob;
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Acquire(

View file

@ -33,7 +33,7 @@ import static java.lang.invoke.MethodHandleStatics.UNSAFE;
#warn
final class VarHandleMemoryAddressAs$Type$s {
final class MemoryAccessVarHandle$Type$Helper {
static final boolean BE = UNSAFE.isBigEndian();
@ -76,7 +76,7 @@ final class VarHandleMemoryAddressAs$Type$s {
static long offset(MemoryAddressProxy bb, long offset, long alignmentMask) {
long address = offsetNoVMAlignCheck(bb, offset, alignmentMask);
if ((address & VM_ALIGN) != 0) {
throw VarHandleMemoryAddressBase.newIllegalStateExceptionForMisalignedAccess(address);
throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address);
}
return address;
}
@ -87,13 +87,14 @@ final class VarHandleMemoryAddressAs$Type$s {
long address = base + offset;
//note: the offset portion has already been aligned-checked, by construction
if ((base & alignmentMask) != 0) {
throw VarHandleMemoryAddressBase.newIllegalStateExceptionForMisalignedAccess(address);
throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address);
}
return address;
}
@ForceInline
static $type$ get0(VarHandleMemoryAddressBase handle, Object obb, long base) {
static $type$ get0(VarHandle ob, Object obb, long base) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, true);
#if[floatingPoint]
$rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
@ -116,7 +117,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static void set0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static void set0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
#if[floatingPoint]
UNSAFE.put$RawType$Unaligned(
@ -141,7 +143,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getVolatile0(VarHandleMemoryAddressBase handle, Object obb, long base) {
static $type$ getVolatile0(VarHandle ob, Object obb, long base) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, true);
return convEndian(handle.be,
UNSAFE.get$RawType$Volatile(
@ -150,7 +153,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static void setVolatile0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static void setVolatile0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
UNSAFE.put$RawType$Volatile(
bb.unsafeGetBase(),
@ -159,7 +163,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base) {
static $type$ getAcquire0(VarHandle ob, Object obb, long base) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, true);
return convEndian(handle.be,
UNSAFE.get$RawType$Acquire(
@ -168,7 +173,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static void setRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static void setRelease0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
UNSAFE.put$RawType$Release(
bb.unsafeGetBase(),
@ -177,7 +183,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getOpaque0(VarHandleMemoryAddressBase handle, Object obb, long base) {
static $type$ getOpaque0(VarHandle ob, Object obb, long base) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, true);
return convEndian(handle.be,
UNSAFE.get$RawType$Opaque(
@ -186,7 +193,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static void setOpaque0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static void setOpaque0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
UNSAFE.put$RawType$Opaque(
bb.unsafeGetBase(),
@ -196,7 +204,8 @@ final class VarHandleMemoryAddressAs$Type$s {
#if[CAS]
@ForceInline
static boolean compareAndSet0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static boolean compareAndSet0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return UNSAFE.compareAndSet$RawType$(
bb.unsafeGetBase(),
@ -205,7 +214,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ compareAndExchange0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static $type$ compareAndExchange0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$(
@ -215,7 +225,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ compareAndExchangeAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static $type$ compareAndExchangeAcquire0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Acquire(
@ -225,7 +236,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ compareAndExchangeRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static $type$ compareAndExchangeRelease0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Release(
@ -235,7 +247,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static boolean weakCompareAndSetPlain0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static boolean weakCompareAndSetPlain0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return UNSAFE.weakCompareAndSet$RawType$Plain(
bb.unsafeGetBase(),
@ -244,7 +257,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static boolean weakCompareAndSet0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static boolean weakCompareAndSet0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return UNSAFE.weakCompareAndSet$RawType$(
bb.unsafeGetBase(),
@ -253,7 +267,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static boolean weakCompareAndSetAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static boolean weakCompareAndSetAcquire0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return UNSAFE.weakCompareAndSet$RawType$Acquire(
bb.unsafeGetBase(),
@ -262,7 +277,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static boolean weakCompareAndSetRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ expected, $type$ value) {
static boolean weakCompareAndSetRelease0(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return UNSAFE.weakCompareAndSet$RawType$Release(
bb.unsafeGetBase(),
@ -271,7 +287,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndSet0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndSet0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$(
@ -281,7 +298,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndSetAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndSetAcquire0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Acquire(
@ -291,7 +309,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndSetRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndSetRelease0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Release(
@ -303,7 +322,8 @@ final class VarHandleMemoryAddressAs$Type$s {
#if[AtomicAdd]
@ForceInline
static $type$ getAndAdd0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ delta) {
static $type$ getAndAdd0(VarHandle ob, Object obb, long base, $type$ delta) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$(
@ -316,7 +336,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndAddAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ delta) {
static $type$ getAndAddAcquire0(VarHandle ob, Object obb, long base, $type$ delta) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Acquire(
@ -329,7 +350,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndAddRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ delta) {
static $type$ getAndAddRelease0(VarHandle ob, Object obb, long base, $type$ delta) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Release(
@ -356,7 +378,8 @@ final class VarHandleMemoryAddressAs$Type$s {
#if[Bitwise]
@ForceInline
static $type$ getAndBitwiseOr0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseOr0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$(
@ -369,7 +392,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseOrRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseOrRelease0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Release(
@ -382,7 +406,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseOrAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseOrAcquire0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Acquire(
@ -407,7 +432,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseAnd0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseAnd0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$(
@ -420,7 +446,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseAndRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseAndRelease0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Release(
@ -433,7 +460,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseAndAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseAndAcquire0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
@ -459,7 +487,8 @@ final class VarHandleMemoryAddressAs$Type$s {
@ForceInline
static $type$ getAndBitwiseXor0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseXor0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$(
@ -472,7 +501,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseXorRelease0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseXorRelease0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Release(
@ -485,7 +515,8 @@ final class VarHandleMemoryAddressAs$Type$s {
}
@ForceInline
static $type$ getAndBitwiseXorAcquire0(VarHandleMemoryAddressBase handle, Object obb, long base, $type$ value) {
static $type$ getAndBitwiseXorAcquire0(VarHandle ob, Object obb, long base, $type$ value) {
MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob;
MemoryAddressProxy bb = checkAddress(obb, base, handle.length, false);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Acquire(