Class HotspotUnsafe
java.lang.Object
org.openjdk.jol.vm.HotspotUnsafe
- All Implemented Interfaces:
VirtualMachine
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final intprivate final longprivate final ThreadLocal<Object[]> private final booleanprivate final booleanprivate final Instrumentationprivate final booleanprivate final booleanprivate static final booleanprivate static final Stringprivate booleanprivate Methodprivate Objectprivate final longprivate final intprivate final longprivate final intprivate final intprivate final intprivate final intprivate final HotspotUnsafe.Sizesprivate final sun.misc.Unsafe -
Constructor Summary
ConstructorsConstructorDescriptionHotspotUnsafe(sun.misc.Unsafe u, Instrumentation inst) HotspotUnsafe(sun.misc.Unsafe u, Instrumentation inst, UniverseData saDetails) -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the machine address of the given object.intReturns native address size.intarrayBaseOffset(String arrayComponentKlass) Returns the array base offset for an array of a given component type.intReturns the array header size.intarrayIndexScale(String arrayComponentKlass) Returns the array index scale for an array of a given component type.intReturns class pointer size.details()Returns the informational details about the current VM modelongfieldOffset(Field field) Returns the field offset for a given field, starting from the object base.private StringformatAddressAsHexByAddressSize(long address) booleangetBoolean(Object obj, long offset) Reads a boolean off the object at given offset.byteReads a byte off the object at given offset.charReads a char off the object at given offset.doubleReads a double off the object at given offset.floatReads a float off the object at given offset.intReads an int off the object at given offset.longReads a long off the object at given offset.private intgetMinDiff(Class<?> klass) Reads an object off the object at given offset.shortReads a short off the object at given offset.private intprivate intprivate booleanguessLilliput(int addressSize) private longprivate intprivate static ObjectinstantiateType(int type) private longmagicFieldOffset(Field field, RuntimeException original) intReturns the object alignment.intReturns the object header size.longReturns the shallow size of the given object.longsizeOfField(String klassName) Returns the size of a field holding the type.private longtoJvmAddress(long address) private longtoJvmKlassAddress(long address) private longtoJvmOopAddress(long address) private longtoNativeAddress(long address) private longtoNativeKlassAddress(long address) private longtoNativeOopAddress(long address)
-
Field Details
-
MAGIC_FIELD_OFFSET_OPTION
- See Also:
-
MAGIC_FIELD_OFFSET
private static final boolean MAGIC_FIELD_OFFSET -
U
private final sun.misc.Unsafe U -
instrumentation
-
isAccurate
private final boolean isAccurate -
addressSize
private final int addressSize -
objectAlignment
private final int objectAlignment -
oopSize
private final int oopSize -
compressedOopsEnabled
private final boolean compressedOopsEnabled -
narrowOopBase
private final long narrowOopBase -
narrowOopShift
private final int narrowOopShift -
compressedKlassOopsEnabled
private final boolean compressedKlassOopsEnabled -
narrowKlassBase
private final long narrowKlassBase -
narrowKlassShift
private final int narrowKlassShift -
arrayHeaderSize
private final int arrayHeaderSize -
objectHeaderSize
private final int objectHeaderSize -
arrayObjectBase
private final long arrayObjectBase -
sizes
-
lilliputVM
private final boolean lilliputVM -
mfoInitialized
private volatile boolean mfoInitialized -
mfoUnsafe
-
mfoMethod
-
BUFFERS
-
-
Constructor Details
-
HotspotUnsafe
HotspotUnsafe(sun.misc.Unsafe u, Instrumentation inst, UniverseData saDetails) -
HotspotUnsafe
HotspotUnsafe(sun.misc.Unsafe u, Instrumentation inst)
-
-
Method Details
-
guessLilliput
private boolean guessLilliput(int addressSize) -
guessNarrowOopBase
private long guessNarrowOopBase() -
guessOopSize
private int guessOopSize() -
guessHeaderSize
private int guessHeaderSize() -
sizeOf
Description copied from interface:VirtualMachineReturns the shallow size of the given object.- Specified by:
sizeOfin interfaceVirtualMachine- Parameters:
o- object- Returns:
- shallow size
-
sizeOfField
Description copied from interface:VirtualMachineReturns the size of a field holding the type.- Specified by:
sizeOfFieldin interfaceVirtualMachine- Parameters:
klassName- klass- Returns:
- slot size
-
objectAlignment
public int objectAlignment()Description copied from interface:VirtualMachineReturns the object alignment.- Specified by:
objectAlignmentin interfaceVirtualMachine- Returns:
- object alignment
-
arrayHeaderSize
public int arrayHeaderSize()Description copied from interface:VirtualMachineReturns the array header size. This includes the array length pseudofield.- Specified by:
arrayHeaderSizein interfaceVirtualMachine- Returns:
- array header size
-
objectHeaderSize
public int objectHeaderSize()Description copied from interface:VirtualMachineReturns the object header size.- Specified by:
objectHeaderSizein interfaceVirtualMachine- Returns:
- header size
-
getMinDiff
-
addressSize
public int addressSize()Description copied from interface:VirtualMachineReturns native address size.- Specified by:
addressSizein interfaceVirtualMachine- Returns:
- address size in bytes
-
classPointerSize
public int classPointerSize()Description copied from interface:VirtualMachineReturns class pointer size.- Specified by:
classPointerSizein interfaceVirtualMachine- Returns:
- class pointer size, in bytes
-
details
Description copied from interface:VirtualMachineReturns the informational details about the current VM mode- Specified by:
detailsin interfaceVirtualMachine- Returns:
- String details
-
instantiateType
-
guessAlignment
private int guessAlignment() -
addressOf
Description copied from interface:VirtualMachineReturns the machine address of the given object. Note that in some VM modes, the addresses would be guesses, based on internal experiments which would try to figure out the reference encoding. Use this data with care. Doing the naked memory access on the result of this method may corrupt the memory.- Specified by:
addressOfin interfaceVirtualMachine- Parameters:
o- object- Returns:
- address
-
arrayBaseOffset
Description copied from interface:VirtualMachineReturns the array base offset for an array of a given component type.- Specified by:
arrayBaseOffsetin interfaceVirtualMachine- Parameters:
arrayComponentKlass- component type- Returns:
- base offset
-
arrayIndexScale
Description copied from interface:VirtualMachineReturns the array index scale for an array of a given component type.- Specified by:
arrayIndexScalein interfaceVirtualMachine- Parameters:
arrayComponentKlass- component type- Returns:
- index scale
-
getBoolean
Description copied from interface:VirtualMachineReads a boolean off the object at given offset.- Specified by:
getBooleanin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the boolean
-
getByte
Description copied from interface:VirtualMachineReads a byte off the object at given offset.- Specified by:
getBytein interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the byte
-
getShort
Description copied from interface:VirtualMachineReads a short off the object at given offset.- Specified by:
getShortin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the short
-
getChar
Description copied from interface:VirtualMachineReads a char off the object at given offset.- Specified by:
getCharin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the char
-
getInt
Description copied from interface:VirtualMachineReads an int off the object at given offset.- Specified by:
getIntin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the int
-
getFloat
Description copied from interface:VirtualMachineReads a float off the object at given offset.- Specified by:
getFloatin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the float
-
getLong
Description copied from interface:VirtualMachineReads a long off the object at given offset.- Specified by:
getLongin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the long
-
getDouble
Description copied from interface:VirtualMachineReads a double off the object at given offset.- Specified by:
getDoublein interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the double
-
getObject
Description copied from interface:VirtualMachineReads an object off the object at given offset.- Specified by:
getObjectin interfaceVirtualMachine- Parameters:
obj- instanceoffset- offset- Returns:
- the Object
-
fieldOffset
Description copied from interface:VirtualMachineReturns the field offset for a given field, starting from the object base.- Specified by:
fieldOffsetin interfaceVirtualMachine- Parameters:
field- field- Returns:
- offset
-
magicFieldOffset
-
toNativeAddress
private long toNativeAddress(long address) -
toJvmAddress
private long toJvmAddress(long address) -
toNativeOopAddress
private long toNativeOopAddress(long address) -
toJvmOopAddress
private long toJvmOopAddress(long address) -
toNativeKlassAddress
private long toNativeKlassAddress(long address) -
toJvmKlassAddress
private long toJvmKlassAddress(long address) -
formatAddressAsHexByAddressSize
-