< prev index next >
src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Print this page
*** 177,187 ****
/**
* Fetches a reference value from a given Java variable.
* @see #getInt(Object, long)
*/
@HotSpotIntrinsicCandidate
! public native Object getObject(Object o, long offset);
/**
* Stores a reference value into a given Java variable.
* <p>
* Unless the reference {@code x} being stored is either null
--- 177,187 ----
/**
* Fetches a reference value from a given Java variable.
* @see #getInt(Object, long)
*/
@HotSpotIntrinsicCandidate
! public native Object getReference(Object o, long offset);
/**
* Stores a reference value into a given Java variable.
* <p>
* Unless the reference {@code x} being stored is either null
*** 190,200 ****
* other store barriers for that object (if the VM requires them)
* are updated.
* @see #putInt(Object, long, int)
*/
@HotSpotIntrinsicCandidate
! public native void putObject(Object o, long offset, Object x);
/** @see #getInt(Object, long) */
@HotSpotIntrinsicCandidate
public native boolean getBoolean(Object o, long offset);
--- 190,200 ----
* other store barriers for that object (if the VM requires them)
* are updated.
* @see #putInt(Object, long, int)
*/
@HotSpotIntrinsicCandidate
! public native void putReference(Object o, long offset, Object x);
/** @see #getInt(Object, long) */
@HotSpotIntrinsicCandidate
public native boolean getBoolean(Object o, long offset);
*** 1295,1353 ****
* and write. Corresponds to C11 atomic_compare_exchange_strong.
*
* @return {@code true} if successful
*/
@HotSpotIntrinsicCandidate
! public final native boolean compareAndSetObject(Object o, long offset,
Object expected,
Object x);
@HotSpotIntrinsicCandidate
! public final native Object compareAndExchangeObject(Object o, long offset,
Object expected,
Object x);
@HotSpotIntrinsicCandidate
! public final Object compareAndExchangeObjectAcquire(Object o, long offset,
Object expected,
Object x) {
! return compareAndExchangeObject(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final Object compareAndExchangeObjectRelease(Object o, long offset,
Object expected,
Object x) {
! return compareAndExchangeObject(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetObjectPlain(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetObject(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetObjectAcquire(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetObject(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetObjectRelease(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetObject(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetObject(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetObject(o, offset, expected, x);
}
/**
* Atomically updates Java variable to {@code x} if it is currently
* holding {@code expected}.
--- 1295,1353 ----
* and write. Corresponds to C11 atomic_compare_exchange_strong.
*
* @return {@code true} if successful
*/
@HotSpotIntrinsicCandidate
! public final native boolean compareAndSetReference(Object o, long offset,
Object expected,
Object x);
@HotSpotIntrinsicCandidate
! public final native Object compareAndExchangeReference(Object o, long offset,
Object expected,
Object x);
@HotSpotIntrinsicCandidate
! public final Object compareAndExchangeReferenceAcquire(Object o, long offset,
Object expected,
Object x) {
! return compareAndExchangeReference(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final Object compareAndExchangeReferenceRelease(Object o, long offset,
Object expected,
Object x) {
! return compareAndExchangeReference(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetReferencePlain(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetReference(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetReferenceAcquire(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetReference(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetReferenceRelease(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetReference(o, offset, expected, x);
}
@HotSpotIntrinsicCandidate
! public final boolean weakCompareAndSetReference(Object o, long offset,
Object expected,
Object x) {
! return compareAndSetReference(o, offset, expected, x);
}
/**
* Atomically updates Java variable to {@code x} if it is currently
* holding {@code expected}.
*** 1956,1976 ****
return compareAndSetLong(o, offset, expected, x);
}
/**
* Fetches a reference value from a given Java variable, with volatile
! * load semantics. Otherwise identical to {@link #getObject(Object, long)}
*/
@HotSpotIntrinsicCandidate
! public native Object getObjectVolatile(Object o, long offset);
/**
* Stores a reference value into a given Java variable, with
! * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
*/
@HotSpotIntrinsicCandidate
! public native void putObjectVolatile(Object o, long offset, Object x);
/** Volatile version of {@link #getInt(Object, long)} */
@HotSpotIntrinsicCandidate
public native int getIntVolatile(Object o, long offset);
--- 1956,1976 ----
return compareAndSetLong(o, offset, expected, x);
}
/**
* Fetches a reference value from a given Java variable, with volatile
! * load semantics. Otherwise identical to {@link #getReference(Object, long)}
*/
@HotSpotIntrinsicCandidate
! public native Object getReferenceVolatile(Object o, long offset);
/**
* Stores a reference value into a given Java variable, with
! * volatile store semantics. Otherwise identical to {@link #putReference(Object, long, Object)}
*/
@HotSpotIntrinsicCandidate
! public native void putReferenceVolatile(Object o, long offset, Object x);
/** Volatile version of {@link #getInt(Object, long)} */
@HotSpotIntrinsicCandidate
public native int getIntVolatile(Object o, long offset);
*** 2034,2047 ****
@HotSpotIntrinsicCandidate
public native void putDoubleVolatile(Object o, long offset, double x);
! /** Acquire version of {@link #getObjectVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
! public final Object getObjectAcquire(Object o, long offset) {
! return getObjectVolatile(o, offset);
}
/** Acquire version of {@link #getBooleanVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
public final boolean getBooleanAcquire(Object o, long offset) {
--- 2034,2047 ----
@HotSpotIntrinsicCandidate
public native void putDoubleVolatile(Object o, long offset, double x);
! /** Acquire version of {@link #getReferenceVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
! public final Object getReferenceAcquire(Object o, long offset) {
! return getReferenceVolatile(o, offset);
}
/** Acquire version of {@link #getBooleanVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
public final boolean getBooleanAcquire(Object o, long offset) {
*** 2089,2111 ****
public final double getDoubleAcquire(Object o, long offset) {
return getDoubleVolatile(o, offset);
}
/*
! * Versions of {@link #putObjectVolatile(Object, long, Object)}
* that do not guarantee immediate visibility of the store to
* other threads. This method is generally only useful if the
* underlying field is a Java volatile (or if an array cell, one
* that is otherwise only accessed using volatile accesses).
*
* Corresponds to C11 atomic_store_explicit(..., memory_order_release).
*/
! /** Release version of {@link #putObjectVolatile(Object, long, Object)} */
@HotSpotIntrinsicCandidate
! public final void putObjectRelease(Object o, long offset, Object x) {
! putObjectVolatile(o, offset, x);
}
/** Release version of {@link #putBooleanVolatile(Object, long, boolean)} */
@HotSpotIntrinsicCandidate
public final void putBooleanRelease(Object o, long offset, boolean x) {
--- 2089,2111 ----
public final double getDoubleAcquire(Object o, long offset) {
return getDoubleVolatile(o, offset);
}
/*
! * Versions of {@link #putReferenceVolatile(Object, long, Object)}
* that do not guarantee immediate visibility of the store to
* other threads. This method is generally only useful if the
* underlying field is a Java volatile (or if an array cell, one
* that is otherwise only accessed using volatile accesses).
*
* Corresponds to C11 atomic_store_explicit(..., memory_order_release).
*/
! /** Release version of {@link #putReferenceVolatile(Object, long, Object)} */
@HotSpotIntrinsicCandidate
! public final void putReferenceRelease(Object o, long offset, Object x) {
! putReferenceVolatile(o, offset, x);
}
/** Release version of {@link #putBooleanVolatile(Object, long, boolean)} */
@HotSpotIntrinsicCandidate
public final void putBooleanRelease(Object o, long offset, boolean x) {
*** 2154,2167 ****
putDoubleVolatile(o, offset, x);
}
// ------------------------------ Opaque --------------------------------------
! /** Opaque version of {@link #getObjectVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
! public final Object getObjectOpaque(Object o, long offset) {
! return getObjectVolatile(o, offset);
}
/** Opaque version of {@link #getBooleanVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
public final boolean getBooleanOpaque(Object o, long offset) {
--- 2154,2167 ----
putDoubleVolatile(o, offset, x);
}
// ------------------------------ Opaque --------------------------------------
! /** Opaque version of {@link #getReferenceVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
! public final Object getReferenceOpaque(Object o, long offset) {
! return getReferenceVolatile(o, offset);
}
/** Opaque version of {@link #getBooleanVolatile(Object, long)} */
@HotSpotIntrinsicCandidate
public final boolean getBooleanOpaque(Object o, long offset) {
*** 2208,2221 ****
@HotSpotIntrinsicCandidate
public final double getDoubleOpaque(Object o, long offset) {
return getDoubleVolatile(o, offset);
}
! /** Opaque version of {@link #putObjectVolatile(Object, long, Object)} */
@HotSpotIntrinsicCandidate
! public final void putObjectOpaque(Object o, long offset, Object x) {
! putObjectVolatile(o, offset, x);
}
/** Opaque version of {@link #putBooleanVolatile(Object, long, boolean)} */
@HotSpotIntrinsicCandidate
public final void putBooleanOpaque(Object o, long offset, boolean x) {
--- 2208,2221 ----
@HotSpotIntrinsicCandidate
public final double getDoubleOpaque(Object o, long offset) {
return getDoubleVolatile(o, offset);
}
! /** Opaque version of {@link #putReferenceVolatile(Object, long, Object)} */
@HotSpotIntrinsicCandidate
! public final void putReferenceOpaque(Object o, long offset, Object x) {
! putReferenceVolatile(o, offset, x);
}
/** Opaque version of {@link #putBooleanVolatile(Object, long, boolean)} */
@HotSpotIntrinsicCandidate
public final void putBooleanOpaque(Object o, long offset, boolean x) {
*** 2640,2672 ****
* @param newValue new value
* @return the previous value
* @since 1.8
*/
@HotSpotIntrinsicCandidate
! public final Object getAndSetObject(Object o, long offset, Object newValue) {
Object v;
do {
! v = getObjectVolatile(o, offset);
! } while (!weakCompareAndSetObject(o, offset, v, newValue));
return v;
}
@ForceInline
! public final Object getAndSetObjectRelease(Object o, long offset, Object newValue) {
Object v;
do {
! v = getObject(o, offset);
! } while (!weakCompareAndSetObjectRelease(o, offset, v, newValue));
return v;
}
@ForceInline
! public final Object getAndSetObjectAcquire(Object o, long offset, Object newValue) {
Object v;
do {
! v = getObjectAcquire(o, offset);
! } while (!weakCompareAndSetObjectAcquire(o, offset, v, newValue));
return v;
}
@HotSpotIntrinsicCandidate
public final byte getAndSetByte(Object o, long offset, byte newValue) {
--- 2640,2672 ----
* @param newValue new value
* @return the previous value
* @since 1.8
*/
@HotSpotIntrinsicCandidate
! public final Object getAndSetReference(Object o, long offset, Object newValue) {
Object v;
do {
! v = getReferenceVolatile(o, offset);
! } while (!weakCompareAndSetReference(o, offset, v, newValue));
return v;
}
@ForceInline
! public final Object getAndSetReferenceRelease(Object o, long offset, Object newValue) {
Object v;
do {
! v = getReference(o, offset);
! } while (!weakCompareAndSetReferenceRelease(o, offset, v, newValue));
return v;
}
@ForceInline
! public final Object getAndSetReferenceAcquire(Object o, long offset, Object newValue) {
Object v;
do {
! v = getReferenceAcquire(o, offset);
! } while (!weakCompareAndSetReferenceAcquire(o, offset, v, newValue));
return v;
}
@HotSpotIntrinsicCandidate
public final byte getAndSetByte(Object o, long offset, byte newValue) {
< prev index next >