| Modifier and Type | Field and Description |
|---|---|
static UnsafeMemory |
INSTANCE |
static boolean |
IS_LITTLE_ENDIAN |
static UnsafeMemory |
MEMORY |
static @NotNull sun.misc.Unsafe |
UNSAFE |
| Constructor and Description |
|---|
UnsafeMemory() |
| Modifier and Type | Method and Description |
|---|---|
int |
addInt(long address,
int increment) |
int |
addInt(Object object,
long offset,
int increment) |
long |
addLong(long address,
long increment) |
long |
addLong(Object object,
long offset,
long increment) |
long |
address(ByteBuffer bb) |
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) |
int |
arrayBaseOffset(Class<?> type) |
boolean |
compareAndSwapInt(long address,
int expected,
int value) |
boolean |
compareAndSwapInt(Object object,
long offset,
int expected,
int value) |
boolean |
compareAndSwapLong(long address,
long expected,
long value) |
boolean |
compareAndSwapLong(Object object,
long offset,
long expected,
long value) |
void |
copy8bit(String s,
int start,
int length,
long addr) |
void |
copyMemory(byte[] src,
int srcOffset,
byte[] dest,
int destOffset,
int length) |
void |
copyMemory(byte[] src,
int srcOffset,
long dest,
int length) |
void |
copyMemory(byte[] src,
int srcOffset,
@Nullable Object dest,
long destOffset,
int length) |
static void |
copyMemory(long from,
long to,
int length) |
void |
copyMemory(long src,
long dest,
long length) |
void |
copyMemory(long src,
@Nullable Object dest,
long destOffset,
int length) |
void |
copyMemory(@Nullable Object src,
long srcOffset,
long dest,
int length) |
void |
copyMemory(@Nullable Object src,
long srcOffset,
@Nullable Object dest,
long destOffset,
int length)
Copy memory from one object to another.
|
void |
freeMemory(long address,
long size) |
long |
getFieldOffset(Field field) |
<T> T |
getObject(@NotNull Object object,
long offset) |
boolean |
is7Bit(byte[] bytes,
int offset,
int length) |
boolean |
is7Bit(char[] chars,
int offset,
int length) |
boolean |
is7Bit(long address,
int length) |
boolean |
isEqual(long addr,
String s,
int length) |
void |
loadFence() |
long |
nativeMemoryUsed() |
long |
objectFieldOffset(Field field) |
int |
pageSize() |
long |
partialRead(byte[] bytes,
int offset,
int length) |
long |
partialRead(long addr,
int length) |
void |
partialWrite(byte[] bytes,
int offset,
long value,
int length) |
void |
partialWrite(long addr,
long value,
int length) |
static void |
putInt(byte[] bytes,
int offset,
int value) |
void |
putObject(@NotNull Object object,
long offset,
Object value) |
byte |
readByte(long address) |
byte |
readByte(Object object,
long offset) |
void |
readBytes(long address,
byte[] b,
long offset,
int length) |
double |
readDouble(long address) |
double |
readDouble(Object object,
long offset) |
float |
readFloat(long address) |
float |
readFloat(Object object,
long offset) |
int |
readInt(long address) |
int |
readInt(Object object,
long offset) |
long |
readLong(long address) |
long |
readLong(Object object,
long offset) |
short |
readShort(long address) |
short |
readShort(Object object,
long offset) |
byte |
readVolatileByte(long address) |
byte |
readVolatileByte(Object object,
long offset) |
double |
readVolatileDouble(long address) |
double |
readVolatileDouble(Object object,
long offset) |
float |
readVolatileFloat(long address) |
float |
readVolatileFloat(Object object,
long offset) |
int |
readVolatileInt(long address) |
int |
readVolatileInt(Object object,
long offset) |
long |
readVolatileLong(long address) |
long |
readVolatileLong(Object object,
long offset) |
short |
readVolatileShort(long address) |
short |
readVolatileShort(Object object,
long offset) |
boolean |
safeAlignedInt(long addr) |
boolean |
safeAlignedLong(long addr) |
void |
setMemory(long address,
long size,
byte b) |
void |
setMemory(Object o,
long offset,
long size,
byte b) |
int |
stopBitLength(int i) |
int |
stopBitLength(long l) |
void |
storeFence() |
void |
testAndSetInt(long address,
long offset,
int expected,
int value) |
void |
testAndSetInt(Object object,
long offset,
int expected,
int value) |
static boolean |
unsafeGetBoolean(Object obj,
long offset) |
static byte |
unsafeGetByte(long address) |
static byte |
unsafeGetByte(Object obj,
long offset) |
static char |
unsafeGetChar(Object obj,
long offset) |
static double |
unsafeGetDouble(Object obj,
long offset) |
static float |
unsafeGetFloat(Object obj,
long offset) |
static int |
unsafeGetInt(long address) |
static int |
unsafeGetInt(Object obj,
long offset) |
static long |
unsafeGetLong(long address) |
static long |
unsafeGetLong(Object obj,
long offset) |
static <T> T |
unsafeGetObject(Object obj,
long offset) |
static short |
unsafeGetShort(Object obj,
long offset) |
static void |
unsafeLoadFence() |
static long |
unsafeObjectFieldOffset(Field field) |
static void |
unsafePutBoolean(Object obj,
long offset,
boolean value) |
static void |
unsafePutByte(byte[] bytes,
int offset,
byte value) |
static void |
unsafePutByte(long address,
byte value) |
static void |
unsafePutByte(Object obj,
long offset,
byte value) |
static void |
unsafePutChar(Object obj,
long offset,
char value) |
static void |
unsafePutDouble(Object obj,
long offset,
double value) |
static void |
unsafePutFloat(Object obj,
long offset,
float value) |
static void |
unsafePutInt(byte[] bytes,
int offset,
int value) |
static void |
unsafePutInt(long address,
int value) |
static void |
unsafePutInt(Object obj,
long offset,
int value) |
static void |
unsafePutLong(byte[] bytes,
int offset,
long value) |
static void |
unsafePutLong(long address,
long value) |
static void |
unsafePutLong(Object obj,
long offset,
long value) |
static void |
unsafePutObject(Object obj,
long offset,
Object value) |
static void |
unsafePutShort(Object obj,
long offset,
short value) |
static void |
unsafeStoreFence() |
void |
write8bit(String s,
int start,
Object object,
long offset,
int length) |
void |
writeByte(long address,
byte b) |
void |
writeByte(Object object,
long offset,
byte b) |
void |
writeBytes(long address,
byte[] b,
int offset,
int length) |
void |
writeDouble(long address,
double d) |
void |
writeDouble(Object object,
long offset,
double d) |
void |
writeFloat(long address,
float f) |
void |
writeFloat(Object object,
long offset,
float f) |
void |
writeInt(long address,
int i32) |
void |
writeInt(Object object,
long offset,
int i32) |
void |
writeLong(long address,
long i64) |
void |
writeLong(Object object,
long offset,
long i64) |
void |
writeOrderedInt(long address,
int i32) |
void |
writeOrderedInt(Object object,
long offset,
int i32) |
void |
writeOrderedLong(long address,
long i) |
void |
writeOrderedLong(Object object,
long offset,
long i) |
void |
writeShort(long address,
short i16) |
void |
writeShort(Object object,
long offset,
short i16) |
void |
writeVolatileByte(long address,
byte b) |
void |
writeVolatileByte(Object object,
long offset,
byte b) |
void |
writeVolatileDouble(long address,
double d) |
void |
writeVolatileDouble(Object object,
long offset,
double d) |
void |
writeVolatileFloat(long address,
float f) |
void |
writeVolatileFloat(Object object,
long offset,
float f) |
void |
writeVolatileInt(long address,
int i32) |
void |
writeVolatileInt(Object object,
long offset,
int i32) |
void |
writeVolatileLong(long address,
long i64) |
void |
writeVolatileLong(Object object,
long offset,
long i64) |
void |
writeVolatileShort(long address,
short i16) |
void |
writeVolatileShort(Object object,
long offset,
short i16) |
@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)
public static void unsafeStoreFence()
public static void unsafeLoadFence()
public static long unsafeGetLong(long address)
public static int unsafeGetInt(long address)
public static byte unsafeGetByte(long address)
public static void unsafePutLong(long address,
long value)
public static void unsafePutInt(long address,
int value)
public static void unsafePutByte(long address,
byte value)
public static void unsafePutLong(byte[] bytes,
int offset,
long value)
public static void unsafePutInt(byte[] bytes,
int offset,
int value)
public static void unsafePutByte(byte[] bytes,
int offset,
byte value)
public static void copyMemory(long from,
long to,
int length)
public static void unsafePutBoolean(Object obj, long offset, boolean value)
public static boolean unsafeGetBoolean(Object obj, long offset)
public static void unsafePutByte(Object obj, long offset, byte value)
public static byte unsafeGetByte(Object obj, long offset)
public static void unsafePutChar(Object obj, long offset, char value)
public static char unsafeGetChar(Object obj, long offset)
public static void unsafePutShort(Object obj, long offset, short value)
public static short unsafeGetShort(Object obj, long offset)
public static void unsafePutInt(Object obj, long offset, int value)
public static int unsafeGetInt(Object obj, long offset)
public static void unsafePutFloat(Object obj, long offset, float value)
public static float unsafeGetFloat(Object obj, long offset)
public static void unsafePutLong(Object obj, long offset, long value)
public static long unsafeGetLong(Object obj, long offset)
public static void unsafePutDouble(Object obj, long offset, double value)
public static double unsafeGetDouble(Object obj, long offset)
public static <T> T unsafeGetObject(Object obj, long offset)
public static long unsafeObjectFieldOffset(Field field)
@NotNull public <E> E allocateInstance(Class<? extends E> clazz) throws InstantiationException
allocateInstance in interface MemoryInstantiationExceptionpublic long getFieldOffset(Field field)
getFieldOffset in interface Memory@NotNull
public <T> T getObject(@NotNull
@NotNull Object object,
long offset)
public void storeFence()
storeFence in interface Memorypublic 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 Memorypublic long allocate(long capacity)
Memorypublic long nativeMemoryUsed()
nativeMemoryUsed in interface Memorypublic 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 MemoryIllegalArgumentExceptionpublic void readBytes(long address,
byte[] b,
long offset,
int length)
throws IllegalArgumentException
readBytes in interface MemoryIllegalArgumentExceptionpublic void writeShort(long address,
short i16)
writeShort in interface Memorypublic void writeShort(Object object, long offset, short i16)
writeShort in interface Memorypublic short readShort(Object object, long offset)
public void writeInt(Object object, long offset, int i32)
public void writeOrderedInt(long address,
int i32)
writeOrderedInt in interface Memorypublic void writeOrderedInt(Object object, long offset, int i32)
writeOrderedInt in interface Memorypublic void writeLong(Object object, long offset, long i64)
public long readLong(Object object, long offset)
public void writeFloat(long address,
float f)
writeFloat in interface Memorypublic void writeFloat(Object object, long offset, float f)
writeFloat in interface Memorypublic float readFloat(Object object, long offset)
public void writeDouble(long address,
double d)
writeDouble in interface Memorypublic void writeDouble(Object object, long offset, double d)
writeDouble in interface Memorypublic double readDouble(long address)
readDouble in interface Memorypublic double readDouble(Object object, long offset)
readDouble in interface Memorypublic void copyMemory(byte[] src,
int srcOffset,
long dest,
int length)
copyMemory in interface Memorypublic void copyMemory(long src,
long dest,
long length)
copyMemory in interface Memorypublic void copyMemory(byte[] src,
int srcOffset,
@Nullable
@Nullable Object dest,
long destOffset,
int length)
copyMemory in interface Memorypublic void copyMemory(byte[] src,
int srcOffset,
byte[] dest,
int destOffset,
int length)
public void copyMemory(@Nullable
@Nullable Object src,
long srcOffset,
long dest,
int length)
copyMemory in interface Memorypublic void copyMemory(@Nullable
@Nullable Object src,
long srcOffset,
@Nullable
@Nullable Object dest,
long destOffset,
int length)
If either {code o} or {code o2} are {code null}, {code offset} or {code offset2} are treated as addresses.
Instead of calling this with {code o == o2 == null}, use copyMemory(long, long, int)
copyMemory in interface Memorypublic void copyMemory(long src,
@Nullable
@Nullable Object dest,
long destOffset,
int length)
copyMemory in interface Memorypublic int stopBitLength(int i)
stopBitLength in interface Memorypublic int stopBitLength(long l)
stopBitLength in interface Memorypublic long partialRead(byte[] bytes,
int offset,
int length)
partialRead in interface Memorypublic long partialRead(long addr,
int length)
partialRead in interface Memorypublic void partialWrite(byte[] bytes,
int offset,
long value,
int length)
partialWrite in interface Memorypublic void partialWrite(long addr,
long value,
int length)
partialWrite in interface Memorypublic boolean is7Bit(byte[] bytes,
int offset,
int length)
public boolean is7Bit(char[] chars,
int offset,
int length)
public void writeOrderedLong(long address,
long i)
writeOrderedLong in interface Memorypublic void writeOrderedLong(Object object, long offset, long i)
writeOrderedLong in interface Memorypublic void testAndSetInt(long address,
long offset,
int expected,
int value)
throws IllegalStateException
testAndSetInt in interface MemoryIllegalStateExceptionpublic void testAndSetInt(Object object, long offset, int expected, int value) throws IllegalStateException
testAndSetInt in interface MemoryIllegalStateExceptionpublic boolean compareAndSwapInt(long address,
int expected,
int value)
throws MisAlignedAssertionError
compareAndSwapInt in interface MemoryMisAlignedAssertionErrorpublic boolean compareAndSwapInt(Object object, long offset, int expected, int value) throws MisAlignedAssertionError
compareAndSwapInt in interface MemoryMisAlignedAssertionErrorpublic boolean compareAndSwapLong(long address,
long expected,
long value)
throws MisAlignedAssertionError
compareAndSwapLong in interface MemoryMisAlignedAssertionErrorpublic boolean compareAndSwapLong(Object object, long offset, long expected, long value) throws MisAlignedAssertionError
compareAndSwapLong in interface MemoryMisAlignedAssertionErrorpublic byte readVolatileByte(long address)
readVolatileByte in interface Memorypublic byte readVolatileByte(Object object, long offset)
readVolatileByte in interface Memorypublic short readVolatileShort(long address)
readVolatileShort in interface Memorypublic short readVolatileShort(Object object, long offset)
readVolatileShort in interface Memorypublic int readVolatileInt(long address)
readVolatileInt in interface Memorypublic int readVolatileInt(Object object, long offset)
readVolatileInt in interface Memorypublic float readVolatileFloat(long address)
readVolatileFloat in interface Memorypublic float readVolatileFloat(Object object, long offset)
readVolatileFloat in interface Memorypublic long readVolatileLong(long address)
readVolatileLong in interface Memorypublic long readVolatileLong(Object object, long offset)
readVolatileLong in interface Memorypublic double readVolatileDouble(long address)
readVolatileDouble in interface Memorypublic double readVolatileDouble(Object object, long offset)
readVolatileDouble in interface Memorypublic void writeVolatileByte(long address,
byte b)
writeVolatileByte in interface Memorypublic void writeVolatileByte(Object object, long offset, byte b)
writeVolatileByte in interface Memorypublic void writeVolatileShort(long address,
short i16)
writeVolatileShort in interface Memorypublic void writeVolatileShort(Object object, long offset, short i16)
writeVolatileShort in interface Memorypublic void writeVolatileInt(long address,
int i32)
writeVolatileInt in interface Memorypublic void writeVolatileInt(Object object, long offset, int i32)
writeVolatileInt in interface Memorypublic void writeVolatileFloat(long address,
float f)
writeVolatileFloat in interface Memorypublic void writeVolatileFloat(Object object, long offset, float f)
writeVolatileFloat in interface Memorypublic void writeVolatileLong(long address,
long i64)
writeVolatileLong in interface Memorypublic void writeVolatileLong(Object object, long offset, long i64)
writeVolatileLong in interface Memorypublic void writeVolatileDouble(long address,
double d)
writeVolatileDouble in interface Memorypublic void writeVolatileDouble(Object object, long offset, double d)
writeVolatileDouble in interface Memorypublic int addInt(long address,
int increment)
throws MisAlignedAssertionError
addInt in interface MemoryMisAlignedAssertionErrorpublic int addInt(Object object, long offset, int increment)
public long addLong(long address,
long increment)
throws MisAlignedAssertionError
addLong in interface MemoryMisAlignedAssertionErrorpublic long addLong(Object object, long offset, long increment) throws MisAlignedAssertionError
addLong in interface MemoryMisAlignedAssertionErrorpublic void copy8bit(String s, int start, int length, long addr)
public boolean isEqual(long addr,
String s,
int length)
public boolean safeAlignedInt(long addr)
safeAlignedInt in interface Memorypublic boolean safeAlignedLong(long addr)
safeAlignedLong in interface Memorypublic int arrayBaseOffset(Class<?> type)
arrayBaseOffset in interface Memorypublic long objectFieldOffset(Field field)
objectFieldOffset in interface Memorypublic long address(ByteBuffer bb)
Copyright © 2022. All rights reserved.