- java.lang.Object
-
- cn.mcres.karlatemp.mxlib.tools.Unsafe
-
public abstract class Unsafe extends Object
A collection of methods for performing low-level, unsafe operations. Although the class and all methods are public, use of this class is limited because only trusted code can obtain instances of it. Note: It is the resposibility of the caller to make sure arguments are checked before methods of this class are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!- 从以下版本开始:
- 2.7
- 作者:
- John R. Rose
- 另请参阅:
getUnsafe()
,Unsafe
,Unsafe.getUnsafe()
,Unsafe
,Unsafe.getUnsafe()
-
-
字段概要
字段 修饰符和类型 字段 说明 static int
ADDRESS_SIZE
The value ofaddressSize()
static int
ARRAY_BOOLEAN_BASE_OFFSET
The value ofarrayBaseOffset(boolean[].class)
static int
ARRAY_BOOLEAN_INDEX_SCALE
The value ofarrayIndexScale(boolean[].class)
static int
ARRAY_BYTE_BASE_OFFSET
The value ofarrayBaseOffset(byte[].class)
static int
ARRAY_BYTE_INDEX_SCALE
The value ofarrayIndexScale(byte[].class)
static int
ARRAY_CHAR_BASE_OFFSET
The value ofarrayBaseOffset(char[].class)
static int
ARRAY_CHAR_INDEX_SCALE
The value ofarrayIndexScale(char[].class)
static int
ARRAY_DOUBLE_BASE_OFFSET
The value ofarrayBaseOffset(double[].class)
static int
ARRAY_DOUBLE_INDEX_SCALE
The value ofarrayIndexScale(double[].class)
static int
ARRAY_FLOAT_BASE_OFFSET
The value ofarrayBaseOffset(float[].class)
static int
ARRAY_FLOAT_INDEX_SCALE
The value ofarrayIndexScale(float[].class)
static int
ARRAY_INT_BASE_OFFSET
The value ofarrayBaseOffset(int[].class)
static int
ARRAY_INT_INDEX_SCALE
The value ofarrayIndexScale(int[].class)
static int
ARRAY_LONG_BASE_OFFSET
The value ofarrayBaseOffset(long[].class)
static int
ARRAY_LONG_INDEX_SCALE
The value ofarrayIndexScale(long[].class)
static int
ARRAY_OBJECT_BASE_OFFSET
The value ofarrayBaseOffset(Object[].class)
static int
ARRAY_OBJECT_INDEX_SCALE
The value ofarrayIndexScale(Object[].class)
static int
ARRAY_SHORT_BASE_OFFSET
The value ofarrayBaseOffset(short[].class)
static int
ARRAY_SHORT_INDEX_SCALE
The value ofarrayIndexScale(short[].class)
static int
INVALID_FIELD_OFFSET
This constant differs from all results that will ever be returned fromstaticFieldOffset(java.lang.reflect.Field)
,objectFieldOffset(java.lang.reflect.Field)
, orarrayBaseOffset(java.lang.Class<?>)
.
-
构造器概要
构造器 构造器 说明 Unsafe()
-
方法概要
修饰符和类型 方法 说明 static void
$finishUnsafeInit()
Call by MXLib Internal Codeabstract int
addressSize()
Reports the size in bytes of a abstract pointer, as stored viaputAddress(java.lang.Object, long, long)
.abstract <T> T
allocateInstance(@NotNull Class<T> cls)
Allocates an instance but does not run any constructor.abstract long
allocateMemory(long bytes)
Allocates a new block of abstract memory, of the given size in bytes.abstract Object
allocateUninitializedArray(@NotNull Class<?> componentType, int length)
Allocates an array of a given type, but does not do zeroing.abstract int
arrayBaseOffset(@NotNull Class<?> arrayClass)
Reports the offset of the first element in the storage allocation of a given array class.abstract int
arrayIndexScale(@NotNull Class<?> arrayClass)
Reports the scale factor for addressing elements in the storage allocation of a given array class.abstract boolean
compareAndExchangeBoolean(Object o, long offset, boolean expected, boolean x)
abstract boolean
compareAndExchangeBooleanAcquire(Object o, long offset, boolean expected, boolean x)
abstract boolean
compareAndExchangeBooleanRelease(Object o, long offset, boolean expected, boolean x)
abstract byte
compareAndExchangeByte(Object o, long offset, byte expected, byte x)
abstract byte
compareAndExchangeByteAcquire(Object o, long offset, byte expected, byte x)
abstract byte
compareAndExchangeByteRelease(Object o, long offset, byte expected, byte x)
abstract char
compareAndExchangeChar(Object o, long offset, char expected, char x)
abstract char
compareAndExchangeCharAcquire(Object o, long offset, char expected, char x)
abstract char
compareAndExchangeCharRelease(Object o, long offset, char expected, char x)
abstract double
compareAndExchangeDouble(Object o, long offset, double expected, double x)
abstract double
compareAndExchangeDoubleAcquire(Object o, long offset, double expected, double x)
abstract double
compareAndExchangeDoubleRelease(Object o, long offset, double expected, double x)
abstract float
compareAndExchangeFloat(Object o, long offset, float expected, float x)
abstract float
compareAndExchangeFloatAcquire(Object o, long offset, float expected, float x)
abstract float
compareAndExchangeFloatRelease(Object o, long offset, float expected, float x)
abstract int
compareAndExchangeInt(Object o, long offset, int expected, int x)
abstract int
compareAndExchangeIntAcquire(Object o, long offset, int expected, int x)
abstract int
compareAndExchangeIntRelease(Object o, long offset, int expected, int x)
abstract long
compareAndExchangeLong(Object o, long offset, long expected, long x)
abstract long
compareAndExchangeLongAcquire(Object o, long offset, long expected, long x)
abstract long
compareAndExchangeLongRelease(Object o, long offset, long expected, long x)
abstract Object
compareAndExchangeReference(Object o, long offset, Object expected, Object x)
abstract Object
compareAndExchangeReferenceAcquire(Object o, long offset, Object expected, Object x)
abstract Object
compareAndExchangeReferenceRelease(Object o, long offset, Object expected, Object x)
abstract short
compareAndExchangeShort(Object o, long offset, short expected, short x)
abstract short
compareAndExchangeShortAcquire(Object o, long offset, short expected, short x)
abstract short
compareAndExchangeShortRelease(Object o, long offset, short expected, short x)
abstract boolean
compareAndSetBoolean(Object o, long offset, boolean expected, boolean x)
abstract boolean
compareAndSetByte(Object o, long offset, byte expected, byte x)
abstract boolean
compareAndSetChar(Object o, long offset, char expected, char x)
abstract boolean
compareAndSetDouble(Object o, long offset, double expected, double x)
Atomically updates Java variable tox
if it is currently holdingexpected
.abstract boolean
compareAndSetFloat(Object o, long offset, float expected, float x)
Atomically updates Java variable tox
if it is currently holdingexpected
.abstract boolean
compareAndSetInt(Object o, long offset, int expected, int x)
Atomically updates Java variable tox
if it is currently holdingexpected
.abstract boolean
compareAndSetLong(Object o, long offset, long expected, long x)
Atomically updates Java variable tox
if it is currently holdingexpected
.abstract boolean
compareAndSetReference(Object o, long offset, Object expected, Object x)
Atomically updates Java variable tox
if it is currently holdingexpected
.abstract boolean
compareAndSetShort(Object o, long offset, short expected, short x)
void
copyMemory(long srcAddress, long destAddress, long bytes)
Sets all bytes in a given block of memory to a copy of another block.abstract void
copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes)
Sets all bytes in a given block of memory to a copy of another block.void
copySwapMemory(long srcAddress, long destAddress, long bytes, long elemSize)
Copies all elements from one block of memory to another block, byte swapping the elements on the fly.abstract void
copySwapMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes, long elemSize)
Copies all elements from one block of memory to another block, *unconditionally* byte swapping the elements on the fly.abstract Class<?>
defineAnonymousClass(@NotNull Class<?> hostClass, @org.jetbrains.annotations.NotNull byte[] data, Object[] cpPatches)
Defines a class but does not make it known to the class loader or system dictionary.abstract Class<?>
defineClass(String name, @org.jetbrains.annotations.NotNull byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain)
Tells the VM to define a class, without security checks.abstract Class<?>
defineClass0(String name, @org.jetbrains.annotations.NotNull byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain)
abstract void
ensureClassInitialized(@NotNull Class<?> c)
Ensures the given class has been initialized.abstract void
freeMemory(long address)
Disposes of a block of abstract memory, as obtained fromallocateMemory(long)
orreallocateMemory(long, long)
.abstract void
fullFence()
Ensures that loads and stores before the fence will not be reordered with loads and stores after the fence.long
getAddress(long address)
abstract long
getAddress(Object o, long offset)
Fetches a abstract pointer from a given memory address.abstract byte
getAndAddByte(Object o, long offset, byte delta)
abstract byte
getAndAddByteAcquire(Object o, long offset, byte delta)
abstract byte
getAndAddByteRelease(Object o, long offset, byte delta)
abstract char
getAndAddChar(Object o, long offset, char delta)
abstract char
getAndAddCharAcquire(Object o, long offset, char delta)
abstract char
getAndAddCharRelease(Object o, long offset, char delta)
abstract double
getAndAddDouble(Object o, long offset, double delta)
abstract double
getAndAddDoubleAcquire(Object o, long offset, double delta)
abstract double
getAndAddDoubleRelease(Object o, long offset, double delta)
abstract float
getAndAddFloat(Object o, long offset, float delta)
abstract float
getAndAddFloatAcquire(Object o, long offset, float delta)
abstract float
getAndAddFloatRelease(Object o, long offset, float delta)
abstract int
getAndAddInt(Object o, long offset, int delta)
Atomically adds the given value to the current value of a field or array element within the given objecto
at the givenoffset
.abstract int
getAndAddIntAcquire(Object o, long offset, int delta)
abstract int
getAndAddIntRelease(Object o, long offset, int delta)
abstract long
getAndAddLong(Object o, long offset, long delta)
Atomically adds the given value to the current value of a field or array element within the given objecto
at the givenoffset
.abstract long
getAndAddLongAcquire(Object o, long offset, long delta)
abstract long
getAndAddLongRelease(Object o, long offset, long delta)
abstract short
getAndAddShort(Object o, long offset, short delta)
abstract short
getAndAddShortAcquire(Object o, long offset, short delta)
abstract short
getAndAddShortRelease(Object o, long offset, short delta)
abstract boolean
getAndBitwiseAndBoolean(Object o, long offset, boolean mask)
abstract boolean
getAndBitwiseAndBooleanAcquire(Object o, long offset, boolean mask)
abstract boolean
getAndBitwiseAndBooleanRelease(Object o, long offset, boolean mask)
abstract byte
getAndBitwiseAndByte(Object o, long offset, byte mask)
abstract byte
getAndBitwiseAndByteAcquire(Object o, long offset, byte mask)
abstract byte
getAndBitwiseAndByteRelease(Object o, long offset, byte mask)
abstract char
getAndBitwiseAndChar(Object o, long offset, char mask)
abstract char
getAndBitwiseAndCharAcquire(Object o, long offset, char mask)
abstract char
getAndBitwiseAndCharRelease(Object o, long offset, char mask)
abstract int
getAndBitwiseAndInt(Object o, long offset, int mask)
Atomically replaces the current value of a field or array element within the given object with the result of bitwise AND between the current value and mask.abstract int
getAndBitwiseAndIntAcquire(Object o, long offset, int mask)
abstract int
getAndBitwiseAndIntRelease(Object o, long offset, int mask)
abstract long
getAndBitwiseAndLong(Object o, long offset, long mask)
abstract long
getAndBitwiseAndLongAcquire(Object o, long offset, long mask)
abstract long
getAndBitwiseAndLongRelease(Object o, long offset, long mask)
abstract short
getAndBitwiseAndShort(Object o, long offset, short mask)
abstract short
getAndBitwiseAndShortAcquire(Object o, long offset, short mask)
abstract short
getAndBitwiseAndShortRelease(Object o, long offset, short mask)
abstract boolean
getAndBitwiseOrBoolean(Object o, long offset, boolean mask)
abstract boolean
getAndBitwiseOrBooleanAcquire(Object o, long offset, boolean mask)
abstract boolean
getAndBitwiseOrBooleanRelease(Object o, long offset, boolean mask)
abstract byte
getAndBitwiseOrByte(Object o, long offset, byte mask)
abstract byte
getAndBitwiseOrByteAcquire(Object o, long offset, byte mask)
abstract byte
getAndBitwiseOrByteRelease(Object o, long offset, byte mask)
abstract char
getAndBitwiseOrChar(Object o, long offset, char mask)
abstract char
getAndBitwiseOrCharAcquire(Object o, long offset, char mask)
abstract char
getAndBitwiseOrCharRelease(Object o, long offset, char mask)
abstract int
getAndBitwiseOrInt(Object o, long offset, int mask)
abstract int
getAndBitwiseOrIntAcquire(Object o, long offset, int mask)
abstract int
getAndBitwiseOrIntRelease(Object o, long offset, int mask)
abstract long
getAndBitwiseOrLong(Object o, long offset, long mask)
abstract long
getAndBitwiseOrLongAcquire(Object o, long offset, long mask)
abstract long
getAndBitwiseOrLongRelease(Object o, long offset, long mask)
abstract short
getAndBitwiseOrShort(Object o, long offset, short mask)
abstract short
getAndBitwiseOrShortAcquire(Object o, long offset, short mask)
abstract short
getAndBitwiseOrShortRelease(Object o, long offset, short mask)
abstract boolean
getAndBitwiseXorBoolean(Object o, long offset, boolean mask)
abstract boolean
getAndBitwiseXorBooleanAcquire(Object o, long offset, boolean mask)
abstract boolean
getAndBitwiseXorBooleanRelease(Object o, long offset, boolean mask)
abstract byte
getAndBitwiseXorByte(Object o, long offset, byte mask)
abstract byte
getAndBitwiseXorByteAcquire(Object o, long offset, byte mask)
abstract byte
getAndBitwiseXorByteRelease(Object o, long offset, byte mask)
abstract char
getAndBitwiseXorChar(Object o, long offset, char mask)
abstract char
getAndBitwiseXorCharAcquire(Object o, long offset, char mask)
abstract char
getAndBitwiseXorCharRelease(Object o, long offset, char mask)
abstract int
getAndBitwiseXorInt(Object o, long offset, int mask)
abstract int
getAndBitwiseXorIntAcquire(Object o, long offset, int mask)
abstract int
getAndBitwiseXorIntRelease(Object o, long offset, int mask)
abstract long
getAndBitwiseXorLong(Object o, long offset, long mask)
abstract long
getAndBitwiseXorLongAcquire(Object o, long offset, long mask)
abstract long
getAndBitwiseXorLongRelease(Object o, long offset, long mask)
abstract short
getAndBitwiseXorShort(Object o, long offset, short mask)
abstract short
getAndBitwiseXorShortAcquire(Object o, long offset, short mask)
abstract short
getAndBitwiseXorShortRelease(Object o, long offset, short mask)
abstract boolean
getAndSetBoolean(Object o, long offset, boolean newValue)
abstract boolean
getAndSetBooleanAcquire(Object o, long offset, boolean newValue)
abstract boolean
getAndSetBooleanRelease(Object o, long offset, boolean newValue)
abstract byte
getAndSetByte(Object o, long offset, byte newValue)
abstract byte
getAndSetByteAcquire(Object o, long offset, byte newValue)
abstract byte
getAndSetByteRelease(Object o, long offset, byte newValue)
abstract char
getAndSetChar(Object o, long offset, char newValue)
abstract char
getAndSetCharAcquire(Object o, long offset, char newValue)
abstract char
getAndSetCharRelease(Object o, long offset, char newValue)
abstract double
getAndSetDouble(Object o, long offset, double newValue)
abstract double
getAndSetDoubleAcquire(Object o, long offset, double newValue)
abstract double
getAndSetDoubleRelease(Object o, long offset, double newValue)
abstract float
getAndSetFloat(Object o, long offset, float newValue)
abstract float
getAndSetFloatAcquire(Object o, long offset, float newValue)
abstract float
getAndSetFloatRelease(Object o, long offset, float newValue)
abstract int
getAndSetInt(Object o, long offset, int newValue)
Atomically exchanges the given value with the current value of a field or array element within the given objecto
at the givenoffset
.abstract int
getAndSetIntAcquire(Object o, long offset, int newValue)
abstract int
getAndSetIntRelease(Object o, long offset, int newValue)
abstract long
getAndSetLong(Object o, long offset, long newValue)
Atomically exchanges the given value with the current value of a field or array element within the given objecto
at the givenoffset
.abstract long
getAndSetLongAcquire(Object o, long offset, long newValue)
abstract long
getAndSetLongRelease(Object o, long offset, long newValue)
abstract Object
getAndSetReference(Object o, long offset, Object newValue)
Atomically exchanges the given reference value with the current reference value of a field or array element within the given objecto
at the givenoffset
.abstract Object
getAndSetReferenceAcquire(Object o, long offset, Object newValue)
abstract Object
getAndSetReferenceRelease(Object o, long offset, Object newValue)
abstract short
getAndSetShort(Object o, long offset, short newValue)
abstract short
getAndSetShortAcquire(Object o, long offset, short newValue)
abstract short
getAndSetShortRelease(Object o, long offset, short newValue)
abstract boolean
getBoolean(Object o, long offset)
abstract boolean
getBooleanAcquire(Object o, long offset)
Acquire version ofgetBooleanVolatile(Object, long)
abstract boolean
getBooleanOpaque(Object o, long offset)
Opaque version ofgetBooleanVolatile(Object, long)
abstract boolean
getBooleanVolatile(Object o, long offset)
Volatile version ofgetBoolean(Object, long)
abstract byte
getByte(long address)
Fetches a value from a given memory address.abstract byte
getByte(Object o, long offset)
abstract byte
getByteAcquire(Object o, long offset)
Acquire version ofgetByteVolatile(Object, long)
abstract byte
getByteOpaque(Object o, long offset)
Opaque version ofgetByteVolatile(Object, long)
abstract byte
getByteVolatile(Object o, long offset)
Volatile version ofgetByte(Object, long)
char
getChar(long address)
abstract char
getChar(Object o, long offset)
abstract char
getCharAcquire(Object o, long offset)
Acquire version ofgetCharVolatile(Object, long)
abstract char
getCharOpaque(Object o, long offset)
Opaque version ofgetCharVolatile(Object, long)
abstract char
getCharUnaligned(Object o, long offset)
abstract char
getCharUnaligned(Object o, long offset, boolean bigEndian)
abstract char
getCharVolatile(Object o, long offset)
Volatile version ofgetChar(Object, long)
double
getDouble(long address)
abstract double
getDouble(Object o, long offset)
abstract double
getDoubleAcquire(Object o, long offset)
Acquire version ofgetDoubleVolatile(Object, long)
abstract double
getDoubleOpaque(Object o, long offset)
Opaque version ofgetDoubleVolatile(Object, long)
abstract double
getDoubleVolatile(Object o, long offset)
Volatile version ofgetDouble(Object, long)
float
getFloat(long address)
abstract float
getFloat(Object o, long offset)
abstract float
getFloatAcquire(Object o, long offset)
Acquire version ofgetFloatVolatile(Object, long)
abstract float
getFloatOpaque(Object o, long offset)
Opaque version ofgetFloatVolatile(Object, long)
abstract float
getFloatVolatile(Object o, long offset)
Volatile version ofgetFloat(Object, long)
int
getInt(long address)
abstract int
getInt(Object o, long offset)
Fetches a value from a given Java variable.abstract int
getIntAcquire(Object o, long offset)
Acquire version ofgetIntVolatile(Object, long)
abstract int
getIntOpaque(Object o, long offset)
Opaque version ofgetIntVolatile(Object, long)
abstract int
getIntUnaligned(Object o, long offset)
abstract int
getIntUnaligned(Object o, long offset, boolean bigEndian)
abstract int
getIntVolatile(Object o, long offset)
Volatile version ofgetInt(Object, long)
abstract int
getLoadAverage(double[] loadavg, int nelems)
Gets the load average in the system run queue assigned to the available processors averaged over various periods of time.long
getLong(long address)
abstract long
getLong(Object o, long offset)
abstract long
getLongAcquire(Object o, long offset)
Acquire version ofgetLongVolatile(Object, long)
abstract long
getLongOpaque(Object o, long offset)
Opaque version ofgetLongVolatile(Object, long)
abstract long
getLongUnaligned(Object o, long offset)
Fetches a value at some byte offset into a given Java object.abstract long
getLongUnaligned(Object o, long offset, boolean bigEndian)
AsgetLongUnaligned(Object, long)
but with an additional argument which specifies the endianness of the value as stored in memory.abstract long
getLongVolatile(Object o, long offset)
Volatile version ofgetLong(Object, long)
abstract Object
getReference(Object o, long offset)
Fetches a reference value from a given Java variable.abstract Object
getReferenceAcquire(Object o, long offset)
Acquire version ofgetReferenceVolatile(Object, long)
abstract Object
getReferenceOpaque(Object o, long offset)
Opaque version ofgetReferenceVolatile(Object, long)
abstract Object
getReferenceVolatile(Object o, long offset)
Fetches a reference value from a given Java variable, with volatile load semantics.short
getShort(long address)
abstract short
getShort(Object o, long offset)
abstract short
getShortAcquire(Object o, long offset)
Acquire version ofgetShortVolatile(Object, long)
abstract short
getShortOpaque(Object o, long offset)
Opaque version ofgetShortVolatile(Object, long)
abstract short
getShortUnaligned(Object o, long offset)
abstract short
getShortUnaligned(Object o, long offset, boolean bigEndian)
abstract short
getShortVolatile(Object o, long offset)
Volatile version ofgetShort(Object, long)
abstract Object
getUncompressedObject(long address)
Fetches an uncompressed reference value from a given abstract variable ignoring the VM's compressed references mode.static Unsafe
getUnsafe()
Provides the caller with the capability of performing unsafe operations.abstract void
invokeCleaner(ByteBuffer directBuffer)
Invokes the given direct byte buffer's cleaner, if any.abstract boolean
isBigEndian()
abstract void
loadFence()
Ensures that loads before the fence will not be reordered with loads and stores after the fence; a "LoadLoad plus LoadStore barrier".abstract void
loadLoadFence()
Ensures that loads before the fence will not be reordered with loads after the fence.abstract long
objectFieldOffset(@NotNull Field f)
Reports the location of a given field in the storage allocation of its class.abstract long
objectFieldOffset(Class<?> c, String name)
Reports the location of the field with a given name in the storage allocation of its class.abstract int
pageSize()
Reports the size in bytes of a abstract memory page (whatever that is).abstract void
park(boolean isAbsolute, long time)
Blocks current thread, returning when a balancingunpark
occurs, or a balancingunpark
has already occurred, or the thread is interrupted, or, if not absolute and time is not zero, the given time nanoseconds have elapsed, or if absolute, the given deadline in milliseconds since Epoch has passed, or spuriously (i.e., returning for no "reason").void
putAddress(long address, long x)
abstract void
putAddress(Object o, long offset, long x)
Stores a abstract pointer into a given memory address.abstract void
putBoolean(Object o, long offset, boolean x)
abstract void
putBooleanOpaque(Object o, long offset, boolean x)
Opaque version ofputBooleanVolatile(Object, long, boolean)
abstract void
putBooleanRelease(Object o, long offset, boolean x)
Release version ofputBooleanVolatile(Object, long, boolean)
abstract void
putBooleanVolatile(Object o, long offset, boolean x)
Volatile version ofputBoolean(Object, long, boolean)
void
putByte(long address, byte x)
Stores a value into a given memory address.abstract void
putByte(Object o, long offset, byte x)
abstract void
putByteOpaque(Object o, long offset, byte x)
Opaque version ofputByteVolatile(Object, long, byte)
abstract void
putByteRelease(Object o, long offset, byte x)
Release version ofputByteVolatile(Object, long, byte)
abstract void
putByteVolatile(Object o, long offset, byte x)
Volatile version ofputByte(Object, long, byte)
void
putChar(long address, char x)
abstract void
putChar(Object o, long offset, char x)
abstract void
putCharOpaque(Object o, long offset, char x)
Opaque version ofputCharVolatile(Object, long, char)
abstract void
putCharRelease(Object o, long offset, char x)
Release version ofputCharVolatile(Object, long, char)
abstract void
putCharUnaligned(Object o, long offset, char x)
abstract void
putCharUnaligned(Object o, long offset, char x, boolean bigEndian)
abstract void
putCharVolatile(Object o, long offset, char x)
Volatile version ofputChar(Object, long, char)
void
putDouble(long address, double x)
abstract void
putDouble(Object o, long offset, double x)
abstract void
putDoubleOpaque(Object o, long offset, double x)
Opaque version ofputDoubleVolatile(Object, long, double)
abstract void
putDoubleRelease(Object o, long offset, double x)
Release version ofputDoubleVolatile(Object, long, double)
abstract void
putDoubleVolatile(Object o, long offset, double x)
Volatile version ofputDouble(Object, long, double)
void
putFloat(long address, float x)
abstract void
putFloat(Object o, long offset, float x)
abstract void
putFloatOpaque(Object o, long offset, float x)
Opaque version ofputFloatVolatile(Object, long, float)
abstract void
putFloatRelease(Object o, long offset, float x)
Release version ofputFloatVolatile(Object, long, float)
abstract void
putFloatVolatile(Object o, long offset, float x)
Volatile version ofputFloat(Object, long, float)
void
putInt(long address, int x)
abstract void
putInt(Object o, long offset, int x)
Stores a value into a given Java variable.abstract void
putIntOpaque(Object o, long offset, int x)
Opaque version ofputIntVolatile(Object, long, int)
abstract void
putIntRelease(Object o, long offset, int x)
Release version ofputIntVolatile(Object, long, int)
abstract void
putIntUnaligned(Object o, long offset, int x)
abstract void
putIntUnaligned(Object o, long offset, int x, boolean bigEndian)
abstract void
putIntVolatile(Object o, long offset, int x)
Volatile version ofputInt(Object, long, int)
void
putLong(long address, long x)
abstract void
putLong(Object o, long offset, long x)
abstract void
putLongOpaque(Object o, long offset, long x)
Opaque version ofputLongVolatile(Object, long, long)
abstract void
putLongRelease(Object o, long offset, long x)
Release version ofputLongVolatile(Object, long, long)
abstract void
putLongUnaligned(Object o, long offset, long x)
Stores a value at some byte offset into a given Java object.abstract void
putLongUnaligned(Object o, long offset, long x, boolean bigEndian)
AsputLongUnaligned(Object, long, long)
but with an additional argument which specifies the endianness of the value as stored in memory.abstract void
putLongVolatile(Object o, long offset, long x)
Volatile version ofputLong(Object, long, long)
abstract void
putReference(Object o, long offset, Object x)
Stores a reference value into a given Java variable.abstract void
putReferenceOpaque(Object o, long offset, Object x)
Opaque version ofputReferenceVolatile(Object, long, Object)
abstract void
putReferenceRelease(Object o, long offset, Object x)
Release version ofputReferenceVolatile(Object, long, Object)
abstract void
putReferenceVolatile(Object o, long offset, Object x)
Stores a reference value into a given Java variable, with volatile store semantics.void
putShort(long address, short x)
abstract void
putShort(Object o, long offset, short x)
abstract void
putShortOpaque(Object o, long offset, short x)
Opaque version ofputShortVolatile(Object, long, short)
abstract void
putShortRelease(Object o, long offset, short x)
Release version ofputShortVolatile(Object, long, short)
abstract void
putShortUnaligned(Object o, long offset, short x)
abstract void
putShortUnaligned(Object o, long offset, short x, boolean bigEndian)
abstract void
putShortVolatile(Object o, long offset, short x)
Volatile version ofputShort(Object, long, short)
abstract long
reallocateMemory(long address, long bytes)
Resizes a new block of abstract memory, to the given size in bytes.void
setMemory(long address, long bytes, byte value)
Sets all bytes in a given block of memory to a fixed value (usually zero).abstract void
setMemory(Object o, long offset, long bytes, byte value)
Sets all bytes in a given block of memory to a fixed value (usually zero).abstract boolean
shouldBeInitialized(@NotNull Class<?> c)
Detects if the given class may need to be initialized.abstract Object
staticFieldBase(@NotNull Field f)
Reports the location of a given static field, in conjunction withstaticFieldOffset(java.lang.reflect.Field)
.abstract long
staticFieldOffset(@NotNull Field f)
Reports the location of a given static field, in conjunction withstaticFieldBase(java.lang.reflect.Field)
.abstract void
storeFence()
Ensures that loads and stores before the fence will not be reordered with stores after the fence; a "StoreStore plus LoadStore barrier".abstract void
storeStoreFence()
Ensures that stores before the fence will not be reordered with stores after the fence.abstract void
throwException(Throwable ee)
Throws the exception without telling the verifier.abstract boolean
unalignedAccess()
abstract void
unpark(Object thread)
Unblocks the given thread blocked onpark
, or, if it is not blocked, causes the subsequent call topark
not to block.abstract boolean
weakCompareAndSetBoolean(Object o, long offset, boolean expected, boolean x)
abstract boolean
weakCompareAndSetBooleanAcquire(Object o, long offset, boolean expected, boolean x)
abstract boolean
weakCompareAndSetBooleanPlain(Object o, long offset, boolean expected, boolean x)
abstract boolean
weakCompareAndSetBooleanRelease(Object o, long offset, boolean expected, boolean x)
abstract boolean
weakCompareAndSetByte(Object o, long offset, byte expected, byte x)
abstract boolean
weakCompareAndSetByteAcquire(Object o, long offset, byte expected, byte x)
abstract boolean
weakCompareAndSetBytePlain(Object o, long offset, byte expected, byte x)
abstract boolean
weakCompareAndSetByteRelease(Object o, long offset, byte expected, byte x)
abstract boolean
weakCompareAndSetChar(Object o, long offset, char expected, char x)
abstract boolean
weakCompareAndSetCharAcquire(Object o, long offset, char expected, char x)
abstract boolean
weakCompareAndSetCharPlain(Object o, long offset, char expected, char x)
abstract boolean
weakCompareAndSetCharRelease(Object o, long offset, char expected, char x)
abstract boolean
weakCompareAndSetDouble(Object o, long offset, double expected, double x)
abstract boolean
weakCompareAndSetDoubleAcquire(Object o, long offset, double expected, double x)
abstract boolean
weakCompareAndSetDoublePlain(Object o, long offset, double expected, double x)
abstract boolean
weakCompareAndSetDoubleRelease(Object o, long offset, double expected, double x)
abstract boolean
weakCompareAndSetFloat(Object o, long offset, float expected, float x)
abstract boolean
weakCompareAndSetFloatAcquire(Object o, long offset, float expected, float x)
abstract boolean
weakCompareAndSetFloatPlain(Object o, long offset, float expected, float x)
abstract boolean
weakCompareAndSetFloatRelease(Object o, long offset, float expected, float x)
abstract boolean
weakCompareAndSetInt(Object o, long offset, int expected, int x)
abstract boolean
weakCompareAndSetIntAcquire(Object o, long offset, int expected, int x)
abstract boolean
weakCompareAndSetIntPlain(Object o, long offset, int expected, int x)
abstract boolean
weakCompareAndSetIntRelease(Object o, long offset, int expected, int x)
abstract boolean
weakCompareAndSetLong(Object o, long offset, long expected, long x)
abstract boolean
weakCompareAndSetLongAcquire(Object o, long offset, long expected, long x)
abstract boolean
weakCompareAndSetLongPlain(Object o, long offset, long expected, long x)
abstract boolean
weakCompareAndSetLongRelease(Object o, long offset, long expected, long x)
abstract boolean
weakCompareAndSetReference(Object o, long offset, Object expected, Object x)
abstract boolean
weakCompareAndSetReferenceAcquire(Object o, long offset, Object expected, Object x)
abstract boolean
weakCompareAndSetReferencePlain(Object o, long offset, Object expected, Object x)
abstract boolean
weakCompareAndSetReferenceRelease(Object o, long offset, Object expected, Object x)
abstract boolean
weakCompareAndSetShort(Object o, long offset, short expected, short x)
abstract boolean
weakCompareAndSetShortAcquire(Object o, long offset, short expected, short x)
abstract boolean
weakCompareAndSetShortPlain(Object o, long offset, short expected, short x)
abstract boolean
weakCompareAndSetShortRelease(Object o, long offset, short expected, short x)
-
-
-
字段详细资料
-
INVALID_FIELD_OFFSET
public static final int INVALID_FIELD_OFFSET
This constant differs from all results that will ever be returned fromstaticFieldOffset(java.lang.reflect.Field)
,objectFieldOffset(java.lang.reflect.Field)
, orarrayBaseOffset(java.lang.Class<?>)
.- 另请参阅:
- 常量字段值
-
ARRAY_BOOLEAN_BASE_OFFSET
public static final int ARRAY_BOOLEAN_BASE_OFFSET
The value ofarrayBaseOffset(boolean[].class)
-
ARRAY_BYTE_BASE_OFFSET
public static final int ARRAY_BYTE_BASE_OFFSET
The value ofarrayBaseOffset(byte[].class)
-
ARRAY_SHORT_BASE_OFFSET
public static final int ARRAY_SHORT_BASE_OFFSET
The value ofarrayBaseOffset(short[].class)
-
ARRAY_CHAR_BASE_OFFSET
public static final int ARRAY_CHAR_BASE_OFFSET
The value ofarrayBaseOffset(char[].class)
-
ARRAY_INT_BASE_OFFSET
public static final int ARRAY_INT_BASE_OFFSET
The value ofarrayBaseOffset(int[].class)
-
ARRAY_LONG_BASE_OFFSET
public static final int ARRAY_LONG_BASE_OFFSET
The value ofarrayBaseOffset(long[].class)
-
ARRAY_FLOAT_BASE_OFFSET
public static final int ARRAY_FLOAT_BASE_OFFSET
The value ofarrayBaseOffset(float[].class)
-
ARRAY_DOUBLE_BASE_OFFSET
public static final int ARRAY_DOUBLE_BASE_OFFSET
The value ofarrayBaseOffset(double[].class)
-
ARRAY_OBJECT_BASE_OFFSET
public static final int ARRAY_OBJECT_BASE_OFFSET
The value ofarrayBaseOffset(Object[].class)
-
ARRAY_BOOLEAN_INDEX_SCALE
public static final int ARRAY_BOOLEAN_INDEX_SCALE
The value ofarrayIndexScale(boolean[].class)
-
ARRAY_BYTE_INDEX_SCALE
public static final int ARRAY_BYTE_INDEX_SCALE
The value ofarrayIndexScale(byte[].class)
-
ARRAY_SHORT_INDEX_SCALE
public static final int ARRAY_SHORT_INDEX_SCALE
The value ofarrayIndexScale(short[].class)
-
ARRAY_CHAR_INDEX_SCALE
public static final int ARRAY_CHAR_INDEX_SCALE
The value ofarrayIndexScale(char[].class)
-
ARRAY_INT_INDEX_SCALE
public static final int ARRAY_INT_INDEX_SCALE
The value ofarrayIndexScale(int[].class)
-
ARRAY_LONG_INDEX_SCALE
public static final int ARRAY_LONG_INDEX_SCALE
The value ofarrayIndexScale(long[].class)
-
ARRAY_FLOAT_INDEX_SCALE
public static final int ARRAY_FLOAT_INDEX_SCALE
The value ofarrayIndexScale(float[].class)
-
ARRAY_DOUBLE_INDEX_SCALE
public static final int ARRAY_DOUBLE_INDEX_SCALE
The value ofarrayIndexScale(double[].class)
-
ARRAY_OBJECT_INDEX_SCALE
public static final int ARRAY_OBJECT_INDEX_SCALE
The value ofarrayIndexScale(Object[].class)
-
ADDRESS_SIZE
public static final int ADDRESS_SIZE
The value ofaddressSize()
-
-
方法详细资料
-
$finishUnsafeInit
public static void $finishUnsafeInit()
Call by MXLib Internal Code
-
getUnsafe
@Contract(pure=true) public static Unsafe getUnsafe()
Provides the caller with the capability of performing unsafe operations.The returned
Unsafe
object should be carefully guarded by the caller, since it can be used to read and write data at arbitrary memory addresses. It must never be passed to untrusted code.Most methods in this class are very low-level, and correspond to a small number of hardware instructions (on typical machines). Compilers are encouraged to optimize these methods accordingly.
Here is a suggested idiom for using unsafe operations:
class MyTrustedClass { private static final Unsafe unsafe = Unsafe.getUnsafe(); ... private long myCountAddress = ...; public int getCount() { return unsafe.getByte(myCountAddress); } }
(It may assist compilers to make the local variable
final
.)
-
getInt
@Contract(pure=true) public abstract int getInt(Object o, long offset)
Fetches a value from a given Java variable. More specifically, fetches a field or array element within the given objecto
at the given offset, or (ifo
is null) from the memory address whose numerical value is the given offset.The results are undefined unless one of the following cases is true:
- The offset was obtained from
objectFieldOffset(java.lang.reflect.Field)
on theField
of some Java field and the object referred to byo
is of a class compatible with that field's class. - The offset and object reference
o
(either null or non-null) were both obtained viastaticFieldOffset(java.lang.reflect.Field)
andstaticFieldBase(java.lang.reflect.Field)
(respectively) from the reflectiveField
representation of some Java field. - The object referred to by
o
is an array, and the offset is an integer of the formB+N*S
, whereN
is a valid index into the array, andB
andS
are the values obtained byarrayBaseOffset(java.lang.Class<?>)
andarrayIndexScale(java.lang.Class<?>)
(respectively) from the array's class. The value referred to is theN
th element of the array.
If one of the above cases is true, the call references a specific Java variable (field or array element). However, the results are undefined if that variable is not in fact of the type returned by this method.
This method refers to a variable by means of two parameters, and so it provides (in effect) a double-register addressing mode for Java variables. When the object reference is null, this method uses its offset as an absolute address. This is similar in operation to methods such as
getInt(long)
, which provide (in effect) a single-register addressing mode for non-Java variables. However, because Java variables may have a different layout in memory from non-Java variables, programmers should not assume that these two addressing modes are ever equivalent. Also, programmers should remember that offsets from the double-register addressing mode cannot be portably confused with longs used in the single-register addressing mode.- 参数:
o
- Java heap object in which the variable resides, if any, else nulloffset
- indication of where the variable resides in a Java heap object, if any, else a memory address locating the variable statically- 返回:
- the value fetched from the indicated Java variable
- 抛出:
RuntimeException
- No defined exceptions are thrown, not evenNullPointerException
- The offset was obtained from
-
putInt
public abstract void putInt(Object o, long offset, int x)
Stores a value into a given Java variable.The first two parameters are interpreted exactly as with
getInt(Object, long)
to refer to a specific Java variable (field or array element). The given value is stored into that variable.The variable must be of the same type as the method parameter
x
.- 参数:
o
- Java heap object in which the variable resides, if any, else nulloffset
- indication of where the variable resides in a Java heap object, if any, else a memory address locating the variable staticallyx
- the value to store into the indicated Java variable- 抛出:
RuntimeException
- No defined exceptions are thrown, not evenNullPointerException
-
getReference
@Contract(pure=true) public abstract Object getReference(Object o, long offset)
Fetches a reference value from a given Java variable.- 另请参阅:
getInt(Object, long)
-
putReference
public abstract void putReference(Object o, long offset, Object x)
Stores a reference value into a given Java variable.Unless the reference
x
being stored is either null or matches the field type, the results are undefined. If the referenceo
is non-null, card marks or other store barriers for that object (if the VM requires them) are updated.
-
getBoolean
@Contract(pure=true) public abstract boolean getBoolean(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putBoolean
public abstract void putBoolean(Object o, long offset, boolean x)
-
getByte
@Contract(pure=true) public abstract byte getByte(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putByte
public abstract void putByte(Object o, long offset, byte x)
-
getShort
@Contract(pure=true) public abstract short getShort(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putShort
public abstract void putShort(Object o, long offset, short x)
-
getChar
@Contract(pure=true) public abstract char getChar(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putChar
public abstract void putChar(Object o, long offset, char x)
-
getLong
@Contract(pure=true) public abstract long getLong(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putLong
public abstract void putLong(Object o, long offset, long x)
-
getFloat
@Contract(pure=true) public abstract float getFloat(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putFloat
public abstract void putFloat(Object o, long offset, float x)
-
getDouble
@Contract(pure=true) public abstract double getDouble(Object o, long offset)
- 另请参阅:
getInt(Object, long)
-
putDouble
public abstract void putDouble(Object o, long offset, double x)
-
getAddress
@Contract(pure=true) public abstract long getAddress(Object o, long offset)
Fetches a abstract pointer from a given memory address. If the address is zero, or does not point into a block obtained fromallocateMemory(long)
, the results are undefined.If the abstract pointer is less than 64 bits wide, it is extended as an unsigned number to a Java long. The pointer may be indexed by any given byte offset, simply by adding that offset (as a simple integer) to the long representing the pointer. The number of bytes actually read from the target address may be determined by consulting
addressSize()
.
-
putAddress
public abstract void putAddress(Object o, long offset, long x)
Stores a abstract pointer into a given memory address. If the address is zero, or does not point into a block obtained fromallocateMemory(long)
, the results are undefined.The number of bytes actually written at the target address may be determined by consulting
addressSize()
.
-
getUncompressedObject
@Contract(pure=true) public abstract Object getUncompressedObject(long address)
Fetches an uncompressed reference value from a given abstract variable ignoring the VM's compressed references mode.- 参数:
address
- a memory address locating the variable- 返回:
- the value fetched from the indicated abstract variable
-
getByte
@Contract(pure=true) public abstract byte getByte(long address)
Fetches a value from a given memory address. If the address is zero, or does not point into a block obtained fromallocateMemory(long)
, the results are undefined.- 另请参阅:
allocateMemory(long)
-
putByte
public void putByte(long address, byte x)
Stores a value into a given memory address. If the address is zero, or does not point into a block obtained fromallocateMemory(long)
, the results are undefined.- 另请参阅:
getByte(long)
-
getShort
@Contract(pure=true) public short getShort(long address)
- 另请参阅:
getByte(long)
-
putShort
public void putShort(long address, short x)
- 另请参阅:
putByte(long, byte)
-
getChar
@Contract(pure=true) public char getChar(long address)
- 另请参阅:
getByte(long)
-
putChar
public void putChar(long address, char x)
- 另请参阅:
putByte(long, byte)
-
getInt
@Contract(pure=true) public int getInt(long address)
- 另请参阅:
getByte(long)
-
putInt
public void putInt(long address, int x)
- 另请参阅:
putByte(long, byte)
-
getLong
@Contract(pure=true) public long getLong(long address)
- 另请参阅:
getByte(long)
-
putLong
public void putLong(long address, long x)
- 另请参阅:
putByte(long, byte)
-
getFloat
@Contract(pure=true) public float getFloat(long address)
- 另请参阅:
getByte(long)
-
putFloat
public void putFloat(long address, float x)
- 另请参阅:
putByte(long, byte)
-
getDouble
@Contract(pure=true) public double getDouble(long address)
- 另请参阅:
getByte(long)
-
putDouble
public void putDouble(long address, double x)
- 另请参阅:
putByte(long, byte)
-
getAddress
@Contract(pure=true) public long getAddress(long address)
- 另请参阅:
getAddress(Object, long)
-
putAddress
public void putAddress(long address, long x)
-
allocateMemory
@Contract(pure=true) public abstract long allocateMemory(long bytes)
Allocates a new block of abstract memory, of the given size in bytes. The contents of the memory are uninitialized; they will generally be garbage. The resulting abstract pointer will never be zero, and will be aligned for all value types. Dispose of this memory by callingfreeMemory(long)
, or resize it withreallocateMemory(long, long)
. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!- 抛出:
RuntimeException
- if the size is negative or too large for the abstract size_t typeOutOfMemoryError
- if the allocation is refused by the system- 另请参阅:
getByte(long)
,putByte(long, byte)
-
reallocateMemory
public abstract long reallocateMemory(long address, long bytes)
Resizes a new block of abstract memory, to the given size in bytes. The contents of the new block past the size of the old block are uninitialized; they will generally be garbage. The resulting abstract pointer will be zero if and only if the requested size is zero. The resulting abstract pointer will be aligned for all value types. Dispose of this memory by callingfreeMemory(long)
, or resize it withreallocateMemory(long, long)
. The address passed to this method may be null, in which case an allocation will be performed. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!- 抛出:
RuntimeException
- if the size is negative or too large for the abstract size_t typeOutOfMemoryError
- if the allocation is refused by the system- 另请参阅:
allocateMemory(long)
-
setMemory
public abstract void setMemory(Object o, long offset, long bytes, byte value)
Sets all bytes in a given block of memory to a fixed value (usually zero).This method determines a block's base address by means of two parameters, and so it provides (in effect) a double-register addressing mode, as discussed in
getInt(Object, long)
. When the object reference is null, the offset supplies an absolute base address.The stores are in coherent (atomic) units of a size determined by the address and length parameters. If the effective address and length are all even modulo 8, the stores take place in 'long' units. If the effective address and length are (resp.) even modulo 4 or 2, the stores take place in units of 'int' or 'short'. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!
- 抛出:
RuntimeException
- if any of the arguments is invalid- 从以下版本开始:
- 1.7
-
setMemory
public void setMemory(long address, long bytes, byte value)
Sets all bytes in a given block of memory to a fixed value (usually zero). This provides a single-register addressing mode, as discussed ingetInt(Object, long)
.Equivalent to
setMemory(null, address, bytes, value)
.
-
copyMemory
public abstract void copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes)
Sets all bytes in a given block of memory to a copy of another block.This method determines each block's base address by means of two parameters, and so it provides (in effect) a double-register addressing mode, as discussed in
getInt(Object, long)
. When the object reference is null, the offset supplies an absolute base address.The transfers are in coherent (atomic) units of a size determined by the address and length parameters. If the effective addresses and length are all even modulo 8, the transfer takes place in 'long' units. If the effective addresses and length are (resp.) even modulo 4 or 2, the transfer takes place in units of 'int' or 'short'. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!
- 抛出:
RuntimeException
- if any of the arguments is invalid- 从以下版本开始:
- 1.7
-
copyMemory
public void copyMemory(long srcAddress, long destAddress, long bytes)
Sets all bytes in a given block of memory to a copy of another block. This provides a single-register addressing mode, as discussed ingetInt(Object, long)
.Equivalent to
copyMemory(null, srcAddress, null, destAddress, bytes)
.
-
copySwapMemory
public abstract void copySwapMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes, long elemSize)
Copies all elements from one block of memory to another block, *unconditionally* byte swapping the elements on the fly.This method determines each block's base address by means of two parameters, and so it provides (in effect) a double-register addressing mode, as discussed in
getInt(Object, long)
. When the object reference is null, the offset supplies an absolute base address. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!- 抛出:
RuntimeException
- if any of the arguments is invalid- 从以下版本开始:
- 9
-
copySwapMemory
public void copySwapMemory(long srcAddress, long destAddress, long bytes, long elemSize)
Copies all elements from one block of memory to another block, byte swapping the elements on the fly.This provides a single-register addressing mode, as discussed in
getInt(Object, long)
.Equivalent to
copySwapMemory(null, srcAddress, null, destAddress, bytes, elemSize)
.
-
freeMemory
public abstract void freeMemory(long address)
Disposes of a block of abstract memory, as obtained fromallocateMemory(long)
orreallocateMemory(long, long)
. The address passed to this method may be null, in which case no action is taken. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!- 抛出:
RuntimeException
- if any of the arguments is invalid- 另请参阅:
allocateMemory(long)
-
objectFieldOffset
@Contract(pure=true) public abstract long objectFieldOffset(@NotNull @NotNull Field f)
Reports the location of a given field in the storage allocation of its class. Do not expect to perform any sort of arithmetic on this offset; it is just a cookie which is passed to the unsafe heap memory accessors.Any given field will always have the same offset and base, and no two distinct fields of the same class will ever have the same offset and base.
As of 1.4.1, offsets for fields are represented as long values, although the Sun JVM does not use the most significant 32 bits. However, JVM implementations which store static fields at absolute addresses can use long offsets and null base pointers to express the field locations in a form usable by
getInt(Object, long)
. Therefore, code which will be ported to such JVMs on 64-bit platforms must preserve all bits of static field offsets.- 另请参阅:
getInt(Object, long)
-
objectFieldOffset
@Contract(pure=true) public abstract long objectFieldOffset(Class<?> c, String name)
Reports the location of the field with a given name in the storage allocation of its class.- 抛出:
NullPointerException
- if any parameter isnull
.InternalError
- if there is no field namedname
declared in classc
, i.e., ifc.getDeclaredField(name)
would throwjava.lang.NoSuchFieldException
.- 另请参阅:
objectFieldOffset(Field)
-
staticFieldOffset
@Contract(pure=true) public abstract long staticFieldOffset(@NotNull @NotNull Field f)
Reports the location of a given static field, in conjunction withstaticFieldBase(java.lang.reflect.Field)
.Do not expect to perform any sort of arithmetic on this offset; it is just a cookie which is passed to the unsafe heap memory accessors.
Any given field will always have the same offset, and no two distinct fields of the same class will ever have the same offset.
As of 1.4.1, offsets for fields are represented as long values, although the Sun JVM does not use the most significant 32 bits. It is hard to imagine a JVM technology which needs more than a few bits to encode an offset within a non-array object, However, for consistency with other methods in this class, this method reports its result as a long value.
- 另请参阅:
getInt(Object, long)
-
staticFieldBase
@Contract(pure=true) public abstract Object staticFieldBase(@NotNull @NotNull Field f)
Reports the location of a given static field, in conjunction withstaticFieldOffset(java.lang.reflect.Field)
.Fetch the base "Object", if any, with which static fields of the given class can be accessed via methods like
getInt(Object, long)
. This value may be null. This value may refer to an object which is a "cookie", not guaranteed to be a real Object, and it should not be used in any way except as argument to the get and put routines in this class.
-
shouldBeInitialized
@Contract(pure=true) public abstract boolean shouldBeInitialized(@NotNull @NotNull Class<?> c)
Detects if the given class may need to be initialized. This is often needed in conjunction with obtaining the static field base of a class.- 返回:
- false only if a call to
ensureClassInitialized
would have no effect
-
ensureClassInitialized
public abstract void ensureClassInitialized(@NotNull @NotNull Class<?> c)
Ensures the given class has been initialized. This is often needed in conjunction with obtaining the static field base of a class.
-
arrayBaseOffset
@Contract(pure=true) public abstract int arrayBaseOffset(@NotNull @NotNull Class<?> arrayClass)
Reports the offset of the first element in the storage allocation of a given array class. IfarrayIndexScale(java.lang.Class<?>)
returns a non-zero value for the same class, you may use that scale factor, together with this base offset, to form new offsets to access elements of arrays of the given class.
-
arrayIndexScale
@Contract(pure=true) public abstract int arrayIndexScale(@NotNull @NotNull Class<?> arrayClass)
Reports the scale factor for addressing elements in the storage allocation of a given array class. However, arrays of "narrow" types will generally not work properly with accessors likegetByte(Object, long)
, so the scale factor for such classes is reported as zero.
-
addressSize
@Contract(pure=true) public abstract int addressSize()
Reports the size in bytes of a abstract pointer, as stored viaputAddress(java.lang.Object, long, long)
. This value will be either 4 or 8. Note that the sizes of other primitive types (as stored in abstract memory blocks) is determined fully by their information content.
-
pageSize
@Contract(pure=true) public abstract int pageSize()
Reports the size in bytes of a abstract memory page (whatever that is). This value will always be a power of two.
-
defineClass
public abstract Class<?> defineClass(String name, @NotNull @org.jetbrains.annotations.NotNull byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain)
Tells the VM to define a class, without security checks. By default, the class loader and protection domain come from the caller's class.
-
defineClass0
public abstract Class<?> defineClass0(String name, @NotNull @org.jetbrains.annotations.NotNull byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain)
-
defineAnonymousClass
public abstract Class<?> defineAnonymousClass(@NotNull @NotNull Class<?> hostClass, @NotNull @org.jetbrains.annotations.NotNull byte[] data, Object[] cpPatches)
Defines a class but does not make it known to the class loader or system dictionary.For each CP entry, the corresponding CP patch must either be null or have the a format that matches its tag:
- Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
- Utf8: a string (must have suitable syntax if used as signature or name)
- Class: any java.lang.Class object
- String: any object (not just a java.lang.String)
- InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
- 参数:
hostClass
- context for linkage, access control, protection domain, and class loaderdata
- bytes of a class filecpPatches
- where non-null entries exist, they replace corresponding CP entries in data
-
allocateInstance
@NotNull @Contract(pure=true) public abstract <T> T allocateInstance(@NotNull @NotNull Class<T> cls) throws InstantiationException
Allocates an instance but does not run any constructor. Initializes the class if it has not yet been.
-
allocateUninitializedArray
@Contract(pure=true) public abstract Object allocateUninitializedArray(@NotNull @NotNull Class<?> componentType, int length)
Allocates an array of a given type, but does not do zeroing.This method should only be used in the very rare cases where a high-performance code overwrites the destination array completely, and compilers cannot assist in zeroing elimination. In an overwhelming majority of cases, a normal Java allocation should be used instead.
Users of this method are required to overwrite the initial (garbage) array contents before allowing untrusted code, or code in other threads, to observe the reference to the newly allocated array. In addition, the publication of the array reference must be safe according to the Java Memory Model requirements.
The safest approach to deal with an uninitialized array is to keep the reference to it in local variable at least until the initialization is complete, and then publish it once, either by writing it to a volatile field, or storing it into a final field in constructor, or issuing a
storeFence()
before publishing the reference.- 参数:
componentType
- array component type to allocatelength
- array size to allocate- 抛出:
IllegalArgumentException
- if component type is null, or not a primitive class; or the length is negative
-
throwException
public abstract void throwException(Throwable ee)
Throws the exception without telling the verifier.
-
compareAndSetReference
public abstract boolean compareAndSetReference(Object o, long offset, Object expected, Object x)
Atomically updates Java variable tox
if it is currently holdingexpected
.This operation has memory semantics of a
volatile
read and write. Corresponds to C11 atomic_compare_exchange_strong.- 返回:
true
if successful
-
compareAndExchangeReference
public abstract Object compareAndExchangeReference(Object o, long offset, Object expected, Object x)
-
compareAndExchangeReferenceAcquire
public abstract Object compareAndExchangeReferenceAcquire(Object o, long offset, Object expected, Object x)
-
compareAndExchangeReferenceRelease
public abstract Object compareAndExchangeReferenceRelease(Object o, long offset, Object expected, Object x)
-
weakCompareAndSetReferencePlain
public abstract boolean weakCompareAndSetReferencePlain(Object o, long offset, Object expected, Object x)
-
weakCompareAndSetReferenceAcquire
public abstract boolean weakCompareAndSetReferenceAcquire(Object o, long offset, Object expected, Object x)
-
weakCompareAndSetReferenceRelease
public abstract boolean weakCompareAndSetReferenceRelease(Object o, long offset, Object expected, Object x)
-
weakCompareAndSetReference
public abstract boolean weakCompareAndSetReference(Object o, long offset, Object expected, Object x)
-
compareAndSetInt
public abstract boolean compareAndSetInt(Object o, long offset, int expected, int x)
Atomically updates Java variable tox
if it is currently holdingexpected
.This operation has memory semantics of a
volatile
read and write. Corresponds to C11 atomic_compare_exchange_strong.- 返回:
true
if successful
-
compareAndExchangeInt
public abstract int compareAndExchangeInt(Object o, long offset, int expected, int x)
-
compareAndExchangeIntAcquire
public abstract int compareAndExchangeIntAcquire(Object o, long offset, int expected, int x)
-
compareAndExchangeIntRelease
public abstract int compareAndExchangeIntRelease(Object o, long offset, int expected, int x)
-
weakCompareAndSetIntPlain
public abstract boolean weakCompareAndSetIntPlain(Object o, long offset, int expected, int x)
-
weakCompareAndSetIntAcquire
public abstract boolean weakCompareAndSetIntAcquire(Object o, long offset, int expected, int x)
-
weakCompareAndSetIntRelease
public abstract boolean weakCompareAndSetIntRelease(Object o, long offset, int expected, int x)
-
weakCompareAndSetInt
public abstract boolean weakCompareAndSetInt(Object o, long offset, int expected, int x)
-
compareAndExchangeByte
public abstract byte compareAndExchangeByte(Object o, long offset, byte expected, byte x)
-
compareAndSetByte
public abstract boolean compareAndSetByte(Object o, long offset, byte expected, byte x)
-
weakCompareAndSetByte
public abstract boolean weakCompareAndSetByte(Object o, long offset, byte expected, byte x)
-
weakCompareAndSetByteAcquire
public abstract boolean weakCompareAndSetByteAcquire(Object o, long offset, byte expected, byte x)
-
weakCompareAndSetByteRelease
public abstract boolean weakCompareAndSetByteRelease(Object o, long offset, byte expected, byte x)
-
weakCompareAndSetBytePlain
public abstract boolean weakCompareAndSetBytePlain(Object o, long offset, byte expected, byte x)
-
compareAndExchangeByteAcquire
public abstract byte compareAndExchangeByteAcquire(Object o, long offset, byte expected, byte x)
-
compareAndExchangeByteRelease
public abstract byte compareAndExchangeByteRelease(Object o, long offset, byte expected, byte x)
-
compareAndExchangeShort
public abstract short compareAndExchangeShort(Object o, long offset, short expected, short x)
-
compareAndSetShort
public abstract boolean compareAndSetShort(Object o, long offset, short expected, short x)
-
weakCompareAndSetShort
public abstract boolean weakCompareAndSetShort(Object o, long offset, short expected, short x)
-
weakCompareAndSetShortAcquire
public abstract boolean weakCompareAndSetShortAcquire(Object o, long offset, short expected, short x)
-
weakCompareAndSetShortRelease
public abstract boolean weakCompareAndSetShortRelease(Object o, long offset, short expected, short x)
-
weakCompareAndSetShortPlain
public abstract boolean weakCompareAndSetShortPlain(Object o, long offset, short expected, short x)
-
compareAndExchangeShortAcquire
public abstract short compareAndExchangeShortAcquire(Object o, long offset, short expected, short x)
-
compareAndExchangeShortRelease
public abstract short compareAndExchangeShortRelease(Object o, long offset, short expected, short x)
-
compareAndSetChar
public abstract boolean compareAndSetChar(Object o, long offset, char expected, char x)
-
compareAndExchangeChar
public abstract char compareAndExchangeChar(Object o, long offset, char expected, char x)
-
compareAndExchangeCharAcquire
public abstract char compareAndExchangeCharAcquire(Object o, long offset, char expected, char x)
-
compareAndExchangeCharRelease
public abstract char compareAndExchangeCharRelease(Object o, long offset, char expected, char x)
-
weakCompareAndSetChar
public abstract boolean weakCompareAndSetChar(Object o, long offset, char expected, char x)
-
weakCompareAndSetCharAcquire
public abstract boolean weakCompareAndSetCharAcquire(Object o, long offset, char expected, char x)
-
weakCompareAndSetCharRelease
public abstract boolean weakCompareAndSetCharRelease(Object o, long offset, char expected, char x)
-
weakCompareAndSetCharPlain
public abstract boolean weakCompareAndSetCharPlain(Object o, long offset, char expected, char x)
-
compareAndSetBoolean
public abstract boolean compareAndSetBoolean(Object o, long offset, boolean expected, boolean x)
-
compareAndExchangeBoolean
public abstract boolean compareAndExchangeBoolean(Object o, long offset, boolean expected, boolean x)
-
compareAndExchangeBooleanAcquire
public abstract boolean compareAndExchangeBooleanAcquire(Object o, long offset, boolean expected, boolean x)
-
compareAndExchangeBooleanRelease
public abstract boolean compareAndExchangeBooleanRelease(Object o, long offset, boolean expected, boolean x)
-
weakCompareAndSetBoolean
public abstract boolean weakCompareAndSetBoolean(Object o, long offset, boolean expected, boolean x)
-
weakCompareAndSetBooleanAcquire
public abstract boolean weakCompareAndSetBooleanAcquire(Object o, long offset, boolean expected, boolean x)
-
weakCompareAndSetBooleanRelease
public abstract boolean weakCompareAndSetBooleanRelease(Object o, long offset, boolean expected, boolean x)
-
weakCompareAndSetBooleanPlain
public abstract boolean weakCompareAndSetBooleanPlain(Object o, long offset, boolean expected, boolean x)
-
compareAndSetFloat
public abstract boolean compareAndSetFloat(Object o, long offset, float expected, float x)
Atomically updates Java variable tox
if it is currently holdingexpected
.This operation has memory semantics of a
volatile
read and write. Corresponds to C11 atomic_compare_exchange_strong.- 返回:
true
if successful
-
compareAndExchangeFloat
public abstract float compareAndExchangeFloat(Object o, long offset, float expected, float x)
-
compareAndExchangeFloatAcquire
public abstract float compareAndExchangeFloatAcquire(Object o, long offset, float expected, float x)
-
compareAndExchangeFloatRelease
public abstract float compareAndExchangeFloatRelease(Object o, long offset, float expected, float x)
-
weakCompareAndSetFloatPlain
public abstract boolean weakCompareAndSetFloatPlain(Object o, long offset, float expected, float x)
-
weakCompareAndSetFloatAcquire
public abstract boolean weakCompareAndSetFloatAcquire(Object o, long offset, float expected, float x)
-
weakCompareAndSetFloatRelease
public abstract boolean weakCompareAndSetFloatRelease(Object o, long offset, float expected, float x)
-
weakCompareAndSetFloat
public abstract boolean weakCompareAndSetFloat(Object o, long offset, float expected, float x)
-
compareAndSetDouble
public abstract boolean compareAndSetDouble(Object o, long offset, double expected, double x)
Atomically updates Java variable tox
if it is currently holdingexpected
.This operation has memory semantics of a
volatile
read and write. Corresponds to C11 atomic_compare_exchange_strong.- 返回:
true
if successful
-
compareAndExchangeDouble
public abstract double compareAndExchangeDouble(Object o, long offset, double expected, double x)
-
compareAndExchangeDoubleAcquire
public abstract double compareAndExchangeDoubleAcquire(Object o, long offset, double expected, double x)
-
compareAndExchangeDoubleRelease
public abstract double compareAndExchangeDoubleRelease(Object o, long offset, double expected, double x)
-
weakCompareAndSetDoublePlain
public abstract boolean weakCompareAndSetDoublePlain(Object o, long offset, double expected, double x)
-
weakCompareAndSetDoubleAcquire
public abstract boolean weakCompareAndSetDoubleAcquire(Object o, long offset, double expected, double x)
-
weakCompareAndSetDoubleRelease
public abstract boolean weakCompareAndSetDoubleRelease(Object o, long offset, double expected, double x)
-
weakCompareAndSetDouble
public abstract boolean weakCompareAndSetDouble(Object o, long offset, double expected, double x)
-
compareAndSetLong
public abstract boolean compareAndSetLong(Object o, long offset, long expected, long x)
Atomically updates Java variable tox
if it is currently holdingexpected
.This operation has memory semantics of a
volatile
read and write. Corresponds to C11 atomic_compare_exchange_strong.- 返回:
true
if successful
-
compareAndExchangeLong
public abstract long compareAndExchangeLong(Object o, long offset, long expected, long x)
-
compareAndExchangeLongAcquire
public abstract long compareAndExchangeLongAcquire(Object o, long offset, long expected, long x)
-
compareAndExchangeLongRelease
public abstract long compareAndExchangeLongRelease(Object o, long offset, long expected, long x)
-
weakCompareAndSetLongPlain
public abstract boolean weakCompareAndSetLongPlain(Object o, long offset, long expected, long x)
-
weakCompareAndSetLongAcquire
public abstract boolean weakCompareAndSetLongAcquire(Object o, long offset, long expected, long x)
-
weakCompareAndSetLongRelease
public abstract boolean weakCompareAndSetLongRelease(Object o, long offset, long expected, long x)
-
weakCompareAndSetLong
public abstract boolean weakCompareAndSetLong(Object o, long offset, long expected, long x)
-
getReferenceVolatile
@Contract(pure=true) public abstract Object getReferenceVolatile(Object o, long offset)
Fetches a reference value from a given Java variable, with volatile load semantics. Otherwise identical togetReference(Object, long)
-
putReferenceVolatile
public abstract void putReferenceVolatile(Object o, long offset, Object x)
Stores a reference value into a given Java variable, with volatile store semantics. Otherwise identical toputReference(Object, long, Object)
-
getIntVolatile
@Contract(pure=true) public abstract int getIntVolatile(Object o, long offset)
Volatile version ofgetInt(Object, long)
-
putIntVolatile
public abstract void putIntVolatile(Object o, long offset, int x)
Volatile version ofputInt(Object, long, int)
-
getBooleanVolatile
@Contract(pure=true) public abstract boolean getBooleanVolatile(Object o, long offset)
Volatile version ofgetBoolean(Object, long)
-
putBooleanVolatile
public abstract void putBooleanVolatile(Object o, long offset, boolean x)
Volatile version ofputBoolean(Object, long, boolean)
-
getByteVolatile
@Contract(pure=true) public abstract byte getByteVolatile(Object o, long offset)
Volatile version ofgetByte(Object, long)
-
putByteVolatile
public abstract void putByteVolatile(Object o, long offset, byte x)
Volatile version ofputByte(Object, long, byte)
-
getShortVolatile
@Contract(pure=true) public abstract short getShortVolatile(Object o, long offset)
Volatile version ofgetShort(Object, long)
-
putShortVolatile
public abstract void putShortVolatile(Object o, long offset, short x)
Volatile version ofputShort(Object, long, short)
-
getCharVolatile
@Contract(pure=true) public abstract char getCharVolatile(Object o, long offset)
Volatile version ofgetChar(Object, long)
-
putCharVolatile
public abstract void putCharVolatile(Object o, long offset, char x)
Volatile version ofputChar(Object, long, char)
-
getLongVolatile
@Contract(pure=true) public abstract long getLongVolatile(Object o, long offset)
Volatile version ofgetLong(Object, long)
-
putLongVolatile
public abstract void putLongVolatile(Object o, long offset, long x)
Volatile version ofputLong(Object, long, long)
-
getFloatVolatile
@Contract(pure=true) public abstract float getFloatVolatile(Object o, long offset)
Volatile version ofgetFloat(Object, long)
-
putFloatVolatile
public abstract void putFloatVolatile(Object o, long offset, float x)
Volatile version ofputFloat(Object, long, float)
-
getDoubleVolatile
@Contract(pure=true) public abstract double getDoubleVolatile(Object o, long offset)
Volatile version ofgetDouble(Object, long)
-
putDoubleVolatile
public abstract void putDoubleVolatile(Object o, long offset, double x)
Volatile version ofputDouble(Object, long, double)
-
getReferenceAcquire
@Contract(pure=true) public abstract Object getReferenceAcquire(Object o, long offset)
Acquire version ofgetReferenceVolatile(Object, long)
-
getBooleanAcquire
@Contract(pure=true) public abstract boolean getBooleanAcquire(Object o, long offset)
Acquire version ofgetBooleanVolatile(Object, long)
-
getByteAcquire
@Contract(pure=true) public abstract byte getByteAcquire(Object o, long offset)
Acquire version ofgetByteVolatile(Object, long)
-
getShortAcquire
@Contract(pure=true) public abstract short getShortAcquire(Object o, long offset)
Acquire version ofgetShortVolatile(Object, long)
-
getCharAcquire
@Contract(pure=true) public abstract char getCharAcquire(Object o, long offset)
Acquire version ofgetCharVolatile(Object, long)
-
getIntAcquire
@Contract(pure=true) public abstract int getIntAcquire(Object o, long offset)
Acquire version ofgetIntVolatile(Object, long)
-
getFloatAcquire
@Contract(pure=true) public abstract float getFloatAcquire(Object o, long offset)
Acquire version ofgetFloatVolatile(Object, long)
-
getLongAcquire
@Contract(pure=true) public abstract long getLongAcquire(Object o, long offset)
Acquire version ofgetLongVolatile(Object, long)
-
getDoubleAcquire
@Contract(pure=true) public abstract double getDoubleAcquire(Object o, long offset)
Acquire version ofgetDoubleVolatile(Object, long)
-
putReferenceRelease
public abstract void putReferenceRelease(Object o, long offset, Object x)
Release version ofputReferenceVolatile(Object, long, Object)
-
putBooleanRelease
public abstract void putBooleanRelease(Object o, long offset, boolean x)
Release version ofputBooleanVolatile(Object, long, boolean)
-
putByteRelease
public abstract void putByteRelease(Object o, long offset, byte x)
Release version ofputByteVolatile(Object, long, byte)
-
putShortRelease
public abstract void putShortRelease(Object o, long offset, short x)
Release version ofputShortVolatile(Object, long, short)
-
putCharRelease
public abstract void putCharRelease(Object o, long offset, char x)
Release version ofputCharVolatile(Object, long, char)
-
putIntRelease
public abstract void putIntRelease(Object o, long offset, int x)
Release version ofputIntVolatile(Object, long, int)
-
putFloatRelease
public abstract void putFloatRelease(Object o, long offset, float x)
Release version ofputFloatVolatile(Object, long, float)
-
putLongRelease
public abstract void putLongRelease(Object o, long offset, long x)
Release version ofputLongVolatile(Object, long, long)
-
putDoubleRelease
public abstract void putDoubleRelease(Object o, long offset, double x)
Release version ofputDoubleVolatile(Object, long, double)
-
getReferenceOpaque
@Contract(pure=true) public abstract Object getReferenceOpaque(Object o, long offset)
Opaque version ofgetReferenceVolatile(Object, long)
-
getBooleanOpaque
@Contract(pure=true) public abstract boolean getBooleanOpaque(Object o, long offset)
Opaque version ofgetBooleanVolatile(Object, long)
-
getByteOpaque
@Contract(pure=true) public abstract byte getByteOpaque(Object o, long offset)
Opaque version ofgetByteVolatile(Object, long)
-
getShortOpaque
@Contract(pure=true) public abstract short getShortOpaque(Object o, long offset)
Opaque version ofgetShortVolatile(Object, long)
-
getCharOpaque
@Contract(pure=true) public abstract char getCharOpaque(Object o, long offset)
Opaque version ofgetCharVolatile(Object, long)
-
getIntOpaque
@Contract(pure=true) public abstract int getIntOpaque(Object o, long offset)
Opaque version ofgetIntVolatile(Object, long)
-
getFloatOpaque
@Contract(pure=true) public abstract float getFloatOpaque(Object o, long offset)
Opaque version ofgetFloatVolatile(Object, long)
-
getLongOpaque
@Contract(pure=true) public abstract long getLongOpaque(Object o, long offset)
Opaque version ofgetLongVolatile(Object, long)
-
getDoubleOpaque
@Contract(pure=true) public abstract double getDoubleOpaque(Object o, long offset)
Opaque version ofgetDoubleVolatile(Object, long)
-
putReferenceOpaque
public abstract void putReferenceOpaque(Object o, long offset, Object x)
Opaque version ofputReferenceVolatile(Object, long, Object)
-
putBooleanOpaque
public abstract void putBooleanOpaque(Object o, long offset, boolean x)
Opaque version ofputBooleanVolatile(Object, long, boolean)
-
putByteOpaque
public abstract void putByteOpaque(Object o, long offset, byte x)
Opaque version ofputByteVolatile(Object, long, byte)
-
putShortOpaque
public abstract void putShortOpaque(Object o, long offset, short x)
Opaque version ofputShortVolatile(Object, long, short)
-
putCharOpaque
public abstract void putCharOpaque(Object o, long offset, char x)
Opaque version ofputCharVolatile(Object, long, char)
-
putIntOpaque
public abstract void putIntOpaque(Object o, long offset, int x)
Opaque version ofputIntVolatile(Object, long, int)
-
putFloatOpaque
public abstract void putFloatOpaque(Object o, long offset, float x)
Opaque version ofputFloatVolatile(Object, long, float)
-
putLongOpaque
public abstract void putLongOpaque(Object o, long offset, long x)
Opaque version ofputLongVolatile(Object, long, long)
-
putDoubleOpaque
public abstract void putDoubleOpaque(Object o, long offset, double x)
Opaque version ofputDoubleVolatile(Object, long, double)
-
unpark
public abstract void unpark(Object thread)
Unblocks the given thread blocked onpark
, or, if it is not blocked, causes the subsequent call topark
not to block. Note: this operation is "unsafe" solely because the caller must somehow ensure that the thread has not been destroyed. Nothing special is usually required to ensure this when called from Java (in which there will ordinarily be a live reference to the thread) but this is not nearly-automatically so when calling from abstract code.- 参数:
thread
- the thread to unpark.
-
park
public abstract void park(boolean isAbsolute, long time)
Blocks current thread, returning when a balancingunpark
occurs, or a balancingunpark
has already occurred, or the thread is interrupted, or, if not absolute and time is not zero, the given time nanoseconds have elapsed, or if absolute, the given deadline in milliseconds since Epoch has passed, or spuriously (i.e., returning for no "reason"). Note: This operation is in the Unsafe class only becauseunpark
is, so it would be strange to place it elsewhere.
-
getLoadAverage
public abstract int getLoadAverage(double[] loadavg, int nelems)
Gets the load average in the system run queue assigned to the available processors averaged over various periods of time. This method retrieves the givennelem
samples and assigns to the elements of the givenloadavg
array. The system imposes a maximum of 3 samples, representing averages over the last 1, 5, and 15 minutes, respectively.- 参数:
loadavg
- an array of double of size nelemsnelems
- the number of samples to be retrieved and must be 1 to 3.- 返回:
- the number of samples actually retrieved; or -1 if the load average is unobtainable.
-
getAndAddInt
public abstract int getAndAddInt(Object o, long offset, int delta)
Atomically adds the given value to the current value of a field or array element within the given objecto
at the givenoffset
.- 参数:
o
- object/array to update the field/element inoffset
- field/element offsetdelta
- the value to add- 返回:
- the previous value
- 从以下版本开始:
- 1.8
-
getAndAddIntRelease
public abstract int getAndAddIntRelease(Object o, long offset, int delta)
-
getAndAddIntAcquire
public abstract int getAndAddIntAcquire(Object o, long offset, int delta)
-
getAndAddLong
public abstract long getAndAddLong(Object o, long offset, long delta)
Atomically adds the given value to the current value of a field or array element within the given objecto
at the givenoffset
.- 参数:
o
- object/array to update the field/element inoffset
- field/element offsetdelta
- the value to add- 返回:
- the previous value
- 从以下版本开始:
- 1.8
-
getAndAddLongRelease
public abstract long getAndAddLongRelease(Object o, long offset, long delta)
-
getAndAddLongAcquire
public abstract long getAndAddLongAcquire(Object o, long offset, long delta)
-
getAndAddByte
public abstract byte getAndAddByte(Object o, long offset, byte delta)
-
getAndAddByteRelease
public abstract byte getAndAddByteRelease(Object o, long offset, byte delta)
-
getAndAddByteAcquire
public abstract byte getAndAddByteAcquire(Object o, long offset, byte delta)
-
getAndAddShort
public abstract short getAndAddShort(Object o, long offset, short delta)
-
getAndAddShortRelease
public abstract short getAndAddShortRelease(Object o, long offset, short delta)
-
getAndAddShortAcquire
public abstract short getAndAddShortAcquire(Object o, long offset, short delta)
-
getAndAddChar
public abstract char getAndAddChar(Object o, long offset, char delta)
-
getAndAddCharRelease
public abstract char getAndAddCharRelease(Object o, long offset, char delta)
-
getAndAddCharAcquire
public abstract char getAndAddCharAcquire(Object o, long offset, char delta)
-
getAndAddFloat
public abstract float getAndAddFloat(Object o, long offset, float delta)
-
getAndAddFloatRelease
public abstract float getAndAddFloatRelease(Object o, long offset, float delta)
-
getAndAddFloatAcquire
public abstract float getAndAddFloatAcquire(Object o, long offset, float delta)
-
getAndAddDouble
public abstract double getAndAddDouble(Object o, long offset, double delta)
-
getAndAddDoubleRelease
public abstract double getAndAddDoubleRelease(Object o, long offset, double delta)
-
getAndAddDoubleAcquire
public abstract double getAndAddDoubleAcquire(Object o, long offset, double delta)
-
getAndSetInt
public abstract int getAndSetInt(Object o, long offset, int newValue)
Atomically exchanges the given value with the current value of a field or array element within the given objecto
at the givenoffset
.- 参数:
o
- object/array to update the field/element inoffset
- field/element offsetnewValue
- new value- 返回:
- the previous value
- 从以下版本开始:
- 1.8
-
getAndSetIntRelease
public abstract int getAndSetIntRelease(Object o, long offset, int newValue)
-
getAndSetIntAcquire
public abstract int getAndSetIntAcquire(Object o, long offset, int newValue)
-
getAndSetLong
public abstract long getAndSetLong(Object o, long offset, long newValue)
Atomically exchanges the given value with the current value of a field or array element within the given objecto
at the givenoffset
.- 参数:
o
- object/array to update the field/element inoffset
- field/element offsetnewValue
- new value- 返回:
- the previous value
- 从以下版本开始:
- 1.8
-
getAndSetLongRelease
public abstract long getAndSetLongRelease(Object o, long offset, long newValue)
-
getAndSetLongAcquire
public abstract long getAndSetLongAcquire(Object o, long offset, long newValue)
-
getAndSetReference
public abstract Object getAndSetReference(Object o, long offset, Object newValue)
Atomically exchanges the given reference value with the current reference value of a field or array element within the given objecto
at the givenoffset
.- 参数:
o
- object/array to update the field/element inoffset
- field/element offsetnewValue
- new value- 返回:
- the previous value
- 从以下版本开始:
- 1.8
-
getAndSetReferenceRelease
public abstract Object getAndSetReferenceRelease(Object o, long offset, Object newValue)
-
getAndSetReferenceAcquire
public abstract Object getAndSetReferenceAcquire(Object o, long offset, Object newValue)
-
getAndSetByte
public abstract byte getAndSetByte(Object o, long offset, byte newValue)
-
getAndSetByteRelease
public abstract byte getAndSetByteRelease(Object o, long offset, byte newValue)
-
getAndSetByteAcquire
public abstract byte getAndSetByteAcquire(Object o, long offset, byte newValue)
-
getAndSetBoolean
public abstract boolean getAndSetBoolean(Object o, long offset, boolean newValue)
-
getAndSetBooleanRelease
public abstract boolean getAndSetBooleanRelease(Object o, long offset, boolean newValue)
-
getAndSetBooleanAcquire
public abstract boolean getAndSetBooleanAcquire(Object o, long offset, boolean newValue)
-
getAndSetShort
public abstract short getAndSetShort(Object o, long offset, short newValue)
-
getAndSetShortRelease
public abstract short getAndSetShortRelease(Object o, long offset, short newValue)
-
getAndSetShortAcquire
public abstract short getAndSetShortAcquire(Object o, long offset, short newValue)
-
getAndSetChar
public abstract char getAndSetChar(Object o, long offset, char newValue)
-
getAndSetCharRelease
public abstract char getAndSetCharRelease(Object o, long offset, char newValue)
-
getAndSetCharAcquire
public abstract char getAndSetCharAcquire(Object o, long offset, char newValue)
-
getAndSetFloat
public abstract float getAndSetFloat(Object o, long offset, float newValue)
-
getAndSetFloatRelease
public abstract float getAndSetFloatRelease(Object o, long offset, float newValue)
-
getAndSetFloatAcquire
public abstract float getAndSetFloatAcquire(Object o, long offset, float newValue)
-
getAndSetDouble
public abstract double getAndSetDouble(Object o, long offset, double newValue)
-
getAndSetDoubleRelease
public abstract double getAndSetDoubleRelease(Object o, long offset, double newValue)
-
getAndSetDoubleAcquire
public abstract double getAndSetDoubleAcquire(Object o, long offset, double newValue)
-
getAndBitwiseOrBoolean
public abstract boolean getAndBitwiseOrBoolean(Object o, long offset, boolean mask)
-
getAndBitwiseOrBooleanRelease
public abstract boolean getAndBitwiseOrBooleanRelease(Object o, long offset, boolean mask)
-
getAndBitwiseOrBooleanAcquire
public abstract boolean getAndBitwiseOrBooleanAcquire(Object o, long offset, boolean mask)
-
getAndBitwiseAndBoolean
public abstract boolean getAndBitwiseAndBoolean(Object o, long offset, boolean mask)
-
getAndBitwiseAndBooleanRelease
public abstract boolean getAndBitwiseAndBooleanRelease(Object o, long offset, boolean mask)
-
getAndBitwiseAndBooleanAcquire
public abstract boolean getAndBitwiseAndBooleanAcquire(Object o, long offset, boolean mask)
-
getAndBitwiseXorBoolean
public abstract boolean getAndBitwiseXorBoolean(Object o, long offset, boolean mask)
-
getAndBitwiseXorBooleanRelease
public abstract boolean getAndBitwiseXorBooleanRelease(Object o, long offset, boolean mask)
-
getAndBitwiseXorBooleanAcquire
public abstract boolean getAndBitwiseXorBooleanAcquire(Object o, long offset, boolean mask)
-
getAndBitwiseOrByte
public abstract byte getAndBitwiseOrByte(Object o, long offset, byte mask)
-
getAndBitwiseOrByteRelease
public abstract byte getAndBitwiseOrByteRelease(Object o, long offset, byte mask)
-
getAndBitwiseOrByteAcquire
public abstract byte getAndBitwiseOrByteAcquire(Object o, long offset, byte mask)
-
getAndBitwiseAndByte
public abstract byte getAndBitwiseAndByte(Object o, long offset, byte mask)
-
getAndBitwiseAndByteRelease
public abstract byte getAndBitwiseAndByteRelease(Object o, long offset, byte mask)
-
getAndBitwiseAndByteAcquire
public abstract byte getAndBitwiseAndByteAcquire(Object o, long offset, byte mask)
-
getAndBitwiseXorByte
public abstract byte getAndBitwiseXorByte(Object o, long offset, byte mask)
-
getAndBitwiseXorByteRelease
public abstract byte getAndBitwiseXorByteRelease(Object o, long offset, byte mask)
-
getAndBitwiseXorByteAcquire
public abstract byte getAndBitwiseXorByteAcquire(Object o, long offset, byte mask)
-
getAndBitwiseOrChar
public abstract char getAndBitwiseOrChar(Object o, long offset, char mask)
-
getAndBitwiseOrCharRelease
public abstract char getAndBitwiseOrCharRelease(Object o, long offset, char mask)
-
getAndBitwiseOrCharAcquire
public abstract char getAndBitwiseOrCharAcquire(Object o, long offset, char mask)
-
getAndBitwiseAndChar
public abstract char getAndBitwiseAndChar(Object o, long offset, char mask)
-
getAndBitwiseAndCharRelease
public abstract char getAndBitwiseAndCharRelease(Object o, long offset, char mask)
-
getAndBitwiseAndCharAcquire
public abstract char getAndBitwiseAndCharAcquire(Object o, long offset, char mask)
-
getAndBitwiseXorChar
public abstract char getAndBitwiseXorChar(Object o, long offset, char mask)
-
getAndBitwiseXorCharRelease
public abstract char getAndBitwiseXorCharRelease(Object o, long offset, char mask)
-
getAndBitwiseXorCharAcquire
public abstract char getAndBitwiseXorCharAcquire(Object o, long offset, char mask)
-
getAndBitwiseOrShort
public abstract short getAndBitwiseOrShort(Object o, long offset, short mask)
-
getAndBitwiseOrShortRelease
public abstract short getAndBitwiseOrShortRelease(Object o, long offset, short mask)
-
getAndBitwiseOrShortAcquire
public abstract short getAndBitwiseOrShortAcquire(Object o, long offset, short mask)
-
getAndBitwiseAndShort
public abstract short getAndBitwiseAndShort(Object o, long offset, short mask)
-
getAndBitwiseAndShortRelease
public abstract short getAndBitwiseAndShortRelease(Object o, long offset, short mask)
-
getAndBitwiseAndShortAcquire
public abstract short getAndBitwiseAndShortAcquire(Object o, long offset, short mask)
-
getAndBitwiseXorShort
public abstract short getAndBitwiseXorShort(Object o, long offset, short mask)
-
getAndBitwiseXorShortRelease
public abstract short getAndBitwiseXorShortRelease(Object o, long offset, short mask)
-
getAndBitwiseXorShortAcquire
public abstract short getAndBitwiseXorShortAcquire(Object o, long offset, short mask)
-
getAndBitwiseOrInt
public abstract int getAndBitwiseOrInt(Object o, long offset, int mask)
-
getAndBitwiseOrIntRelease
public abstract int getAndBitwiseOrIntRelease(Object o, long offset, int mask)
-
getAndBitwiseOrIntAcquire
public abstract int getAndBitwiseOrIntAcquire(Object o, long offset, int mask)
-
getAndBitwiseAndInt
public abstract int getAndBitwiseAndInt(Object o, long offset, int mask)
Atomically replaces the current value of a field or array element within the given object with the result of bitwise AND between the current value and mask.- 参数:
o
- object/array to update the field/element inoffset
- field/element offsetmask
- the mask value- 返回:
- the previous value
- 从以下版本开始:
- 9
-
getAndBitwiseAndIntRelease
public abstract int getAndBitwiseAndIntRelease(Object o, long offset, int mask)
-
getAndBitwiseAndIntAcquire
public abstract int getAndBitwiseAndIntAcquire(Object o, long offset, int mask)
-
getAndBitwiseXorInt
public abstract int getAndBitwiseXorInt(Object o, long offset, int mask)
-
getAndBitwiseXorIntRelease
public abstract int getAndBitwiseXorIntRelease(Object o, long offset, int mask)
-
getAndBitwiseXorIntAcquire
public abstract int getAndBitwiseXorIntAcquire(Object o, long offset, int mask)
-
getAndBitwiseOrLong
public abstract long getAndBitwiseOrLong(Object o, long offset, long mask)
-
getAndBitwiseOrLongRelease
public abstract long getAndBitwiseOrLongRelease(Object o, long offset, long mask)
-
getAndBitwiseOrLongAcquire
public abstract long getAndBitwiseOrLongAcquire(Object o, long offset, long mask)
-
getAndBitwiseAndLong
public abstract long getAndBitwiseAndLong(Object o, long offset, long mask)
-
getAndBitwiseAndLongRelease
public abstract long getAndBitwiseAndLongRelease(Object o, long offset, long mask)
-
getAndBitwiseAndLongAcquire
public abstract long getAndBitwiseAndLongAcquire(Object o, long offset, long mask)
-
getAndBitwiseXorLong
public abstract long getAndBitwiseXorLong(Object o, long offset, long mask)
-
getAndBitwiseXorLongRelease
public abstract long getAndBitwiseXorLongRelease(Object o, long offset, long mask)
-
getAndBitwiseXorLongAcquire
public abstract long getAndBitwiseXorLongAcquire(Object o, long offset, long mask)
-
loadFence
public abstract void loadFence()
Ensures that loads before the fence will not be reordered with loads and stores after the fence; a "LoadLoad plus LoadStore barrier".Corresponds to C11 atomic_thread_fence(memory_order_acquire) (an "acquire fence").
A pure LoadLoad fence is not provided, since the addition of LoadStore is almost always desired, and most current hardware instructions that provide a LoadLoad barrier also provide a LoadStore barrier for free.
- 从以下版本开始:
- 1.8
-
storeFence
public abstract void storeFence()
Ensures that loads and stores before the fence will not be reordered with stores after the fence; a "StoreStore plus LoadStore barrier".Corresponds to C11 atomic_thread_fence(memory_order_release) (a "release fence").
A pure StoreStore fence is not provided, since the addition of LoadStore is almost always desired, and most current hardware instructions that provide a StoreStore barrier also provide a LoadStore barrier for free.
- 从以下版本开始:
- 1.8
-
fullFence
public abstract void fullFence()
Ensures that loads and stores before the fence will not be reordered with loads and stores after the fence. Implies the effects of both loadFence() and storeFence(), and in addition, the effect of a StoreLoad barrier.Corresponds to C11 atomic_thread_fence(memory_order_seq_cst).
- 从以下版本开始:
- 1.8
-
loadLoadFence
public abstract void loadLoadFence()
Ensures that loads before the fence will not be reordered with loads after the fence.
-
storeStoreFence
public abstract void storeStoreFence()
Ensures that stores before the fence will not be reordered with stores after the fence.
-
isBigEndian
public abstract boolean isBigEndian()
- 返回:
- Returns true if the abstract byte ordering of this platform is big-endian, false if it is little-endian.
-
unalignedAccess
public abstract boolean unalignedAccess()
- 返回:
- Returns true if this platform is capable of performing accesses at addresses which are not aligned for the type of the primitive type being accessed, false otherwise.
-
getLongUnaligned
@Contract(pure=true) public abstract long getLongUnaligned(Object o, long offset)
Fetches a value at some byte offset into a given Java object. More specifically, fetches a value within the given objecto
at the given offset, or (ifo
is null) from the memory address whose numerical value is the given offset.The specification of this method is the same as
getLong(Object, long)
except that the offset does not need to have been obtained fromobjectFieldOffset(java.lang.reflect.Field)
on theField
of some Java field. The value in memory is raw data, and need not correspond to any Java variable. Unlesso
is null, the value accessed must be entirely within the allocated object. The endianness of the value in memory is the endianness of the abstract platform.The read will be atomic with respect to the largest power of two that divides the GCD of the offset and the storage size. For example, getLongUnaligned will make atomic reads of 2-, 4-, or 8-byte storage units if the offset is zero mod 2, 4, or 8, respectively. There are no other guarantees of atomicity.
8-byte atomicity is only guaranteed on platforms on which support atomic accesses to longs.
- 参数:
o
- Java heap object in which the value resides, if any, else nulloffset
- The offset in bytes from the start of the object- 返回:
- the value fetched from the indicated object
- 抛出:
RuntimeException
- No defined exceptions are thrown, not evenNullPointerException
- 从以下版本开始:
- 9
-
getLongUnaligned
@Contract(pure=true) public abstract long getLongUnaligned(Object o, long offset, boolean bigEndian)
AsgetLongUnaligned(Object, long)
but with an additional argument which specifies the endianness of the value as stored in memory.- 参数:
o
- Java heap object in which the variable residesoffset
- The offset in bytes from the start of the objectbigEndian
- The endianness of the value- 返回:
- the value fetched from the indicated object
- 从以下版本开始:
- 9
-
getIntUnaligned
@Contract(pure=true) public abstract int getIntUnaligned(Object o, long offset)
-
getIntUnaligned
@Contract(pure=true) public abstract int getIntUnaligned(Object o, long offset, boolean bigEndian)
-
getShortUnaligned
@Contract(pure=true) public abstract short getShortUnaligned(Object o, long offset)
-
getShortUnaligned
@Contract(pure=true) public abstract short getShortUnaligned(Object o, long offset, boolean bigEndian)
-
getCharUnaligned
@Contract(pure=true) public abstract char getCharUnaligned(Object o, long offset)
-
getCharUnaligned
@Contract(pure=true) public abstract char getCharUnaligned(Object o, long offset, boolean bigEndian)
-
putLongUnaligned
public abstract void putLongUnaligned(Object o, long offset, long x)
Stores a value at some byte offset into a given Java object.The specification of this method is the same as
getLong(Object, long)
except that the offset does not need to have been obtained fromobjectFieldOffset(java.lang.reflect.Field)
on theField
of some Java field. The value in memory is raw data, and need not correspond to any Java variable. The endianness of the value in memory is the endianness of the abstract platform.The write will be atomic with respect to the largest power of two that divides the GCD of the offset and the storage size. For example, putLongUnaligned will make atomic writes of 2-, 4-, or 8-byte storage units if the offset is zero mod 2, 4, or 8, respectively. There are no other guarantees of atomicity.
8-byte atomicity is only guaranteed on platforms on which support atomic accesses to longs.
- 参数:
o
- Java heap object in which the value resides, if any, else nulloffset
- The offset in bytes from the start of the objectx
- the value to store- 抛出:
RuntimeException
- No defined exceptions are thrown, not evenNullPointerException
- 从以下版本开始:
- 9
-
putLongUnaligned
public abstract void putLongUnaligned(Object o, long offset, long x, boolean bigEndian)
AsputLongUnaligned(Object, long, long)
but with an additional argument which specifies the endianness of the value as stored in memory.- 参数:
o
- Java heap object in which the value residesoffset
- The offset in bytes from the start of the objectx
- the value to storebigEndian
- The endianness of the value- 抛出:
RuntimeException
- No defined exceptions are thrown, not evenNullPointerException
- 从以下版本开始:
- 9
-
putIntUnaligned
public abstract void putIntUnaligned(Object o, long offset, int x)
-
putIntUnaligned
public abstract void putIntUnaligned(Object o, long offset, int x, boolean bigEndian)
-
putShortUnaligned
public abstract void putShortUnaligned(Object o, long offset, short x)
-
putShortUnaligned
public abstract void putShortUnaligned(Object o, long offset, short x, boolean bigEndian)
-
putCharUnaligned
public abstract void putCharUnaligned(Object o, long offset, char x)
-
putCharUnaligned
public abstract void putCharUnaligned(Object o, long offset, char x, boolean bigEndian)
-
invokeCleaner
public abstract void invokeCleaner(ByteBuffer directBuffer)
Invokes the given direct byte buffer's cleaner, if any.- 参数:
directBuffer
- a direct byte buffer- 抛出:
NullPointerException
- ifdirectBuffer
is nullIllegalArgumentException
- ifdirectBuffer
is non-direct, or is aslice
, or is aduplicate
-
-