use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class ITableSizeCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
long currentSize = 0;
long duplicatedSize = 0;
long extendedSize = 0;
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer clazz = (J9ClassPointer) classSegmentIterator.next();
int classDepth = clazz.classDepthAndFlags().bitAnd(J9_JAVA_CLASS_DEPTH_MASK).intValue();
J9ITablePointer superITable = J9ITablePointer.NULL;
J9ITablePointer startITable = J9ITablePointer.cast(clazz.iTable());
if (0 != classDepth) {
PointerPointer superclasses = clazz.superclasses();
J9ClassPointer superclazz = J9ClassPointer.cast(superclasses.at(classDepth - 1));
superITable = J9ITablePointer.cast(superclazz.iTable());
}
currentSize += iTableChainSize(startITable, superITable);
duplicatedSize += iTableChainSize(superITable, J9ITablePointer.NULL);
extendedSize += iTableExtendedSize(startITable, superITable);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
long totalSize = duplicatedSize + currentSize;
double percent = (double) totalSize / (double) currentSize;
out.append("iTable duplication" + nl);
out.append("------------------" + nl);
out.append("current iTable size : " + currentSize + nl);
out.append("additional iTable size : " + duplicatedSize + nl);
out.append("total iTable size : " + totalSize + nl);
out.append("growth factor : " + percent + nl);
out.append(nl);
percent = (double) extendedSize / (double) currentSize;
out.append("iTable contains extends" + nl);
out.append("-----------------------" + nl);
out.append("current iTable size : " + currentSize + nl);
out.append("new iTable size : " + extendedSize + nl);
out.append("growth factor : " + percent + nl);
out.append(nl);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class J9ClassShapeCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 1) {
CommandUtils.dbgPrint(out, "Usage: !j9classshape <classAddress>\n");
return;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9ClassPointer instanceClass = J9ClassPointer.NULL;
String classSelector = args[0];
if (classSelector.matches("\\p{Digit}.*")) {
/* addresses start with a decimal digit, possibly the '0' in "0x" */
instanceClass = J9ClassPointer.cast(CommandUtils.parsePointer(classSelector, J9BuildFlags.env_data64));
} else {
J9ClassPointer[] candidates = findClassByName(vm, classSelector);
if (candidates.length == 0) {
CommandUtils.dbgPrint(out, "No classes matching \"" + classSelector + "\" found\n");
return;
} else if (candidates.length > 1) {
CommandUtils.dbgPrint(out, "Multiple classes matching \"" + classSelector + "\" found\n");
return;
} else {
instanceClass = candidates[0];
String javaName = J9ClassHelper.getJavaName(instanceClass);
String hexString = instanceClass.getHexAddress();
CommandUtils.dbgPrint(out, String.format("!j9class %1$s\n", hexString));
}
}
J9ClassPointer previousSuperclass = J9ClassPointer.NULL;
String className = J9ClassHelper.getName(instanceClass);
J9VMThreadPointer mainThread = vm.mainThread();
boolean lockwordPrinted = true;
if (J9BuildFlags.thr_lockNursery) {
lockwordPrinted = false;
}
CommandUtils.dbgPrint(out, "Instance fields in %s:\n", className);
CommandUtils.dbgPrint(out, "\noffset name\tsignature\t(declaring class)\n");
if (mainThread.isNull()) {
/* we cannot print the instance fields without this */
return;
}
long depth = J9ClassHelper.classDepth(instanceClass).longValue();
for (long superclassIndex = 0; superclassIndex <= depth; superclassIndex++) {
J9ClassPointer superclass;
if (superclassIndex == depth) {
superclass = instanceClass;
} else {
superclass = J9ClassPointer.cast(instanceClass.superclasses().at(superclassIndex));
}
U32 flags = new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_INCLUDE_HIDDEN);
Iterator<J9ObjectFieldOffset> iterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(superclass.romClass(), instanceClass, previousSuperclass, flags);
while (iterator.hasNext()) {
J9ObjectFieldOffset result = (J9ObjectFieldOffset) iterator.next();
boolean printField = true;
boolean isHiddenField = result.isHidden();
if (J9BuildFlags.thr_lockNursery) {
boolean isLockword = (isHiddenField && (result.getOffsetOrAddress().add(J9Object.SIZEOF).eq(superclass.lockOffset())));
if (isLockword) {
/*
* Print the lockword field if it is indeed the
* lockword for this instanceClass and we haven't
* printed it yet.
*/
printField = !lockwordPrinted && instanceClass.lockOffset().eq(superclass.lockOffset());
if (printField) {
lockwordPrinted = true;
}
}
}
if (printField) {
printShapeField(out, superclass, result.getField(), result.getOffsetOrAddress(), isHiddenField);
}
}
previousSuperclass = superclass;
}
CommandUtils.dbgPrint(out, "\nTotal instance size: %d\n", instanceClass.totalInstanceSize().longValue());
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class JitMetadataFromPcCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
UDATA searchValue = new UDATA(Long.decode(args[0]));
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9JITExceptionTablePointer metaData = JITLook.jit_artifact_search(vm.jitConfig().translationArtifacts(), searchValue);
if (!metaData.isNull()) {
dbgext_j9jitexceptiontable(out, metaData);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class ObjectRefsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (args.length < 1) {
throw new DDRInteractiveCommandException("This debug extension takes an address argument \" !objectrefs <address> [ heapWalk ] [ rootWalk ]\"");
}
long addr = Long.decode(args[0]);
J9ObjectPointer targetObject = J9ObjectPointer.cast(addr);
boolean dumpHeap = false;
boolean dumpRoots = false;
if (1 == args.length) {
dumpHeap = true;
dumpRoots = true;
} else {
for (int i = 1; i < args.length; i++) {
if ("heapWalk".equals(args[i])) {
dumpHeap = true;
} else if ("rootWalk".equals(args[i])) {
dumpRoots = true;
}
}
}
if (dumpHeap) {
try {
dumpHeapReferences(vm, targetObject, out);
} catch (CorruptDataException cde) {
cde.printStackTrace();
}
}
if (dumpRoots) {
try {
dumpLiveReferences(vm, targetObject, out);
} catch (CorruptDataException cde) {
cde.printStackTrace();
}
}
} catch (DDRInteractiveCommandException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace(out);
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class ObjectRefsCommand method dumpHeapReferences.
/**
* Write the on heap references stanza to the output stream.
* @param vm
* @param targetObject
* @param out
* @throws CorruptDataException
*/
private void dumpHeapReferences(J9JavaVMPointer vm, J9ObjectPointer targetObject, PrintStream out) throws CorruptDataException {
if (GCExtensions.isVLHGC()) {
Table table = new Table("On Heap References");
table.row("object (!j9object)", "field (!j9object)", "!mm_heapregiondescriptorvlhgc", "AC (type)");
/* iterate over all heap regions */
GCHeapRegionIterator regionIterator = GCHeapRegionIterator.from();
while (regionIterator.hasNext()) {
GCHeapRegionDescriptor region = regionIterator.next();
if (region.containsObjects()) {
MM_HeapRegionDescriptorVLHGCPointer vlhgcRegion = MM_HeapRegionDescriptorVLHGCPointer.cast(region.getHeapRegionDescriptorPointer());
MM_AllocationContextTarokPointer currentAllocationContextTarok = vlhgcRegion._allocateData()._owningContext();
/* iterate over all objects in region */
GCObjectHeapIterator heapObjectIterator = region.objectIterator(true, false);
while (heapObjectIterator.hasNext()) {
J9ObjectPointer currentObject = heapObjectIterator.next();
/* Iterate over the object's fields and list any that point at @ref targetObject */
GCObjectIterator fieldIterator = GCObjectIterator.fromJ9Object(currentObject, false);
while (fieldIterator.hasNext()) {
J9ObjectPointer currentTargetObject = fieldIterator.next();
if (currentTargetObject.eq(targetObject)) {
/* found a reference to our targetObject, add it to the table */
J9ClassPointer objectClass = J9ObjectHelper.clazz(currentObject);
String objectClassString = J9ClassHelper.getJavaName(objectClass);
table.row(currentObject.getHexAddress() + " //" + objectClassString, currentTargetObject.getHexAddress(), vlhgcRegion.getHexAddress(), currentAllocationContextTarok.getHexAddress() + " (" + currentAllocationContextTarok._allocationContextType() + ")");
}
}
}
}
}
table.render(out);
}
}
Aggregations