8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference

Reviewed-by: dholmes, thartmann
This commit is contained in:
Mandy Chung 2018-10-22 17:00:04 -07:00
parent fd8d1cd6bf
commit 5e6d6b8642
70 changed files with 643 additions and 603 deletions

View file

@ -238,7 +238,7 @@ class BufferedInputStream extends FilterInputStream {
nsz = marklimit;
byte[] nbuf = new byte[nsz];
System.arraycopy(buffer, 0, nbuf, 0, pos);
if (!U.compareAndSetObject(this, BUF_OFFSET, buffer, nbuf)) {
if (!U.compareAndSetReference(this, BUF_OFFSET, buffer, nbuf)) {
// Can't replace buf if there was an async close.
// Note: This would need to be changed if fill()
// is ever made accessible to multiple threads.
@ -482,7 +482,7 @@ class BufferedInputStream extends FilterInputStream {
public void close() throws IOException {
byte[] buffer;
while ( (buffer = buf) != null) {
if (U.compareAndSetObject(this, BUF_OFFSET, buffer, null)) {
if (U.compareAndSetReference(this, BUF_OFFSET, buffer, null)) {
InputStream input = in;
in = null;
if (input != null)

View file

@ -2237,7 +2237,7 @@ public class File
if (sep != separatorChar)
pathField = pathField.replace(sep, separatorChar);
String path = fs.normalize(pathField);
UNSAFE.putObject(this, PATH_OFFSET, path);
UNSAFE.putReference(this, PATH_OFFSET, path);
UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
}

View file

@ -2135,7 +2135,7 @@ public class ObjectStreamClass implements Serializable {
switch (typeCodes[i]) {
case 'L':
case '[':
vals[offsets[i]] = unsafe.getObject(obj, readKeys[i]);
vals[offsets[i]] = unsafe.getReference(obj, readKeys[i]);
break;
default:
@ -2190,7 +2190,7 @@ public class ObjectStreamClass implements Serializable {
obj.getClass().getName());
}
if (!dryRun)
unsafe.putObject(obj, key, val);
unsafe.putReference(obj, key, val);
break;
default:

View file

@ -2904,19 +2904,19 @@ public final class Class<T> implements java.io.Serializable,
static <T> boolean casReflectionData(Class<?> clazz,
SoftReference<ReflectionData<T>> oldData,
SoftReference<ReflectionData<T>> newData) {
return unsafe.compareAndSetObject(clazz, reflectionDataOffset, oldData, newData);
return unsafe.compareAndSetReference(clazz, reflectionDataOffset, oldData, newData);
}
static <T> boolean casAnnotationType(Class<?> clazz,
AnnotationType oldType,
AnnotationType newType) {
return unsafe.compareAndSetObject(clazz, annotationTypeOffset, oldType, newType);
return unsafe.compareAndSetReference(clazz, annotationTypeOffset, oldType, newType);
}
static <T> boolean casAnnotationData(Class<?> clazz,
AnnotationData oldData,
AnnotationData newData) {
return unsafe.compareAndSetObject(clazz, annotationDataOffset, oldData, newData);
return unsafe.compareAndSetReference(clazz, annotationDataOffset, oldData, newData);
}
}

View file

@ -3002,7 +3002,7 @@ public abstract class ClassLoader {
Class<?> k = ClassLoader.class;
long offset;
offset = unsafe.objectFieldOffset(k, name);
return unsafe.compareAndSetObject(this, offset, null, obj);
return unsafe.compareAndSetReference(this, offset, null, obj);
}
}

View file

@ -287,7 +287,7 @@ public class CallSite {
}
/*package-private*/
MethodHandle getTargetVolatile() {
return (MethodHandle) UNSAFE.getObjectVolatile(this, getTargetOffset());
return (MethodHandle) UNSAFE.getReferenceVolatile(this, getTargetOffset());
}
/*package-private*/
void setTargetVolatile(MethodHandle newTarget) {

View file

@ -940,7 +940,7 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
Object base = MethodHandleNatives.staticFieldBase(sdField);
long offset = MethodHandleNatives.staticFieldOffset(sdField);
UNSAFE.loadFence();
return metaType.cast(UNSAFE.getObject(base, offset));
return metaType.cast(UNSAFE.getReference(base, offset));
} catch (Error err) {
throw err;
} catch (Exception ex) {
@ -970,7 +970,7 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
Object base = MethodHandleNatives.staticFieldBase(sdField);
long offset = MethodHandleNatives.staticFieldOffset(sdField);
UNSAFE.storeFence();
UNSAFE.putObject(base, offset, speciesData);
UNSAFE.putReference(base, offset, speciesData);
UNSAFE.storeFence();
} catch (Error err) {
throw err;

View file

@ -655,7 +655,7 @@ class DirectMethodHandle extends MethodHandle {
case LONG: return GET_LONG_VOLATILE;
case FLOAT: return GET_FLOAT_VOLATILE;
case DOUBLE: return GET_DOUBLE_VOLATILE;
case OBJECT: return GET_OBJECT_VOLATILE;
case OBJECT: return GET_REFERENCE_VOLATILE;
}
} else {
switch (wrapper) {
@ -667,7 +667,7 @@ class DirectMethodHandle extends MethodHandle {
case LONG: return GET_LONG;
case FLOAT: return GET_FLOAT;
case DOUBLE: return GET_DOUBLE;
case OBJECT: return GET_OBJECT;
case OBJECT: return GET_REFERENCE;
}
}
} else {
@ -681,7 +681,7 @@ class DirectMethodHandle extends MethodHandle {
case LONG: return PUT_LONG_VOLATILE;
case FLOAT: return PUT_FLOAT_VOLATILE;
case DOUBLE: return PUT_DOUBLE_VOLATILE;
case OBJECT: return PUT_OBJECT_VOLATILE;
case OBJECT: return PUT_REFERENCE_VOLATILE;
}
} else {
switch (wrapper) {
@ -693,7 +693,7 @@ class DirectMethodHandle extends MethodHandle {
case LONG: return PUT_LONG;
case FLOAT: return PUT_FLOAT;
case DOUBLE: return PUT_DOUBLE;
case OBJECT: return PUT_OBJECT;
case OBJECT: return PUT_REFERENCE;
}
}
}

View file

@ -653,7 +653,7 @@ class InvokerBytecodeGenerator {
case LINK_TO_TARGET_METHOD: // fall-through
case GENERIC_INVOKER: // fall-through
case GENERIC_LINKER: return resolveFrom(name, invokerType.basicType(), Invokers.Holder.class);
case GET_OBJECT: // fall-through
case GET_REFERENCE: // fall-through
case GET_BOOLEAN: // fall-through
case GET_BYTE: // fall-through
case GET_CHAR: // fall-through
@ -662,7 +662,7 @@ class InvokerBytecodeGenerator {
case GET_LONG: // fall-through
case GET_FLOAT: // fall-through
case GET_DOUBLE: // fall-through
case PUT_OBJECT: // fall-through
case PUT_REFERENCE: // fall-through
case PUT_BOOLEAN: // fall-through
case PUT_BYTE: // fall-through
case PUT_CHAR: // fall-through

View file

@ -296,10 +296,10 @@ class LambdaForm {
DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial", "newInvokeSpecial"),
DIRECT_INVOKE_INTERFACE("DMH.invokeInterface", "invokeInterface"),
DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit", "invokeStaticInit"),
GET_OBJECT("getObject"),
PUT_OBJECT("putObject"),
GET_OBJECT_VOLATILE("getObjectVolatile"),
PUT_OBJECT_VOLATILE("putObjectVolatile"),
GET_REFERENCE("getReference"),
PUT_REFERENCE("putReference"),
GET_REFERENCE_VOLATILE("getReferenceVolatile"),
PUT_REFERENCE_VOLATILE("putReferenceVolatile"),
GET_INT("getInt"),
PUT_INT("putInt"),
GET_INT_VOLATILE("getIntVolatile"),

View file

@ -1663,7 +1663,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
assert(newForm.customized == null || newForm.customized == this);
if (form == newForm) return;
newForm.prepare(); // as in MethodHandle.<init>
UNSAFE.putObject(this, FORM_OFFSET, newForm);
UNSAFE.putReference(this, FORM_OFFSET, newForm);
UNSAFE.fullFence();
}

View file

@ -1245,8 +1245,8 @@ s.writeObject(this.parameterArray());
// store them into the implementation-specific final fields.
checkRtype(rtype);
checkPtypes(ptypes);
UNSAFE.putObject(this, OffsetHolder.rtypeOffset, rtype);
UNSAFE.putObject(this, OffsetHolder.ptypesOffset, ptypes);
UNSAFE.putReference(this, OffsetHolder.rtypeOffset, rtype);
UNSAFE.putReference(this, OffsetHolder.ptypesOffset, ptypes);
}
// Support for resetting final fields while deserializing. Implement Holder

View file

@ -1999,7 +1999,7 @@ public abstract class VarHandle {
/*non-public*/
final void updateVarForm(VarForm newVForm) {
if (vform == newVForm) return;
UNSAFE.putObject(this, VFORM_OFFSET, newVForm);
UNSAFE.putReference(this, VFORM_OFFSET, newVForm);
UNSAFE.fullFence();
}

View file

@ -34,8 +34,8 @@ final class VarHandles {
long foffset = MethodHandleNatives.objectFieldOffset(f);
if (!type.isPrimitive()) {
return f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleObjects.FieldInstanceReadOnly(refc, foffset, type)
: new VarHandleObjects.FieldInstanceReadWrite(refc, foffset, type);
? new VarHandleReferences.FieldInstanceReadOnly(refc, foffset, type)
: new VarHandleReferences.FieldInstanceReadWrite(refc, foffset, type);
}
else if (type == boolean.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
@ -95,8 +95,8 @@ final class VarHandles {
long foffset = MethodHandleNatives.staticFieldOffset(f);
if (!type.isPrimitive()) {
return f.isFinal() && !isWriteAllowedOnFinalFields
? new VarHandleObjects.FieldStaticReadOnly(base, foffset, type)
: new VarHandleObjects.FieldStaticReadWrite(base, foffset, type);
? new VarHandleReferences.FieldStaticReadOnly(base, foffset, type)
: new VarHandleReferences.FieldStaticReadWrite(base, foffset, type);
}
else if (type == boolean.class) {
return f.isFinal() && !isWriteAllowedOnFinalFields
@ -155,7 +155,7 @@ final class VarHandles {
int ashift = 31 - Integer.numberOfLeadingZeros(ascale);
if (!componentType.isPrimitive()) {
return new VarHandleObjects.Array(aoffset, ashift, arrayClass);
return new VarHandleReferences.Array(aoffset, ashift, arrayClass);
}
else if (componentType == boolean.class) {
return new VarHandleBooleans.Array(aoffset, ashift);

View file

@ -186,10 +186,17 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
byte[] ba = (byte[]) oba;
#if[Object]
return UNSAFE.compareAndSetReference(
ba,
address(ba, index(ba, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
#else[Object]
return UNSAFE.compareAndSet$RawType$(
ba,
address(ba, index(ba, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
#end[Object]
}
@ForceInline
@ -261,11 +268,19 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) {
byte[] ba = (byte[]) oba;
#if[Object]
return convEndian(handle.be,
UNSAFE.getAndSetReference(
ba,
address(ba, index(ba, index)),
convEndian(handle.be, value)));
#else[Object]
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$(
ba,
address(ba, index(ba, index)),
convEndian(handle.be, value)));
#end[Object]
}
@ForceInline
@ -537,13 +552,13 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[floatingPoint]
$rawType$ rawValue = UNSAFE.get$RawType$Unaligned(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
handle.be);
return $Type$.$rawType$BitsTo$Type$(rawValue);
#else[floatingPoint]
return UNSAFE.get$Type$Unaligned(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
handle.be);
#end[floatingPoint]
@ -554,13 +569,13 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[floatingPoint]
UNSAFE.put$RawType$Unaligned(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
$Type$.$type$ToRaw$RawType$Bits(value),
handle.be);
#else[floatingPoint]
UNSAFE.put$Type$Unaligned(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS),
value,
handle.be);
@ -572,7 +587,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.get$RawType$Volatile(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, index(bb, index))));
}
@ -580,7 +595,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
UNSAFE.put$RawType$Volatile(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value));
}
@ -590,7 +605,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.get$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, index(bb, index))));
}
@ -598,7 +613,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
UNSAFE.put$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value));
}
@ -608,7 +623,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.get$RawType$Opaque(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, index(bb, index))));
}
@ -616,7 +631,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
UNSAFE.put$RawType$Opaque(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value));
}
@ -625,10 +640,17 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.compareAndSet$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
#if[Object]
return UNSAFE.compareAndSetReference(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
#else[Object]
return UNSAFE.compareAndSet$RawType$(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
#end[Object]
}
@ForceInline
@ -636,7 +658,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value)));
}
@ -646,7 +668,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value)));
}
@ -656,7 +678,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.compareAndExchange$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value)));
}
@ -665,7 +687,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$Plain(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
}
@ -674,7 +696,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
}
@ -683,7 +705,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
}
@ -692,7 +714,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return UNSAFE.weakCompareAndSet$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, expected), convEndian(handle.be, value));
}
@ -700,11 +722,19 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
#if[Object]
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getAndSetReference(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value)));
#else[Object]
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$(
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value)));
#end[Object]
}
@ForceInline
@ -712,7 +742,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value)));
}
@ -722,7 +752,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
return convEndian(handle.be,
UNSAFE.getAndSet$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
convEndian(handle.be, value)));
}
@ -734,7 +764,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
delta);
} else {
@ -747,7 +777,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
delta);
} else {
@ -760,7 +790,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndAdd$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
delta);
} else {
@ -771,7 +801,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) {
$type$ nativeExpectedValue, expectedValue;
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
long offset = address(bb, indexRO(bb, index));
do {
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
@ -788,7 +818,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -801,7 +831,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -814,7 +844,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseOr$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -825,7 +855,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
$type$ nativeExpectedValue, expectedValue;
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
long offset = address(bb, indexRO(bb, index));
do {
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
@ -840,7 +870,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -853,7 +883,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -866,7 +896,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseAnd$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -877,7 +907,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
$type$ nativeExpectedValue, expectedValue;
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
long offset = address(bb, indexRO(bb, index));
do {
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
@ -893,7 +923,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -906,7 +936,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Release(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -919,7 +949,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
ByteBuffer bb = (ByteBuffer) Objects.requireNonNull(obb);
if (handle.be == BE) {
return UNSAFE.getAndBitwiseXor$RawType$Acquire(
UNSAFE.getObject(bb, BYTE_BUFFER_HB),
UNSAFE.getReference(bb, BYTE_BUFFER_HB),
address(bb, indexRO(bb, index)),
value);
} else {
@ -930,7 +960,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
@ForceInline
static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) {
$type$ nativeExpectedValue, expectedValue;
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
Object base = UNSAFE.getReference(bb, BYTE_BUFFER_HB);
long offset = address(bb, indexRO(bb, index));
do {
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);

View file

@ -4079,7 +4079,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
}
static void setIntValVolatile(BigDecimal bd, BigInteger val) {
unsafe.putObjectVolatile(bd, intValOffset, val);
unsafe.putReferenceVolatile(bd, intValOffset, val);
}
}

View file

@ -4600,7 +4600,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
}
static void putMag(BigInteger bi, int[] magnitude) {
unsafe.putObject(bi, magOffset, magnitude);
unsafe.putReference(bi, magOffset, magnitude);
}
}

View file

@ -641,7 +641,7 @@ class Inet6Address extends InetAddress {
ipaddress, scope_id, scope_id_set, scope_ifname, scope_ifname_set
);
UNSAFE.putObject(this, FIELDS_OFFSET, h);
UNSAFE.putReference(this, FIELDS_OFFSET, h);
}
/**

View file

@ -1734,7 +1734,7 @@ class InetAddress implements java.io.Serializable {
throw new InvalidObjectException("invalid address family type: " + family);
}
InetAddressHolder h = new InetAddressHolder(host, address, family);
UNSAFE.putObject(this, FIELDS_OFFSET, h);
UNSAFE.putReference(this, FIELDS_OFFSET, h);
}
/* needed because the serializable fields no longer exist */

View file

@ -293,7 +293,7 @@ public class InetSocketAddress
InetSocketAddressHolder h = new InetSocketAddressHolder(oisHostname,
oisAddr,
oisPort);
UNSAFE.putObject(this, FIELDS_OFFSET, h);
UNSAFE.putReference(this, FIELDS_OFFSET, h);
}
private void readObjectNoData()

