public interface Memory
| Modifier and Type | Method and Description |
|---|---|
int |
addInt(long address,
int increment)
Adds the specified increment to the value at the given memory address and returns the updated value.
|
int |
addInt(Object object,
long offset,
int increment)
Adds the specified increment to the value at the given offset in the object and returns the updated value.
|
long |
addLong(long address,
long increment)
Adds the specified increment to the value at the given memory address and returns the updated value.
|
long |
addLong(Object object,
long offset,
long increment)
Adds the specified increment to the value at the given offset in the object and returns the updated value.
|
long |
address(ByteBuffer bb)
Returns the memory address associated with the given ByteBuffer.
|
long |
allocate(long capacity)
Allocates memory and returns the low level base address of the newly allocated
memory region.
|
<E> E |
allocateInstance(Class<? extends E> clazz)
Allocates and returns a new instance of the specified class.
|
int |
arrayBaseOffset(Class<?> type)
Returns the base offset of the elements in the specified array type.
|
boolean |
compareAndSwapInt(long address,
int expected,
int value)
Compares the value at the specified memory address with the expected value and, if equal, sets it to the new value.
|
boolean |
compareAndSwapInt(Object object,
long offset,
int expected,
int value)
Compares the value at the specified offset in the object with the expected value and, if equal, sets it to the new value.
|
boolean |
compareAndSwapLong(long address,
long expected,
long value)
Compares the value at the specified memory address with the expected value and, if equal, sets it to the new value.
|
boolean |
compareAndSwapLong(Object object,
long offset,
long expected,
long value)
Compares the value at the specified offset in the object with the expected value and, if equal, sets it to the new value.
|
void |
copyMemory(byte[] bytes,
int offset,
long address,
int length)
Copies a range of bytes from the given byte array to the specified memory address.
|
void |
copyMemory(long fromAddress,
long address,
long length)
Copies a range of memory from one address to another.
|
void |
copyMemory(long fromAddress,
Object obj2,
long offset2,
int length)
Copies a range of memory from the given memory address to the specified object at the given offset.
|
void |
copyMemory(Object o,
long offset,
long toAddress,
int length)
Copies a range of memory from the given object to the specified memory address.
|
void |
copyMemory(Object o,
long offset,
Object o2,
long offset2,
int length)
Copies a range of memory from one object to another at the specified offsets.
|
void |
freeMemory(long address,
long size)
Frees the memory block at the specified address with the given size.
|
int |
getAndSetInt(long address,
int value)
Atomically sets the value at the specified address to the given value and returns the previous value
|
int |
getAndSetInt(Object object,
long offset,
int value)
Atomically sets the value at the specified offset in the object to the given value and returns the previous value.
|
long |
getFieldOffset(Field field)
Returns the offset of the specified field in its containing object.
|
<T> T |
getObject(@NotNull Object o,
long offset)
Returns the value of the specified field in the given object.
|
boolean |
is7Bit(byte[] bytes,
int offset,
int length)
Checks if the bytes in the specified byte array are 7-bit ASCII characters.
|
boolean |
is7Bit(char[] chars,
int offset,
int length)
Checks if the characters in the specified char array are 7-bit ASCII characters.
|
boolean |
is7Bit(long address,
int length)
Checks if the bytes in the memory at the given address are 7-bit ASCII characters.
|
void |
loadFence()
Ensures that all previous reads from memory are completed before any
subsequent memory access instruction.
|
long |
nativeMemoryUsed()
Retrieves the amount of native memory currently used by the application.
|
long |
objectFieldOffset(Field field)
Returns the offset of the specified field in its containing object.
|
int |
pageSize()
Returns the page size of the underlying memory system.
|
long |
partialRead(byte[] bytes,
int offset,
int length)
Reads a partial value from the given byte array starting at the specified offset.
|
long |
partialRead(long addr,
int length)
Reads a partial value from the memory at the given address.
|
void |
partialWrite(byte[] bytes,
int offset,
long value,
int length)
Writes a partial value to the byte array at the specified offset.
|
void |
partialWrite(long addr,
long value,
int length)
Writes a partial value to the memory at the given address.
|
void |
putObject(@NotNull Object o,
long offset,
Object value)
Sets the value of the specified field in the given object.
|
byte |
readByte(long address)
Reads a byte value from the memory at the specified address.
|
byte |
readByte(Object object,
long offset)
Reads a byte value from the memory at the specified offset within the given object.
|
void |
readBytes(long address,
byte[] b,
long offset,
int length)
Reads an array of bytes from the memory at the specified address and stores it in the provided byte array.
|
double |
readDouble(long address)
Reads a double value from the memory at the specified address.
|
double |
readDouble(Object object,
long offset)
Reads a double value from the memory at the specified offset within the given object.
|
float |
readFloat(long address)
Reads a float value from the memory at the specified address.
|
float |
readFloat(Object object,
long offset)
Reads a float value from the memory at the specified offset within the given object.
|
int |
readInt(long address)
Reads an int value from the memory at the specified address.
|
int |
readInt(Object object,
long offset)
Reads an int value from the memory at the specified offset within the given object.
|
long |
readLong(long address)
Reads a long value from the memory at the specified address.
|
long |
readLong(Object object,
long offset)
Reads a long value from the memory at the specified offset within the given object.
|
short |
readShort(long address)
Reads a short value from the memory at the specified address.
|
short |
readShort(Object object,
long offset)
Reads a short value from the memory at the specified offset within the given object.
|
byte |
readVolatileByte(long address)
Reads a volatile byte from the memory at the given address.
|
byte |
readVolatileByte(Object object,
long offset)
Reads a volatile byte from the object at the given offset.
|
double |
readVolatileDouble(long address)
Reads a volatile double from the memory at the given address.
|
double |
readVolatileDouble(Object object,
long offset)
Reads a volatile double from the object at the given offset.
|
float |
readVolatileFloat(long address)
Reads a volatile float from the memory at the given address.
|
float |
readVolatileFloat(Object object,
long offset)
Reads a volatile float from the object at the given offset.
|
int |
readVolatileInt(long address)
Reads a volatile integer from the memory at the given address.
|
int |
readVolatileInt(Object object,
long offset)
Reads a volatile integer from the object at the given offset.
|
long |
readVolatileLong(long address)
Reads a volatile long from the memory at the given address.
|
long |
readVolatileLong(Object object,
long offset)
Reads a volatile long from the object at the given offset.
|
short |
readVolatileShort(long address)
Reads a volatile short from the memory at the given address.
|
short |
readVolatileShort(Object object,
long offset)
Reads a volatile short from the object at the given offset.
|
boolean |
safeAlignedInt(long addr)
Returns if the provided
addr would provide access to
an int that would reside entirely within a distinct cache-line. |
boolean |
safeAlignedLong(long addr)
Returns if the provided
addr would provide access to
a long that would reside entirely within a distinct cache-line. |
void |
setMemory(long address,
long size,
byte b)
Sets the memory at the specified address with the given byte value.
|
void |
setMemory(Object o,
long offset,
long size,
byte b)
Sets the memory at the specified offset within the given object with
the given byte value.
|
static int |
sizeOf(Class<?> type) |
int |
stopBitLength(int i)
Returns the length in bytes required to encode an integer using stop-bit encoding.
|
int |
stopBitLength(long l)
Returns the length in bytes required to encode a long integer using stop-bit encoding.
|
void |
storeFence()
Ensures that all previous writes to memory are completed before any
subsequent memory access instruction.
|
void |
testAndSetInt(long address,
long offset,
int expected,
int value)
Atomically sets the value at the specified address to the given value if it equals the expected value.
|
void |
testAndSetInt(Object object,
long offset,
int expected,
int value)
Atomically sets the value at the specified offset in the object to the given value if it equals the expected value.
|
void |
writeByte(long address,
byte i8)
Writes a byte value to the memory at the specified address.
|
void |
writeByte(Object object,
long offset,
byte b)
Writes a byte value to the memory at the specified offset within the given object.
|
void |
writeBytes(long address,
byte[] b,
int offset,
int length)
Writes an array of bytes to the memory at the specified address.
|
void |
writeDouble(long address,
double d)
Writes a double value to the memory at the specified address.
|
void |
writeDouble(Object object,
long offset,
double d)
Writes a double value to the memory at the specified offset within the given object.
|
void |
writeFloat(long address,
float f)
Writes a float value to the memory at the specified address.
|
void |
writeFloat(Object object,
long offset,
float f)
Writes a float value to the memory at the specified offset within the given object.
|
void |
writeInt(long address,
int i32)
Writes an int value to the memory at the specified address.
|
void |
writeInt(Object object,
long offset,
int i32)
Writes an int value to the memory at the specified offset within the given object.
|
void |
writeLong(long address,
long i64)
Writes a long value to the memory at the specified address.
|
void |
writeLong(Object object,
long offset,
long i64)
Writes a long value to the memory at the specified offset within the given object.
|
void |
writeOrderedInt(long offset,
int i32)
Writes an int value to the memory at the specified offset within the given object in an ordered manner.
|
void |
writeOrderedInt(Object object,
long offset,
int i32)
Writes an int value to the memory at the specified offset within the given object in an ordered manner.
|
void |
writeOrderedLong(long address,
long i)
Writes a long value to memory at the given address with ordered store semantics.
|
void |
writeOrderedLong(Object object,
long offset,
long i)
Writes a long value to the object at the given offset with ordered store semantics.
|
void |
writeShort(long address,
short i16)
Writes a short value to the memory at the specified address.
|
void |
writeShort(Object object,
long offset,
short i16)
Writes a short value to the memory at the specified offset within the given object.
|
void |
writeVolatileByte(long address,
byte b)
Writes a volatile byte to the memory at the given address.
|
void |
writeVolatileByte(Object object,
long offset,
byte b)
Writes a volatile byte to the object at the given offset.
|
void |
writeVolatileDouble(long address,
double d)
Writes a volatile double to the memory at the given address.
|
void |
writeVolatileDouble(Object object,
long offset,
double d)
Writes a volatile double to the object at the given offset.
|
void |
writeVolatileFloat(long address,
float f)
Writes a volatile float to the memory at the given address.
|
void |
writeVolatileFloat(Object object,
long offset,
float f)
Writes a volatile float to the object at the given offset.
|
void |
writeVolatileInt(long address,
int i32)
Writes a volatile integer to the memory at the given address.
|
void |
writeVolatileInt(Object object,
long offset,
int i32)
Writes a volatile integer to the object at the given offset.
|
void |
writeVolatileLong(long address,
long i64)
Writes a volatile long to the memory at the given address.
|
void |
writeVolatileLong(Object object,
long offset,
long i64)
Writes a volatile long to the object at the given offset.
|
void |
writeVolatileShort(long address,
short i16)
Writes a volatile short to the memory at the given address.
|
void |
writeVolatileShort(Object object,
long offset,
short i16)
Writes a volatile short to the object at the given offset.
|
void storeFence()
void loadFence()
void setMemory(long address,
long size,
byte b)
address - The starting address of the memory block.size - The size of the memory block in bytes.b - The byte value to be set.void setMemory(Object o, long offset, long size, byte b)
o - The object containing the memory block.offset - The offset within the object where the memory block starts.size - The size of the memory block in bytes.b - The byte value to be set.void freeMemory(long address,
long size)
address - The starting address of the memory block.size - The size of the memory block in bytes.long allocate(long capacity)
capacity - to allocateIllegalArgumentException - If the capacity is non-positiveOutOfMemoryError - if there are not enough memory to allocatelong nativeMemoryUsed()
void writeByte(long address,
byte i8)
address - The address where the byte should be written.i8 - The byte value to be written.void writeByte(Object object, long offset, byte b)
object - The object containing the memory block.offset - The offset within the object where the byte should be written.b - The byte value to be written.byte readByte(Object object, long offset)
object - The object containing the memory block.offset - The offset within the object where the byte should be read.void writeBytes(long address,
byte[] b,
int offset,
int length)
throws IllegalArgumentException
address - The address where the bytes should be written.b - The byte array containing the bytes to be written.offset - The starting offset within the array.length - The number of bytes to be written.IllegalArgumentException - If the offset or length is invalid.void readBytes(long address,
byte[] b,
long offset,
int length)
throws IllegalArgumentException
address - The address where the bytes should be read from.b - The byte array to store the read bytes.offset - The starting offset within the byte array.length - The number of bytes to be read.IllegalArgumentException - If the offset or length is invalid.byte readByte(long address)
address - The address where the byte should be read from.void writeShort(long address,
short i16)
address - The address where the short should be written.i16 - The short value to be written.void writeShort(Object object, long offset, short i16)
object - The object containing the memory block.offset - The offset within the object where the short should be written.i16 - The short value to be written.short readShort(long address)
address - The address where the short should be read from.short readShort(Object object, long offset)
object - The object containing the memory block.offset - The offset within the object where the short should be read.void writeInt(long address,
int i32)
address - The address where the int should be written.i32 - The int value to be written.void writeInt(Object object, long offset, int i32)
object - The object containing the memory block.offset - The offset within the object where the int should be written.i32 - The int value to be written.void writeOrderedInt(long offset,
int i32)
offset - The offset within the object where the int should be written.i32 - The int value to be written.void writeOrderedInt(Object object, long offset, int i32)
object - The object containing the memory block.offset - The offset within the object where the int should be written.i32 - The int value to be written.int readInt(long address)
address - The address where the int should be read from.int readInt(Object object, long offset)
object - The object containing the memory block.offset - The offset within the object where the int should be read.void writeLong(long address,
long i64)
address - The address where the long should be written.i64 - The long value to be written.void writeLong(Object object, long offset, long i64)
object - The object containing the memory block.offset - The offset within the object where the long should be written.i64 - The long value to be written.long readLong(long address)
address - The address where the long should be read from.long readLong(Object object, long offset)
object - The object containing the memory block.offset - The offset within the object where the long should be read.void writeFloat(long address,
float f)
address - The address where the float should be written.f - The float value to be written.void writeFloat(Object object, long offset, float f)
object - The object containing the memory block.offset - The offset within the object where the float should be written.f - The float value to be written.float readFloat(long address)
address - The address where the float should be read from.float readFloat(Object object, long offset)
object - The object containing the memory block.offset - The offset within the object where the float should be read.void writeDouble(long address,
double d)
address - The address where the double should be written.d - The double value to be written.void writeDouble(Object object, long offset, double d)
object - The object containing the memory block.offset - The offset within the object where the double should be written.d - The double value to be written.double readDouble(long address)
address - The address where the double should be read from.double readDouble(Object object, long offset)
object - The object containing the memory block.offset - The offset within the object where the double should be read.void copyMemory(byte[] bytes,
int offset,
long address,
int length)
bytes - the source byte arrayoffset - the starting index in the byte arrayaddress - the destination memory addresslength - the number of bytes to copyvoid copyMemory(long fromAddress,
long address,
long length)
fromAddress - the source memory addressaddress - the destination memory addresslength - the number of bytes to copyvoid copyMemory(Object o, long offset, long toAddress, int length)
o - the source objectoffset - the starting offset in the source objecttoAddress - the destination memory addresslength - the number of bytes to copyvoid copyMemory(Object o, long offset, Object o2, long offset2, int length)
o - the source objectoffset - the starting offset in the source objecto2 - the destination objectoffset2 - the starting offset in the destination objectlength - the number of bytes to copyvoid copyMemory(long fromAddress,
Object obj2,
long offset2,
int length)
fromAddress - the source memory addressobj2 - the destination objectoffset2 - the starting offset in the destination objectlength - the number of bytes to copyint stopBitLength(int i)
i - the integer valueint stopBitLength(long l)
l - the long integer valuelong partialRead(byte[] bytes,
int offset,
int length)
bytes - the source byte arrayoffset - the starting index in the byte arraylength - the number of bytes to readlong partialRead(long addr,
int length)
addr - the source memory addresslength - the number of bytes to readvoid partialWrite(byte[] bytes,
int offset,
long value,
int length)
bytes - the destination byte arrayoffset - the starting index in the byte arrayvalue - the partial value to writelength - the number of bytes to writevoid partialWrite(long addr,
long value,
int length)
addr - the destination memory addressvalue - the partial value to writelength - the number of bytes to writeboolean is7Bit(byte[] bytes,
int offset,
int length)
bytes - the byte arrayoffset - the starting index in the byte arraylength - the number of bytes to checktrue if all bytes are 7-bit ASCII characters, false otherwiseboolean is7Bit(char[] chars,
int offset,
int length)
chars - the char arrayoffset - the starting index in the char arraylength - the number of characters to checktrue if all characters are 7-bit ASCII characters, false otherwiseboolean is7Bit(long address,
int length)
address - the memory addresslength - the number of bytes to checktrue if all bytes are 7-bit ASCII characters, false otherwisevoid writeOrderedLong(long address,
long i)
address - the memory addressi - the long value to writevoid writeOrderedLong(Object object, long offset, long i)
object - the destination objectoffset - the offset in the destination objecti - the long value to writevoid testAndSetInt(long address,
long offset,
int expected,
int value)
throws IllegalStateException
address - the memory addressoffset - the offset in the memory addressexpected - the expected valuevalue - the new valueIllegalStateException - if the current value does not match the expected valuevoid testAndSetInt(Object object, long offset, int expected, int value) throws IllegalStateException
object - the destination objectoffset - the offset in the destination objectexpected - the expected valuevalue - the new valueIllegalStateException - if the current value does not match the expected valueboolean compareAndSwapInt(long address,
int expected,
int value)
throws MisAlignedAssertionError
true if the value was successfully swapped, false otherwise.address - the memory addressexpected - the expected valuevalue - the new valuetrue if the value was successfully swapped, false otherwiseMisAlignedAssertionError - if the memory address is misaligned for the operationboolean compareAndSwapInt(Object object, long offset, int expected, int value) throws MisAlignedAssertionError
true if the value was successfully swapped, false otherwise.object - the destination objectoffset - the offset in the destination objectexpected - the expected valuevalue - the new valuetrue if the value was successfully swapped, false otherwiseMisAlignedAssertionError - if the offset is misaligned for the operationboolean compareAndSwapLong(long address,
long expected,
long value)
throws MisAlignedAssertionError
true if the value was successfully swapped, false otherwise.address - the memory addressexpected - the expected valuevalue - the new valuetrue if the value was successfully swapped, false otherwiseMisAlignedAssertionError - if the memory address is misaligned for the operationboolean compareAndSwapLong(Object object, long offset, long expected, long value) throws MisAlignedAssertionError
true if the value was successfully swapped, false otherwise.object - the destination objectoffset - the offset in the destination objectexpected - the expected valuevalue - the new valuetrue if the value was successfully swapped, false otherwiseMisAlignedAssertionError - if the offset is misaligned for the operationint getAndSetInt(long address,
int value)
throws MisAlignedAssertionError
address - the memory addressvalue - the new valueMisAlignedAssertionError - if the memory address is misaligned for the operationint getAndSetInt(Object object, long offset, int value) throws MisAlignedAssertionError
object - the destination objectoffset - the offset in the destination objectvalue - the new valueMisAlignedAssertionError - if the offset is misaligned for the operationint pageSize()
byte readVolatileByte(long address)
address - the memory addressbyte readVolatileByte(Object object, long offset)
object - the source objectoffset - the offset in the objectshort readVolatileShort(long address)
address - the memory addressshort readVolatileShort(Object object, long offset)
object - the source objectoffset - the offset in the objectint readVolatileInt(long address)
address - the memory addressint readVolatileInt(Object object, long offset)
object - the source objectoffset - the offset in the objectfloat readVolatileFloat(long address)
address - the memory addressfloat readVolatileFloat(Object object, long offset)
object - the source objectoffset - the offset in the objectlong readVolatileLong(long address)
address - the memory addresslong readVolatileLong(Object object, long offset)
object - the source objectoffset - the offset in the objectread from the object
double readVolatileDouble(long address)
address - the memory addressdouble readVolatileDouble(Object object, long offset)
object - the source objectoffset - the offset in the objectvoid writeVolatileByte(long address,
byte b)
address - the memory addressb - the byte value to writevoid writeVolatileByte(Object object, long offset, byte b)
object - the destination objectoffset - the offset in the destination objectb - the byte value to writevoid writeVolatileShort(long address,
short i16)
address - the memory addressi16 - the short value to writevoid writeVolatileShort(Object object, long offset, short i16)
object - the destination objectoffset - the offset in the destination objecti16 - the short value to writevoid writeVolatileInt(long address,
int i32)
address - the memory addressi32 - the integer value to writevoid writeVolatileInt(Object object, long offset, int i32)
object - the destination objectoffset - the offset in the destination objecti32 - the integer value to writevoid writeVolatileFloat(long address,
float f)
address - the memory addressf - the float value to writevoid writeVolatileFloat(Object object, long offset, float f)
object - the destination objectoffset - the offset in the destination objectf - the float value to writevoid writeVolatileLong(long address,
long i64)
address - the memory addressi64 - the long value to writevoid writeVolatileLong(Object object, long offset, long i64)
object - the destination objectoffset - the offset in the destination objecti64 - the long value to writevoid writeVolatileDouble(long address,
double d)
address - the memory addressd - the double value to writevoid writeVolatileDouble(Object object, long offset, double d)
object - the destination objectoffset - the offset in the destination objectd - the double value to writeint addInt(long address,
int increment)
throws MisAlignedAssertionError
address - the memory addressincrement - the value to addMisAlignedAssertionError - if the memory address is misaligned for the operationint addInt(Object object, long offset, int increment)
object - the destination objectoffset - the offset in the destination objectincrement - the value to addlong addLong(long address,
long increment)
throws MisAlignedAssertionError
address - the memory addressincrement - the value to addMisAlignedAssertionError - if the memory address is misaligned for the operationlong addLong(Object object, long offset, long increment) throws MisAlignedAssertionError
object - the destination objectoffset - the offset in the destination objectincrement - the value to addMisAlignedAssertionError - if the offset is misaligned for the operation@NotNull <E> E allocateInstance(Class<? extends E> clazz) throws InstantiationException
E - the type of the classclazz - the class to instantiateInstantiationException - If the class cannot be instantiatedlong getFieldOffset(Field field)
field - the fieldvoid putObject(@NotNull
@NotNull Object o,
long offset,
Object value)
o - the objectoffset - the offset of the field in the objectvalue - the new value of the field@NotNull
<T> T getObject(@NotNull
@NotNull Object o,
long offset)
T - the type of the fieldo - the objectoffset - the offset of the field in the objectint arrayBaseOffset(Class<?> type)
type - the array typelong objectFieldOffset(Field field)
field - the fieldstatic int sizeOf(Class<?> type)
type - of primitive or a referenceboolean safeAlignedInt(long addr)
addr would provide access to
an int that would reside entirely within a distinct cache-line.addr - to useboolean safeAlignedLong(long addr)
addr would provide access to
a long that would reside entirely within a distinct cache-line.addr - to uselong address(ByteBuffer bb)
bb - the ByteBufferCopyright © 2024. All rights reserved.