Search in sources :

Example 31 with J9VMThreadPointer

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();
    }
}
Also used : MM_HeapRegionListPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionListPointer) MM_LockingHeapRegionQueuePointer(com.ibm.j9ddr.vm29.pointer.generated.MM_LockingHeapRegionQueuePointer) MM_RegionPoolSegregatedPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_RegionPoolSegregatedPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9VMGCSegregatedAllocationCacheEntryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMGCSegregatedAllocationCacheEntryPointer) J9VMGCSizeClassesPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMGCSizeClassesPointer) MM_RealtimeGCPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_RealtimeGCPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) MM_GCExtensionsPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_GCExtensionsPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 32 with J9VMThreadPointer

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);
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) J9JavaStackIterator(com.ibm.j9ddr.vm29.j9.J9JavaStackIterator) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 33 with J9VMThreadPointer

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);
    }
}
Also used : BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) StackWalkResult(com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) J9VMEntryLocalStoragePointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMEntryLocalStoragePointer)

Example 34 with J9VMThreadPointer

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);
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 35 with J9VMThreadPointer

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);
    }
}
Also used : J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)

Aggregations

J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)39 CorruptDataException (com.ibm.j9ddr.CorruptDataException)28 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)16 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)15 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)13 J9ThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer)9 WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)7 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)6 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)5 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)5 StackWalkResult (com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)4 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)4 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)4 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)3 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)3 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)3 J9ThreadLibraryPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadLibraryPointer)3 LinkedList (java.util.LinkedList)3 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)2