Class GridUnsafe
java.lang.Object
org.apache.ignite.shaded.internal.util.GridUnsafe
Wrapper for Unsafe class.
The following statements for memory access operations are true:
- All
putXxx(long addr, xxx val),getXxx(long addr),putXxx(byte[] arr, long off, xxx val),getXxx(byte[] arr, long off)and corresponding methods withLEsuffix are alignment aware and can be safely used with unaligned pointers. - All
putXxxField(Object obj, long fieldOff, xxx val)andgetXxxField(Object obj, long fieldOff)methods are not alignment aware and can't be safely used with unaligned pointers. This methods can be safely used for object field values access because all object fields addresses are aligned. - All
putXxxLE(...)andgetXxxLE(...)methods assumes that byte order is fixed as little-endian while native byte order is big-endian. So it is client code responsibility to check native byte order before invoking of this methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAddress size.static final booleanBig endian.static final longstatic final intstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final ByteOrderstatic final long -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferallocateBuffer(int len) static ObjectallocateInstance(Class cls) Allocates instance of given class.static longallocateMemory(long size) Allocates memory.static intarrayBaseOffset(Class cls) Returns the offset of the first element in the storage allocation of a given array class.static intarrayIndexScale(Class<?> cls) Returns the scale factor for addressing elements in the storage allocation of a given array class.static longbufferAddress(ByteBuffer buf) Returns address ofBufferinstance.static voidCleans directjava.nio.ByteBufferstatic booleancompareAndSwapInt(Object obj, long off, int exp, int upd) Integer CAS.static booleancompareAndSwapLong(Object obj, long off, long exp, long upd) Long CAS.static voidcopyHeapOffheap(Object srcBase, long srcOff, long dstAddr, long len) Copy memory from heap to offheap.static voidcopyMemory(long src, long dst, long len) Copies memory.static voidcopyMemory(Object srcBase, long srcOff, Object dstBase, long dstOff, long len) Sets all bytes in a given block of memory to a copy of another block.static voidcopyOffheapHeap(long srcAddr, Object dstBase, long dstOff, long len) Copy memory from offheap to heap.static voidcopyOffheapOffheap(long srcAddr, long dstAddr, long len) Copy memory between offheap locations.static intdecrementAndGetInt(long ptr) Atomically increments value stored in an integer pointed byptr.static voidfreeBuffer(ByteBuffer buf) static voidfreeMemory(long addr) Frees memory.static booleangetBoolean(byte[] arr, long off) Gets boolean value from byte array.static booleangetBooleanField(Object obj, long fieldOff) Gets boolean value from object field.static bytegetByte(byte[] arr, long off) Gets byte value from byte array.static bytegetByte(long addr) Gets byte value from given address.static bytegetByteField(Object obj, long fieldOff) Gets byte value from object field.static bytegetByteVolatile(Object obj, long off) Gets byte value with volatile semantic.static chargetChar(byte[] arr, long off) Gets char value from byte array.static chargetChar(long addr) Gets char value from given address.static chargetCharField(Object obj, long fieldOff) Gets char value from object field.static chargetCharLE(byte[] arr, long off) Gets char value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian.static chargetCharLE(long addr) Gets char value from given address assuming that value stored in little-endian byte order and native byte order is big-endian.static doublegetDouble(byte[] arr, long off) Gets double value from byte array.static doublegetDouble(long addr) Gets double value from given address.static doublegetDoubleField(Object obj, long fieldOff) Gets double value from object field.static doublegetDoubleLE(byte[] arr, long off) Gets double value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian.static doublegetDoubleLE(long addr) Gets double value from given address assuming that value stored in little-endian byte order and native byte order is big-endian.static floatgetFloat(byte[] arr, long off) Gets float value from byte array.static floatgetFloat(long addr) Gets float value from given address.static floatgetFloatField(Object obj, long fieldOff) Gets float value from object field.static floatgetFloatLE(byte[] arr, long off) Gets float value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian.static floatgetFloatLE(long addr) Gets float value from given address assuming that value stored in little-endian byte order and native byte order is big-endian.static intgetInt(byte[] arr, long off) Gets integer value from byte array.static intgetInt(long addr) Gets integer value from given address.static intgetIntField(Object obj, long fieldOff) Gets integer value from object field.static intgetIntLE(byte[] arr, long off) Gets integer value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian.static intgetIntLE(long addr) Gets integer value from given address assuming that value stored in little-endian byte order and native byte order is big-endian.static intgetIntVolatile(Object obj, long off) Gets integer value with volatile semantic.static longgetLong(byte[] arr, long off) Gets long value from byte array.static longgetLong(long addr) Gets long value from given address.static longgetLongField(Object obj, long fieldOff) Gets long value from object field.static longgetLongLE(byte[] arr, long off) Gets long value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian.static longgetLongLE(long addr) Gets long value from given address assuming that value stored in little-endian byte order and native byte order is big-endian.static longgetLongVolatile(Object obj, long off) Gets long value with volatile semantic.static ObjectgetObjectField(Object obj, long fieldOff) Gets reference from object field.static shortgetShort(byte[] arr, long off) Gets short value from byte array.static shortgetShort(long addr) Gets short value from given address.static shortgetShortField(Object obj, long fieldOff) Gets short value from object field.static shortgetShortLE(byte[] arr, long off) Gets short value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian.static shortgetShortLE(long addr) Gets short value from given address assuming that value stored in little-endian byte order and native byte order is big-endian.static intincrementAndGetInt(long ptr) Atomically increments value stored in an integer pointed byptr.static ObjectInvokes some method onsun.misc.Unsafeinstance.static longobjectFieldOffset(Field field) Returns object field offset.static intpageSize()Returns page size.static voidputBoolean(byte[] arr, long off, boolean val) Stores boolean value into byte array.static voidputBooleanField(Object obj, long fieldOff, boolean val) Stores boolean value into object field.static voidputByte(byte[] arr, long off, byte val) Stores byte value into byte array.static voidputByte(long addr, byte val) Stores given byte value.static voidputByteField(Object obj, long fieldOff, byte val) Stores byte value into object field.static voidputByteVolatile(Object obj, long off, byte val) Stores byte value with volatile semantic.static voidputChar(byte[] arr, long off, char val) Stores char value into byte array.static voidputChar(long addr, char val) Stores given char value.static voidputCharField(Object obj, long fieldOff, char val) Stores char value into object field.static voidputCharLE(byte[] arr, long off, char val) Stores char value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputCharLE(long addr, char val) Stores given char value assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputDouble(byte[] arr, long off, double val) Stores double value into byte array.static voidputDouble(long addr, double val) Stores given double value.static voidputDoubleField(Object obj, long fieldOff, double val) Stores double value into object field.static voidputDoubleLE(byte[] arr, long off, double val) Stores double value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputDoubleLE(long addr, double val) Stores given double value assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputFloat(byte[] arr, long off, float val) Stores float value into byte array.static voidputFloat(long addr, float val) Stores given float value.static voidputFloatField(Object obj, long fieldOff, float val) Stores float value into object field.static voidputFloatLE(byte[] arr, long off, float val) Stores float value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputFloatLE(long addr, float val) Stores given float value assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputInt(byte[] arr, long off, int val) Stores integer value into byte array.static voidputInt(long addr, int val) Stores given integer value.static voidputIntField(Object obj, long fieldOff, int val) Stores integer value into object field.static voidputIntLE(byte[] arr, long off, int val) Stores integer value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputIntLE(long addr, int val) Stores given integer value assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputIntVolatile(Object obj, long off, int val) Stores integer value with volatile semantic.static voidputLong(byte[] arr, long off, long val) Stores long value into byte array.static voidputLong(long addr, long val) Stores given integer value.static voidputLongField(Object obj, long fieldOff, long val) Stores long value into object field.static voidputLongLE(byte[] arr, long off, long val) Stores long value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputLongLE(long addr, long val) Stores given integer value assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputLongVolatile(Object obj, long off, long val) Stores long value with volatile semantic.static voidputObjectField(Object obj, long fieldOff, Object val) Stores reference value into object field.static voidputObjectVolatile(Object obj, long off, Object val) Stores reference value with volatile semantic.static voidputShort(byte[] arr, long off, short val) Stores short value into byte array.static voidputShort(long addr, short val) Stores given short value.static voidputShortField(Object obj, long fieldOff, short val) Stores short value into object field.static voidputShortLE(byte[] arr, long off, short val) Stores short value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian.static voidputShortLE(long addr, short val) Stores given short value assuming that value should be stored in little-endian byte order and native byte order is big-endian.static ByteBufferreallocateBuffer(ByteBuffer buf, int len) static longreallocateMemory(long addr, long len) Reallocates memory.static voidsetMemory(long addr, long len, byte val) Fills memory with given value.static ObjectstaticFieldBase(Field field) Returns static field base.static longstaticFieldOffset(Field field) Returns static field offset.static ByteBufferwrapPointer(long ptr, int len) Wraps pointer to unmanaged memory into direct byte buffer.static voidzeroMemory(long addr, long len) Fills memory with zeroes.
-
Field Details
-
NATIVE_BYTE_ORDER
-
DFLT_MEMORY_PER_BYTE_COPY_THRESHOLD
public static final long DFLT_MEMORY_PER_BYTE_COPY_THRESHOLD- See Also:
-
IgniteSystemProperties.IGNITE_MEMORY_PER_BYTE_COPY_THRESHOLD- Constant Field Values
-
BIG_ENDIAN
public static final boolean BIG_ENDIANBig endian. -
ADDR_SIZE
public static final int ADDR_SIZEAddress size. -
BYTE_ARR_OFF
public static final long BYTE_ARR_OFF -
BYTE_ARR_INT_OFF
public static final int BYTE_ARR_INT_OFF -
SHORT_ARR_OFF
public static final long SHORT_ARR_OFF -
INT_ARR_OFF
public static final long INT_ARR_OFF -
LONG_ARR_OFF
public static final long LONG_ARR_OFF -
FLOAT_ARR_OFF
public static final long FLOAT_ARR_OFF -
DOUBLE_ARR_OFF
public static final long DOUBLE_ARR_OFF -
CHAR_ARR_OFF
public static final long CHAR_ARR_OFF -
BOOLEAN_ARR_OFF
public static final long BOOLEAN_ARR_OFF
-
-
Method Details
-
wrapPointer
Wraps pointer to unmanaged memory into direct byte buffer.- Parameters:
ptr- Pointer to wrap.len- Memory location length.- Returns:
- Byte buffer wrapping the given memory.
-
allocateBuffer
- Parameters:
len- Length.- Returns:
- Allocated direct buffer.
-
freeBuffer
- Parameters:
buf- Direct buffer allocated byallocateBuffer(int).
-
reallocateBuffer
- Parameters:
buf- Buffer.len- New length.- Returns:
- Reallocated direct buffer.
-
getBooleanField
Gets boolean value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Boolean value from object field.
-
putBooleanField
Stores boolean value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getByteField
Gets byte value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Byte value from object field.
-
putByteField
Stores byte value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getShortField
Gets short value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Short value from object field.
-
putShortField
Stores short value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getCharField
Gets char value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Char value from object field.
-
putCharField
Stores char value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getIntField
Gets integer value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Integer value from object field.
-
putIntField
Stores integer value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getLongField
Gets long value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Long value from object field.
-
putLongField
Stores long value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getFloatField
Gets float value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Float value from object field.
-
putFloatField
Stores float value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getDoubleField
Gets double value from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Double value from object field.
-
putDoubleField
Stores double value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getObjectField
Gets reference from object field.- Parameters:
obj- Object.fieldOff- Field offset.- Returns:
- Reference from object field.
-
putObjectField
Stores reference value into object field.- Parameters:
obj- Object.fieldOff- Field offset.val- Value.
-
getBoolean
public static boolean getBoolean(byte[] arr, long off) Gets boolean value from byte array.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Boolean value from byte array.
-
putBoolean
public static void putBoolean(byte[] arr, long off, boolean val) Stores boolean value into byte array.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getByte
public static byte getByte(byte[] arr, long off) Gets byte value from byte array.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Byte value from byte array.
-
putByte
public static void putByte(byte[] arr, long off, byte val) Stores byte value into byte array.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getShort
public static short getShort(byte[] arr, long off) Gets short value from byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Short value from byte array.
-
putShort
public static void putShort(byte[] arr, long off, short val) Stores short value into byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getChar
public static char getChar(byte[] arr, long off) Gets char value from byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Char value from byte array.
-
putChar
public static void putChar(byte[] arr, long off, char val) Stores char value into byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getInt
public static int getInt(byte[] arr, long off) Gets integer value from byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Integer value from byte array.
-
putInt
public static void putInt(byte[] arr, long off, int val) Stores integer value into byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getLong
public static long getLong(byte[] arr, long off) Gets long value from byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Long value from byte array.
-
putLong
public static void putLong(byte[] arr, long off, long val) Stores long value into byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getFloat
public static float getFloat(byte[] arr, long off) Gets float value from byte array. Alignment aware.- Parameters:
arr- Object.off- Offset.- Returns:
- Float value from byte array.
-
putFloat
public static void putFloat(byte[] arr, long off, float val) Stores float value into byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getDouble
public static double getDouble(byte[] arr, long off) Gets double value from byte array. Alignment aware.- Parameters:
arr- byte array.off- Offset.- Returns:
- Double value from byte array. Alignment aware.
-
putDouble
public static void putDouble(byte[] arr, long off, double val) Stores double value into byte array. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getShortLE
public static short getShortLE(byte[] arr, long off) Gets short value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Short value from byte array.
-
putShortLE
public static void putShortLE(byte[] arr, long off, short val) Stores short value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getCharLE
public static char getCharLE(byte[] arr, long off) Gets char value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Char value from byte array.
-
putCharLE
public static void putCharLE(byte[] arr, long off, char val) Stores char value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getIntLE
public static int getIntLE(byte[] arr, long off) Gets integer value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Integer value from byte array.
-
putIntLE
public static void putIntLE(byte[] arr, long off, int val) Stores integer value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getLongLE
public static long getLongLE(byte[] arr, long off) Gets long value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Long value from byte array.
-
putLongLE
public static void putLongLE(byte[] arr, long off, long val) Stores long value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getFloatLE
public static float getFloatLE(byte[] arr, long off) Gets float value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Float value from byte array.
-
putFloatLE
public static void putFloatLE(byte[] arr, long off, float val) Stores float value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getDoubleLE
public static double getDoubleLE(byte[] arr, long off) Gets double value from byte array assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.- Returns:
- Double value from byte array.
-
putDoubleLE
public static void putDoubleLE(byte[] arr, long off, double val) Stores double value into byte array assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
arr- Byte array.off- Offset.val- Value.
-
getByte
public static byte getByte(long addr) Gets byte value from given address.- Parameters:
addr- Address.- Returns:
- Byte value from given address.
-
putByte
public static void putByte(long addr, byte val) Stores given byte value.- Parameters:
addr- Address.val- Value.
-
getShort
public static short getShort(long addr) Gets short value from given address. Alignment aware.- Parameters:
addr- Address.- Returns:
- Short value from given address.
-
putShort
public static void putShort(long addr, short val) Stores given short value. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getChar
public static char getChar(long addr) Gets char value from given address. Alignment aware.- Parameters:
addr- Address.- Returns:
- Char value from given address.
-
putChar
public static void putChar(long addr, char val) Stores given char value. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getInt
public static int getInt(long addr) Gets integer value from given address. Alignment aware.- Parameters:
addr- Address.- Returns:
- Integer value from given address.
-
putInt
public static void putInt(long addr, int val) Stores given integer value. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getLong
public static long getLong(long addr) Gets long value from given address. Alignment aware.- Parameters:
addr- Address.- Returns:
- Long value from given address.
-
putLong
public static void putLong(long addr, long val) Stores given integer value. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getFloat
public static float getFloat(long addr) Gets float value from given address. Alignment aware.- Parameters:
addr- Address.- Returns:
- Float value from given address.
-
putFloat
public static void putFloat(long addr, float val) Stores given float value. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getDouble
public static double getDouble(long addr) Gets double value from given address. Alignment aware.- Parameters:
addr- Address.- Returns:
- Double value from given address.
-
putDouble
public static void putDouble(long addr, double val) Stores given double value. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getShortLE
public static short getShortLE(long addr) Gets short value from given address assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.- Returns:
- Short value from given address.
-
putShortLE
public static void putShortLE(long addr, short val) Stores given short value assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getCharLE
public static char getCharLE(long addr) Gets char value from given address assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.- Returns:
- Char value from given address.
-
putCharLE
public static void putCharLE(long addr, char val) Stores given char value assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getIntLE
public static int getIntLE(long addr) Gets integer value from given address assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.- Returns:
- Integer value from given address.
-
putIntLE
public static void putIntLE(long addr, int val) Stores given integer value assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getLongLE
public static long getLongLE(long addr) Gets long value from given address assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.- Returns:
- Long value from given address.
-
putLongLE
public static void putLongLE(long addr, long val) Stores given integer value assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getFloatLE
public static float getFloatLE(long addr) Gets float value from given address assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.- Returns:
- Float value from given address.
-
putFloatLE
public static void putFloatLE(long addr, float val) Stores given float value assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.val- Value.
-
getDoubleLE
public static double getDoubleLE(long addr) Gets double value from given address assuming that value stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.- Returns:
- Double value from given address.
-
putDoubleLE
public static void putDoubleLE(long addr, double val) Stores given double value assuming that value should be stored in little-endian byte order and native byte order is big-endian. Alignment aware.- Parameters:
addr- Address.val- Value.
-
staticFieldOffset
Returns static field offset.- Parameters:
field- Field.- Returns:
- Static field offset.
-
objectFieldOffset
Returns object field offset.- Parameters:
field- Field.- Returns:
- Object field offset.
-
staticFieldBase
Returns static field base.- Parameters:
field- Field.- Returns:
- Static field base.
-
allocateMemory
public static long allocateMemory(long size) Allocates memory.- Parameters:
size- Size.- Returns:
- address.
-
reallocateMemory
public static long reallocateMemory(long addr, long len) Reallocates memory.- Parameters:
addr- Address.len- Length.- Returns:
- address.
-
setMemory
public static void setMemory(long addr, long len, byte val) Fills memory with given value.- Parameters:
addr- Address.len- Length.val- Value.
-
zeroMemory
public static void zeroMemory(long addr, long len) Fills memory with zeroes.- Parameters:
addr- Address.len- Length.
-
copyOffheapOffheap
public static void copyOffheapOffheap(long srcAddr, long dstAddr, long len) Copy memory between offheap locations.- Parameters:
srcAddr- Source address.dstAddr- Destination address.len- Length.
-
copyOffheapHeap
Copy memory from offheap to heap.- Parameters:
srcAddr- Source address.dstBase- Destination base.dstOff- Destination offset.len- Length.
-
copyHeapOffheap
Copy memory from heap to offheap.- Parameters:
srcBase- Source base.srcOff- Source offset.dstAddr- Destination address.len- Length.
-
copyMemory
public static void copyMemory(long src, long dst, long len) Copies memory.- Parameters:
src- Source.dst- Dst.len- Length.
-
copyMemory
Sets all bytes in a given block of memory to a copy of another block.- Parameters:
srcBase- Source base.srcOff- Source offset.dstBase- Dst base.dstOff- Dst offset.len- Length.
-
freeMemory
public static void freeMemory(long addr) Frees memory.- Parameters:
addr- Address.
-
arrayBaseOffset
Returns the offset of the first element in the storage allocation of a given array class.- Parameters:
cls- Class.- Returns:
- the offset of the first element in the storage allocation of a given array class.
-
arrayIndexScale
Returns the scale factor for addressing elements in the storage allocation of a given array class.- Parameters:
cls- Class.- Returns:
- the scale factor for addressing elements in the storage allocation of a given array class.
-
allocateInstance
Allocates instance of given class.- Parameters:
cls- Class.- Returns:
- Allocated instance.
- Throws:
InstantiationException
-
compareAndSwapInt
Integer CAS.- Parameters:
obj- Object.off- Offset.exp- Expected.upd- Upd.- Returns:
Trueif operation completed successfully,false- otherwise.
-
compareAndSwapLong
Long CAS.- Parameters:
obj- Object.off- Offset.exp- Expected.upd- Upd.- Returns:
Trueif operation completed successfully,false- otherwise.
-
incrementAndGetInt
public static int incrementAndGetInt(long ptr) Atomically increments value stored in an integer pointed byptr.- Parameters:
ptr- Pointer to an integer.- Returns:
- Updated value.
-
decrementAndGetInt
public static int decrementAndGetInt(long ptr) Atomically increments value stored in an integer pointed byptr.- Parameters:
ptr- Pointer to an integer.- Returns:
- Updated value.
-
getByteVolatile
Gets byte value with volatile semantic.- Parameters:
obj- Object.off- Offset.- Returns:
- Byte value.
-
putByteVolatile
Stores byte value with volatile semantic.- Parameters:
obj- Object.off- Offset.val- Value.
-
getIntVolatile
Gets integer value with volatile semantic.- Parameters:
obj- Object.off- Offset.- Returns:
- Integer value.
-
putIntVolatile
Stores integer value with volatile semantic.- Parameters:
obj- Object.off- Offset.val- Value.
-
getLongVolatile
Gets long value with volatile semantic.- Parameters:
obj- Object.off- Offset.- Returns:
- Long value.
-
putLongVolatile
Stores long value with volatile semantic.- Parameters:
obj- Object.off- Offset.val- Value.
-
putObjectVolatile
Stores reference value with volatile semantic.- Parameters:
obj- Object.off- Offset.val- Value.
-
pageSize
public static int pageSize()Returns page size.- Returns:
- Page size.
-
bufferAddress
Returns address ofBufferinstance.- Parameters:
buf- Buffer.- Returns:
- Buffer memory address.
-
invoke
Invokes some method onsun.misc.Unsafeinstance.- Parameters:
mtd- Method.args- Arguments.
-
cleanDirectBuffer
Cleans directjava.nio.ByteBuffer- Parameters:
buf- Direct buffer.
-