Class HotspotUnsafe

java.lang.Object
org.openjdk.jol.vm.HotspotUnsafe
All Implemented Interfaces:
VirtualMachine

class HotspotUnsafe extends Object implements VirtualMachine
  • Field Details

    • MAGIC_FIELD_OFFSET_OPTION

      private static final String MAGIC_FIELD_OFFSET_OPTION
      See Also:
    • MAGIC_FIELD_OFFSET

      private static final boolean MAGIC_FIELD_OFFSET
    • U

      private final sun.misc.Unsafe U
    • instrumentation

      private final Instrumentation 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

      private final HotspotUnsafe.Sizes sizes
    • lilliputVM

      private final boolean lilliputVM
    • mfoInitialized

      private volatile boolean mfoInitialized
    • mfoUnsafe

      private Object mfoUnsafe
    • mfoMethod

      private Method mfoMethod
    • BUFFERS

      private final ThreadLocal<Object[]> BUFFERS
  • Constructor Details

  • Method Details

    • guessLilliput

      private boolean guessLilliput(int addressSize)
    • guessNarrowOopBase

      private long guessNarrowOopBase()
    • guessOopSize

      private int guessOopSize()
    • guessHeaderSize

      private int guessHeaderSize()
    • sizeOf

      public long sizeOf(Object o)
      Description copied from interface: VirtualMachine
      Returns the shallow size of the given object.
      Specified by:
      sizeOf in interface VirtualMachine
      Parameters:
      o - object
      Returns:
      shallow size
    • sizeOfField

      public long sizeOfField(String klassName)
      Description copied from interface: VirtualMachine
      Returns the size of a field holding the type.
      Specified by:
      sizeOfField in interface VirtualMachine
      Parameters:
      klassName - klass
      Returns:
      slot size
    • objectAlignment

      public int objectAlignment()
      Description copied from interface: VirtualMachine
      Returns the object alignment.
      Specified by:
      objectAlignment in interface VirtualMachine
      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 interface VirtualMachine
      Returns:
      array header size
    • objectHeaderSize

      public int objectHeaderSize()
      Description copied from interface: VirtualMachine
      Returns the object header size.
      Specified by:
      objectHeaderSize in interface VirtualMachine
      Returns:
      header size
    • getMinDiff

      private int getMinDiff(Class<?> klass)
    • addressSize

      public int addressSize()
      Description copied from interface: VirtualMachine
      Returns native address size.
      Specified by:
      addressSize in interface VirtualMachine
      Returns:
      address size in bytes
    • classPointerSize

      public int classPointerSize()
      Description copied from interface: VirtualMachine
      Returns class pointer size.
      Specified by:
      classPointerSize in interface VirtualMachine
      Returns:
      class pointer size, in bytes
    • details

      public String details()
      Description copied from interface: VirtualMachine
      Returns the informational details about the current VM mode
      Specified by:
      details in interface VirtualMachine
      Returns:
      String details
    • instantiateType

      private static Object instantiateType(int type)
    • guessAlignment

      private int guessAlignment()
    • addressOf

      public long addressOf(Object o)
      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 interface VirtualMachine
      Parameters:
      o - object
      Returns:
      address
    • arrayBaseOffset

      public int arrayBaseOffset(String arrayComponentKlass)
      Description copied from interface: VirtualMachine
      Returns the array base offset for an array of a given component type.
      Specified by:
      arrayBaseOffset in interface VirtualMachine
      Parameters:
      arrayComponentKlass - component type
      Returns:
      base offset
    • arrayIndexScale

      public int arrayIndexScale(String arrayComponentKlass)
      Description copied from interface: VirtualMachine
      Returns the array index scale for an array of a given component type.
      Specified by:
      arrayIndexScale in interface VirtualMachine
      Parameters:
      arrayComponentKlass - component type
      Returns:
      index scale
    • getBoolean

      public boolean getBoolean(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a boolean off the object at given offset.
      Specified by:
      getBoolean in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the boolean
    • getByte

      public byte getByte(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a byte off the object at given offset.
      Specified by:
      getByte in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the byte
    • getShort

      public short getShort(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a short off the object at given offset.
      Specified by:
      getShort in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the short
    • getChar

      public char getChar(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a char off the object at given offset.
      Specified by:
      getChar in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the char
    • getInt

      public int getInt(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads an int off the object at given offset.
      Specified by:
      getInt in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the int
    • getFloat

      public float getFloat(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a float off the object at given offset.
      Specified by:
      getFloat in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the float
    • getLong

      public long getLong(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a long off the object at given offset.
      Specified by:
      getLong in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the long
    • getDouble

      public double getDouble(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads a double off the object at given offset.
      Specified by:
      getDouble in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the double
    • getObject

      public Object getObject(Object obj, long offset)
      Description copied from interface: VirtualMachine
      Reads an object off the object at given offset.
      Specified by:
      getObject in interface VirtualMachine
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the Object
    • fieldOffset

      public long fieldOffset(Field field)
      Description copied from interface: VirtualMachine
      Returns the field offset for a given field, starting from the object base.
      Specified by:
      fieldOffset in interface VirtualMachine
      Parameters:
      field - field
      Returns:
      offset
    • magicFieldOffset

      private long magicFieldOffset(Field field, RuntimeException original)
    • 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

      private String formatAddressAsHexByAddressSize(long address)