Search in sources :

Example 11 with U32Pointer

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

the class J9BCUtil method dumpStackMapTable.

private static void dumpStackMapTable(PrintStream out, J9ROMClassPointer romclass, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    U32Pointer stackMapMethod = ROMHelp.getStackMapFromROMMethod(romMethod);
    U16 stackMapCount;
    U8Pointer stackMapData;
    long mapPC = -1;
    long mapType;
    if (stackMapMethod.notNull()) {
        stackMapData = U8Pointer.cast(stackMapMethod.add(1));
        stackMapCount = new U16(stackMapData.at(0)).leftShift(8).bitOr(stackMapData.at(1));
        stackMapData = stackMapData.add(2);
        out.println("\n  StackMapTable\n    Stackmaps(" + stackMapCount.intValue() + "):");
        for (int i = 0; i < stackMapCount.intValue(); i++) {
            mapPC++;
            mapType = stackMapData.at(0).longValue();
            stackMapData = stackMapData.add(1);
            if (mapType < 64) {
                mapPC += mapType;
                out.println("      pc: " + mapPC + " same");
            } else if (mapType < 128) {
                mapPC += (mapType - 64);
                out.print("      pc: " + mapPC + " same_locals_1_stack_item: ");
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, 1);
                out.println();
            } else if (mapType < 247) {
                out.println("      UNKNOWN FRAME TAG: (" + mapType + ")\n");
            } else if (mapType == 247) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.print("      pc: " + mapPC + " same_locals_1_stack_item_extended: ");
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, 1);
                out.println();
            } else if (mapType < 251) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.println("      pc: " + mapPC + " chop " + (251 - mapType));
            } else if (mapType == 251) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.println("      pc: " + mapPC + " same_extended\n");
            } else if (mapType < 255) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.print("      pc: " + mapPC + " append: ");
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, (mapType - 251));
                out.println();
            } else if (mapType == 255) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.print("      pc: " + mapPC + " full, local(s): ");
                offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, offset);
                out.print(", stack: ");
                offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, offset);
                out.println();
            }
        }
    }
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) U16(com.ibm.j9ddr.vm29.types.U16) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 12 with U32Pointer

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

the class VmCheckCommand method verifyJ9ROMClass.

