use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer 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.J9ClassPointer in project openj9 by eclipse.
the class BytecodesCommand method run.
// dbgext_bytecodes
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
J9MethodPointer ramMethod = J9MethodPointer.cast(address);
long maps = 0;
if (ramMethod.isNull()) {
CommandUtils.dbgPrint(out, "bad or missing ram method addr\n");
return;
}
J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
if (args.length == 2 && args[1].equals("maps")) {
maps |= BCT_DumpMaps;
}
if (J9BuildFlags.env_littleEndian) {
maps |= BCT_LittleEndianOutput;
} else {
maps |= BCT_BigEndianOutput;
}
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
J9ROMClassPointer romClass = ramClass.romClass();
J9BCUtil.j9bcutil_dumpRomMethod(out, romMethod, romClass, maps, 0);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class DumpRomClassCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long maps = 0;
if (args.length != 1 && args.length != 2) {
printUsage(out);
return;
}
if (args.length == 2 && args[1].equals("maps")) {
maps |= J9BCTranslationData.BCT_DumpMaps;
}
if (J9BuildFlags.env_littleEndian) {
maps |= J9BCTranslationData.BCT_LittleEndianOutput;
} else {
maps |= J9BCTranslationData.BCT_BigEndianOutput;
}
/* check for name:<name> */
if (args[0].startsWith("name:")) {
long hitCount = 0;
String searchClassName = args[0].substring(args[0].indexOf(':') + 1);
PatternString pattern = new PatternString(searchClassName);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
while (iterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
String javaName = J9ClassHelper.getJavaName(classPointer);
if (pattern.isMatch(javaName)) {
hitCount++;
J9ROMClassPointer clazz = classPointer.romClass();
String hexString = clazz.getHexAddress();
out.println(String.format("ROMClass %1$s named %2$s\n", hexString, javaName));
J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
}
}
out.println(String.format("Found %1$d class(es) with name %2$s\n", hitCount, searchClassName));
} else {
/* treat argument as address */
long addr = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class DumpRomMethodCommand method romMethodIteratorFromRamMethod.
private Iterable<J9ROMClassAndMethod> romMethodIteratorFromRamMethod(J9MethodPointer ramMethod) throws CorruptDataException {
Iterable<J9ROMClassAndMethod> methodIterator;
J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
J9ROMClassPointer romClass = ramClass.romClass();
Vector<J9ROMClassAndMethod> methodInfoVector = new Vector<J9ROMClassAndMethod>(1);
methodInfoVector.add(new J9ROMClassAndMethod(romMethod, romClass));
methodIterator = methodInfoVector;
return methodIterator;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class ITableSizeCommand method iTableExtendedSize.
public long iTableExtendedSize(J9ITablePointer startTable, J9ITablePointer superTable) throws CorruptDataException {
long size = 0;
J9ITablePointer iTable = startTable;
while (!iTable.eq(superTable)) {
size += J9ITable.SIZEOF;
J9ClassPointer interfaceClass = iTable.interfaceClass();
J9ROMClassPointer romClass = interfaceClass.romClass();
J9ITablePointer allInterfaces = J9ITablePointer.cast(interfaceClass.iTable());
do {
size += (UDATA.SIZEOF * allInterfaces.interfaceClass().romClass().romMethodCount().intValue());
allInterfaces = allInterfaces.next();
} while (!allInterfaces.eq(J9ITablePointer.NULL));
iTable = iTable.next();
}
return size;
}
Aggregations