Search in sources :

Example 1 with J9MemorySegmentPointer

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

the class RootScanner method scanPermanentClasses.

protected void scanPermanentClasses() throws CorruptDataException {
    J9ClassLoaderPointer sysClassLoader = _vm.systemClassLoader();
    J9ClassLoaderPointer appClassLoader = J9ClassLoaderPointer.cast(_vm.applicationClassLoader());
    GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(_vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    setReachability(Reachability.STRONG);
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer segment = segmentIterator.next();
        if (segment.classLoader().equals(sysClassLoader) || segment.classLoader().equals(appClassLoader)) {
            GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
            while (classHeapIterator.hasNext()) {
                doClass(classHeapIterator.next());
            }
        }
    }
}
Also used : J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) GCClassHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator) GCSegmentIterator(com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)

Example 2 with J9MemorySegmentPointer

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

the class GCClassLoaderSegmentIterator method next.

public J9MemorySegmentPointer next() {
    try {
        if (hasNext()) {
            J9MemorySegmentPointer currentMemorySegment = memorySegment;
            memorySegment = memorySegment.nextSegmentInClassLoader();
            return currentMemorySegment;
        } else {
            throw new NoSuchElementException("There are no more items available through this iterator");
        }
    } catch (CorruptDataException cde) {
        // can try to recover from this
        raiseCorruptDataEvent("Error returning next segment", cde, false);
        return null;
    }
}
Also used : J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with J9MemorySegmentPointer

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

the class ROMClassesIterator method getNextClass.

private ClassAndSegment getNextClass() {
    J9ROMClassPointer newNextClass = J9ROMClassPointer.NULL;
    J9MemorySegmentPointer nextSegmentPtr = nextSegment;
    try {
        if (!nextSegment.isNull()) {
            long newHeapPtr = 0;
            if (nextClass == J9ROMClassPointer.NULL) {
                newHeapPtr = nextSegmentPtr.heapBase().longValue();
            } else {
                newHeapPtr = nextClass.getAddress() + nextClass.romSize().longValue();
            }
            do {
                if (nextSegmentPtr.type().anyBitsIn(MEMORY_TYPE_ROM_CLASS)) {
                    if (newHeapPtr < nextSegmentPtr.heapAlloc().longValue()) {
                        newNextClass = J9ROMClassPointer.cast(newHeapPtr);
                        try {
                            if (newNextClass.romSize().eq(0)) {
                                out.append("Size of ROMClass at " + newNextClass.getHexAddress() + "is invalid. Skipping to next segment.\n");
                                newNextClass = J9ROMClassPointer.NULL;
                            } else {
                                return new ClassAndSegment(newNextClass, nextSegmentPtr);
                            }
                        } catch (CorruptDataException e) {
                            out.append("Unable to read size of ROMClass at " + newNextClass.getHexAddress() + ". Skipping to next segment.\n");
                            newNextClass = J9ROMClassPointer.NULL;
                        }
                    }
                }
                /* move to next segment */
                nextSegmentPtr = nextSegmentPtr.nextSegment();
                if (!nextSegmentPtr.isNull()) {
                    newHeapPtr = nextSegmentPtr.heapBase().longValue();
                }
            } while (!nextSegmentPtr.isNull());
        }
    } catch (CorruptDataException e) {
        newNextClass = J9ROMClassPointer.NULL;
    }
    return new ClassAndSegment(newNextClass, nextSegmentPtr);
}
Also used : J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 4 with J9MemorySegmentPointer

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

the class ClassloadersSummaryCommand method getStat.

