Search in sources :

Example 61 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer 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 62 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class DumpSegregatedStatsCommand method getFreeCellCount.

/**
 * Count the number of free cells in the MM_HeapRegionDescriptorSegregatedPointer freelist
 * @throws CorruptDataException
 */
public long getFreeCellCount(MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptor) throws CorruptDataException {
    /* TODO assumes a small region */
    MM_MemoryPoolAggregatedCellListPointer memoryPoolACL = heapRegionDescriptor._memoryPoolACL();
    GCHeapLinkedFreeHeader heapLinkedFreeHeader = GCHeapLinkedFreeHeader.fromLinkedFreeHeaderPointer(memoryPoolACL._freeListHead());
    /* Get the size classes */
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    J9VMGCSizeClassesPointer sizeClasses = vm.realtimeSizeClasses();
    UDATA sizeClassIndex = heapRegionDescriptor._sizeClass();
    long cellSize = sizeClasses.smallCellSizesEA().at(sizeClassIndex).longValue();
    long freeCellCount = 0;
    while (heapLinkedFreeHeader.getHeader().notNull()) {
        freeCellCount += heapLinkedFreeHeader.getSize().longValue() / cellSize;
        heapLinkedFreeHeader = heapLinkedFreeHeader.getNext();
    }
    return freeCellCount;
}
Also used : MM_MemoryPoolAggregatedCellListPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_MemoryPoolAggregatedCellListPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9VMGCSizeClassesPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMGCSizeClassesPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) GCHeapLinkedFreeHeader(com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader)

Example 63 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class FindMethodFromPcCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        U8Pointer pc = U8Pointer.cast(address);
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (pc.isNull()) {
            CommandUtils.dbgPrint(out, "bad or missing PC\n");
            return;
        }
        CommandUtils.dbgPrint(out, "Searching for PC=%s in VM=%s...\n", pc.getHexAddress(), vm.getHexAddress());
        J9MethodPointer result = J9JavaVMHelper.getMethodFromPC(vm, pc);
        if (!result.isNull()) {
            CommandUtils.dbgPrint(out, "!j9method %s %s\n", result.getHexAddress(), J9MethodHelper.getName(result));
            CommandUtils.dbgPrint(out, "Bytecode PC offset = %s\n", pc.sub(result.bytecodes()).getHexValue());
        } else {
            CommandUtils.dbgPrint(out, "Not found\n");
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 64 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class ClassForNameCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
        int hitCount = 0;
        String searchClassName = args[0];
        PatternString pattern = new PatternString(searchClassName);
        out.println(String.format("Searching for classes named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
        while (iterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
            String javaName = J9ClassHelper.getJavaName(classPointer);
            if (pattern.isMatch(javaName)) {
                hitCount++;
                String hexString = classPointer.getHexAddress();
                out.println(String.format("!j9class %1$s named %2$s", hexString, javaName));
            }
        }
        out.println(String.format("Found %1$d class(es) named %2$s", hitCount, searchClassName));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 65 with J9JavaVMPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.

the class LocalMapCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        if (args.length != 1) {
            CommandUtils.dbgPrint(out, "bad or missing PC\n");
            return;
        }
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        U8Pointer pc = U8Pointer.cast(address);
        CommandUtils.dbgPrint(out, "Searching for PC=%d in VM=%s...\n", pc.longValue(), vm.getHexAddress());
        J9MethodPointer localMethod = J9JavaVMHelper.getMethodFromPC(vm, pc);
        if (localMethod.notNull()) {
            int[] localMap = new int[65536 / 32];
            CommandUtils.dbgPrint(out, "Found method %s !j9method %s\n", J9MethodHelper.getName(localMethod), localMethod.getHexAddress());
            UDATA offsetPC = new UDATA(pc.sub(U8Pointer.cast(localMethod.bytecodes())));
            CommandUtils.dbgPrint(out, "Relative PC = %d\n", offsetPC.longValue());
            J9ClassPointer localClass = J9_CLASS_FROM_CP(localMethod.constantPool());
            long methodIndex = new UDATA(localMethod.sub(localClass.ramMethods())).longValue();
            CommandUtils.dbgPrint(out, "Method index is %d\n", methodIndex);
            J9ROMMethodPointer localROMMethod = J9ROMCLASS_ROMMETHODS(localClass.romClass());
            while (methodIndex != 0) {
                localROMMethod = ROMHelp.nextROMMethod(localROMMethod);
                --methodIndex;
            }
            CommandUtils.dbgPrint(out, "Using ROM method %s\n", localROMMethod.getHexAddress());
            U16 tempCount = localROMMethod.tempCount();
            U8 argCount = localROMMethod.argCount();
            long localCount = tempCount.add(argCount).longValue();
            if (localCount > 0) {
                int errorCode = LocalMap.j9localmap_LocalBitsForPC(localROMMethod, offsetPC, localMap);
                if (errorCode != 0) {
                    CommandUtils.dbgPrint(out, "Local map failed, error code = %d\n", errorCode);
                } else {
                    int currentDescription = localMap[(int) ((localCount + 31) / 32)];
                    long descriptionLong = 0;
                    CommandUtils.dbgPrint(out, "Local map (%d slots mapped): local %d --> ", localCount, localCount - 1);
                    long bitsRemaining = localCount % 32;
                    if (bitsRemaining != 0) {
                        descriptionLong = currentDescription << (32 - bitsRemaining);
                        currentDescription--;
                    }
                    while (localCount != 0) {
                        if (bitsRemaining == 0) {
                            descriptionLong = currentDescription;
                            currentDescription--;
                            bitsRemaining = 32;
                        }
                        CommandUtils.dbgPrint(out, "%d", (descriptionLong & (1 << 32)) != 0 ? 1 : 0);
                        descriptionLong = descriptionLong << 1;
                        --bitsRemaining;
                        --localCount;
                    }
                    CommandUtils.dbgPrint(out, " <-- local 0\n");
                }
            } else {
                CommandUtils.dbgPrint(out, "No locals to map\n");
            }
        } else {
            CommandUtils.dbgPrint(out, "Not found\n");
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : U8(com.ibm.j9ddr.vm29.types.U8) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) U16(com.ibm.j9ddr.vm29.types.U16)

Aggregations

J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)57 CorruptDataException (com.ibm.j9ddr.CorruptDataException)49 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)39 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)23 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)17 UDATA (com.ibm.j9ddr.vm29.types.UDATA)13 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)10 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)8 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)6 PatternString (com.ibm.j9ddr.util.PatternString)5 MonitorIterator (com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)5 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)5 MM_HeapRegionManagerPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer)5 Table (com.ibm.j9ddr.tools.ddrinteractive.Table)4 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)4 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)4 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)4