use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer in project openj9 by eclipse.
the class J9BCUtil method dumpCallSiteData.
/**
* This method is Java implementation of rdump.c#dumpCallSiteData function.
* This method is called when dumping a ROMClass.
* This method has only affect for invokedDynamic stuff,
* for other ROMClasses, there wont be anything to print since their callsite and bsm count are zero.
*
* @param out PrintStream to print the user info to the console
* @param romClass ROMClass address in the dump file.
*
* @throws CorruptDataException
*/
private static void dumpCallSiteData(PrintStream out, J9ROMClassPointer romClass) throws CorruptDataException {
int HEX_RADIX = 16;
long callSiteCount = romClass.callSiteCount().longValue();
long bsmCount = romClass.bsmCount().longValue();
SelfRelativePointer callSiteData = SelfRelativePointer.cast(romClass.callSiteData());
U16Pointer bsmIndices = U16Pointer.cast(callSiteData.addOffset(4 * callSiteCount));
if (0 != callSiteCount) {
out.println(String.format(" Call Sites (%d):\n", callSiteCount));
for (int i = 0; i < callSiteCount; i++) {
J9ROMNameAndSignaturePointer nameAndSig = J9ROMNameAndSignaturePointer.cast(callSiteData.add(i).get());
out.println(" Name: " + J9UTF8Helper.stringValue(nameAndSig.name()));
out.println(" Signature: " + J9UTF8Helper.stringValue(nameAndSig.signature()));
out.println(" Bootstrap Method Index: " + bsmIndices.at(i).longValue());
out.println();
}
}
if (0 != bsmCount) {
J9ROMConstantPoolItemPointer constantPool = ConstantPoolHelpers.J9_ROM_CP_FROM_ROM_CLASS(romClass);
U32Pointer cpShapeDescription = romClass.cpShapeDescription();
U16Pointer bsmDataCursor = bsmIndices.add(callSiteCount);
out.println(String.format(" Bootstrap Methods (%d):", bsmCount));
for (int i = 0; i < bsmCount; i++) {
J9ROMMethodHandleRefPointer methodHandleRef = J9ROMMethodHandleRefPointer.cast(constantPool.add(bsmDataCursor.at(0).longValue()));
bsmDataCursor = bsmDataCursor.add(1);
/* methodRef will be either a field or a method ref - they both have the same shape so we can pretend it is always a methodref */
J9ROMMethodRefPointer methodRef = J9ROMMethodRefPointer.cast(constantPool.add(methodHandleRef.methodOrFieldRefIndex().longValue()));
J9ROMClassRefPointer classRef = J9ROMClassRefPointer.cast(constantPool.add(methodRef.classRefCPIndex().longValue()));
J9ROMNameAndSignaturePointer nameAndSig = methodRef.nameAndSignature();
long bsmArgumentCount = bsmDataCursor.at(0).longValue();
bsmDataCursor = bsmDataCursor.add(1);
out.println(" Name: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()));
out.println(" Signature: " + J9UTF8Helper.stringValue(nameAndSig.signature()));
out.println(String.format(" Bootstrap Method Arguments (%d):", bsmArgumentCount));
for (; 0 != bsmArgumentCount; bsmArgumentCount--) {
long argCPIndex = bsmDataCursor.at(0).longValue();
bsmDataCursor = bsmDataCursor.add(1);
J9ROMConstantPoolItemPointer item = constantPool.add(argCPIndex);
long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(cpShapeDescription, (int) argCPIndex);
if (shapeDesc == J9CPTYPE_CLASS) {
J9ROMClassRefPointer romClassRef = J9ROMClassRefPointer.cast(item);
out.println(" Class: " + J9UTF8Helper.stringValue(romClassRef.name()));
} else if (shapeDesc == J9CPTYPE_STRING) {
J9ROMStringRefPointer romStringRef = J9ROMStringRefPointer.cast(item);
out.println(" String: " + J9UTF8Helper.stringValue(romStringRef.utf8Data()));
} else if (shapeDesc == J9CPTYPE_INT) {
J9ROMSingleSlotConstantRefPointer singleSlotConstantRef = J9ROMSingleSlotConstantRefPointer.cast(item);
out.println(" Int: " + singleSlotConstantRef.data().getHexValue());
} else if (shapeDesc == J9CPTYPE_FLOAT) {
J9ROMSingleSlotConstantRefPointer singleSlotConstantRef = J9ROMSingleSlotConstantRefPointer.cast(item);
FloatPointer floatPtr = FloatPointer.cast(singleSlotConstantRef.dataEA());
out.println(" Float: " + floatPtr.getHexValue() + " (" + floatPtr.floatAt(0) + ")");
} else if (shapeDesc == J9CPTYPE_LONG) {
String hexValue = "";
if (J9BuildFlags.env_littleEndian) {
hexValue += item.slot2().getHexValue();
hexValue += item.slot1().getHexValue().substring(2);
} else {
hexValue += item.slot1().getHexValue();
hexValue += item.slot2().getHexValue().substring(2);
}
long longValue = Long.parseLong(hexValue.substring(2), HEX_RADIX);
out.println(" Long: " + hexValue + "(" + longValue + ")");
} else if (shapeDesc == J9CPTYPE_DOUBLE) {
String hexValue = "";
if (J9BuildFlags.env_littleEndian) {
hexValue += item.slot2().getHexValue();
hexValue += item.slot1().getHexValue().substring(2);
} else {
hexValue += item.slot1().getHexValue();
hexValue += item.slot2().getHexValue().substring(2);
}
long longValue = Long.parseLong(hexValue.substring(2), HEX_RADIX);
double doubleValue = Double.longBitsToDouble(longValue);
out.println(" Double: " + hexValue + "(" + Double.toString(doubleValue) + ")");
} else if (shapeDesc == J9CPTYPE_FIELD) {
J9ROMFieldRefPointer romFieldRef = J9ROMFieldRefPointer.cast(item);
classRef = J9ROMClassRefPointer.cast(constantPool.add(romFieldRef.classRefCPIndex()));
nameAndSig = romFieldRef.nameAndSignature();
out.println(" Field: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()) + " " + J9UTF8Helper.stringValue(nameAndSig.signature()));
} else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD)) {
J9ROMMethodRefPointer romMethodRef = J9ROMMethodRefPointer.cast(item);
classRef = J9ROMClassRefPointer.cast(constantPool.add(romMethodRef.classRefCPIndex()));
nameAndSig = romMethodRef.nameAndSignature();
out.println(" Method: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()) + " " + J9UTF8Helper.stringValue(nameAndSig.signature()));
} else if (shapeDesc == J9CPTYPE_METHOD_TYPE) {
J9ROMMethodTypeRefPointer romMethodTypeRef = J9ROMMethodTypeRefPointer.cast(item);
out.println(" Method Type: " + J9UTF8Helper.stringValue(J9UTF8Pointer.cast(romMethodTypeRef.signature())));
} else if (shapeDesc == J9CPTYPE_METHODHANDLE) {
methodHandleRef = J9ROMMethodHandleRefPointer.cast(item);
methodRef = J9ROMMethodRefPointer.cast(constantPool.add(methodHandleRef.methodOrFieldRefIndex()));
classRef = J9ROMClassRefPointer.cast(constantPool.add(methodRef.classRefCPIndex()));
nameAndSig = methodRef.nameAndSignature();
out.print(" Method Handle: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()));
long methodType = methodHandleRef.handleTypeAndCpType().rightShift((int) J9DescriptionCpTypeShift).longValue();
if ((methodType == MH_REF_GETFIELD) || (methodType == MH_REF_PUTFIELD) || (methodType == MH_REF_GETSTATIC) || (methodType == MH_REF_PUTSTATIC)) {
out.print(" ");
}
out.println(J9UTF8Helper.stringValue(nameAndSig.signature()));
} else {
out.println(" <unknown type>");
}
}
}
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer in project openj9 by eclipse.
the class RomClassWalker method allSlotsInConstantPoolDo.
private void allSlotsInConstantPoolDo() throws CorruptDataException {
J9ROMConstantPoolItemPointer constantPool;
int index;
U32Pointer cpShapeDescription;
int constPoolCount;
constantPool = J9ROMClassHelper.constantPool(romClass);
cpShapeDescription = romClass.cpShapeDescription();
if (cpShapeDescription.isNull()) {
return;
}
constPoolCount = romClass.romConstantPoolCount().intValue();
PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
// 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, constantPool, constPoolCount * U64.SIZEOF, "constantPool ", true);
for (index = 0; index < constPoolCount; index++) {
long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(cpShapeDescription, index);
if (shapeDesc == J9CPTYPE_CLASS) {
J9ROMStringRefPointer ref = J9ROMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, ref.utf8DataEA(), "cpFieldUtf8");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.cpTypeEA(), "cpFieldType");
} else if ((shapeDesc == J9CPTYPE_STRING) || (shapeDesc == J9CPTYPE_ANNOTATION_UTF8)) {
J9ROMStringRefPointer ref = J9ROMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, ref.utf8DataEA(), "cpFieldUtf8");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.cpTypeEA(), "cpFieldType");
} else if (shapeDesc == J9CPTYPE_INT) {
J9ROMConstantPoolItemPointer ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot1EA(), "cpFieldInt");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot2EA(), "cpFieldIntUnused");
} else if (shapeDesc == J9CPTYPE_FLOAT) {
J9ROMConstantPoolItemPointer ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot1EA(), "cpFieldFloat");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot2EA(), "cpFieldFloatUnused");
} else if (shapeDesc == J9CPTYPE_LONG) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "cpField8");
} else if (shapeDesc == J9CPTYPE_DOUBLE) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "cpField8");
} else if (shapeDesc == J9CPTYPE_FIELD) {
J9ROMFieldRefPointer ref = J9ROMFieldRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_SRPNAS, ref.nameAndSignatureEA(), "cpFieldNAS");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.classRefCPIndexEA(), "cpFieldClassRef");
} else if ((shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD)) {
J9ROMMethodRefPointer ref = J9ROMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_SRPNAS, ref.nameAndSignatureEA(), "cpFieldNAS");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.classRefCPIndexEA(), "cpFieldClassRef");
} else if (shapeDesc == J9CPTYPE_METHOD_TYPE) {
J9ROMMethodTypeRefPointer ref = J9ROMMethodTypeRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, ref.signatureEA(), "signature");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.cpTypeEA(), "cpType");
} else if (shapeDesc == J9CPTYPE_METHODHANDLE) {
J9ROMMethodHandleRefPointer ref = J9ROMMethodHandleRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.methodOrFieldRefIndexEA(), "methodOrFieldRefIndex");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.handleTypeAndCpTypeEA(), "handleTypeAndCpType");
} else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "cpFieldUnused");
}
cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer in project openj9 by eclipse.
the class J9BCUtil method j9bcutil_dumpRomMethod.
/*
* Dump a printed representation of the specified @romMethod.
*/
/* note that methodIndex was not used and was removed */
public static void j9bcutil_dumpRomMethod(PrintStream out, J9ROMMethodPointer romMethod, J9ROMClassPointer romClass, long flags, int options) throws CorruptDataException {
J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
J9UTF8Pointer name = nameAndSignature.name();
J9UTF8Pointer signature = nameAndSignature.signature();
J9ROMConstantPoolItemPointer constantPool = J9ROMClassHelper.constantPool(romClass);
out.append(" Name: " + J9UTF8Helper.stringValue(name) + nl);
out.append(" Signature: " + J9UTF8Helper.stringValue(signature) + nl);
out.append(String.format(" Access Flags (%s): ", Long.toHexString(romMethod.modifiers().longValue())));
dumpModifiers(out, romMethod.modifiers().longValue(), MODIFIERSOURCE_METHOD, INCLUDE_INTERNAL_MODIFIERS);
out.append(nl);
out.append(" Max Stack: " + romMethod.maxStack().longValue() + nl);
if (J9ROMMethodHelper.hasExceptionInfo(romMethod)) {
J9ExceptionInfoPointer exceptionData = ROMHelp.J9_EXCEPTION_DATA_FROM_ROM_METHOD(romMethod);
long catchCount = exceptionData.catchCount().longValue();
if (catchCount > 0) {
J9ExceptionHandlerPointer handler = ROMHelp.J9EXCEPTIONINFO_HANDLERS(exceptionData);
out.append(String.format(" Caught Exceptions (%d):", catchCount));
out.append(nl);
out.append(" start end handler catch type" + nl);
out.append(" ----- --- ------- ----------" + nl);
for (int i = 0; i < catchCount; i++) {
out.append(String.format(" %d %d %d ", handler.startPC().longValue(), handler.endPC().longValue(), handler.handlerPC().longValue()));
long exceptionClassIndex = handler.exceptionClassIndex().longValue();
if (exceptionClassIndex != 0) {
J9ROMConstantPoolItemPointer addOffset = constantPool.add(exceptionClassIndex);
J9ROMStringRefPointer romStringRefPointer = J9ROMStringRefPointer.cast(addOffset.longValue());
out.append(J9UTF8Helper.stringValue(romStringRefPointer.utf8Data()));
} else {
out.append("(any)");
}
out.append(nl);
handler = handler.add(1);
}
}
long throwCount = exceptionData.throwCount().longValue();
if (throwCount > 0) {
out.append(String.format(" Thrown Exceptions (%d):", throwCount));
out.append(nl);
SelfRelativePointer currentThrowName = ROMHelp.J9EXCEPTIONINFO_THROWNAMES(exceptionData);
for (long i = 0; i < throwCount; i++) {
J9UTF8Pointer currentName = J9UTF8Pointer.cast(currentThrowName.get());
out.append(J9UTF8Helper.stringValue(currentName));
}
}
}
if (romMethod.modifiers().anyBitsIn(J9CfrClassFile.CFR_ACC_NATIVE)) {
dumpNative(out, romMethod, flags);
} else {
dumpBytecodes(out, romClass, romMethod, flags);
}
dumpMethodDebugInfo(out, romClass, romMethod, flags);
dumpStackMapTable(out, romClass, romMethod, flags);
dumpMethodParameters(out, romClass, romMethod, flags);
if (0 != (BCUtil_DumpAnnotations & options)) {
dumpMethodAnnotations(out, romMethod);
}
out.append(nl);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer 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