public Collection<ClassloadersSummaryNode> getStat() throws CorruptDataException {
    Map<J9ClassLoaderPointer, Counter> classloadersCount = new HashMap<J9ClassLoaderPointer, Counter>();
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
    while (iterator.hasNext()) {
        J9ClassLoaderPointer classLoader = iterator.next();
        classloadersCount.put(classLoader, new Counter(0));
    }
    /* Iterate through all classes and count how many were loaded by each classLoader */
    ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
    while (classSegmentIterator.hasNext()) {
        J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
        Counter counter = classloadersCount.get(classPointer.classLoader());
        if (counter != null) {
            counter.addOne();
        } else {
            classloadersCount.put(classPointer.classLoader(), new Counter(1));
        }
    }
    J9ObjectPointer sys = vm.systemClassLoader().classLoaderObject();
    final UDATA valueROM = new UDATA(J9MemorySegment.MEMORY_TYPE_ROM_CLASS);
    final UDATA valueRAM = new UDATA(J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    Map<String, ClassloadersSummaryNode> classloaders = new LinkedHashMap<String, ClassloadersSummaryNode>();
    for (Map.Entry<J9ClassLoaderPointer, Counter> entry : classloadersCount.entrySet()) {
        J9ObjectPointer classLoaderObject = entry.getKey().classLoaderObject();
        boolean isSystem = classLoaderObject.equals(sys);
        String loader = isSystem ? "*System*" : J9ObjectHelper.getClassName(classLoaderObject);
        /*	For each classloader, iterate through each associated memory segment and identify whether it is  
			 * 	a ROM or a RAM type memory segment  */
        long romSegmentCount = 0;
        long ramSegmentCount = 0;
        long romSegmentAllocatedMem = 0;
        long ramSegmentAllocatedMem = 0;
        J9MemorySegmentPointer segment = entry.getKey().classSegments();
        while (segment.notNull()) {
            if ((segment.type().bitAnd(valueROM)).equals(valueROM)) {
                romSegmentCount += 1;
                romSegmentAllocatedMem += segment.size().longValue();
            } else if ((segment.type().bitAnd(valueRAM)).equals(valueRAM)) {
                ramSegmentCount += 1;
                ramSegmentAllocatedMem += segment.size().longValue();
            }
            segment = segment.nextSegmentInClassLoader();
        }
        ClassloadersSummaryNode cpentry = classloaders.get(loader);
        if (cpentry == null) {
            // If the classLoader is not in the list, add it with "# Classloaders = 1" and "# Loaded Classes = classesLoaded"
            classloaders.put(loader, new ClassloadersSummaryNode(loader, 1L, entry.getValue().getCount(), ramSegmentCount, romSegmentCount, romSegmentAllocatedMem, ramSegmentAllocatedMem));
        } else {
            // If the classLoader is in the list, increment "# Classloaders" by 1 and increment "# Loaded Classes" by classesLoaded
            cpentry.numClassloaders += 1;
            cpentry.numLoadedClasses += entry.getValue().getCount();
            cpentry.ramSegmentCounter += ramSegmentCount;
            cpentry.romSegmentCounter += romSegmentCount;
            cpentry.totalROMSegmentAllocatedMemory += romSegmentAllocatedMem;
            cpentry.totalRAMSegmentAllocatedMemory += ramSegmentAllocatedMem;
        }
    }
    return classloaders.values();
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) GCClassLoaderIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) LinkedHashMap(java.util.LinkedHashMap) ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 5 with J9MemorySegmentPointer

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

the class SegmentsUtil method dbgDumpJITCodeSegmentList.

public static void dbgDumpJITCodeSegmentList(PrintStream out, J9MemorySegmentListPointer segmentListPointer) throws CorruptDataException {
    String fmt = null;
    if (J9BuildFlags.env_data64) {
        out.append("+----------------+----------------+----------------+----------------+----------------+--------+\n");
        out.append("|    segment     |     start      |    warmAlloc   |    coldAlloc   |      end       |  size  |\n");
        out.append("+----------------+----------------+----------------+----------------+----------------+--------+\n");
        fmt = " %016x %016x %016x %016x %016x %8x";
    } else {
        out.append("+--------+--------+--------+--------+--------+--------+\n");
        out.append("|segment | start  |  warm  |  cold  |  end   |  size  |\n");
        out.append("+--------+--------+--------+--------+--------+--------+\n");
        fmt = " %08x %08x %08x %08x %08x %8x";
    }
    MemorySegmentIterator segmentIterator = new MemorySegmentIterator(segmentListPointer, MemorySegmentIterator.MEMORY_ALL_TYPES, false);
    long totalMemory = 0L, totalMemoryInUse = 0L;
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer seg = (J9MemorySegmentPointer) segmentIterator.next();
        final UDATA heapBase = UDATAPointer.cast(seg.heapBase()).at(0);
        long warmAlloc = UDATAPointer.cast(heapBase).at(0).longValue();
        long coldAlloc = UDATAPointer.cast(heapBase.add(UDATA.SIZEOF)).at(0).longValue();
        totalMemory += seg.size().longValue();
        totalMemoryInUse += (warmAlloc - seg.heapBase().longValue()) + (seg.heapTop().longValue() - coldAlloc);
        String msg = String.format(fmt, seg.getAddress(), seg.heapBase().getAddress(), warmAlloc, coldAlloc, seg.heapTop().getAddress(), seg.size().longValue());
        out.append(msg);
        out.append(nl);
        seg = segmentListPointer.nextSegment();
    }
    if (J9BuildFlags.env_data64) {
        out.append("+----------------+----------------+----------------+----------------+----------------+--------+\n");
    } else {
        out.append("+--------+--------+--------+--------+--------+--------+\n");
    }
    printMemoryUsed(out, totalMemory, totalMemoryInUse);
    out.append(nl);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) MemorySegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)

Aggregations

J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)17 CorruptDataException (com.ibm.j9ddr.CorruptDataException)7 GCSegmentIterator (com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)7 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)7 GCClassHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator)6 MemorySegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)4 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)4 UDATA (com.ibm.j9ddr.vm29.types.UDATA)4 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 ArrayList (java.util.ArrayList)2 NoSuchElementException (java.util.NoSuchElementException)2 GCClassIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassIterator)1 GCClassIteratorClassSlots (com.ibm.j9ddr.vm29.j9.gc.GCClassIteratorClassSlots)1 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)1 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)1 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 J9JITDataCacheHeaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JITDataCacheHeaderPointer)1