use of com.ibm.j9ddr.vm29.j9.MonitorTable 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.MonitorTable 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);
}
}
use of com.ibm.j9ddr.vm29.j9.MonitorTable in project openj9 by eclipse.
the class MonitorsCommand method tableCommand.
/**
* See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
* function documentation
*
* @param args
* command args
* @param out
* the output stream
* @throws DDRInteractiveCommandException
*/
private void tableCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
FilterOptions filter = FilterOptions.defaultOption();
if (args.length > 2) {
filter = FilterOptions.parseOption(args[2]);
} else if (args.length == 2) {
out.println("No filter specified, defaulting to 'active' monitors.");
} else if (args.length < 2) {
out.println("This command takes one address argument: \"!monitors table <address>\"");
return;
}
try {
StringBuilder builder = new StringBuilder();
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
MonitorTableListIterator iterator = new MonitorTableListIterator();
boolean foundTable = false;
while (iterator.hasNext()) {
J9ObjectMonitorPointer objectMonitorPointer = iterator.next();
MonitorTable currentMonitorTable = iterator.currentMonitorTable();
if (currentMonitorTable.getMonitorTableListEntryPointer().equals(ptr)) {
tablePrintHelper(filter, builder, objectMonitorPointer);
foundTable = true;
}
}
out.append(builder);
if (false == foundTable) {
out.append(String.format("Could not find any J9MonitorTableListEntryPointer at address %s\n", ptr.getHexAddress()));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.MonitorTable in project openj9 by eclipse.
the class MonitorTableList method initializeCaches.
private static synchronized void initializeCaches() throws CorruptDataException {
if (!initialized) {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
PointerPointer cursor = vm.monitorTables();
int count = vm.monitorTableCount().intValue();
monitorTables = new MonitorTable[count];
for (int i = 0; i < count; i++) {
J9MonitorTableListEntryPointer entries = vm.monitorTableList();
while (entries.notNull()) {
if (entries.monitorTable().eq(cursor.at(i))) {
monitorTables[i] = MonitorTable.from(entries);
break;
}
entries = entries.next();
}
}
initialized = true;
}
}
use of com.ibm.j9ddr.vm29.j9.MonitorTable in project openj9 by eclipse.
the class MonitorsCommand method tablesCommand.
/**
* See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
* function documentation
*
* @param args
* command args
* @param out
* the output stream
*/
private void tablesCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
try {
MonitorTableListIterator iterator = new MonitorTableListIterator();
MonitorTable previousMonitorTable = null;
while (iterator.hasNext()) {
MonitorTable currentMonitorTable = iterator.currentMonitorTable();
if (!currentMonitorTable.equals(previousMonitorTable)) {
/* Print header for new monitor table */
out.println(iterator.currentMonitorTable().extraInfo());
}
previousMonitorTable = currentMonitorTable;
iterator.next();
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations