Package org.openjdk.jol.vm
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 int
private final int
private final long
private final ThreadLocal
<Object[]> private final boolean
private final boolean
private final Instrumentation
private final boolean
private final boolean
private static final boolean
private static final String
private boolean
private Method
private Object
private final long
private final int
private final long
private final int
private final int
private final int
private final int
private final HotspotUnsafe.Sizes
private 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 TypeMethodDescriptionlong
Returns the machine address of the given object.int
Returns native address size.int
arrayBaseOffset
(String arrayComponentKlass) Returns the array base offset for an array of a given component type.int
Returns the array header size.int
arrayIndexScale
(String arrayComponentKlass) Returns the array index scale for an array of a given component type.int
Returns class pointer size.details()
Returns the informational details about the current VM modelong
fieldOffset
(Field field) Returns the field offset for a given field, starting from the object base.private String
formatAddressAsHexByAddressSize
(long address) boolean
getBoolean
(Object obj, long offset) Reads a boolean off the object at given offset.byte
Reads a byte off the object at given offset.char
Reads a char off the object at given offset.double
Reads a double off the object at given offset.float
Reads a float off the object at given offset.int
Reads an int off the object at given offset.long
Reads a long off the object at given offset.private int
getMinDiff
(Class<?> klass) Reads an object off the object at given offset.short
Reads a short off the object at given offset.private int
private int
private boolean
guessLilliput
(int addressSize) private long
private int
private static Object
instantiateType
(int type) private long
magicFieldOffset
(Field field, RuntimeException original) int
Returns the object alignment.int
Returns the object header size.long
Returns the shallow size of the given object.long
sizeOfField
(String klassName) Returns the size of a field holding the type.private long
toJvmAddress
(long address) private long
toJvmKlassAddress
(long address) private long
toJvmOopAddress
(long address) private long
toNativeAddress
(long address) private long
toNativeKlassAddress
(long address) private long
toNativeOopAddress
(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:VirtualMachine
Returns the shallow size of the given object.- Specified by:
sizeOf
in interfaceVirtualMachine
- Parameters:
o
- object- Returns:
- shallow size
-
sizeOfField
Description copied from interface:VirtualMachine
Returns the size of a field holding the type.- Specified by:
sizeOfField
in interfaceVirtualMachine
- Parameters:
klassName
- klass- Returns:
- slot size
-
objectAlignment
public int objectAlignment()Description copied from interface:VirtualMachine
Returns the object alignment.- Specified by:
objectAlignment
in interfaceVirtualMachine
- Returns:
- object alignment
-
arrayHeaderSize
public int arrayHeaderSize()Description copied from interface:VirtualMachine
Returns the array header size. This includes the array length pseudofield.- Specified by:
arrayHeaderSize
in interfaceVirtualMachine
- Returns:
- array header size
-
objectHeaderSize
public int objectHeaderSize()Description copied from interface:VirtualMachine
Returns the object header size.- Specified by:
objectHeaderSize
in interfaceVirtualMachine
- Returns:
- header size
-
getMinDiff
-
addressSize
public int addressSize()Description copied from interface:VirtualMachine
Returns native address size.- Specified by:
addressSize
in interfaceVirtualMachine
- Returns:
- address size in bytes
-
classPointerSize
public int classPointerSize()Description copied from interface:VirtualMachine
Returns class pointer size.- Specified by:
classPointerSize
in interfaceVirtualMachine
- Returns:
- class pointer size, in bytes
-
details
Description copied from interface:VirtualMachine
Returns the informational details about the current VM mode- Specified by:
details
in interfaceVirtualMachine
- Returns:
- String details
-
instantiateType
-
guessAlignment
private int guessAlignment() -
addressOf
Description copied from interface:VirtualMachine
Returns 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:
addressOf
in interfaceVirtualMachine
- Parameters:
o
- object- Returns:
- address
-
arrayBaseOffset
Description copied from interface:VirtualMachine
Returns the array base offset for an array of a given component type.- Specified by:
arrayBaseOffset
in interfaceVirtualMachine
- Parameters:
arrayComponentKlass
- component type- Returns:
- base offset
-
arrayIndexScale
Description copied from interface:VirtualMachine
Returns the array index scale for an array of a given component type.- Specified by:
arrayIndexScale
in interfaceVirtualMachine
- Parameters:
arrayComponentKlass
- component type- Returns:
- index scale
-
getBoolean
Description copied from interface:VirtualMachine
Reads a boolean off the object at given offset.- Specified by:
getBoolean
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the boolean
-
getByte
Description copied from interface:VirtualMachine
Reads a byte off the object at given offset.- Specified by:
getByte
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the byte
-
getShort
Description copied from interface:VirtualMachine
Reads a short off the object at given offset.- Specified by:
getShort
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the short
-
getChar
Description copied from interface:VirtualMachine
Reads a char off the object at given offset.- Specified by:
getChar
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the char
-
getInt
Description copied from interface:VirtualMachine
Reads an int off the object at given offset.- Specified by:
getInt
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the int
-
getFloat
Description copied from interface:VirtualMachine
Reads a float off the object at given offset.- Specified by:
getFloat
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the float
-
getLong
Description copied from interface:VirtualMachine
Reads a long off the object at given offset.- Specified by:
getLong
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the long
-
getDouble
Description copied from interface:VirtualMachine
Reads a double off the object at given offset.- Specified by:
getDouble
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the double
-
getObject
Description copied from interface:VirtualMachine
Reads an object off the object at given offset.- Specified by:
getObject
in interfaceVirtualMachine
- Parameters:
obj
- instanceoffset
- offset- Returns:
- the Object
-
fieldOffset
Description copied from interface:VirtualMachine
Returns the field offset for a given field, starting from the object base.- Specified by:
fieldOffset
in 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
-