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;
}
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);
}
}
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;
}
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);
}
}
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);
}
}
}
}
}
Aggregations