use of com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType in project openj9 by eclipse.
the class GCConstantPoolSlotIterator method initializeSlots_V1.
protected void initializeSlots_V1(J9ClassPointer clazz, boolean returnClassSlots, boolean returnObjectSlots) throws CorruptDataException {
U32Pointer cpDescriptionSlots = clazz.romClass().cpShapeDescription();
PointerPointer cpEntry = PointerPointer.cast(clazz.ramConstantPool());
long cpDescription = 0;
long cpEntryCount = clazz.romClass().ramConstantPoolCount().longValue();
long cpDescriptionIndex = 0;
ArrayList<AbstractPointer> slots = new ArrayList<AbstractPointer>();
ArrayList<VoidPointer> addresses = new ArrayList<VoidPointer>();
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;
}
long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
if (returnObjectSlots) {
J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.stringObject();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.stringObjectEA()));
}
}
} else if (slotType == J9CPTYPE_METHOD_TYPE) {
if (returnObjectSlots) {
J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.type();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.typeEA()));
}
}
} else if (slotType == J9CPTYPE_METHODHANDLE) {
if (returnObjectSlots) {
J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.methodHandle();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.methodHandleEA()));
}
}
} else if (slotType == J9CPTYPE_CLASS) {
if (returnClassSlots) {
J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
J9ClassPointer slot = ref.value();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.valueEA()));
}
}
}
cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
cpEntryCount -= 1;
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
slotIterator = slots.iterator();
addressIterator = addresses.iterator();
}
use of com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType 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.tools.ddrinteractive.IClassWalkCallbacks.SlotType in project openj9 by eclipse.
the class LinearDumper method addSlot.
public void addSlot(StructurePointer clazz, SlotType type, AbstractPointer slotPtr, String slotName, String additionalInfo) throws CorruptDataException {
try {
J9ROMNameAndSignaturePointer nas;
long offset;
/* The slots of the type J9_ROM_UTF8 are changed to have 2 slots:
* -J9_SRP_TO_STRING
* -J9_ROM_UTF8
* This is done because we want to print the SRP field and also print
* the UTF8 it is pointing to */
switch(type) {
case J9_ROM_UTF8:
offset = slotPtr.getAddress() - clazz.getAddress();
classRegions.add(new J9ClassRegion(slotPtr, SlotType.J9_SRP_TO_STRING, slotName, additionalInfo, type.getSize(), offset, true));
VoidPointer srp = SelfRelativePointer.cast(slotPtr).get();
addUTF8Region(clazz, slotName, additionalInfo, srp);
break;
case J9_UTF8:
addUTF8Region(clazz, slotName, additionalInfo, slotPtr);
break;
/* The fields of the type J9_SRPNAS or J9_SRP are changed to have 2 J9_ROM_UTF8
* fields for their name and signature separated. */
case J9_SRPNAS:
nas = J9ROMNameAndSignaturePointer.cast(SelfRelativePointer.cast(slotPtr).get());
if (nas.notNull()) {
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.nameEA(), "name");
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.signatureEA(), "signature");
}
/* Since it is a SRP to a NAS, also print the SRP field. */
addSlot(clazz, SlotType.J9_SRP, slotPtr, "cpFieldNAS");
break;
case J9_NAS:
nas = J9ROMNameAndSignaturePointer.cast(slotPtr);
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.nameEA(), "name");
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.signatureEA(), "signature");
break;
case J9_IntermediateClassData:
offset = slotPtr.getAddress() - clazz.getAddress();
classRegions.add(new J9ClassRegion(slotPtr, type, slotName, additionalInfo, ((J9ROMClassPointer) clazz).intermediateClassDataLength().longValue(), offset, true));
break;
default:
offset = slotPtr.getAddress() - clazz.getAddress();
classRegions.add(new J9ClassRegion(slotPtr, type, slotName, additionalInfo, type.getSize(), offset, true));
break;
}
} catch (Exception e) {
}
}
use of com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType in project openj9 by eclipse.
the class ClassWalker method addObjectsAsSlot.
/**
* It walks through each field in this structure that is represented by methodClass and
* registers each field as a slot into ClassWalkerCallBack
*
* It uses the StructureDescriptor of J9DDR to get the FieldDescriptor of a structure.
* The name, type and address are found in the FieldDescriptor. The name, type and address
* are guaranteed to match the current core file, since they are taken from it.
*
* @param methodClass pointer class that is generated for the VM structure
* @param renameFields list of names to rename the original field names in the structure
* @throws CorruptDataException
*/
protected void addObjectsAsSlot(StructurePointer methodClass, HashMap<String, String> renameFields) throws CorruptDataException {
/* Get the structure name by removing "Pointer" suffix from the DDR generated class name*/
String structureName = methodClass.getClass().getSimpleName().substring(0, methodClass.getClass().getSimpleName().indexOf("Pointer"));
/* Get structure descriptor by using structure name */
StructureDescriptor sd = StructureCommandUtil.getStructureDescriptor(structureName, getContext());
/* Structure descriptor can not be null in normal circumstances,
* because StructurePointer "methodClass" is generated for an existing structure in the VM,
* so it should exist. If not, throw an exception.
*/
if (sd == null) {
throw new CorruptDataException("Structure \"" + structureName + "\" can not be found.");
}
for (FieldDescriptor fd : sd.getFields()) {
/* Get the name of the field from field descriptor */
String outName = fd.getName();
/* Get SlotType by using field type name */
SlotType type = getTypeByFieldTypeName(fd.getType());
/* Get the address of the field by adding the offset to the methodClass'address */
AbstractPointer address = U8Pointer.cast(methodClass).addOffset(fd.getOffset());
/* Rename fields if any defined. */
if (null != renameFields) {
if (renameFields.containsKey(outName)) {
outName = renameFields.get(outName);
}
}
/*add the field into classWalkerCallback by its name, type, address and debug extension method name */
classWalkerCallback.addSlot(clazz, type, address, outName, getDebugExtForMethodName(outName));
}
}
use of com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType in project openj9 by eclipse.
the class J9BCUtil method dumpStackMapSlots.
static U8Pointer dumpStackMapSlots(PrintStream out, J9ROMClassPointer classfile, U8Pointer slotData, long slotCount) throws CorruptDataException {
int slotType;
String[] slotTypes = { "top", "int", "float", "double", "long", "null", "uninitialized_this" };
String[] primitiveArrayTypes = { "I", "F", "D", "J", "S", "B", "C", "Z" };
out.print("(");
for (int i = 0; i < slotCount; i++) {
slotType = slotData.at(0).intValue();
slotData = slotData.add(1);
if (slotType <= 0x06) /*FR_STACKMAP_TYPE_INIT_OBJECT*/
{
out.print(slotTypes[slotType]);
} else if (slotType == 0x07) /* CFR_STACKMAP_TYPE_OBJECT */
{
long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
J9ROMConstantPoolItemPointer constantPool = ConstantPoolHelpers.J9_ROM_CP_FROM_ROM_CLASS(classfile);
J9ROMStringRefPointer item = J9ROMStringRefPointer.cast(constantPool.add(index));
J9UTF8Pointer data = item.utf8Data();
String s = J9UTF8Helper.stringValue(data);
if (s.charAt(0) != '[') {
out.print("L");
}
out.print(s);
slotData = slotData.add(2);
} else if (slotType == 0x08) /* CFR_STACKMAP_TYPE_NEW_OBJECT */
{
long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
out.print("this pc:" + index);
slotData = slotData.add(2);
} else {
/* J9-ism: primitive array types start at slotType 9 and arity is really NEXT_U16()+1*/
StringBuffer primitiveType = new StringBuffer("[");
long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
while (index-- > 0) {
primitiveType.append("[");
}
primitiveType.append(primitiveArrayTypes[slotType - 9]);
out.print(primitiveType.toString());
slotData = slotData.add(2);
}
if (i != (slotCount - 1)) {
out.print(", ");
}
}
out.print(")");
return slotData;
}
Aggregations