use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class RamClassWalker method allSlotsInConstantPoolDo.
private void allSlotsInConstantPoolDo() throws CorruptDataException {
final J9ROMClassPointer romClass = ramClass.romClass();
final int constPoolCount = romClass.ramConstantPoolCount().intValue();
final J9ConstantPoolPointer cpp = J9ConstantPoolPointer.cast(ramClass.ramConstantPool());
U32Pointer cpDescriptionSlots = romClass.cpShapeDescription();
PointerPointer cpEntry = PointerPointer.cast(ramClass.ramConstantPool());
long cpDescription = 0;
long cpEntryCount = ramClass.romClass().ramConstantPoolCount().longValue();
long cpDescriptionIndex = 0;
while (cpEntryCount > 0) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpDescriptionSlots.at(0).longValue();
cpDescriptionSlots = cpDescriptionSlots.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
/*
* A switch statement can't be used on long type, it might be
* erroneous to cast it to an int as it might change in the future.
*/
long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_RAM_UTF8, ref.stringObjectEA(), "stringObject");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
if (slotType == J9CPTYPE_STRING) {
classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_STRING", false);
} else {
classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_ANNOTATION_UTF8", false);
}
} else if (slotType == J9CPTYPE_METHOD_TYPE) {
J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.type();
if (slot.notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type", "!j9object");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slotCountEA(), "slotCount");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodTypeRef.SIZEOF, "J9CPTYPE_METHOD_TYPE", false);
} else if (slotType == J9CPTYPE_METHODHANDLE) {
J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.methodHandle();
if (slot.notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle", "!j9object");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodHandleRef.SIZEOF, "J9CPTYPE_METHODHANDLE", false);
} else if (slotType == J9CPTYPE_CLASS) {
J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
if (ref.value().notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value", "!j9class");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.modifiersEA(), "modifiers");
classWalkerCallback.addSection(clazz, ref, J9RAMClassRef.SIZEOF, "J9CPTYPE_CLASS", false);
} else if (slotType == J9CPTYPE_INT) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldInt");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_INT", false);
} else if (slotType == J9CPTYPE_FLOAT) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldFloat");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_FLOAT", false);
} else if (slotType == J9CPTYPE_LONG) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_LONG");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_LONG", false);
} else if (slotType == J9CPTYPE_DOUBLE) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_DOUBLE");
classWalkerCallback.addSection(clazz, ref, I64.SIZEOF, "J9CPTYPE_DOUBLE", false);
} else if (slotType == J9CPTYPE_FIELD) {
J9RAMFieldRefPointer ref = J9RAMFieldRefPointer.cast(cpEntry);
J9RAMStaticFieldRefPointer staticRef = J9RAMStaticFieldRefPointer.cast(cpEntry);
/* if the field ref is resolved static, it has 'flagsAndClass', for other cases (unresolved and resolved instance) it has 'flags'. */
if ((staticRef.flagsAndClass().longValue() > 0) && (staticRef.valueOffset().longValue() != -1)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_IDATA, staticRef.flagsAndClassEA(), "flagsAndClass");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.flagsEA(), "flags");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueOffsetEA(), "valueOffset");
classWalkerCallback.addSection(clazz, ref, J9RAMFieldRef.SIZEOF, "J9CPTYPE_FIELD", false);
} else if (slotType == J9CPTYPE_INTERFACE_METHOD) {
J9RAMInterfaceMethodRefPointer ref = J9RAMInterfaceMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.interfaceClassEA(), "interfaceClass", "!j9class");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
classWalkerCallback.addSection(clazz, ref, J9RAMInterfaceMethodRef.SIZEOF, "J9CPTYPE_INTERFACE_METHOD", false);
} else if (slotType == J9CPTYPE_STATIC_METHOD) {
J9RAMStaticMethodRefPointer ref = J9RAMStaticMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMStaticMethodRef.SIZEOF, "J9CPTYPE_STATIC_METHOD", false);
} else if ((slotType == J9CPTYPE_UNUSED) || (slotType == J9CPTYPE_UNUSED8)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry, "unused");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry.add(1), "unused");
classWalkerCallback.addSection(clazz, cpEntry, 2 * UDATA.SIZEOF, "J9CPTYPE_UNUSED", false);
} else if (slotType == J9CPTYPE_INSTANCE_METHOD) {
J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_INSTANCE_METHOD", false);
} else if (slotType == J9CPTYPE_HANDLE_METHOD) {
J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodTypeIndexAndArgCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_HANDLE_METHOD", false);
}
cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
cpEntryCount -= 1;
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
// The spaces at the end of "Constant Pool" are important since the
// regions are sorted
// by address and size, but when they are equal they are sorted by
// longest name and "Constant Pool" has to come first
classWalkerCallback.addSection(clazz, cpp, constPoolCount * 2 * UDATA.SIZEOF, "Constant Pool ", false);
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class RamClassWalker method allSlotsInRAMStaticsDo.
private void allSlotsInRAMStaticsDo() throws CorruptDataException {
if (ramClass.ramStatics().isNull()) {
return;
}
Iterator<?> ofoIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(ramClass, J9ClassHelper.superclass(ramClass), new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC));
J9ObjectFieldOffset fields = null;
while (ofoIterator.hasNext()) {
fields = (J9ObjectFieldOffset) ofoIterator.next();
J9ROMFieldShapePointer field = fields.getField();
String info = fields.getName();
U32 modifiers = field.modifiers();
UDATAPointer fieldAddress = ramClass.ramStatics().addOffset(fields.getOffsetOrAddress());
String additionalInfo = modifiers.anyBitsIn(J9FieldFlagObject) ? "!j9object" : "";
if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(fieldAddress), info, additionalInfo);
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, fieldAddress, info, additionalInfo);
}
}
U32 staticSlotCount = ramClass.romClass().objectStaticCount().add(ramClass.romClass().singleScalarStaticCount());
if (J9BuildFlags.env_data64) {
staticSlotCount = staticSlotCount.add(ramClass.romClass().doubleScalarStaticCount());
} else {
staticSlotCount = staticSlotCount.add(1).bitAnd(~1L).add(ramClass.romClass().doubleScalarStaticCount().mult(2));
}
UDATA size = Scalar.convertSlotsToBytes(new UDATA(staticSlotCount));
classWalkerCallback.addSection(clazz, ramClass.ramStatics(), size.longValue(), "Ram static", false);
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class J9StaticsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
if (args.length != 1) {
CommandUtils.dbgPrint(out, "Usage: !j9statics <classAddress>\n");
return;
}
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
J9ClassPointer ramClass = J9ClassPointer.cast(address);
J9ROMClassPointer romClass = ramClass.romClass();
J9UTF8Pointer className = romClass.className();
CommandUtils.dbgPrint(out, "Static fields in %s:\n", J9UTF8Helper.stringValue(className));
Iterator<J9ObjectFieldOffset> ofoIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(ramClass, J9ClassHelper.superclass(ramClass), new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC));
while (ofoIterator.hasNext()) {
J9ObjectFieldOffset fieldOffset = ofoIterator.next();
J9ROMFieldShapePointer field = fieldOffset.getField();
String name = J9ROMFieldShapeHelper.getName(field);
String sig = J9ROMFieldShapeHelper.getSignature(field);
UDATAPointer fieldAddress = ramClass.ramStatics().addOffset(fieldOffset.getOffsetOrAddress());
switch(sig.charAt(0)) {
case 'L':
case '[':
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticstringfieldshape %s) = !j9object %s\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), fieldAddress.at(0).getHexValue());
break;
case 'D':
DoublePointer doublePointer = DoublePointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticdoublefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), doublePointer.getHexValue(), new Double(doublePointer.doubleAt(0)).toString());
break;
case 'F':
FloatPointer floatPointer = FloatPointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), floatPointer.getHexValue(), new Float(floatPointer.floatAt(0)).toString());
break;
case 'J':
I64Pointer longPointer = I64Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticdoublefieldshape %s) = %s (%d)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), longPointer.getHexValue(), longPointer.at(0).longValue());
break;
case 'I':
I32Pointer intPointer = I32Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%d)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), intPointer.getHexValue(), intPointer.at(0).intValue());
break;
case 'B':
I8Pointer bytePointer = I8Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), bytePointer.getHexValue(), bytePointer.at(0).byteValue());
break;
case 'S':
I16Pointer shortPointer = I16Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%d)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), shortPointer.getHexValue(), shortPointer.at(0).shortValue());
break;
case 'Z':
BoolPointer booleanPointer = BoolPointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), booleanPointer.getHexValue(), booleanPointer.boolAt(0) ? "true" : "false");
break;
default:
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), fieldAddress.at(0).getHexValue());
break;
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class ObjectRefsCommand method dumpLiveReferences.
private void dumpLiveReferences(J9JavaVMPointer vm, J9ObjectPointer targetObject, PrintStream out) throws CorruptDataException {
MM_HeapRegionManagerPointer hrmPointer = MM_GCExtensionsPointer.cast(vm.gcExtensions()).heapRegionManager();
GCHeapRegionManager heapRegionManager = GCHeapRegionManager.fromHeapRegionManager(hrmPointer);
Table table = new Table("All Live Objects That Refer To !j9object " + targetObject.getHexAddress());
table.row("Object");
LiveSetWalker.walkLiveSet(new LiveReferenceVisitor(heapRegionManager, targetObject, table));
table.render(out);
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class MonitorsCommand method objectCommand.
/**
* See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
* function documentation
*
* @param args
* command args
* @param out
* the output stream
*/
private void objectCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
FilterOptions filter = FilterOptions.defaultOption();
try {
J9ObjectPointer object = null;
if (args.length < 2) {
out.println("This command takes one address \"!monitors object <J9Object address>\"");
return;
}
long objectAddr = Long.decode(args[1]);
object = J9ObjectPointer.cast(objectAddr);
ObjectMonitor objMonitor = ObjectMonitor.fromJ9Object(object);
if (null == objMonitor) {
out.printf("No corresponding monitor was found for %s\n", object.getHexAddress());
} else {
writeObjectMonitor(filter, objMonitor, out);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations