< prev index next >
src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Print this page
rev 55127 : 8223351: [lworld] Primary mirror and nullable mirror for inline type
Reviewed-by: tbd
*** 176,189 ****
*/
@HotSpotIntrinsicCandidate
public native void putInt(Object o, long offset, int x);
/**
! * Returns true if the given class is a regular value type.
*/
! public boolean isValueType(Class<?> c) {
! return c.isValue() && c == c.asValueType();
}
private static final int JVM_ACC_FLATTENED = 0x00008000; // HotSpot-specific bit
/**
--- 176,189 ----
*/
@HotSpotIntrinsicCandidate
public native void putInt(Object o, long offset, int x);
/**
! * Returns true if the given class is a regular inline type.
*/
! public boolean isInlineType(Class<?> c) {
! return c.isInlineClass() && c == c.asPrimaryType();
}
private static final int JVM_ACC_FLATTENED = 0x00008000; // HotSpot-specific bit
/**
*** 232,242 ****
* @param o Java heap object in which the variable resides, if any, else
* null
* @param offset indication of where the variable resides in a Java heap
* object, if any, else a memory address locating the variable
* statically
! * @param vc value class
* @param <V> the type of a value
* @return the value fetched from the indicated Java variable
* @throws RuntimeException No defined exceptions are thrown, not even
* {@link NullPointerException}
*/
--- 232,242 ----
* @param o Java heap object in which the variable resides, if any, else
* null
* @param offset indication of where the variable resides in a Java heap
* object, if any, else a memory address locating the variable
* statically
! * @param vc inline class
* @param <V> the type of a value
* @return the value fetched from the indicated Java variable
* @throws RuntimeException No defined exceptions are thrown, not even
* {@link NullPointerException}
*/
*** 252,262 ****
* @param o Java heap object in which the variable resides, if any, else
* null
* @param offset indication of where the variable resides in a Java heap
* object, if any, else a memory address locating the variable
* statically
! * @param vc value class
* @param v the value to store into the indicated Java variable
* @param <V> the type of a value
* @throws RuntimeException No defined exceptions are thrown, not even
* {@link NullPointerException}
*/
--- 252,262 ----
* @param o Java heap object in which the variable resides, if any, else
* null
* @param offset indication of where the variable resides in a Java heap
* object, if any, else a memory address locating the variable
* statically
! * @param vc inline class
* @param v the value to store into the indicated Java variable
* @param <V> the type of a value
* @throws RuntimeException No defined exceptions are thrown, not even
* {@link NullPointerException}
*/
*** 264,299 ****
public native <V> void putValue(Object o, long offset, Class<?> vc, V v);
/**
* Fetches a reference value of type {@code vc} from a given Java variable.
* This method can return a reference to a value or a null reference
! * for a boxed value type.
*
! * @param vc value class
*/
public Object getReference(Object o, long offset, Class<?> vc) {
Object ref = getReference(o, offset);
! if (ref == null && isValueType(vc)) {
! // If the type of the returned reference is a normal value type
// return an uninitialized default value if null
ref = uninitializedDefaultValue(vc);
}
return ref;
}
public Object getReferenceVolatile(Object o, long offset, Class<?> vc) {
Object ref = getReferenceVolatile(o, offset);
! if (ref == null && isValueType(vc)) {
! // If the type of the returned reference is a normal value type
// return an uninitialized default value if null
ref = uninitializedDefaultValue(vc);
}
return ref;
}
/**
! * Returns an uninitialized default value of the given value class.
*/
public native <V> V uninitializedDefaultValue(Class<?> vc);
/**
* Returns an object instance with a private buffered value whose layout
--- 264,299 ----
public native <V> void putValue(Object o, long offset, Class<?> vc, V v);
/**
* Fetches a reference value of type {@code vc} from a given Java variable.
* This method can return a reference to a value or a null reference
! * for a nullable-projection of an inline type.
*
! * @param vc inline class
*/
public Object getReference(Object o, long offset, Class<?> vc) {
Object ref = getReference(o, offset);
! if (ref == null && isInlineType(vc)) {
! // If the type of the returned reference is a regular inline type
// return an uninitialized default value if null
ref = uninitializedDefaultValue(vc);
}
return ref;
}
public Object getReferenceVolatile(Object o, long offset, Class<?> vc) {
Object ref = getReferenceVolatile(o, offset);
! if (ref == null && isInlineType(vc)) {
! // If the type of the returned reference is a regular inline type
// return an uninitialized default value if null
ref = uninitializedDefaultValue(vc);
}
return ref;
}
/**
! * Returns an uninitialized default value of the given inline class.
*/
public native <V> V uninitializedDefaultValue(Class<?> vc);
/**
* Returns an object instance with a private buffered value whose layout
*** 314,328 ****
*/
@HotSpotIntrinsicCandidate
public native <V> V finishPrivateBuffer(V value);
/**
! * Returns the header size of the given value class
*
! * @param vc Value class
* @param <V> value clas
! * @return the header size of the value class
*/
public native <V> long valueHeaderSize(Class<V> vc);
/** @see #getInt(Object, long) */
@HotSpotIntrinsicCandidate
--- 314,328 ----
*/
@HotSpotIntrinsicCandidate
public native <V> V finishPrivateBuffer(V value);
/**
! * Returns the header size of the given inline class
*
! * @param vc inline class
* @param <V> value clas
! * @return the header size of the inline class
*/
public native <V> long valueHeaderSize(Class<V> vc);
/** @see #getInt(Object, long) */
@HotSpotIntrinsicCandidate
*** 2170,2181 ****
@HotSpotIntrinsicCandidate
public native Object getReferenceVolatile(Object o, long offset);
/**
* Global lock for atomic and volatile strength access to any value of
! * a value type. This is a temporary workaround until better localized
! * atomic access mechanisms are supported for value types.
*/
private static final Object valueLock = new Object();
public final <V> Object getValueVolatile(Object base, long offset, Class<?> valueType) {
synchronized (valueLock) {
--- 2170,2181 ----
@HotSpotIntrinsicCandidate
public native Object getReferenceVolatile(Object o, long offset);
/**
* Global lock for atomic and volatile strength access to any value of
! * an inline type. This is a temporary workaround until better localized
! * atomic access mechanisms are supported for inline types.
*/
private static final Object valueLock = new Object();
public final <V> Object getValueVolatile(Object base, long offset, Class<?> valueType) {
synchronized (valueLock) {
< prev index next >