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());
}
}
}
}
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;
}
}
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);
}
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();
}
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);
}
Aggregations