Search in sources :

Example 1 with ObjectMonitor

use of com.ibm.j9ddr.vm29.j9.ObjectMonitor 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 ObjectMonitor

use of com.ibm.j9ddr.vm29.j9.ObjectMonitor 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 ObjectMonitor

use of com.ibm.j9ddr.vm29.j9.ObjectMonitor 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)

Example 4 with ObjectMonitor

use of com.ibm.j9ddr.vm29.j9.ObjectMonitor in project openj9 by eclipse.

the class MonitorsCommand method objectCommand.

/**
 * See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
 * function documentation
 *
 * @param args
 *            command args
 * @param out
 *            the output stream
 */
private void objectCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    FilterOptions filter = FilterOptions.defaultOption();
    try {
        J9ObjectPointer object = null;
        if (args.length < 2) {
            out.println("This command takes one address \"!monitors object <J9Object address>\"");
            return;
        }
        long objectAddr = Long.decode(args[1]);
        object = J9ObjectPointer.cast(objectAddr);
        ObjectMonitor objMonitor = ObjectMonitor.fromJ9Object(object);
        if (null == objMonitor) {
            out.printf("No corresponding monitor was found for %s\n", object.getHexAddress());
        } else {
            writeObjectMonitor(filter, objMonitor, out);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Example 5 with ObjectMonitor

use of com.ibm.j9ddr.vm29.j9.ObjectMonitor in project openj9 by eclipse.

the class MonitorsCommand method printMonitorsForJ9VMThread.

private void printMonitorsForJ9VMThread(PrintStream out, J9JavaVMPointer vm, J9VMThreadPointer thread) throws CorruptDataException {
    FilterOptions defaultFilter = FilterOptions.defaultOption();
    MonitorIterator iterator = new MonitorIterator(vm);
    while (iterator.hasNext()) {
        Object current = iterator.next();
        if (current instanceof ObjectMonitor) {
            ObjectMonitor objMon = (ObjectMonitor) current;
            // Step 2: Print any monitors that the thread is the owner of:
            if (thread.equals(objMon.getOwner())) {
                out.print("Owns Object Monitor:\n\t");
                writeObjectMonitor(defaultFilter, objMon, out);
            }
            // Step 3: Print any monitors that the thread is blocking on::
            for (J9VMThreadPointer threadPtr : objMon.getBlockedThreads()) {
                if (threadPtr.equals(thread)) {
                    out.print(String.format("Blocking on (Enter Waiter):\n\t"));
                    writeObjectMonitor(defaultFilter, objMon, out);
                }
            }
            // Step 4: Print any monitors that the thread is waiting on:
            for (J9VMThreadPointer threadPtr : objMon.getWaitingThreads()) {
                if (threadPtr.equals(thread)) {
                    out.print(String.format("Waiting on (Notify Waiter):\n\t"));
                    writeObjectMonitor(defaultFilter, objMon, out);
                }
            }
        }
    }
}
Also used : MonitorIterator(com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Aggregations

ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)6 J9ObjectMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)6 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)6 J9ThreadAbstractMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)6 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)4 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)3 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)3 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)2 GCMonitorReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCMonitorReferenceIterator)2 MonitorIterator (com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator)2 J9ThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer)2 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)1 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)1 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)1 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 MM_GCExtensionsPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_GCExtensionsPointer)1 MM_HeapRegionManagerPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer)1