Class HotspotUnsafe

    • Field Detail

      • MAGIC_FIELD_OFFSET_OPTION

        private static final java.lang.String MAGIC_FIELD_OFFSET_OPTION
        See Also:
        Constant Field Values
      • MAGIC_FIELD_OFFSET

        private static final boolean MAGIC_FIELD_OFFSET
      • U

        private final sun.misc.Unsafe U
      • instrumentation

        private final java.lang.instrument.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
      • lilliputVM

        private final boolean lilliputVM
      • mfoInitialized

        private volatile boolean mfoInitialized
      • mfoUnsafe

        private java.lang.Object mfoUnsafe
      • mfoMethod

        private java.lang.reflect.Method mfoMethod
      • BUFFERS

        private final java.lang.ThreadLocal<java.lang.Object[]> BUFFERS
    • Constructor Detail

      • HotspotUnsafe

        HotspotUnsafe​(sun.misc.Unsafe u,
                      java.lang.instrument.Instrumentation inst,
                      UniverseData saDetails)
      • HotspotUnsafe

        HotspotUnsafe​(sun.misc.Unsafe u,
                      java.lang.instrument.Instrumentation inst)
    • Method Detail

      • guessLilliput

        private boolean guessLilliput​(int addressSize)
      • guessNarrowOopBase

        private long guessNarrowOopBase()
      • guessOopSize

        private int guessOopSize()
      • guessHeaderSize

        private int guessHeaderSize()
      • sizeOf

        public long sizeOf​(java.lang.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​(java.lang.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
      • getMinDiff

        private int getMinDiff​(java.lang.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 java.lang.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 java.lang.Object instantiateType​(int type)
      • guessAlignment

        private int guessAlignment()
      • addressOf

        public long addressOf​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.Object getObject​(java.lang.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​(java.lang.reflect.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​(java.lang.reflect.Field field,
                                      java.lang.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 java.lang.String formatAddressAsHexByAddressSize​(long address)