private void verifyJ9ROMClass(PrintStream out, J9JavaVMPointer vm, J9ClassPointer clazz) throws CorruptDataException {
    J9ROMClassPointer romClass = clazz.romClass();
    J9ClassLoaderPointer classLoader = clazz.classLoader();
    J9MemorySegmentPointer segment = findSegmentInClassLoaderForAddress(classLoader, romClass);
    if (!segment.isNull()) {
        long address;
        if (romClass.interfaceCount().longValue() != 0) {
            address = romClass.interfaces().getAddress();
            verifyAddressInSegment(out, vm, segment, address, "romClass->interfaces");
        }
        if (romClass.romMethodCount().longValue() != 0) {
            address = romClass.romMethods().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->romMethods");
        }
        if (romClass.romFieldCount().longValue() != 0) {
            address = romClass.romFields().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->romFields");
        }
        if (romClass.innerClassCount().longValue() != 0) {
            address = romClass.innerClasses().longValue();
            verifyAddressInSegment(out, vm, segment, address, "romClass->innerClasses");
        }
        U32Pointer cpShapeDescription = romClass.cpShapeDescription();
        /* TODO: is !isNull() check required or not? */
        if (!cpShapeDescription.isNull()) {
            address = cpShapeDescription.getAddress();
            verifyAddressInSegment(out, vm, segment, address, "romClass->cpShapeDescription");
        }
    }
    {
        J9UTF8Pointer className = romClass.className();
        J9UTF8Pointer superclassName = romClass.superclassName();
        J9UTF8Pointer outerClassName = romClass.outerClassName();
        if (className.isNull() || !verifyUTF8(className)) {
            reportError(out, "invalid className=0x%s utf8 for romClass=0x%s", Long.toHexString(className.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!superclassName.isNull() && !verifyUTF8(superclassName)) {
            reportError(out, "invalid superclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(superclassName.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!outerClassName.isNull() && !verifyUTF8(outerClassName)) {
            reportError(out, "invalid outerclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(outerClassName.getAddress()), Long.toHexString(romClass.getAddress()));
        }
    }
    U32 ramConstantPoolCount = romClass.ramConstantPoolCount();
    U32 romConstantPoolCount = romClass.romConstantPoolCount();
    if (ramConstantPoolCount.gt(romConstantPoolCount)) {
        reportError(out, "ramConstantPoolCount=%d > romConstantPoolCount=%d for romClass=0x%s", ramConstantPoolCount.longValue(), romConstantPoolCount.longValue(), Long.toHexString(romClass.getAddress()));
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 13 with U32Pointer

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

the class ConstantPoolHelpers method J9_CP_TYPE.

/**
 * This method is Java implementation of the define J9_CP_TYPE in j9cp.h in VM.
 * It basically find out the type of the constant pool entry at the given index.
 *
 * #define J9_CP_TYPE(cpShapeDescription, index) \
 *	(((cpShapeDescription)[(index) / J9_CP_DESCRIPTIONS_PER_U32] >> \
 *	(((index) % J9_CP_DESCRIPTIONS_PER_U32) * J9_CP_BITS_PER_DESCRIPTION)) & J9_CP_DESCRIPTION_MASK)
 *
 * @param cpShapeDescription Description of the constantPool
 * @param index Type index
 * @return Type
 * @throws CorruptDataException
 */
public static long J9_CP_TYPE(U32Pointer cpShapeDescription, int index) throws CorruptDataException {
    U32 cpDescription = cpShapeDescription.at(index / J9_CP_DESCRIPTIONS_PER_U32);
    long shapeDesc = cpDescription.rightShift((int) ((index % J9_CP_DESCRIPTIONS_PER_U32) * J9_CP_BITS_PER_DESCRIPTION)).bitAnd(J9_CP_DESCRIPTION_MASK).longValue();
    return shapeDesc;
}
Also used : J9_CP_DESCRIPTIONS_PER_U32(com.ibm.j9ddr.vm29.structure.J9ConstantPool.J9_CP_DESCRIPTIONS_PER_U32) U32(com.ibm.j9ddr.vm29.types.U32)

Example 14 with U32Pointer

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

the class Pool_29_V0 method isPuddleSlotFree.

// PUDDLE_SLOT_FREE
private boolean isPuddleSlotFree(J9PoolPuddlePointer currentPuddle) throws CorruptDataException {
    U32Pointer ptr = U32Pointer.cast(currentPuddle.add(1));
    ptr = ptr.add(slot / 32);
    long value = ptr.at(0).longValue();
    int bitmask = (1 << (31 - slot % 32));
    return (value & bitmask) != 0;
}
Also used : U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 15 with U32Pointer

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

the class J9MemTagHelper method checkTagSumCheck.

/**
 * Checks that the memory tag is not corrupt.
 *
 * @param[in] tagAddress the in-process or out-of-process address of the
 *            header/footer memory tag
 * @param[in] eyeCatcher the eyecatcher corresponding to the memory tag
 *
 * @return 0 if the sum check is successful, non-zero otherwise
 * @throws CorruptDataException
 */
public static void checkTagSumCheck(J9MemTagPointer tag, long eyeCatcher) throws CorruptDataException {
    int sum = 0;
    U32Pointer slots;
    if (!checkEyecatcher(tag, eyeCatcher)) {
        throw new J9MemTagCheckError(tag, "Wrong eyecatcher. Expected 0x" + Long.toHexString(eyeCatcher) + " but was " + UDATA.cast(tag).getHexValue());
    }
    slots = U32Pointer.cast(tag);
    /*
		 * Could be unrolled into chained xors with a J9VM_ENV_DATA64
		 * conditional on the extra 2 U_32s
		 */
    for (int i = 0; i < (J9MemTag.SIZEOF / U32.SIZEOF); i++) {
        sum ^= slots.at(i).longValue();
    }
    if (J9BuildFlags.env_data64) {
        U32 a = new U32(UDATA.cast(tag).rightShift(32));
        U32 b = new U32(UDATA.cast(tag).bitAnd(U32.MAX));
        sum ^= a.longValue() ^ b.longValue();
    } else {
        sum ^= tag.longValue();
    }
    if (sum != 0) {
        throw new J9MemTagCheckError(tag, "J9MemTag sumcheck failed: " + sum);
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Aggregations

U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)19 U32 (com.ibm.j9ddr.vm29.types.U32)7 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)4 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)4 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)2 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)2 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)2 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)2 J9RAMClassRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMClassRefPointer)2 J9RAMMethodHandleRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodHandleRefPointer)2 J9RAMMethodTypeRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodTypeRefPointer)2 J9RAMStringRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMStringRefPointer)2 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)2 J9ROMFieldRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldRefPointer)2 J9ROMMethodHandleRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodHandleRefPointer)2 J9ROMMethodRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodRefPointer)2 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1