Search in sources :

Example 1 with MemorySegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator 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)

Example 2 with MemorySegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator in project openj9 by eclipse.

the class SegmentsUtil method dbgDumpSegmentList.

public static void dbgDumpSegmentList(PrintStream out, J9MemorySegmentListPointer segmentListPointer) throws CorruptDataException {
    String fmt = null;
    if (J9BuildFlags.env_data64) {
        out.append("+----------------+----------------+----------------+----------------+--------+--------+\n");
        out.append("|    segment     |     start      |     alloc      |      end       |  type  |  size  |\n");
        out.append("+----------------+----------------+----------------+----------------+--------+--------+\n");
        fmt = " %016x %016x %016x %016x %08x %8x";
    } else {
        out.append("+--------+--------+--------+--------+--------+--------+\n");
        out.append("|segment | start  | alloc  |  end   |  type  |  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();
        totalMemory += seg.size().longValue();
        totalMemoryInUse += seg.heapAlloc().sub(seg.heapBase()).longValue();
        String msg = String.format(fmt, seg.getAddress(), seg.heapBase().getAddress(), seg.heapAlloc().getAddress(), seg.heapTop().getAddress(), seg.type().longValue(), 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 : MemorySegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)

Example 3 with MemorySegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator in project openj9 by eclipse.

the class VmCheckCommand method findSegmentInClassLoaderForAddress.

/**
 * Based on vmchk/checkclasses.c function: findSegmentInClassLoaderForAddress
 *
 * This method searches classloader's segments to find out on which segment this ROMClass lays in.
 * @param classLoader Classloader that romclass is being searched
 * @param romClassPointer ROMClass that is searched in classloader segments
 * @return Classloader segment which has this romclass, otherwise null.
 * @throws CorruptDataException
 */
public J9MemorySegmentPointer findSegmentInClassLoaderForAddress(J9ClassLoaderPointer classLoader, J9ROMClassPointer romClassPointer) throws CorruptDataException {
    MemorySegmentIterator memorySegmentIterator = new MemorySegmentIterator(classLoader.classSegments(), MemorySegmentIterator.MEMORY_ALL_TYPES, true);
    J9MemorySegmentPointer memorySegmentPointer = J9MemorySegmentPointer.NULL;
    J9MemorySegmentPointer foundMemorySegmentPointer = J9MemorySegmentPointer.NULL;
    while (memorySegmentIterator.hasNext()) {
        Object next2 = memorySegmentIterator.next();
        memorySegmentPointer = (J9MemorySegmentPointer) next2;
        if (romClassPointer.getAddress() >= memorySegmentPointer.heapBase().longValue() && romClassPointer.getAddress() < memorySegmentPointer.heapAlloc().longValue()) {
            foundMemorySegmentPointer = memorySegmentPointer;
            break;
        }
    }
    return foundMemorySegmentPointer;
}
Also used : J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) MemorySegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)

Example 4 with MemorySegmentIterator

use of com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator in project openj9 by eclipse.

the class SegmentsUtil method addSegmentsToArrayList.

private static void addSegmentsToArrayList(J9MemorySegmentListPointer segmentListPointer, ArrayList<J9MemorySegmentPointer> segmentArray, int segmentType) throws CorruptDataException {
    MemorySegmentIterator segmentIterator = new MemorySegmentIterator(segmentListPointer, segmentType, false);
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer seg = (J9MemorySegmentPointer) segmentIterator.next();
        segmentArray.add(seg);
    }
}
Also used : MemorySegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)

Aggregations

MemorySegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.MemorySegmentIterator)4 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)1 UDATA (com.ibm.j9ddr.vm29.types.UDATA)1