Search in sources :

Example 1 with J9ROMFieldShapePointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer in project openj9 by eclipse.

the class J9ROMFieldShapeHelper method getFieldAnnotationLocation.

private static U32Pointer getFieldAnnotationLocation(J9ROMFieldShapePointer fieldShapePointer) throws CorruptDataException {
    long size = 0;
    if ((fieldShapePointer.modifiers().allBitsIn(J9FieldFlagConstant))) {
        size += ((fieldShapePointer.modifiers().allBitsIn(J9FieldSizeDouble)) ? U64.SIZEOF : U32.SIZEOF);
    }
    if (fieldShapePointer.modifiers().allBitsIn(J9FieldFlagHasGenericSignature)) {
        size += U32.SIZEOF;
    }
    // move past J9ROMFieldShape struct and then add size in bytes
    U32Pointer fieldAnnotationOffset = U32Pointer.cast(fieldShapePointer.add(1)).addOffset(size);
    return fieldAnnotationOffset;
}
Also used : U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 2 with J9ROMFieldShapePointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer 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);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) J9_CP_DESCRIPTIONS_PER_U32(com.ibm.j9ddr.vm29.structure.J9ConstantPool.J9_CP_DESCRIPTIONS_PER_U32) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)

Example 3 with J9ROMFieldShapePointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer 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);
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMFieldShapeIterator(com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator) SelfRelativePointer(com.ibm.j9ddr.vm29.pointer.SelfRelativePointer) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)

Example 4 with J9ROMFieldShapePointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer 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);
    }
}
Also used : BoolPointer(com.ibm.j9ddr.vm29.pointer.BoolPointer) I64Pointer(com.ibm.j9ddr.vm29.pointer.I64Pointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) DoublePointer(com.ibm.j9ddr.vm29.pointer.DoublePointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) CorruptDataException(com.ibm.j9ddr.CorruptDataException) I16Pointer(com.ibm.j9ddr.vm29.pointer.I16Pointer) I32Pointer(com.ibm.j9ddr.vm29.pointer.I32Pointer) I8Pointer(com.ibm.j9ddr.vm29.pointer.I8Pointer) U32(com.ibm.j9ddr.vm29.types.U32) FloatPointer(com.ibm.j9ddr.vm29.pointer.FloatPointer) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)

Example 5 with J9ROMFieldShapePointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer in project openj9 by eclipse.

the class J9BCUtil method dumpAnnotationInfo.

private static void dumpAnnotationInfo(PrintStream out, J9ROMClassPointer romClass, long flags) throws CorruptDataException {
    U32Pointer classAnnotationData = OptInfo.getClassAnnotationsDataForROMClass(romClass);
    U32Pointer classTypeAnnotationData = OptInfo.getClassTypeAnnotationsDataForROMClass(romClass);
    out.append("  Annotation Info:" + nl);
    if (!classAnnotationData.isNull()) {
        U32 length = classAnnotationData.at(0);
        U32Pointer data = classAnnotationData.add(1);
        out.append(String.format("    Class Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!classTypeAnnotationData.isNull()) {
        U32 length = classTypeAnnotationData.at(0);
        U32Pointer data = classTypeAnnotationData.add(1);
        out.append(String.format("    Class Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    /* print field annotations */
    J9ROMFieldShapeIterator iterator = new J9ROMFieldShapeIterator(romClass.romFields(), romClass.romFieldCount());
    out.append("    Field Annotations:" + nl);
    while (iterator.hasNext()) {
        J9ROMFieldShapePointer currentField = (J9ROMFieldShapePointer) iterator.next();
        U32Pointer fieldAnnotationData = J9ROMFieldShapeHelper.getFieldAnnotationsDataFromROMField(currentField);
        U32Pointer fieldTypeAnnotationData = J9ROMFieldShapeHelper.getFieldTypeAnnotationsDataFromROMField(currentField);
        if (!fieldAnnotationData.isNull()) {
            U32 length = fieldAnnotationData.at(0);
            U32Pointer data = fieldAnnotationData.add(1);
            out.append("     Name: " + J9UTF8Helper.stringValue(currentField.nameAndSignature().name()) + nl);
            out.append("     Signature: " + J9UTF8Helper.stringValue(currentField.nameAndSignature().signature()) + nl);
            out.append(String.format("      Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
        }
        if (!fieldTypeAnnotationData.isNull()) {
            U32 length = fieldTypeAnnotationData.at(0);
            U32Pointer data = fieldTypeAnnotationData.add(1);
            out.append(String.format("      Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
        }
    }
    out.append(nl);
    /* print method, parameter and default annotations */
    J9ROMMethodPointer romMethod = romClass.romMethods();
    out.append("    Method Annotations:" + nl);
    for (int i = 0; i < romClass.romMethodCount().intValue(); i++) {
        dumpMethodAnnotations(out, romMethod);
        romMethod = ROMHelp.nextROMMethod(romMethod);
    }
    out.append(nl);
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMFieldShapeIterator(com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Aggregations

J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)9 U32 (com.ibm.j9ddr.vm29.types.U32)9 UDATA (com.ibm.j9ddr.vm29.types.UDATA)5 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)3 J9ROMFieldShapeIterator (com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator)3 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)2 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)1 BoolPointer (com.ibm.j9ddr.vm29.pointer.BoolPointer)1 DoublePointer (com.ibm.j9ddr.vm29.pointer.DoublePointer)1 FloatPointer (com.ibm.j9ddr.vm29.pointer.FloatPointer)1 I16Pointer (com.ibm.j9ddr.vm29.pointer.I16Pointer)1 I32Pointer (com.ibm.j9ddr.vm29.pointer.I32Pointer)1 I64Pointer (com.ibm.j9ddr.vm29.pointer.I64Pointer)1 I8Pointer (com.ibm.j9ddr.vm29.pointer.I8Pointer)1