Search in sources :

Example 1 with J9ObjectMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.

the class MonitorTableList method peek.

/**
 * Search all the monitor tables in the J9JavaVM->monitorTables for the inflated monitor corresponding to the specified object
 *
 * @throws CorruptDataException
 *
 * @param object the object
 *
 * @returns the J9ObjectMonitorPointer found in the table, or J9ObjectMonitorPointer.NULL if no entry was found
 *
 * @see util/thrinfo.c : monitorTablePeek
 */
public static J9ObjectMonitorPointer peek(J9ObjectPointer object) throws CorruptDataException {
    if ((null == object) || (object.isNull())) {
        return J9ObjectMonitorPointer.NULL;
    }
    MonitorTable table = null;
    if (!initialized) {
        initializeCaches();
    }
    J9ObjectMonitorPointer objectMonitor = J9ObjectMonitorPointer.NULL;
    long hashcode = new U32(ObjectModel.getObjectHashCode(object)).longValue();
    int index = (int) (hashcode % monitorTables.length);
    table = monitorTables[index];
    if (table == null) {
        return objectMonitor;
    }
    if (null != table) {
        objectMonitor = table.peek(object);
        if (null == objectMonitor) {
            return J9ObjectMonitorPointer.NULL;
        }
    }
    return objectMonitor;
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)

Example 2 with J9ObjectMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.

the class MonitorTable method initializedCachedMonitorTable.

private void initializedCachedMonitorTable() {
    cachedMonitorTable = new HashMap<J9ObjectPointer, J9ObjectMonitorPointer>();
    try {
        Iterator<J9ObjectMonitorPointer> iterator = iterator();
        while (iterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitor = iterator.next();
            J9ObjectPointer object = J9ObjectPointer.cast(objectMonitor.monitor().userData());
            cachedMonitorTable.put(object, objectMonitor);
        }
    } catch (CorruptDataException e) {
        raiseCorruptDataEvent("Error building cached monitor table", e, false);
    }
}
Also used : J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 3 with J9ObjectMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.

the class SimpleRootScanner method doMonitorLookupCacheSlot.

@Override
protected void doMonitorLookupCacheSlot(J9ObjectMonitorPointer slot, ObjectMonitorReferencePointer address) {
    try {
        J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(slot.monitor());
        doSlot(J9ObjectPointer.cast(monitor.userData()), VoidPointer.cast(monitor.userDataEA()));
    } catch (CorruptDataException e) {
        EventManager.raiseCorruptDataEvent("Errror accessing object slot from J9ObjectMonitorPointer: " + slot.getHexAddress(), e, false);
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)

Example 4 with J9ObjectMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.

the class ThreadsCommand method monitors.

/**
 * Prints all of the J9ObjectMonitors in the list of monitor tables.
 *
 * NOTE: It does not dump system monitors found in the thread lib monitor_pool
 *
 * @param out the PrintStream to write output to
 *
 * @see {@link MonitorsCommand}
 */
private void monitors(PrintStream out) throws DDRInteractiveCommandException {
    try {
        MonitorTableListIterator iterator = new MonitorTableListIterator();
        MonitorTable previousMonitorTable = null;
        while (iterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitorPointer = iterator.next();
            MonitorTable currentMonitorTable = iterator.currentMonitorTable();
            if (!currentMonitorTable.equals(previousMonitorTable)) {
                /* Print header for new monitor table */
                out.append("Table = " + currentMonitorTable.getTableName() + ", itemCount=" + currentMonitorTable.getCount());
                out.append(nl);
            }
            out.append(String.format("\n    !j9thread 0x%s    !j9threadmonitor 0x%s", Long.toHexString(objectMonitorPointer.monitor().owner().getAddress()), Long.toHexString(objectMonitorPointer.monitor().getAddress())));
            out.append(nl);
            previousMonitorTable = currentMonitorTable;
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) MonitorTableListIterator(com.ibm.j9ddr.vm29.j9.MonitorTableListIterator) MonitorTable(com.ibm.j9ddr.vm29.j9.MonitorTable)

Example 5 with J9ObjectMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer in project openj9 by eclipse.

the class MonitorsCommand method tablePrintHelper.

/**
 * Helper to print monitor tables.
 *
 * @param filter
 * @param builder
 * @param objectMonitorPointer
 * @return
 * @throws DDRInteractiveCommandException
 */
private ObjectMonitor tablePrintHelper(FilterOptions filter, StringBuilder builder, J9ObjectMonitorPointer objectMonitorPointer) throws DDRInteractiveCommandException {
    try {
        J9ThreadMonitorPointer threadMonitorPointer = objectMonitorPointer.monitor();
        J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(threadMonitorPointer);
        if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
            if (!lock.userData().eq(0)) {
                // this is an object monitor in the system monitor table
                J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
                ObjectMonitor objMon = ObjectAccessBarrier.getMonitor(obj);
                if (null != objMon) {
                    writeObjectMonitorToBuffer(filter, objMon, builder);
                    return objMon;
                }
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    return null;
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)9 J9ObjectMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)8 J9ThreadAbstractMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)5 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)4 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)4 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)3 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)2 GCMonitorReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCMonitorReferenceIterator)2 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)2 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)1 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)1 U32 (com.ibm.j9ddr.vm29.types.U32)1 HashSet (java.util.HashSet)1