use of com.ibm.j9ddr.vm29.pointer.SelfRelativePointer in project openj9 by eclipse.
the class RomClassWalker method allSlotsInOptionalInfoDo.
void allSlotsInOptionalInfoDo() throws CorruptDataException {
U32Pointer optionalInfo = romClass.optionalInfo();
SelfRelativePointer cursor = SelfRelativePointer.cast(optionalInfo);
if (romClass.optionalFlags().anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_FILE_NAME)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, cursor, "optionalFileNameUTF8");
cursor = cursor.add(1);
}
if (romClass.optionalFlags().anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_GENERIC_SIGNATURE)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, cursor, "optionalGenSigUTF8");
cursor = cursor.add(1);
}
if (romClass.optionalFlags().anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_DEBUG_EXTENSION)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, cursor, "optionalSourceDebugExtUTF8");
cursor = cursor.add(1);
}
if (romClass.optionalFlags().anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_ENCLOSING_METHOD)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "optionalEnclosingMethodSRP");
allSlotsInEnclosingObjectDo(J9EnclosingObjectPointer.cast(cursor.get()));
cursor = cursor.add(1);
}
if (romClass.optionalFlags().anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SIMPLE_NAME)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, cursor, "optionalSimpleNameUTF8");
cursor = cursor.add(1);
}
if (romClass.optionalFlags().allBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_VERIFY_EXCLUDE)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, cursor, "optionalVerifyExclude");
cursor = cursor.add(1);
}
if (romClass.optionalFlags().allBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_CLASS_ANNOTATION_INFO)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "classAnnotationsSRP");
allSlotsInAnnotationDo(U32Pointer.cast(cursor.get()), "classAnnotations");
cursor = cursor.add(1);
}
classWalkerCallback.addSection(clazz, optionalInfo, cursor.getAddress() - optionalInfo.getAddress(), "optionalInfo", true);
}
use of com.ibm.j9ddr.vm29.pointer.SelfRelativePointer in project openj9 by eclipse.
the class RomClassWalker method allSlotsInExceptionInfoDo.
void allSlotsInExceptionInfoDo(J9ExceptionInfoPointer exceptionInfo) throws CorruptDataException {
J9ExceptionHandlerPointer exceptionHandler;
SelfRelativePointer throwNames;
classWalkerCallback.addSlot(clazz, SlotType.J9_U16, exceptionInfo.catchCountEA(), "catchCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_U16, exceptionInfo.throwCountEA(), "throwCount");
exceptionHandler = ROMHelp.J9EXCEPTIONINFO_HANDLERS(exceptionInfo);
/* endian safe */
for (int i = 0; i < exceptionInfo.catchCount().longValue(); i++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, exceptionHandler.startPCEA(), "startPC");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, exceptionHandler.endPCEA(), "endPC");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, exceptionHandler.handlerPCEA(), "handlerPC");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, exceptionHandler.exceptionClassIndexEA(), "exceptionClassIndex");
exceptionHandler = exceptionHandler.add(1);
}
/* not using J9EXCEPTIONINFO_THROWNAMES...we're already there */
throwNames = SelfRelativePointer.cast(exceptionHandler);
for (int i = 0; i < exceptionInfo.throwCount().intValue(); i++, throwNames = throwNames.add(1)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, throwNames, "throwNameUTF8");
}
}
use of com.ibm.j9ddr.vm29.pointer.SelfRelativePointer 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.SelfRelativePointer in project openj9 by eclipse.
the class J9BCUtil method j9bcutil_dumpRomClass.
public static void j9bcutil_dumpRomClass(PrintStream out, J9ROMClassPointer romClass, long flags) throws CorruptDataException {
out.append((String.format("ROM Size: 0x%s (%d)", Long.toHexString(romClass.romSize().longValue()), romClass.romSize().longValue())));
out.append(nl);
out.append(String.format("Class Name: %s", J9UTF8Helper.stringValue(romClass.className())));
out.append(nl);
if (romClass.superclassName().isNull()) {
out.append("Superclass Name: <none>");
} else {
out.append(String.format("Superclass Name: %s", J9UTF8Helper.stringValue(romClass.superclassName())));
}
out.append(nl);
/* dump the source file name */
dumpSourceFileName(out, romClass, flags);
/* dump the simple name */
dumpSimpleName(out, romClass, flags);
/* dump the class generic signature */
dumpGenericSignature(out, romClass, flags);
/* dump the enclosing method */
dumpEnclosingMethod(out, romClass, flags);
out.append(String.format("Sun Access Flags (0x%s): ", Long.toHexString(romClass.modifiers().longValue())));
dumpModifiers(out, romClass.modifiers().longValue(), MODIFIERSOURCE_CLASS, ONLY_SPEC_MODIFIERS);
out.append(String.format("J9 Access Flags (0x%s): ", Long.toHexString(romClass.extraModifiers().longValue())));
dumpClassJ9ExtraModifiers(out, romClass.extraModifiers().longValue());
out.append(nl);
out.append(String.format("Class file version: %d.%d", romClass.majorVersion().longValue(), romClass.minorVersion().longValue()));
out.append(nl);
out.append(String.format("Instance Shape: 0x%s", Long.toHexString(romClass.instanceShape().longValue())));
out.append(nl);
out.append(String.format("Intermediate Class Data (%d bytes): %s", romClass.intermediateClassDataLength().longValue(), Long.toHexString(romClass.intermediateClassData().longValue())));
out.append(nl);
out.append(String.format("Maximum Branch Count: %d", romClass.maxBranchCount().longValue()));
out.append(nl);
out.append(String.format("Interfaces (%d):" + nl, romClass.interfaceCount().longValue()));
if (!romClass.interfaceCount().eq(0)) {
SelfRelativePointer interfaces = romClass.interfaces();
long interfaceCount = romClass.interfaceCount().longValue();
for (int i = 0; i < interfaceCount; i++) {
out.append(" ");
J9UTF8Pointer interfaceName = J9UTF8Pointer.cast(interfaces.get());
out.append(J9UTF8Helper.stringValue(interfaceName));
out.append(nl);
interfaces = interfaces.add(1);
}
}
J9UTF8Pointer outerClassName = romClass.outerClassName();
if (!outerClassName.isNull()) {
out.append("Declaring Class: " + J9UTF8Helper.stringValue(romClass.outerClassName()));
out.append(nl);
out.append(String.format("Member Access Flags (0x%s): ", Long.toHexString(romClass.memberAccessFlags().longValue())));
dumpModifiers(out, romClass.memberAccessFlags().longValue(), MODIFIERSOURCE_CLASS, ONLY_SPEC_MODIFIERS);
out.append(nl);
outerClassName = outerClassName.add(1);
}
long innerClassCount = romClass.innerClassCount().longValue();
if (innerClassCount != 0) {
SelfRelativePointer innerClasses = romClass.innerClasses();
out.append(String.format("Declared Classes (%d):" + nl, innerClassCount));
for (int i = 0; i < innerClassCount; i++) {
J9UTF8Pointer innerClassName = J9UTF8Pointer.cast(innerClasses.get());
out.append(" " + J9UTF8Helper.stringValue(innerClassName));
innerClasses = innerClasses.add(1);
}
}
U32 romFieldCount = romClass.romFieldCount();
out.append(String.format("Fields (%d):" + nl, romFieldCount.longValue()));
J9ROMFieldShapeIterator iterator = new J9ROMFieldShapeIterator(romClass.romFields(), romFieldCount);
while (iterator.hasNext()) {
J9ROMFieldShapePointer currentField = (J9ROMFieldShapePointer) iterator.next();
if (!currentField.modifiers().bitAnd(J9JavaAccessFlags.J9AccStatic).eq(0)) {
dumpRomStaticField(out, currentField, flags);
} else {
dumpRomField(out, currentField, flags);
}
out.append(nl);
}
dumpCPShapeDescription(out, romClass, flags);
long romMethodsCount = romClass.romMethodCount().longValue();
out.append(String.format("Methods (%d):" + nl, romMethodsCount));
J9ROMMethodPointer romMethod = romClass.romMethods();
for (int i = 0; i < romClass.romMethodCount().intValue(); i++) {
J9BCUtil.j9bcutil_dumpRomMethod(out, romMethod, romClass, flags, 0);
romMethod = ROMHelp.nextROMMethod(romMethod);
}
/* dump source debug extension */
dumpSourceDebugExtension(out, romClass, flags);
/* dump annotation info */
dumpAnnotationInfo(out, romClass, flags);
/* dump callsite data */
dumpCallSiteData(out, romClass);
/* dump split side tables */
dumpStaticSplitSideTable(out, romClass);
dumpSpecialSplitSideTable(out, romClass);
}
use of com.ibm.j9ddr.vm29.pointer.SelfRelativePointer in project openj9 by eclipse.
the class DTFJJavaClass method getInterfaces.
@SuppressWarnings("rawtypes")
public Iterator getInterfaces() {
ArrayList<Object> interfaceNames;
int interfaceCount;
SelfRelativePointer interfaceName;
try {
// a failure in the following calls mean that we cannot find any interfaces
interfaceCount = j9class.romClass().interfaceCount().intValue();
if (interfaceCount > 0xFFFF) {
// class file format limits the number of interfaces to U2 (unsigned 2 bytes)
String msg = String.format("Invalid number of interfaces for class@0x%s", Long.toHexString(j9class.getAddress()));
throw new com.ibm.j9ddr.CorruptDataException(msg);
}
interfaceNames = new ArrayList<Object>(interfaceCount);
interfaceName = j9class.romClass().interfaces();
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
return corruptIterator(cd);
}
// a failure in the loop should return what we've found so far + a corrupt data
try {
for (int i = 0; i < interfaceCount; i++) {
VoidPointer namePointer = interfaceName.add(i).get();
// a failure to get the name means we can still move to the next iface
try {
interfaceNames.add(J9UTF8Helper.stringValue(J9UTF8Pointer.cast(namePointer)));
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
interfaceNames.add(cd);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
interfaceNames.add(cd);
}
return interfaceNames.iterator();
}
Aggregations