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