View file

@ -1222,6 +1222,6 @@ class Random implements java.io.Serializable {
} catch (Exception ex) { throw new Error(ex); }
}
private void resetSeed(long seedVal) {
unsafe.putObjectVolatile(this, seedOffset, new AtomicLong(seedVal));
unsafe.putReferenceVolatile(this, seedOffset, new AtomicLong(seedVal));
}
}

View file

@ -757,16 +757,16 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
@SuppressWarnings("unchecked")
static final <K,V> Node<K,V> tabAt(Node<K,V>[] tab, int i) {
return (Node<K,V>)U.getObjectAcquire(tab, ((long)i << ASHIFT) + ABASE);
return (Node<K,V>)U.getReferenceAcquire(tab, ((long)i << ASHIFT) + ABASE);
}
static final <K,V> boolean casTabAt(Node<K,V>[] tab, int i,
Node<K,V> c, Node<K,V> v) {
return U.compareAndSetObject(tab, ((long)i << ASHIFT) + ABASE, c, v);
return U.compareAndSetReference(tab, ((long)i << ASHIFT) + ABASE, c, v);
}
static final <K,V> void setTabAt(Node<K,V>[] tab, int i, Node<K,V> v) {
U.putObjectRelease(tab, ((long)i << ASHIFT) + ABASE, v);
U.putReferenceRelease(tab, ((long)i << ASHIFT) + ABASE, v);
}
/* ---------------- Fields -------------- */

