Search in sources :

Example 6 with U64

use of com.ibm.j9ddr.vm29.types.U64 in project openj9 by eclipse.

the class J9ObjectFieldOffsetIterator_V1 method fieldOffsetsFindNext.

// Based on fieldOffsetsFindNext from resolvefield.c
private void fieldOffsetsFindNext() throws CorruptDataException {
    while (romFieldsShapeIterator.hasNext()) {
        J9ROMFieldShapePointer localField = (J9ROMFieldShapePointer) romFieldsShapeIterator.next();
        U32 modifiers = localField.modifiers();
        /* count the index for jvmti */
        index = index.add(1);
        if (modifiers.anyBitsIn(J9AccStatic)) {
            if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC)) {
                /* found a static, the walk wants statics */
                if (modifiers.anyBitsIn(J9FieldFlagObject)) {
                    offset = new UDATA(objectStaticsSeen.mult(UDATA.SIZEOF));
                    objectStaticsSeen = objectStaticsSeen.add(1);
                    field = localField;
                    break;
                } else if (!(walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS))) {
                    if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
                        /* Add single scalar and object counts together, round up to 2 and divide by 2 to get number of doubles used by singles */
                        UDATA doubleSlots;
                        if (J9BuildFlags.env_data64) {
                            doubleSlots = new UDATA(romClass.objectStaticCount().add(romClass.singleScalarStaticCount()));
                        } else {
                            doubleSlots = new UDATA(romClass.objectStaticCount().add(romClass.singleScalarStaticCount()).add(1)).rightShift(1);
                        }
                        offset = doubleSlots.mult(U64.SIZEOF).add(doubleStaticsSeen.mult(U64.SIZEOF));
                        doubleStaticsSeen = doubleStaticsSeen.add(1);
                    } else {
                        offset = new UDATA(romClass.objectStaticCount().mult(UDATA.SIZEOF).add(singleStaticsSeen.mult(UDATA.SIZEOF)));
                        singleStaticsSeen = singleStaticsSeen.add(1);
                    }
                    field = localField;
                    break;
                }
            }
        } else {
            if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE)) {
                if (modifiers.anyBitsIn(J9FieldFlagObject)) {
                    if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD)) {
                        // Assert_VM_true(state->backfillOffsetToUse >= 0);
                        offset = new UDATA(backfillOffsetToUse);
                        walkFlags = walkFlags.bitAnd(new U32(new UDATA(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD).bitNot()));
                    } else {
                        offset = firstObjectOffset.add(objectsSeen.mult(fj9object_t_SizeOf));
                        objectsSeen = objectsSeen.add(1);
                    }
                    field = localField;
                    break;
                } else if (!walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS)) {
                    if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
                        offset = firstDoubleOffset.add(doubleSeen.mult(U64.SIZEOF));
                        doubleSeen = doubleSeen.add(1);
                    } else {
                        if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD)) {
                            // Assert_VM_true(state->backfillOffsetToUse >= 0);
                            offset = new UDATA(backfillOffsetToUse);
                            walkFlags = walkFlags.bitAnd(new U32(new UDATA(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD).bitNot()));
                        } else {
                            offset = firstSingleOffset.add(singlesSeen.mult(U32.SIZEOF));
                            singlesSeen = singlesSeen.add(1);
                        }
                    }
                    field = localField;
                    break;
                }
            }
        }
    }
    // At this point all the info we need is stashed away in private state variables
    return;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)

Example 7 with U64

use of com.ibm.j9ddr.vm29.types.U64 in project openj9 by eclipse.

the class J9ROMFieldShapeHelper method romFieldSizeOf.

