8148146: Integrate new internal Unsafe entry points, and basic intrinsic support for VarHandles
Reviewed-by: psandoz, kvn, jrose, adinn, simonis, coleenp
This commit is contained in:
parent
ef5eb42e40
commit
7386fd0385
@ -782,6 +782,46 @@ public final class Unsafe {
|
||||
Object expected,
|
||||
Object x);
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final native Object compareAndExchangeObjectVolatile(Object o, long offset,
|
||||
Object expected,
|
||||
Object x);
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final Object compareAndExchangeObjectAcquire(Object o, long offset,
|
||||
Object expected,
|
||||
Object x) {
|
||||
return compareAndExchangeObjectVolatile(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final Object compareAndExchangeObjectRelease(Object o, long offset,
|
||||
Object expected,
|
||||
Object x) {
|
||||
return compareAndExchangeObjectVolatile(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapObject(Object o, long offset,
|
||||
Object expected,
|
||||
Object x) {
|
||||
return compareAndSwapObject(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapObjectAcquire(Object o, long offset,
|
||||
Object expected,
|
||||
Object x) {
|
||||
return compareAndSwapObject(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapObjectRelease(Object o, long offset,
|
||||
Object expected,
|
||||
Object x) {
|
||||
return compareAndSwapObject(o, offset, expected, x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates Java variable to {@code x} if it is currently
|
||||
* holding {@code expected}.
|
||||
@ -796,6 +836,46 @@ public final class Unsafe {
|
||||
int expected,
|
||||
int x);
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final native int compareAndExchangeIntVolatile(Object o, long offset,
|
||||
int expected,
|
||||
int x);
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final int compareAndExchangeIntAcquire(Object o, long offset,
|
||||
int expected,
|
||||
int x) {
|
||||
return compareAndExchangeIntVolatile(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final int compareAndExchangeIntRelease(Object o, long offset,
|
||||
int expected,
|
||||
int x) {
|
||||
return compareAndExchangeIntVolatile(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapInt(Object o, long offset,
|
||||
int expected,
|
||||
int x) {
|
||||
return compareAndSwapInt(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapIntAcquire(Object o, long offset,
|
||||
int expected,
|
||||
int x) {
|
||||
return compareAndSwapInt(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapIntRelease(Object o, long offset,
|
||||
int expected,
|
||||
int x) {
|
||||
return compareAndSwapInt(o, offset, expected, x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically updates Java variable to {@code x} if it is currently
|
||||
* holding {@code expected}.
|
||||
@ -810,6 +890,46 @@ public final class Unsafe {
|
||||
long expected,
|
||||
long x);
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final native long compareAndExchangeLongVolatile(Object o, long offset,
|
||||
long expected,
|
||||
long x);
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final long compareAndExchangeLongAcquire(Object o, long offset,
|
||||
long expected,
|
||||
long x) {
|
||||
return compareAndExchangeLongVolatile(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final long compareAndExchangeLongRelease(Object o, long offset,
|
||||
long expected,
|
||||
long x) {
|
||||
return compareAndExchangeLongVolatile(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapLong(Object o, long offset,
|
||||
long expected,
|
||||
long x) {
|
||||
return compareAndSwapLong(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapLongAcquire(Object o, long offset,
|
||||
long expected,
|
||||
long x) {
|
||||
return compareAndSwapLong(o, offset, expected, x);
|
||||
}
|
||||
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final boolean weakCompareAndSwapLongRelease(Object o, long offset,
|
||||
long expected,
|
||||
long x) {
|
||||
return compareAndSwapLong(o, offset, expected, x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a reference value from a given Java variable, with volatile
|
||||
* load semantics. Otherwise identical to {@link #getObject(Object, long)}
|
||||
@ -908,6 +1028,224 @@ public final class Unsafe {
|
||||
@HotSpotIntrinsicCandidate
|
||||
public native void putOrderedLong(Object o, long offset, long 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) {
|
||||
return getBooleanVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getByteVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final byte getByteAcquire(Object o, long offset) {
|
||||
return getByteVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getShortVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final short getShortAcquire(Object o, long offset) {
|
||||
return getShortVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getCharVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final char getCharAcquire(Object o, long offset) {
|
||||
return getCharVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getIntVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final int getIntAcquire(Object o, long offset) {
|
||||
return getIntVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getFloatVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final float getFloatAcquire(Object o, long offset) {
|
||||
return getFloatVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getLongVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final long getLongAcquire(Object o, long offset) {
|
||||
return getLongVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Acquire version of {@link #getDoubleVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final double getDoubleAcquire(Object o, long offset) {
|
||||
return getDoubleVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** 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) {
|
||||
putBooleanVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putByteVolatile(Object, long, byte)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putByteRelease(Object o, long offset, byte x) {
|
||||
putByteVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putShortVolatile(Object, long, short)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putShortRelease(Object o, long offset, short x) {
|
||||
putShortVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putCharVolatile(Object, long, char)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putCharRelease(Object o, long offset, char x) {
|
||||
putCharVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putIntVolatile(Object, long, int)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putIntRelease(Object o, long offset, int x) {
|
||||
putIntVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putFloatVolatile(Object, long, float)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putFloatRelease(Object o, long offset, float x) {
|
||||
putFloatVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putLongVolatile(Object, long, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putLongRelease(Object o, long offset, long x) {
|
||||
putLongVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Release version of {@link #putDoubleVolatile(Object, long, double)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putDoubleRelease(Object o, long offset, double x) {
|
||||
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) {
|
||||
return getBooleanVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getByteVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final byte getByteOpaque(Object o, long offset) {
|
||||
return getByteVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getShortVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final short getShortOpaque(Object o, long offset) {
|
||||
return getShortVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getCharVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final char getCharOpaque(Object o, long offset) {
|
||||
return getCharVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getIntVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final int getIntOpaque(Object o, long offset) {
|
||||
return getIntVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getFloatVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final float getFloatOpaque(Object o, long offset) {
|
||||
return getFloatVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getLongVolatile(Object, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final long getLongOpaque(Object o, long offset) {
|
||||
return getLongVolatile(o, offset);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #getDoubleVolatile(Object, long)} */
|
||||
@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) {
|
||||
putBooleanVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putByteVolatile(Object, long, byte)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putByteOpaque(Object o, long offset, byte x) {
|
||||
putByteVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putShortVolatile(Object, long, short)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putShortOpaque(Object o, long offset, short x) {
|
||||
putShortVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putCharVolatile(Object, long, char)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putCharOpaque(Object o, long offset, char x) {
|
||||
putCharVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putIntVolatile(Object, long, int)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putIntOpaque(Object o, long offset, int x) {
|
||||
putIntVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putFloatVolatile(Object, long, float)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putFloatOpaque(Object o, long offset, float x) {
|
||||
putFloatVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putLongVolatile(Object, long, long)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putLongOpaque(Object o, long offset, long x) {
|
||||
putLongVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/** Opaque version of {@link #putDoubleVolatile(Object, long, double)} */
|
||||
@HotSpotIntrinsicCandidate
|
||||
public final void putDoubleOpaque(Object o, long offset, double x) {
|
||||
putDoubleVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks the given thread blocked on {@code park}, or, if it is
|
||||
* not blocked, causes the subsequent call to {@code park} not to
|
||||
@ -1100,6 +1438,23 @@ public final class Unsafe {
|
||||
@HotSpotIntrinsicCandidate
|
||||
public native void fullFence();
|
||||
|
||||
/**
|
||||
* Ensures that loads before the fence will not be reordered with
|
||||
* loads after the fence.
|
||||
*/
|
||||
public final void loadLoadFence() {
|
||||
loadFence();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that stores before the fence will not be reordered with
|
||||
* stores after the fence.
|
||||
*/
|
||||
public final void storeStoreFence() {
|
||||
storeFence();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Throws IllegalAccessError; for use by the VM for access control
|
||||
* error support.
|
||||
|
Loading…
x
Reference in New Issue
Block a user