View file

@ -976,13 +976,13 @@ public class ThreadLocalRandom extends Random {
* Erases ThreadLocals by nulling out Thread maps.
*/
static final void eraseThreadLocals(Thread thread) {
U.putObject(thread, THREADLOCALS, null);
U.putObject(thread, INHERITABLETHREADLOCALS, null);
U.putReference(thread, THREADLOCALS, null);
U.putReference(thread, INHERITABLETHREADLOCALS, null);
}
static final void setInheritedAccessControlContext(Thread thread,
AccessControlContext acc) {
U.putObjectRelease(thread, INHERITEDACCESSCONTROLCONTEXT, acc);
U.putReferenceRelease(thread, INHERITEDACCESSCONTROLCONTEXT, acc);
}
// Serialization support

View file

@ -439,39 +439,39 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
public final boolean compareAndSet(T obj, V expect, V update) {
accessCheck(obj);
valueCheck(update);
return U.compareAndSetObject(obj, offset, expect, update);
return U.compareAndSetReference(obj, offset, expect, update);
}
public final boolean weakCompareAndSet(T obj, V expect, V update) {
// same implementation as strong form for now
accessCheck(obj);
valueCheck(update);
return U.compareAndSetObject(obj, offset, expect, update);
return U.compareAndSetReference(obj, offset, expect, update);
}
public final void set(T obj, V newValue) {
accessCheck(obj);
valueCheck(newValue);
U.putObjectVolatile(obj, offset, newValue);
U.putReferenceVolatile(obj, offset, newValue);
}
public final void lazySet(T obj, V newValue) {
accessCheck(obj);
valueCheck(newValue);
U.putObjectRelease(obj, offset, newValue);
U.putReferenceRelease(obj, offset, newValue);
}
@SuppressWarnings("unchecked")
public final V get(T obj) {
accessCheck(obj);
return (V)U.getObjectVolatile(obj, offset);
return (V)U.getReferenceVolatile(obj, offset);
}
@SuppressWarnings("unchecked")
public final V getAndSet(T obj, V newValue) {
accessCheck(obj);
valueCheck(newValue);
return (V)U.getAndSetObject(obj, offset, newValue);
return (V)U.getAndSetReference(obj, offset, newValue);
}
}
}

