use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class DumpSegregatedStatsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (!GCExtensions.isSegregatedHeap()) {
out.append("Only valid for a segregated heap\n");
return;
}
try {
/* Get the region pool */
MM_GCExtensionsPointer extensions = GCExtensions.getGCExtensionsPointer();
MM_RealtimeGCPointer realtimeGC = MM_RealtimeGCPointer.cast(extensions._globalCollector());
MM_RegionPoolSegregatedPointer regionPool = realtimeGC._memoryPool()._regionPool();
/* Get the size classes */
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMGCSizeClassesPointer sizeClasses = vm.realtimeSizeClasses();
long countTotal = 0;
long countAvailableSmallTotal = 0;
long countFullSmallTotal = 0;
long darkMatterBytesTotal = 0;
long allocCacheBytesTotal = 0;
/* arrayOffset is the total offset into a two dimensional array. Used to walk the
* the array linearly */
long arrayOffset = J9Consts.J9VMGC_SIZECLASSES_MIN_SMALL * MM_RegionPoolSegregated.NUM_DEFRAG_BUCKETS;
out.append("sizeClass | full | available | total | free cell count | dark | cache\n");
out.append("===============================================================================\n");
for (long sizeClassIndex = J9Consts.J9VMGC_SIZECLASSES_MIN_SMALL; sizeClassIndex <= J9Consts.J9VMGC_SIZECLASSES_MAX_SMALL; sizeClassIndex++) {
/* Print the sizeclass */
UDATA cellSize = sizeClasses.smallCellSizesEA().at(sizeClassIndex);
out.format("%2d: %5d | ", sizeClassIndex, cellSize.longValue());
MM_HeapRegionListPointer heapRegionQueue = MM_HeapRegionListPointer.cast(regionPool._smallFullRegionsEA().at(sizeClassIndex));
long countSmall = getTotalRegions(heapRegionQueue);
countFullSmallTotal += countSmall;
/* Print the number of full regions of this size class */
out.format("%4d | ", countSmall);
/* The number of free cells of this sizeclass */
long freeCellCount = 0;
for (long i = 0; i < MM_RegionPoolSegregated.NUM_DEFRAG_BUCKETS; i++) {
long count = 0;
MM_LockingHeapRegionQueuePointer heapRegionList = MM_LockingHeapRegionQueuePointer.cast(regionPool._smallAvailableRegionsEA().add(arrayOffset).at(0));
for (long j = 0; j < regionPool._splitAvailableListSplitCount().longValue(); j++) {
count += getTotalRegions(heapRegionList);
freeCellCount += getFreeCellCount(heapRegionList);
heapRegionList = heapRegionList.add(1);
}
/* increment to the next list */
arrayOffset += 1;
countSmall += count;
countAvailableSmallTotal += count;
/* Print the number of available regions in this defrag bucket */
out.format("%4d ", count);
}
countTotal += countSmall;
/* Print the total number of regions of this size class, and the number of free cells */
out.format("| %5d | %15d |", countSmall, freeCellCount);
/* Print the percentage of darkmatter in this region */
long darkMatterCellCount = regionPool._darkMatterCellCountEA().at(sizeClassIndex).longValue();
darkMatterBytesTotal += darkMatterCellCount * cellSize.longValue();
out.format("%%%3d | ", countSmall == 0 ? 0 : darkMatterCellCount / (countSmall * cellSize.longValue()));
/* Calculate the number of bytes in allocation caches */
long allocCacheSize = 0;
J9VMThreadPointer mainThread = vm.mainThread();
if (mainThread.notNull()) {
J9VMThreadPointer threadCursor = vm.mainThread();
do {
J9VMGCSegregatedAllocationCacheEntryPointer cache = threadCursor.segregatedAllocationCache();
cache = cache.add(sizeClassIndex);
allocCacheSize += cache.top().longValue() - cache.current().longValue();
threadCursor = threadCursor.linkNext();
} while (!threadCursor.eq(mainThread));
}
out.format("%5d\n", allocCacheSize);
allocCacheBytesTotal += allocCacheSize;
}
long regionSize = extensions.heap()._heapRegionManager()._regionSize().longValue();
out.format("region size %d\n", regionSize);
long arrayletLeafSize = extensions._omrVM()._arrayletLeafSize().longValue();
out.format("arraylet leaf size %d\n", arrayletLeafSize);
out.format("small total (full, available) region count %d (%d, %d)\n", countTotal, countFullSmallTotal, countAvailableSmallTotal);
long countFullArraylet = getTotalRegions(regionPool._arrayletFullRegions());
long countAvailArraylet = getTotalRegions(regionPool._arrayletAvailableRegions());
long countTotalArraylet = countFullArraylet + countAvailArraylet;
countTotal += countTotalArraylet;
out.format("arraylet total (full, available) region count %d (%d %d)\n", countTotalArraylet, countFullArraylet, countAvailArraylet);
long countLarge = getTotalRegions(regionPool._largeFullRegions());
countTotal += countLarge;
out.format("large full region count %d\n", countLarge);
long countFree = getTotalRegions(regionPool._singleFreeList());
countTotal += countFree;
out.format("free region count %d\n", countFree);
long countMultiFree = getTotalRegions(regionPool._multiFreeList());
countTotal += countMultiFree;
out.format("multiFree region count %d\n", countMultiFree);
long countCoalesce = getTotalRegions(regionPool._coalesceFreeList());
countTotal += countCoalesce;
out.format("coalesce region count %d\n", countCoalesce);
long heapSize = countTotal * regionSize;
out.format("total region count %d, total heap size %d \n", countTotal, heapSize);
out.format("dark matter total bytes %d (%2.2f%% of heap)\n", darkMatterBytesTotal, 100.0 * darkMatterBytesTotal / heapSize);
out.format("allocation cache total bytes %d (%2.2f%% of heap)\n", allocCacheBytesTotal, 100.0 * allocCacheBytesTotal / heapSize);
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class FindStackValueCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 == args.length) {
out.println("Usage error: Missing stackvalue to search for. See usage.");
printUsage(out);
return;
} else if (1 < args.length) {
out.println("Usage error: Too many stackvalues to search for. See usage.");
printUsage(out);
return;
}
try {
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
UDATAPointer value = UDATAPointer.cast(address);
GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
while (gcvmThreadListIterator.hasNext()) {
J9VMThreadPointer vmThreadPointer = gcvmThreadListIterator.next();
J9JavaStackPointer javaStackPointer = vmThreadPointer.stackObject();
J9JavaStackIterator javaStackIterator = J9JavaStackIterator.fromJ9JavaStack(javaStackPointer);
boolean found = false;
UDATA relativeSP = new UDATA(javaStackPointer.end().sub(vmThreadPointer.sp()));
while (javaStackIterator.hasNext()) {
J9JavaStackPointer stack = javaStackIterator.next();
UDATAPointer localEnd = stack.end().sub(1).add(1);
UDATAPointer search = localEnd.sub(relativeSP);
while (!search.eq(localEnd)) {
if (search.at(0).longValue() == value.longValue()) {
if (!found) {
out.append(String.format("!j9vmthread %s\n", Long.toHexString(vmThreadPointer.getAddress())));
found = true;
}
out.append(String.format("\tFound at %s\n", Long.toHexString(search.getAddress())));
}
search = search.add(1);
}
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class JitstackCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (!J9BuildFlags.interp_nativeSupport) {
CommandUtils.dbgPrint(out, "No JIT in this build\n");
return;
}
try {
String[] realArgs = null;
if (args.length != 0) {
realArgs = args[0].split(",");
}
if (args.length == 0 || !((realArgs.length == 3) || (realArgs.length == 4))) {
CommandUtils.dbgPrint(out, "Usage:\n");
CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc\n");
CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc,els\n");
CommandUtils.dbgPrint(out, "\tUse !jitstackslots instead of !jitstack to see slot values\n");
return;
}
long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
StackWalkerUtils.enableVerboseLogging(2, out);
WalkState walkState = new WalkState();
address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
UDATAPointer sp = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
U8Pointer pc = U8Pointer.cast(address);
UDATAPointer arg0EA = UDATAPointer.NULL;
J9MethodPointer literals = J9MethodPointer.NULL;
J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
if (realArgs.length == 4) {
address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
} else {
entryLocalStorage = thread.entryLocalStorage();
}
walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
walkState.flags |= J9_STACKWALK_START_AT_JIT_FRAME;
if (command.equalsIgnoreCase("!jitstackslots")) {
walkState.flags |= J9_STACKWALK_ITERATE_O_SLOTS;
// 100 is highly arbitrary but basically means "print everything".
// It is used in jextract where the message levels have been copied
// from to begin with, so it should mean we get the same output.
StackWalkerUtils.enableVerboseLogging(100, out);
}
walkState.walkThread = thread;
walkState.callBacks = new BaseStackWalkerCallbacks();
walkState.frameFlags = new UDATA(0);
StackWalkResult result = StackWalker.walkStackFrames(walkState, sp, arg0EA, pc, literals, entryLocalStorage);
if (result != StackWalkResult.NONE) {
out.println("Stack walk result: " + result);
}
StackWalkerUtils.disableVerboseLogging();
out.flush();
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class J9ClassShapeCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 1) {
CommandUtils.dbgPrint(out, "Usage: !j9classshape <classAddress>\n");
return;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9ClassPointer instanceClass = J9ClassPointer.NULL;
String classSelector = args[0];
if (classSelector.matches("\\p{Digit}.*")) {
/* addresses start with a decimal digit, possibly the '0' in "0x" */
instanceClass = J9ClassPointer.cast(CommandUtils.parsePointer(classSelector, J9BuildFlags.env_data64));
} else {
J9ClassPointer[] candidates = findClassByName(vm, classSelector);
if (candidates.length == 0) {
CommandUtils.dbgPrint(out, "No classes matching \"" + classSelector + "\" found\n");
return;
} else if (candidates.length > 1) {
CommandUtils.dbgPrint(out, "Multiple classes matching \"" + classSelector + "\" found\n");
return;
} else {
instanceClass = candidates[0];
String javaName = J9ClassHelper.getJavaName(instanceClass);
String hexString = instanceClass.getHexAddress();
CommandUtils.dbgPrint(out, String.format("!j9class %1$s\n", hexString));
}
}
J9ClassPointer previousSuperclass = J9ClassPointer.NULL;
String className = J9ClassHelper.getName(instanceClass);
J9VMThreadPointer mainThread = vm.mainThread();
boolean lockwordPrinted = true;
if (J9BuildFlags.thr_lockNursery) {
lockwordPrinted = false;
}
CommandUtils.dbgPrint(out, "Instance fields in %s:\n", className);
CommandUtils.dbgPrint(out, "\noffset name\tsignature\t(declaring class)\n");
if (mainThread.isNull()) {
/* we cannot print the instance fields without this */
return;
}
long depth = J9ClassHelper.classDepth(instanceClass).longValue();
for (long superclassIndex = 0; superclassIndex <= depth; superclassIndex++) {
J9ClassPointer superclass;
if (superclassIndex == depth) {
superclass = instanceClass;
} else {
superclass = J9ClassPointer.cast(instanceClass.superclasses().at(superclassIndex));
}
U32 flags = new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_INCLUDE_HIDDEN);
Iterator<J9ObjectFieldOffset> iterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(superclass.romClass(), instanceClass, previousSuperclass, flags);
while (iterator.hasNext()) {
J9ObjectFieldOffset result = (J9ObjectFieldOffset) iterator.next();
boolean printField = true;
boolean isHiddenField = result.isHidden();
if (J9BuildFlags.thr_lockNursery) {
boolean isLockword = (isHiddenField && (result.getOffsetOrAddress().add(J9Object.SIZEOF).eq(superclass.lockOffset())));
if (isLockword) {
/*
* Print the lockword field if it is indeed the
* lockword for this instanceClass and we haven't
* printed it yet.
*/
printField = !lockwordPrinted && instanceClass.lockOffset().eq(superclass.lockOffset());
if (printField) {
lockwordPrinted = true;
}
}
}
if (printField) {
printShapeField(out, superclass, result.getField(), result.getOffsetOrAddress(), isHiddenField);
}
}
previousSuperclass = superclass;
}
CommandUtils.dbgPrint(out, "\nTotal instance size: %d\n", instanceClass.totalInstanceSize().longValue());
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class MonitorsCommand method writeObjectMonitorToBuffer.
/**
* Helper to write details for an object monitor to a buffer.
*
* @param objectMonitor
* @param out
* @throws CorruptDataException
*/
private void writeObjectMonitorToBuffer(FilterOptions filter, ObjectMonitor objMon, StringBuilder out) throws CorruptDataException {
if (filter.shouldPrint(objMon)) {
out.append(String.format("Object monitor for %s\t\n", objMon.getObject().formatShortInteractive()));
if (objMon.isInflated()) {
out.append("\tInflated\n");
} else {
if (objMon.isContended()) {
out.append("\tContended Flatlocked\n");
} else if (objMon.getLockword().isNull()) {
out.append("\tDeflated\n");
} else {
out.append("\tFlatlocked\n");
}
}
J9ObjectMonitorPointer j9ObjMonPtr = objMon.getJ9ObjectMonitorPointer();
if (j9ObjMonPtr.notNull()) {
out.append(String.format("\t%s %s\n", j9ObjMonPtr.formatShortInteractive(), j9ObjMonPtr.monitor().formatShortInteractive()));
}
J9VMThreadPointer ownerThreadPointer = objMon.getOwner();
if (ownerThreadPointer.notNull()) {
out.append(String.format("\tOwner:\t%s\t%s\n", ownerThreadPointer.formatShortInteractive(), J9VMThreadHelper.getName(ownerThreadPointer)));
}
if (!objMon.getBlockedThreads().isEmpty()) {
out.append(String.format("\t%s\t\n", "Blocking (Enter Waiter):"));
for (J9VMThreadPointer threadPtr : objMon.getBlockedThreads()) {
out.append(String.format("\t\t%s\t%s\n", threadPtr.formatShortInteractive(), J9VMThreadHelper.getName(threadPtr)));
}
}
if (!objMon.getWaitingThreads().isEmpty()) {
out.append(String.format("\t%s\t\n", "Waiting (Notify Waiter):"));
for (J9VMThreadPointer threadPtr : objMon.getWaitingThreads()) {
out.append(String.format("\t\t%s\t%s\n", threadPtr.formatShortInteractive(), J9VMThreadHelper.getName(threadPtr)));
}
}
out.append(nl);
}
}
Aggregations