public static UDATA romFieldSizeOf(J9ROMFieldShapePointer fieldShapePointer) throws CorruptDataException {
    long size = J9ROMFieldShape.SIZEOF;
    U32 modifiers = fieldShapePointer.modifiers();
    if ((modifiers.anyBitsIn(J9FieldFlagConstant))) {
        size += ((modifiers.allBitsIn(J9FieldSizeDouble)) ? U64.SIZEOF : U32.SIZEOF);
    }
    if (modifiers.anyBitsIn(J9FieldFlagHasGenericSignature)) {
        size += U32.SIZEOF;
    }
    if (modifiers.anyBitsIn(J9FieldFlagHasFieldAnnotations)) {
        long bytesToPad = 0;
        // long annotationSize = U32Pointer.cast(address + size).at(0).longValue();
        long annotationSize = U32Pointer.cast(fieldShapePointer.addOffset(size)).at(0).longValue();
        /* add the length of annotation data */
        size += annotationSize;
        /* add the size of the size of the annotation data */
        size += U32.SIZEOF;
        bytesToPad = U32.SIZEOF - (annotationSize % U32.SIZEOF);
        if (U32.SIZEOF == bytesToPad) {
            bytesToPad = 0;
        }
        /* add the padding */
        size += bytesToPad;
    }
    if (modifiers.anyBitsIn(J9FieldFlagHasTypeAnnotations)) {
        long bytesToPad = 0;
        long annotationSize = U32Pointer.cast(fieldShapePointer.addOffset(size)).at(0).longValue();
        /* add the length of annotation data */
        size += annotationSize;
        /* add the size of the size of the annotation data */
        size += U32.SIZEOF;
        bytesToPad = U32.SIZEOF - (annotationSize % U32.SIZEOF);
        if (U32.SIZEOF == bytesToPad) {
            bytesToPad = 0;
        }
        /* add the padding */
        size += bytesToPad;
    }
    return new UDATA(size);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32)

Example 8 with U64

use of com.ibm.j9ddr.vm29.types.U64 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);
    }
}
Also used : J9ROMFieldRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldRefPointer) J9ROMMethodRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodRefPointer) J9ROMConstantPoolItemPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ROMMethodHandleRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodHandleRefPointer) J9ROMStringRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer) J9ROMMethodTypeRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodTypeRefPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 9 with U64

use of com.ibm.j9ddr.vm29.types.U64 in project openj9 by eclipse.

the class VMConstantPoolCommand method run.

/**
 * Run method for !vmconstantpool extension.
 *
 * @param command  !vmconstantpool
 * @param args	args passed by !vmconstantpool extension.
 * @param context Context
 * @param out PrintStream
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer javaVM;
        javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (args.length == 1) {
            long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            if (vmaddress != javaVM.getAddress()) {
                out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
                return;
            }
        } else if (args.length > 1) {
            printUsage(out);
        }
        J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
        J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
        int index;
        U32Pointer cpShapeDescription;
        int constPoolCount;
        cpShapeDescription = romClass.cpShapeDescription();
        long cpDescription = cpShapeDescription.at(0).longValue();
        constPoolCount = romClass.romConstantPoolCount().intValue();
        PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
        long cpDescriptionIndex = 0;
        for (index = 0; index < constPoolCount; index++) {
            if (0 == cpDescriptionIndex) {
                // Load a new description word
                cpDescription = cpShapeDescription.at(0).longValue();
                cpShapeDescription = cpShapeDescription.add(1);
                cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
            }
            long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
            AbstractPointer ref = PointerPointer.NULL;
            if (shapeDesc == J9CPTYPE_CLASS) {
                ref = J9ROMClassRefPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_STRING) {
                ref = J9ROMStringRefPointer.cast(cpEntry);
            } else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
                ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_LONG) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
            } else if (shapeDesc == J9CPTYPE_DOUBLE) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
                long classRefCPIndex;
                if (shapeDesc == J9CPTYPE_FIELD) {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    /* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
                    classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
                } else {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
                }
                PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
                /* gets the DDR output of the item */
                String outString = ref.formatFullInteractive();
                String[] parts = outString.split(nl);
                /* add a debug extension(!j9romclassref) on the second line of the output */
                parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
                out.print(join(nl, parts));
            } else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if (ref.notNull()) {
                out.println(ref.formatFullInteractive());
            }
            cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
            cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
            cpDescriptionIndex -= 1;
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) U64Pointer(com.ibm.j9ddr.vm29.pointer.U64Pointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Aggregations

UDATA (com.ibm.j9ddr.vm29.types.UDATA)4 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)3 U32 (com.ibm.j9ddr.vm29.types.U32)3 ImageSection (com.ibm.dtfj.image.ImageSection)2 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 J9DDRImageSection (com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)2 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)2 U64 (com.ibm.j9ddr.vm29.types.U64)2 InvalidDataTypeException (com.ibm.j9ddr.InvalidDataTypeException)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 J9DDRDTFJUtils.corruptIterator (com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator)1 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)1 GCScavengerForwardedHeader (com.ibm.j9ddr.vm29.j9.gc.GCScavengerForwardedHeader)1 J9MemTagIterator (com.ibm.j9ddr.vm29.j9.walkers.J9MemTagIterator)1 MemoryCategoryIterator (com.ibm.j9ddr.vm29.j9.walkers.MemoryCategoryIterator)1 AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)1 U64Pointer (com.ibm.j9ddr.vm29.pointer.U64Pointer)1 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)1 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)1