View file

@ -141,7 +141,7 @@ public class LockSupport {
private static void setBlocker(Thread t, Object arg) {
// Even though volatile, hotspot doesn't need a write barrier here.
U.putObject(t, PARKBLOCKER, arg);
U.putReference(t, PARKBLOCKER, arg);
}
/**
@ -291,7 +291,7 @@ public class LockSupport {
public static Object getBlocker(Thread t) {
if (t == null)
throw new NullPointerException();
return U.getObjectVolatile(t, PARKBLOCKER);
return U.getReferenceVolatile(t, PARKBLOCKER);
}
/**

View file

@ -25,7 +25,6 @@
package java.util.zip;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.file.attribute.FileTime;
import java.security.AccessController;
@ -40,7 +39,6 @@ import java.util.concurrent.TimeUnit;
import static java.util.zip.ZipConstants.ENDHDR;
import jdk.internal.misc.Unsafe;
import sun.nio.ch.DirectBuffer;
class ZipUtils {
@ -295,7 +293,7 @@ class ZipUtils {
private static final long byteBufferOffsetOffset = unsafe.objectFieldOffset(ByteBuffer.class, "offset");
static byte[] getBufferArray(ByteBuffer byteBuffer) {
return (byte[]) unsafe.getObject(byteBuffer, byteBufferArrayOffset);
return (byte[]) unsafe.getReference(byteBuffer, byteBufferArrayOffset);
}
static int getBufferOffset(ByteBuffer byteBuffer) {