| Modifier and Type | Field and Description |
|---|---|
static UnsafeMemory |
INSTANCE
Singleton instance of UnsafeMemory for use in memory operations.
|
static boolean |
IS_LITTLE_ENDIAN |
static UnsafeMemory |
MEMORY |
static @NotNull sun.misc.Unsafe |
UNSAFE
A constant for the Unsafe object.
|
| Constructor and Description |
|---|
UnsafeMemory()
Creates a new instance of UnsafeMemory.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addInt(long address,
int increment)
Atomically adds the given increment to an integer value at the specified memory address.
|
int |
addInt(Object object,
long offset,
int increment)
Atomically adds the given increment to an integer value at the specified offset in the given object.
|
long |
addLong(long address,
long increment)
Atomically adds the given increment to a long value at the specified memory address.
|
long |
addLong(Object object,
long offset,
long increment)
Atomically adds the given increment to a long value at the specified offset in the given object.
|
long |
address(ByteBuffer bb)
Returns the address of the ByteBuffer's backing data.
|
long |
allocate(long capacity)
Allocates a block of native memory of the given capacity.
|
<E> E |
allocateInstance(Class<? extends E> clazz)
Allocates an instance of the provided class without invoking its constructor.
|
int |
arrayBaseOffset(Class<?> type)
Returns the array base offset for the given type.
|
boolean |
compareAndSwapInt(long address,
int expected,
int value)
Performs an atomic compare-and-swap operation on an integer value at the specified memory address.
|
boolean |
compareAndSwapInt(Object object,
long offset,
int expected,
int value)
Performs an atomic compare-and-swap operation on an integer field of the specified object.
|
boolean |
compareAndSwapLong(long address,
long expected,
long value)
Performs an atomic compare-and-swap operation on a long value at the specified memory address.
|
boolean |
compareAndSwapLong(Object object,
long offset,
long expected,
long value)
Performs an atomic compare-and-swap operation on a long field of the specified object.
|
void |
copy8bit(String s,
int start,
int length,
long addr)
Copies an 8-bit representation of the specified substring of the given string into memory at the specified address.
|
void |
copyMemory(byte[] src,
int srcOffset,
byte[] dest,
int destOffset,
int length)
Copies memory from one byte array to another.
|
void |
copyMemory(byte[] src,
int srcOffset,
long destAddress,
int length)
Copies memory from a byte array to a given memory address.
|
static void |
copyMemory(long from,
long to,
int length)
Copies memory from one address to another.
|
void |
copyMemory(long srcAddress,
long destAddress,
long length)
Copies memory from a given memory address to another.
|
void |
copyMemory(long srcAddress,
@Nullable Object dest,
long destOffset,
int length)
Copies memory from a given memory address to an object.
|
void |
copyMemory(@Nullable Object src,
long srcOffset,
long destAddress,
int length)
Copies memory from an object to a given memory address.
|
void |
copyMemory(@Nullable Object src,
long srcOffset,
@Nullable Object dest,
long destOffset,
int length)
Copies memory from one object to another.
|
void |
freeMemory(long address,
long size)
Releases the specified amount of memory starting from the given address.
|
int |
getAndSetInt(long address,
int value)
Performs an atomic get-and-set operation on an integer value at the specified memory address.
|
int |
getAndSetInt(Object object,
long offset,
int value)
Performs an atomic get-and-set operation on an integer field of the specified object.
|
long |
getFieldOffset(Field field)
Retrieves the offset of the provided field within its class or interface.
|
<T> T |
getObject(@NotNull Object object,
long offset)
Fetches an object of type
T from the given object at the specified offset. |
boolean |
is7Bit(byte[] bytes,
int offset,
int length)
Checks if a range of bytes in the provided byte array contains only 7-bit ASCII characters.
|
boolean |
is7Bit(char[] chars,
int offset,
int length)
Checks if a range of characters in the provided character array contains only 7-bit ASCII characters.
|
boolean |
is7Bit(long address,
int length)
Checks if a range of bytes in the memory starting from the provided address contains only 7-bit ASCII characters.
|
boolean |
isEqual(long addr,
String s,
int length)
Compares the substring of the given string with the string represented in the memory at the specified address.
|
void |
loadFence()
Ensures that all reads made by the current thread are visible to other threads.
|
long |
nativeMemoryUsed()
Retrieves the total amount of native memory used by the application.
|
long |
objectFieldOffset(Field field)
Returns the offset of the field represented by the given Field object.
|
int |
pageSize()
Returns the memory page size.
|
long |
partialRead(byte[] bytes,
int offset,
int length)
Reads a portion of the given byte array starting from a given offset for a specified length.
|
long |
partialRead(long addr,
int length)
Reads a portion of memory from a given address for a specified length.
|
void |
partialWrite(byte[] bytes,
int offset,
long value,
int length)
Writes a long value to a portion of the given byte array starting from a given offset for a specified length.
|
void |
partialWrite(long addr,
long value,
int length)
Writes a long value to a portion of memory at a given address for a specified length.
|
static void |
putInt(byte[] bytes,
int offset,
int value)
Puts an integer value into the byte array at the specified offset.
|
void |
putObject(@NotNull Object object,
long offset,
Object value)
Puts the provided
value into the given object at the specified offset. |
byte |
readByte(long address)
Reads a byte from the given memory address.
|
byte |
readByte(Object object,
long offset)
Reads a byte from the given memory offset of an object.
|
void |
readBytes(long address,
byte[] b,
long offset,
int length)
Reads bytes from the given memory address into a byte array.
|
double |
readDouble(long address)
Reads a double value from the given memory address.
|
double |
readDouble(Object object,
long offset)
Reads a double value from the given memory offset of an object.
|
float |
readFloat(long address)
Reads a float value from the given memory address.
|
float |
readFloat(Object object,
long offset)
Reads a float value from the given memory offset of an object.
|
int |
readInt(long address)
Reads an int value from the given memory address.
|
int |
readInt(Object object,
long offset)
Reads an int value from the given memory offset of an object.
|
long |
readLong(long address)
Reads a long value from the given memory address.
|
long |
readLong(Object object,
long offset)
Reads a long value from the given memory offset of an object.
|
short |
readShort(long address)
Reads a short value from the given memory address.
|
short |
readShort(Object object,
long offset)
Reads a short value from the given memory offset of an object.
|
byte |
readVolatileByte(long address)
Reads a byte value in a volatile manner from the specified memory address.
|
byte |
readVolatileByte(Object object,
long offset)
Reads a byte value in a volatile manner from the specified object at the given offset.
|
double |
readVolatileDouble(long address)
Reads a double value in a volatile manner from the specified memory address.
|
double |
readVolatileDouble(Object object,
long offset)
Reads a double value in a volatile manner from the specified object at the given offset.
|
float |
readVolatileFloat(long address)
Reads a float value in a volatile manner from the specified memory address.
|
float |
readVolatileFloat(Object object,
long offset)
Reads a float value in a volatile manner from the specified object at the given offset.
|
int |
readVolatileInt(long address)
Reads an integer value in a volatile manner from the specified memory address.
|
int |
readVolatileInt(Object object,
long offset)
Reads an integer value in a volatile manner from the specified object at the given offset.
|
long |
readVolatileLong(long address)
Reads a long value in a volatile manner from the specified memory address.
|
long |
readVolatileLong(Object object,
long offset)
Reads a long value in a volatile manner from the specified object at the given offset.
|
short |
readVolatileShort(long address)
Reads a short value in a volatile manner from the specified memory address.
|
short |
readVolatileShort(Object object,
long offset)
Reads a short value in a volatile manner from the specified object at the given offset.
|
boolean |
safeAlignedInt(long addr)
Checks if the given address is safely aligned for an int operation.
|
boolean |
safeAlignedLong(long addr)
Checks if the given address is safely aligned for a long operation.
|
void |
setMemory(long address,
long size,
byte b)
Sets a given amount of memory, starting at the provided address, to a specified byte value.
|
void |
setMemory(Object o,
long offset,
long size,
byte b)
Sets a given amount of memory within an object, starting at the provided offset, to a specified byte value.
|
int |
stopBitLength(int i)
Calculates the stop bit length of an integer value.
|
int |
stopBitLength(long l)
Calculates the stop bit length of a long integer value.
|
void |
storeFence()
Ensures that all writes made by the current thread are visible to other threads.
|
void |
testAndSetInt(long address,
long offset,
int expected,
int value)
Performs an atomic compare-and-set operation on an integer value at the specified memory address.
|
void |
testAndSetInt(Object object,
long offset,
int expected,
int value)
Performs an atomic compare-and-set operation on an integer field of the specified object.
|
static boolean |
unsafeGetBoolean(Object obj,
long offset)
Retrieves the value of a boolean field or array element within an object at the given offset.
|
static byte |
unsafeGetByte(long address)
Fetches a byte value from the memory location at the given address.
|
static byte |
unsafeGetByte(Object obj,
long offset)
Puts the provided byte
value into the given object at the specified offset. |
static char |
unsafeGetChar(Object obj,
long offset)
Fetches a char value from the given object at the specified
offset. |
static double |
unsafeGetDouble(Object obj,
long offset)
Fetches a double value from the given object at the specified
offset. |
static float |
unsafeGetFloat(Object obj,
long offset)
Fetches a float value from the given object at the specified
offset. |
static int |
unsafeGetInt(long address)
Fetches an integer value from the memory location at the given address.
|
static int |
unsafeGetInt(Object obj,
long offset)
Fetches an int value from the given object at the specified
offset. |
static long |
unsafeGetLong(long address)
Fetches a long value from the memory location at the given address.
|
static long |
unsafeGetLong(Object obj,
long offset)
Fetches a long value from the given object at the specified
offset. |
static <T> T |
unsafeGetObject(Object obj,
long offset)
Fetches an object of type
T from the given object at the specified offset. |
static short |
unsafeGetShort(Object obj,
long offset)
Fetches a short value from the given object at the specified
offset. |
static void |
unsafeLoadFence()
Establishes a load-load and load-store barrier.
|
static long |
unsafeObjectFieldOffset(Field field)
Retrieves the offset of the provided field within its class or interface.
|
static void |
unsafePutBoolean(Object obj,
long offset,
boolean value)
Sets the value of a boolean field or array element within an object at the given offset.
|
static void |
unsafePutByte(byte[] bytes,
int offset,
byte value)
Puts the provided
value into the provided bytes array at the provided byte offset. |
static void |
unsafePutByte(long address,
byte value)
Puts the provided byte
value at the specified memory address. |
static void |
unsafePutByte(Object obj,
long offset,
byte value)
Fetches a byte value from the given object at the specified
offset. |
static void |
unsafePutChar(Object obj,
long offset,
char value)
Sets the value of a char field or array element within an object at the given offset.
|
static void |
unsafePutDouble(Object obj,
long offset,
double value)
Puts the provided double
value into the given object at the specified offset. |
static void |
unsafePutFloat(Object obj,
long offset,
float value)
Puts the provided float
value into the given object at the specified offset. |
static void |
unsafePutInt(byte[] bytes,
int offset,
int value)
Puts the provided
value into the provided bytes array at the provided byte offset. |
static void |
unsafePutInt(long address,
int value)
Puts the provided int
value at the specified memory address. |
static void |
unsafePutInt(Object obj,
long offset,
int value)
Puts the provided int
value into the given object at the specified offset. |
static void |
unsafePutLong(byte[] bytes,
int offset,
long value)
Puts the provided
value into the provided bytes array at the provided byte offset. |
static void |
unsafePutLong(long address,
long value)
Puts the provided long
value at the specified memory address. |
static void |
unsafePutLong(Object obj,
long offset,
long value)
Puts the provided long
value into the given object at the specified offset. |
static void |
unsafePutObject(Object obj,
long offset,
Object value)
Puts the provided
value into the given object at the specified offset. |
static void |
unsafePutShort(Object obj,
long offset,
short value)
Puts the provided short
value into the given object at the specified offset. |
static void |
unsafeStoreFence()
Establishes a happens-before relationship, without any corresponding guarantee of visibility.
|
void |
write8bit(String s,
int start,
Object object,
long offset,
int length)
Writes an 8-bit representation of the specified substring of the given string to the specified offset in the given object.
|
void |
writeByte(long address,
byte b)
Writes a byte to the given memory address.
|
void |
writeByte(Object object,
long offset,
byte b)
Writes a byte to the given memory offset of an object.
|
void |
writeBytes(long address,
byte[] b,
int offset,
int length)
Writes a byte array to the given memory address.
|
void |
writeDouble(long address,
double d)
Writes a double value to the given memory address.
|
void |
writeDouble(Object object,
long offset,
double d)
Writes a double value to the given memory offset of an object.
|
void |
writeFloat(long address,
float f)
Writes a float value to the given memory address.
|
void |
writeFloat(Object object,
long offset,
float f)
Writes a float value to the given memory offset of an object.
|
void |
writeInt(long address,
int i32)
Writes an int value to the given memory address.
|
void |
writeInt(Object object,
long offset,
int i32)
Writes an int value to the given memory offset of an object.
|
void |
writeLong(long address,
long i64)
Writes a long value to the given memory address.
|
void |
writeLong(Object object,
long offset,
long i64)
Writes a long value to the given memory offset of an object.
|
void |
writeOrderedInt(long address,
int i32)
Writes an int value to the given memory address ensuring the order of memory operations.
|
void |
writeOrderedInt(Object object,
long offset,
int i32)
Writes an int value to the given memory offset of an object ensuring the order of memory operations.
|
void |
writeOrderedLong(long address,
long i)
Writes a long value to the memory location specified by the address, in a way that is
guaranteed to be ordered with respect to other memory operations.
|
void |
writeOrderedLong(Object object,
long offset,
long i)
Writes a long value to the field of the specified object at the given offset, in a way that is
guaranteed to be ordered with respect to other memory operations.
|
void |
writeShort(long address,
short i16)
Writes a short value to the given memory address.
|
void |
writeShort(Object object,
long offset,
short i16)
Writes a short value to the given memory offset of an object.
|
void |
writeVolatileByte(long address,
byte b)
Writes a byte value in a volatile manner to the specified memory address.
|
void |
writeVolatileByte(Object object,
long offset,
byte b)
Writes a byte value in a volatile manner to the specified object at the given offset.
|
void |
writeVolatileDouble(long address,
double d)
Writes a double value in a volatile manner to the specified memory address.
|
void |
writeVolatileDouble(Object object,
long offset,
double d)
Writes a double value in a volatile manner to the specified object at the given offset.
|
void |
writeVolatileFloat(long address,
float f)
Writes a float value in a volatile manner to the specified memory address.
|
void |
writeVolatileFloat(Object object,
long offset,
float f)
Writes a float value in a volatile manner to the specified object at the given offset.
|
void |
writeVolatileInt(long address,
int i32)
Writes an integer value in a volatile manner to the specified memory address.
|
void |
writeVolatileInt(Object object,
long offset,
int i32)
Writes an integer value in a volatile manner to the specified object at the given offset.
|
void |
writeVolatileLong(long address,
long i64)
Writes a long value in a volatile manner to the specified memory address.
|
void |
writeVolatileLong(Object object,
long offset,
long i64)
Writes a long value in a volatile manner to the specified object at the given offset.
|
void |
writeVolatileShort(long address,
short i16)
Writes a short value in a volatile manner to the specified memory address.
|
void |
writeVolatileShort(Object object,
long offset,
short i16)
Writes a short value in a volatile manner to the specified object at the given offset.
|
@NotNull public static final @NotNull sun.misc.Unsafe UNSAFE
public static final UnsafeMemory INSTANCE
public static final UnsafeMemory MEMORY
public static final boolean IS_LITTLE_ENDIAN
public static void putInt(byte[] bytes,
int offset,
int value)
bytes - the byte array.offset - the offset at which to insert the value.value - the integer value to insert.public static void unsafeStoreFence()
Can be used to prevent reordering of instructions by the compiler or processor.
public static void unsafeLoadFence()
Can be used to prevent reordering of load instructions by the compiler or processor.
public static long unsafeGetLong(long address)
address - memory address to fetch the long value from.public static int unsafeGetInt(long address)
address - memory address to fetch the integer value from.public static byte unsafeGetByte(long address)
address - memory address to fetch the byte value from.public static void unsafePutLong(long address,
long value)
value at the specified memory address.address - memory address where the value is to be put.value - the long value to put.public static void unsafePutInt(long address,
int value)
value at the specified memory address.address - memory address where the value is to be put.value - the int value to put.public static void unsafePutByte(long address,
byte value)
value at the specified memory address.address - memory address where the value is to be put.value - the byte value to put.public static void unsafePutLong(byte[] bytes,
int offset,
long value)
value into the provided bytes array at the provided byte offset.bytes - non-null byte array.offset - in the provided bytes where the value is writtenvalue - to putpublic static void unsafePutInt(byte[] bytes,
int offset,
int value)
value into the provided bytes array at the provided byte offset.bytes - non-null byte array.offset - in the provided bytes where the value is writtenvalue - to putpublic static void unsafePutByte(byte[] bytes,
int offset,
byte value)
value into the provided bytes array at the provided byte offset.bytes - non-null byte array.offset - in the provided bytes where the value is writtenvalue - to putpublic static void copyMemory(long from,
long to,
int length)
from - the starting address to copy memory from.to - the starting address to copy memory to.length - the amount of memory to copy, in bytes.public static void unsafePutBoolean(Object obj, long offset, boolean value)
obj - the object containing the field or array element, or null for static fields.offset - the offset to the field or array element.value - the new value.public static boolean unsafeGetBoolean(Object obj, long offset)
obj - the object containing the field or array element, or null for static fields.offset - the offset to the field or array element.public static void unsafePutByte(Object obj, long offset, byte value)
offset.obj - the object containing the byte to fetch.offset - the offset to the byte within the object.public static byte unsafeGetByte(Object obj, long offset)
value into the given object at the specified offset.obj - the object in which to put the byte.offset - the offset at which to put the byte within the object.public static void unsafePutChar(Object obj, long offset, char value)
obj - the object containing the field or array element, or null for static fields.offset - the offset to the field or array element.value - the new value.public static char unsafeGetChar(Object obj, long offset)
offset.obj - the object containing the char to fetch.offset - the offset to the char within the object.public static void unsafePutShort(Object obj, long offset, short value)
value into the given object at the specified offset.obj - the object in which to put the short.offset - the offset at which to put the short within the object.value - the short value to put.public static short unsafeGetShort(Object obj, long offset)
offset.obj - the object containing the short to fetch.offset - the offset to the short within the object.public static void unsafePutInt(Object obj, long offset, int value)
value into the given object at the specified offset.obj - the object in which to put the int.offset - the offset at which to put the int within the object.value - the int value to put.public static int unsafeGetInt(Object obj, long offset)
offset.obj - the object containing the int to fetch.offset - the offset to the int within the object.public static void unsafePutFloat(Object obj, long offset, float value)
value into the given object at the specified offset.obj - the object in which to put the float.offset - the offset at which to put the float within the object.value - the float value to put.public static float unsafeGetFloat(Object obj, long offset)
offset.obj - the object containing the float to fetch.offset - the offset to the float within the object.public static void unsafePutLong(Object obj, long offset, long value)
value into the given object at the specified offset.obj - the object in which to put the long.offset - the offset at which to put the long within the object.value - the long value to put.public static long unsafeGetLong(Object obj, long offset)
offset.obj - the object containing the long to fetch.offset - the offset to the long within the object.public static void unsafePutDouble(Object obj, long offset, double value)
value into the given object at the specified offset.obj - the object in which to put the double.offset - the offset at which to put the double within the object.value - the double value to put.public static double unsafeGetDouble(Object obj, long offset)
offset.obj - the object containing the double to fetch.offset - the offset to the double within the object.public static void unsafePutObject(Object obj, long offset, Object value)
value into the given object at the specified offset.obj - the object in which to put the value.offset - the offset at which to put the value within the object.value - the value to put.public static <T> T unsafeGetObject(Object obj, long offset)
T from the given object at the specified offset.T - the type of the object to fetch.obj - the object containing the object to fetch.offset - the offset to the object within the object.public static long unsafeObjectFieldOffset(Field field)
field - the field whose offset should be fetched.@NotNull public <E> E allocateInstance(Class<? extends E> clazz) throws InstantiationException
allocateInstance in interface MemoryE - the type of the instance to allocate.clazz - the class to allocate an instance of.InstantiationException - if an instance of the class or interface represented by the specified Class object could not be instantiated.public long getFieldOffset(Field field)
getFieldOffset in interface Memoryfield - the field whose offset should be fetched.public void putObject(@NotNull
@NotNull Object object,
long offset,
Object value)
value into the given object at the specified offset.@NotNull
public <T> T getObject(@NotNull
@NotNull Object object,
long offset)
T from the given object at the specified offset.public void storeFence()
storeFence in interface Memorypublic void loadFence()
public void setMemory(long address,
long size,
byte b)
public void setMemory(Object o, long offset, long size, byte b)
public void freeMemory(long address,
long size)
freeMemory in interface Memoryaddress - the starting address.size - the amount of memory to free.public long allocate(long capacity)
allocate in interface Memorycapacity - the size of the memory block to allocate.AssertionError - if the requested capacity is not positive.OutOfMemoryError - if not enough free native memory is available.public long nativeMemoryUsed()
nativeMemoryUsed in interface Memorypublic void writeByte(long address,
byte b)
public void writeByte(Object object, long offset, byte b)
public byte readByte(Object object, long offset)
public void writeBytes(long address,
byte[] b,
int offset,
int length)
throws IllegalArgumentException
writeBytes in interface Memoryaddress - the memory address.b - the byte array to be written.offset - the starting offset in the byte array.length - the number of bytes to write.IllegalArgumentException - if offset + length exceeds the byte array's length.public void readBytes(long address,
byte[] b,
long offset,
int length)
throws IllegalArgumentException
readBytes in interface Memoryaddress - the memory address.b - the byte array to be filled.offset - the starting offset in the byte array.length - the number of bytes to read.IllegalArgumentException - if offset + length exceeds the byte array's length.public byte readByte(long address)
public void writeShort(long address,
short i16)
writeShort in interface Memoryaddress - the memory address.i16 - the short value to be written.public void writeShort(Object object, long offset, short i16)
writeShort in interface Memoryobject - the object containing the memory to write to.offset - the offset in the object's memory.i16 - the short value to be written.public short readShort(long address)
public short readShort(Object object, long offset)
public void writeInt(long address,
int i32)
public void writeInt(Object object, long offset, int i32)
public void writeOrderedInt(long address,
int i32)
writeOrderedInt in interface Memoryaddress - the memory address.i32 - the int value to be written.public void writeOrderedInt(Object object, long offset, int i32)
writeOrderedInt in interface Memoryobject - the object containing the memory to write to.offset - the offset in the object's memory.i32 - the int value to be written.public int readInt(long address)
public int readInt(Object object, long offset)
public void writeLong(long address,
long i64)
public void writeLong(Object object, long offset, long i64)
public long readLong(long address)
public long readLong(Object object, long offset)
public void writeFloat(long address,
float f)
writeFloat in interface Memoryaddress - the memory address.f - the float value to be written.public void writeFloat(Object object, long offset, float f)
writeFloat in interface Memoryobject - the object containing the memory to write to.offset - the offset in the object's memory.f - the float value to be written.public float readFloat(long address)
public float readFloat(Object object, long offset)
public void writeDouble(long address,
double d)
writeDouble in interface Memoryaddress - the memory address.d - the double value to be written.public void writeDouble(Object object, long offset, double d)
writeDouble in interface Memoryobject - the object containing the memory to write to.offset - the offset in the object's memory.d - the double value to be written.public double readDouble(long address)
readDouble in interface Memoryaddress - the memory address.public double readDouble(Object object, long offset)
readDouble in interface Memoryobject - the object containing the memory to read from.offset - the offset in the object's memory.public void copyMemory(byte[] src,
int srcOffset,
long destAddress,
int length)
copyMemory in interface Memorysrc - source byte array.srcOffset - offset of the source array from where to start copying.destAddress - destination memory address.length - the length of memory to copy.public void copyMemory(long srcAddress,
long destAddress,
long length)
copyMemory in interface MemorysrcAddress - source memory address.destAddress - destination memory address.length - the length of memory to copy.public void copyMemory(byte[] src,
int srcOffset,
byte[] dest,
int destOffset,
int length)
src - source byte array.srcOffset - offset of the source array from where to start copying.dest - destination byte array.destOffset - offset of the destination array from where to place the copied memory.length - the length of memory to copy.public void copyMemory(@Nullable
@Nullable Object src,
long srcOffset,
long destAddress,
int length)
copyMemory in interface Memorysrc - source object.srcOffset - offset of the source object from where to start copying.destAddress - destination memory address.length - the length of memory to copy.public void copyMemory(@Nullable
@Nullable Object src,
long srcOffset,
@Nullable
@Nullable Object dest,
long destOffset,
int length)
copyMemory(long, long, int)copyMemory in interface Memorysrc - source object.srcOffset - offset of the source object from where to start copying.dest - destination object.destOffset - offset of the destination object from where to place the copied memory.length - the length of memory to copy.public void copyMemory(long srcAddress,
@Nullable
@Nullable Object dest,
long destOffset,
int length)
copyMemory in interface MemorysrcAddress - source memory address.dest - destination object.destOffset - offset of the destination object from where to place the copied memory.length - the length of memory to copy.public int stopBitLength(int i)
1 + stopBitLength(~i).stopBitLength in interface Memoryi - the integer value to calculate its stop bit length.public int stopBitLength(long l)
1 + stopBitLength(~i).stopBitLength in interface Memoryl - the long integer value to calculate its stop bit length.public long partialRead(byte[] bytes,
int offset,
int length)
partialRead in interface Memorybytes - the byte array to read from.offset - the offset from which to start reading.length - the number of bytes to read.public long partialRead(long addr,
int length)
partialRead in interface Memoryaddr - the address from which to read.length - the number of bytes to read.public void partialWrite(byte[] bytes,
int offset,
long value,
int length)
partialWrite in interface Memorybytes - the byte array to write to.offset - the offset from which to start writing.value - the value to be written.length - the number of bytes to write.public void partialWrite(long addr,
long value,
int length)
partialWrite in interface Memoryaddr - the address to write to.value - the value to be written.length - the number of bytes to write.public boolean is7Bit(byte[] bytes,
int offset,
int length)
public boolean is7Bit(char[] chars,
int offset,
int length)
public boolean is7Bit(long address,
int length)
public void writeOrderedLong(long address,
long i)
writeOrderedLong in interface Memoryaddress - the memory address to write to.i - the long value to write.public void writeOrderedLong(Object object, long offset, long i)
writeOrderedLong in interface Memoryobject - the object whose field to write to.offset - the offset of the field.i - the long value to write.public void testAndSetInt(long address,
long offset,
int expected,
int value)
throws IllegalStateException
testAndSetInt in interface Memoryaddress - the memory address.offset - the offset of the integer value.expected - the expected integer value.value - the new integer value.IllegalStateException - if the current value does not equal the expected value.public void testAndSetInt(Object object, long offset, int expected, int value) throws IllegalStateException
testAndSetInt in interface Memoryobject - the object whose field to operate on.offset - the offset of the field.expected - the expected integer value.value - the new integer value.IllegalStateException - if the current value does not equal the expected value.public boolean compareAndSwapInt(long address,
int expected,
int value)
throws MisAlignedAssertionError
compareAndSwapInt in interface Memoryaddress - the memory address.expected - the expected integer value.value - the new integer value.MisAlignedAssertionError - if the address is not correctly aligned.public boolean compareAndSwapInt(Object object, long offset, int expected, int value) throws MisAlignedAssertionError
compareAndSwapInt in interface Memoryobject - the object whose field to operate on.offset - the offset of the field.expected - the expected integer value.value - the new integer value.MisAlignedAssertionError - if the offset is not correctly aligned.public boolean compareAndSwapLong(long address,
long expected,
long value)
throws MisAlignedAssertionError
compareAndSwapLong in interface Memoryaddress - the memory address.expected - the expected long value.value - the new long value.MisAlignedAssertionError - if the address is not correctly aligned.public boolean compareAndSwapLong(Object object, long offset, long expected, long value) throws MisAlignedAssertionError
compareAndSwapLong in interface Memoryobject - the object whose field to operate on.offset - the offset of the field.expected - the expected long value.value - the new long value.MisAlignedAssertionError - if the offset is not correctly aligned.public int getAndSetInt(long address,
int value)
throws MisAlignedAssertionError
getAndSetInt in interface Memoryaddress - the memory address.value - the new integer value.MisAlignedAssertionError - if the address is not correctly aligned.public int getAndSetInt(Object object, long offset, int value) throws MisAlignedAssertionError
getAndSetInt in interface Memoryobject - the object whose field to operate on.offset - the offset of the field.value - the new integer value.MisAlignedAssertionError - if the offset is not correctly aligned.public int pageSize()
public byte readVolatileByte(long address)
readVolatileByte in interface Memoryaddress - the memory address.public byte readVolatileByte(Object object, long offset)
readVolatileByte in interface Memoryobject - the object from which to read.offset - the offset from which to read.public short readVolatileShort(long address)
readVolatileShort in interface Memoryaddress - the memory address.public short readVolatileShort(Object object, long offset)
readVolatileShort in interface Memoryobject - the object from which to read.offset - the offset from which to read.public int readVolatileInt(long address)
readVolatileInt in interface Memoryaddress - the memory address.public int readVolatileInt(Object object, long offset)
readVolatileInt in interface Memoryobject - the object from which to read.offset - the offset from which to read.public float readVolatileFloat(long address)
readVolatileFloat in interface Memoryaddress - the memory address.public float readVolatileFloat(Object object, long offset)
readVolatileFloat in interface Memoryobject - the object from which to read.offset - the offset from which to read.public long readVolatileLong(long address)
readVolatileLong in interface Memoryaddress - the memory address.public long readVolatileLong(Object object, long offset)
readVolatileLong in interface Memoryobject - the object from which to read.offset - the offset from which to read.public double readVolatileDouble(long address)
readVolatileDouble in interface Memoryaddress - the memory address.public double readVolatileDouble(Object object, long offset)
readVolatileDouble in interface Memoryobject - the object from which to read.offset - the offset from which to read.public void writeVolatileByte(long address,
byte b)
writeVolatileByte in interface Memoryaddress - the memory address.b - the byte value to write.public void writeVolatileByte(Object object, long offset, byte b)
writeVolatileByte in interface Memoryobject - the object to which to write.offset - the offset at which to write.b - the byte value to write.public void writeVolatileShort(long address,
short i16)
writeVolatileShort in interface Memoryaddress - the memory address.i16 - the short value to write.public void writeVolatileShort(Object object, long offset, short i16)
writeVolatileShort in interface Memoryobject - the object to which to write.offset - the offset at which to write.i16 - the short value to write.public void writeVolatileInt(long address,
int i32)
writeVolatileInt in interface Memoryaddress - the memory address.i32 - the integer value to write.public void writeVolatileInt(Object object, long offset, int i32)
writeVolatileInt in interface Memoryobject - the object to which to write.offset - the offset at which to write.i32 - the integer value to write.public void writeVolatileFloat(long address,
float f)
writeVolatileFloat in interface Memoryaddress - the memory address.f - the float value to write.public void writeVolatileFloat(Object object, long offset, float f)
writeVolatileFloat in interface Memoryobject - the object to which to write.offset - the offset at which to write.f - the float value to write.public void writeVolatileLong(long address,
long i64)
writeVolatileLong in interface Memoryaddress - the memory address.i64 - the long value to write.public void writeVolatileLong(Object object, long offset, long i64)
writeVolatileLong in interface Memoryobject - the object to which to write.offset - the offset at which to write.i64 - the long value to write.public void writeVolatileDouble(long address,
double d)
writeVolatileDouble in interface Memoryaddress - the memory address.d - the double value to write.public void writeVolatileDouble(Object object, long offset, double d)
writeVolatileDouble in interface Memoryobject - the object to which to write.offset - the offset at which to write.d - the double value to write.public int addInt(long address,
int increment)
throws MisAlignedAssertionError
addInt in interface Memoryaddress - the memory address.increment - the value to add.MisAlignedAssertionError - if address is not properly aligned.public int addInt(Object object, long offset, int increment)
public long addLong(long address,
long increment)
throws MisAlignedAssertionError
addLong in interface Memoryaddress - the memory address.increment - the value to add.MisAlignedAssertionError - if address is not properly aligned.public long addLong(Object object, long offset, long increment) throws MisAlignedAssertionError
addLong in interface Memoryobject - the object to which to add the value.offset - the offset at which to add the value.increment - the value to add.MisAlignedAssertionError - if offset is not properly aligned.public void copy8bit(String s, int start, int length, long addr)
s - the source string.start - the beginning index, inclusive.length - the number of characters to be copied.addr - the target memory address.public void write8bit(String s, int start, Object object, long offset, int length)
s - the source string.start - the beginning index, inclusive.object - the target object.offset - the offset within the object.length - the number of characters to be copied.public boolean isEqual(long addr,
String s,
int length)
addr - the memory address of the source string.s - the target string.length - the number of characters to be compared.public boolean safeAlignedInt(long addr)
safeAlignedInt in interface Memoryaddr - the address to check.public boolean safeAlignedLong(long addr)
safeAlignedLong in interface Memoryaddr - the address to check.public int arrayBaseOffset(Class<?> type)
arrayBaseOffset in interface Memorytype - the class representing the array type.public long objectFieldOffset(Field field)
objectFieldOffset in interface Memoryfield - the field object.public long address(ByteBuffer bb)
Copyright © 2024. All rights reserved.