Package one.microstream.memory
Class XMemory
- java.lang.Object
-
- one.microstream.memory.XMemory
-
public final class XMemory extends Object
Util class for low-level VM memory operations and information that makes the call site independent of a certain JVM implementation (e.g. java.misc.Unsafe).
-
-
Constructor Summary
Constructors Constructor Description XMemory()
-
Method Summary
Modifier and Type Method Description static long
_longFromByteArray(byte[] bytes)
static void
_longInByteArray(byte[] bytes, long value)
static long
alignAddress(long address)
static long
allocate(long bytes)
static byte[]
asByteArray(long value)
static byte[]
asByteArray(long[] longArray)
static int
bitSize_boolean()
static int
bitSize_byte()
static int
bitSize_char()
static int
bitSize_double()
static int
bitSize_float()
static int
bitSize_int()
static int
bitSize_long()
static int
bitSize_short()
static int
byteSize_boolean()
static int
byteSize_byte()
static int
byteSize_char()
static int
byteSize_double()
static int
byteSize_float()
static int
byteSize_int()
static int
byteSize_long()
static int
byteSize_short()
static long
byteSizeArray_boolean(long elementCount)
static long
byteSizeArray_byte(long elementCount)
static long
byteSizeArray_char(long elementCount)
static long
byteSizeArray_double(long elementCount)
static long
byteSizeArray_float(long elementCount)
static long
byteSizeArray_int(long elementCount)
static long
byteSizeArray_long(long elementCount)
static long
byteSizeArray_short(long elementCount)
static long
byteSizeArrayObject(long elementCount)
static int
byteSizeFieldValue(Class<?> type)
static int
byteSizeInstance(Class<?> type)
static int
byteSizeObjectHeader()
static int
byteSizePrimitive(Class<?> type)
static int
byteSizeReference()
static int
calculatePrimitivesLength(Field[] primFields)
static Field[]
collectPrimitiveFieldsByByteSize(Field[] fields, int byteSize)
static boolean
compareAndSwap_int(Object subject, long offset, int expected, int replacement)
static boolean
compareAndSwap_long(Object subject, long offset, long expected, long replacement)
static boolean
compareAndSwapObject(Object subject, long offset, Object expected, Object replacement)
static void
copyArrayToAddress(boolean[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(boolean[] array, long targetAddress)
static void
copyArrayToAddress(byte[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(byte[] array, long targetAddress)
static void
copyArrayToAddress(char[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(char[] array, long targetAddress)
static void
copyArrayToAddress(double[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(double[] array, long targetAddress)
static void
copyArrayToAddress(float[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(float[] array, long targetAddress)
static void
copyArrayToAddress(int[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(int[] array, long targetAddress)
static void
copyArrayToAddress(long[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(long[] array, long targetAddress)
static void
copyArrayToAddress(short[] array, int offset, int length, long targetAddress)
static void
copyArrayToAddress(short[] array, long targetAddress)
static void
copyRange(long sourceAddress, long targetAddress, long length)
static void
copyRange(Object source, long sourceOffset, Object target, long targetOffset, long length)
static void
copyRangeToArray(long sourceAddress, boolean[] target)
static void
copyRangeToArray(long sourceAddress, byte[] target)
static void
copyRangeToArray(long sourceAddress, byte[] target, int targetIndex, long length)
static void
copyRangeToArray(long sourceAddress, char[] target)
static void
copyRangeToArray(long sourceAddress, char[] target, int targetIndex, long targetLength)
static void
copyRangeToArray(long sourceAddress, double[] target)
static void
copyRangeToArray(long sourceAddress, float[] target)
static void
copyRangeToArray(long sourceAddress, int[] target)
static void
copyRangeToArray(long sourceAddress, long[] target)
static void
copyRangeToArray(long sourceAddress, short[] target)
static int
defaultBufferSize()
Arbitrary value that coincidently matches most hardware's page sizes without being hard-tied to Unsafe#pageSize.static void
ensureClassInitialized(Class<?> c)
static void
ensureClassInitialized(Class<?>... classes)
static void
fillRange(long address, long length, byte value)
static void
free(long address)
static boolean
get_boolean(long address)
static boolean
get_boolean(Object instance, long address)
static boolean
get_booleanFromBytes(byte[] data, int offset)
static byte
get_byte(long address)
static byte
get_byte(Object instance, long address)
static byte
get_byteFromBytes(byte[] data, int offset)
static char
get_char(long address)
static char
get_char(Object instance, long address)
static char
get_charFromBytes(byte[] data, int offset)
static double
get_double(long address)
static double
get_double(Object instance, long address)
static double
get_doubleFromBytes(byte[] data, int offset)
static float
get_float(long address)
static float
get_float(Object instance, long address)
static float
get_floatFromBytes(byte[] data, int offset)
static int
get_int(long address)
static int
get_int(Object instance, long address)
static int
get_intFromBytes(byte[] data, int offset)
static long
get_long(long address)
static long
get_long(Object instance, long address)
static long
get_longFromBytes(byte[] data, int offset)
static short
get_short(long address)
static short
get_short(Object instance, long address)
static short
get_shortFromBytes(byte[] data, int offset)
static Object
getObject(long address)
static Object
getObject(Object instance, long address)
static Object
getStaticFieldBase(Field field)
static Object
getStaticReference(Field field)
static Object
getSystemInstance()
static <T> T
instantiate(Class<T> c)
static ByteOrder
nativeByteOrder()
static long
objectFieldOffset(Field field)
static long[]
objectFieldOffsets(Field[] fields)
static int
pageSize()
Returns the system's memory "page size" (whatever that may be exactely for a given system).static void
put_boolean(byte[] bytes, int index, char value)
static void
put_byte(byte[] bytes, int index, short value)
static void
put_char(byte[] bytes, int index, char value)
static void
put_double(byte[] bytes, int index, double value)
static void
put_float(byte[] bytes, int index, float value)
static void
put_int(byte[] bytes, int index, int value)
static void
put_long(byte[] bytes, int index, long value)
static void
put_short(byte[] bytes, int index, short value)
static long
reallocate(long address, long bytes)
static ByteOrder
resolveByteOrder(String name)
static void
set_boolean(long address, boolean value)
static void
set_boolean(Object instance, long offset, boolean value)
static void
set_byte(long address, byte value)
static void
set_byte(Object instance, long offset, byte value)
static void
set_char(long address, char value)
static void
set_char(Object instance, long offset, char value)
static void
set_double(long address, double value)
static void
set_double(Object instance, long offset, double value)
static void
set_float(long address, float value)
static void
set_float(Object instance, long offset, float value)
static void
set_int(long address, int value)
static void
set_int(Object instance, long offset, int value)
static void
set_long(long address, long value)
static void
set_long(Object instance, long offset, long value)
static void
set_short(long address, short value)
static void
set_short(Object instance, long offset, short value)
static void
setObject(Object instance, long offset, Object value)
static long[]
staticFieldOffsets(Field[] fields)
static void
throwUnchecked(Throwable t)
-
-
-
Method Detail
-
getSystemInstance
public static final Object getSystemInstance()
-
objectFieldOffset
public static long objectFieldOffset(Field field)
-
objectFieldOffsets
public static long[] objectFieldOffsets(Field[] fields)
-
bitSize_byte
public static final int bitSize_byte()
-
bitSize_boolean
public static final int bitSize_boolean()
-
bitSize_short
public static final int bitSize_short()
-
bitSize_char
public static final int bitSize_char()
-
bitSize_int
public static final int bitSize_int()
-
bitSize_float
public static final int bitSize_float()
-
bitSize_long
public static final int bitSize_long()
-
bitSize_double
public static final int bitSize_double()
-
byteSizeFieldValue
public static final int byteSizeFieldValue(Class<?> type)
-
byteSizePrimitive
public static final int byteSizePrimitive(Class<?> type)
-
byteSize_byte
public static final int byteSize_byte()
-
byteSize_boolean
public static final int byteSize_boolean()
-
byteSize_short
public static final int byteSize_short()
-
byteSize_char
public static final int byteSize_char()
-
byteSize_int
public static final int byteSize_int()
-
byteSize_float
public static final int byteSize_float()
-
byteSize_long
public static final int byteSize_long()
-
byteSize_double
public static final int byteSize_double()
-
byteSizeObjectHeader
public static final int byteSizeObjectHeader()
-
byteSizeReference
public static final int byteSizeReference()
-
byteSizeArray_byte
public static final long byteSizeArray_byte(long elementCount)
-
byteSizeArray_boolean
public static final long byteSizeArray_boolean(long elementCount)
-
byteSizeArray_short
public static final long byteSizeArray_short(long elementCount)
-
byteSizeArray_char
public static final long byteSizeArray_char(long elementCount)
-
byteSizeArray_int
public static final long byteSizeArray_int(long elementCount)
-
byteSizeArray_float
public static final long byteSizeArray_float(long elementCount)
-
byteSizeArray_long
public static final long byteSizeArray_long(long elementCount)
-
byteSizeArray_double
public static final long byteSizeArray_double(long elementCount)
-
byteSizeArrayObject
public static final long byteSizeArrayObject(long elementCount)
-
byteSizeInstance
public static final int byteSizeInstance(Class<?> type)
-
alignAddress
public static final long alignAddress(long address)
-
collectPrimitiveFieldsByByteSize
public static Field[] collectPrimitiveFieldsByByteSize(Field[] fields, int byteSize)
-
calculatePrimitivesLength
public static int calculatePrimitivesLength(Field[] primFields)
-
staticFieldOffsets
public static long[] staticFieldOffsets(Field[] fields)
-
asByteArray
public static byte[] asByteArray(long[] longArray)
-
asByteArray
public static byte[] asByteArray(long value)
-
defaultBufferSize
public static int defaultBufferSize()
Arbitrary value that coincidently matches most hardware's page sizes without being hard-tied to Unsafe#pageSize. So this value is an educated guess and most of the time (almost always) a "good" value when paged-sized-ish buffer sizes are needed, while still not being at the mercy of an OS's JVM implementation.- Returns:
- a "good" value for a paged-sized-ish default buffer size.
-
pageSize
public static int pageSize()
Returns the system's memory "page size" (whatever that may be exactely for a given system). Use with care (and the dependency to a system value in mind!).- Returns:
- the system's memory "page size".
-
put_byte
public static void put_byte(byte[] bytes, int index, short value)
-
put_boolean
public static void put_boolean(byte[] bytes, int index, char value)
-
put_short
public static void put_short(byte[] bytes, int index, short value)
-
put_char
public static void put_char(byte[] bytes, int index, char value)
-
put_int
public static void put_int(byte[] bytes, int index, int value)
-
put_float
public static void put_float(byte[] bytes, int index, float value)
-
put_long
public static void put_long(byte[] bytes, int index, long value)
-
put_double
public static void put_double(byte[] bytes, int index, double value)
-
_longInByteArray
public static void _longInByteArray(byte[] bytes, long value)
-
_longFromByteArray
public static long _longFromByteArray(byte[] bytes)
-
get_byte
public static final byte get_byte(long address)
-
get_boolean
public static final boolean get_boolean(long address)
-
get_short
public static final short get_short(long address)
-
get_char
public static final char get_char(long address)
-
get_int
public static final int get_int(long address)
-
get_float
public static final float get_float(long address)
-
get_long
public static final long get_long(long address)
-
get_double
public static final double get_double(long address)
-
getObject
public static final Object getObject(long address)
-
get_byte
public static final byte get_byte(Object instance, long address)
-
get_boolean
public static final boolean get_boolean(Object instance, long address)
-
get_short
public static final short get_short(Object instance, long address)
-
get_char
public static final char get_char(Object instance, long address)
-
get_int
public static final int get_int(Object instance, long address)
-
get_float
public static final float get_float(Object instance, long address)
-
get_long
public static final long get_long(Object instance, long address)
-
get_double
public static final double get_double(Object instance, long address)
-
set_byte
public static final void set_byte(long address, byte value)
-
set_boolean
public static final void set_boolean(long address, boolean value)
-
set_short
public static final void set_short(long address, short value)
-
set_char
public static final void set_char(long address, char value)
-
set_int
public static final void set_int(long address, int value)
-
set_float
public static final void set_float(long address, float value)
-
set_long
public static final void set_long(long address, long value)
-
set_double
public static final void set_double(long address, double value)
-
set_byte
public static final void set_byte(Object instance, long offset, byte value)
-
set_boolean
public static final void set_boolean(Object instance, long offset, boolean value)
-
set_short
public static final void set_short(Object instance, long offset, short value)
-
set_char
public static final void set_char(Object instance, long offset, char value)
-
set_int
public static final void set_int(Object instance, long offset, int value)
-
set_float
public static final void set_float(Object instance, long offset, float value)
-
set_long
public static final void set_long(Object instance, long offset, long value)
-
set_double
public static final void set_double(Object instance, long offset, double value)
-
copyRange
public static final void copyRange(long sourceAddress, long targetAddress, long length)
-
copyRange
public static final void copyRange(Object source, long sourceOffset, Object target, long targetOffset, long length)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, byte[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, byte[] target, int targetIndex, long length)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, boolean[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, short[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, char[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, char[] target, int targetIndex, long targetLength)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, int[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, float[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, long[] target)
-
copyRangeToArray
public static final void copyRangeToArray(long sourceAddress, double[] target)
-
copyArrayToAddress
public static final void copyArrayToAddress(byte[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(byte[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(boolean[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(boolean[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(short[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(short[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(char[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(char[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(int[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(int[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(float[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(float[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(long[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(long[] array, int offset, int length, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(double[] array, long targetAddress)
-
copyArrayToAddress
public static final void copyArrayToAddress(double[] array, int offset, int length, long targetAddress)
-
get_byteFromBytes
public static final byte get_byteFromBytes(byte[] data, int offset)
-
get_booleanFromBytes
public static final boolean get_booleanFromBytes(byte[] data, int offset)
-
get_shortFromBytes
public static final short get_shortFromBytes(byte[] data, int offset)
-
get_charFromBytes
public static final char get_charFromBytes(byte[] data, int offset)
-
get_intFromBytes
public static final int get_intFromBytes(byte[] data, int offset)
-
get_floatFromBytes
public static final float get_floatFromBytes(byte[] data, int offset)
-
get_longFromBytes
public static final long get_longFromBytes(byte[] data, int offset)
-
get_doubleFromBytes
public static final double get_doubleFromBytes(byte[] data, int offset)
-
allocate
public static final long allocate(long bytes)
-
reallocate
public static final long reallocate(long address, long bytes)
-
fillRange
public static final void fillRange(long address, long length, byte value)
-
free
public static final void free(long address)
-
compareAndSwap_int
public static final boolean compareAndSwap_int(Object subject, long offset, int expected, int replacement)
-
compareAndSwap_long
public static final boolean compareAndSwap_long(Object subject, long offset, long expected, long replacement)
-
compareAndSwapObject
public static final boolean compareAndSwapObject(Object subject, long offset, Object expected, Object replacement)
-
nativeByteOrder
public static ByteOrder nativeByteOrder()
-
instantiate
public static final <T> T instantiate(Class<T> c) throws InstantiationRuntimeException
- Throws:
InstantiationRuntimeException
-
throwUnchecked
public static final void throwUnchecked(Throwable t)
-
ensureClassInitialized
public static final void ensureClassInitialized(Class<?>... classes)
-
ensureClassInitialized
public static final void ensureClassInitialized(Class<?> c)
-
-