Search in sources :

Example 6 with U16

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

the class VmCheckCommand method verifyUTF8.

private boolean verifyUTF8(J9UTF8Pointer utf8) throws CorruptDataException {
    if (utf8.isNull()) {
        return false;
    }
    UDATA length = new UDATA(utf8.length());
    U8Pointer utf8Data = utf8.dataEA();
    while (length.longValue() > 0) {
        // not used
        U16 temp = new U16(0);
        U32 lengthRead = decodeUTF8CharN(utf8Data, temp, length);
        if (lengthRead.eq(0)) {
            return false;
        }
        length = length.sub(lengthRead);
        utf8Data = utf8Data.addOffset(lengthRead);
    }
    return true;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) U16(com.ibm.j9ddr.vm29.types.U16)

Example 7 with U16

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

the class VmCheckCommand method decodeUTF8CharN.

/**
 * Decode the UTF8 character.
 *
 * Decode the input UTF8 character and stores it into result.
 *
 * @param[in] input The UTF8 character
 * @param[out] result buffer for unicode characters
 * @param[in] bytesRemaining number of bytes remaining in input
 *
 * @return The number of UTF8 characters consumed (1,2,3) on success, 0 on
 *         failure
 * @throws CorruptDataException
 * @note Don't read more than bytesRemaining characters.
 * @note If morecharacters are required to fully decode the character,
 *       return failure
 */
U32 decodeUTF8CharN(U8Pointer input, /**
 * not used *
 */
U16 result, UDATA bytesRemaining) throws CorruptDataException {
    U8 c;
    U8Pointer cursor = input;
    if (bytesRemaining.longValue() < 1) {
        return new U32(0);
    }
    c = cursor.at(0);
    cursor = cursor.add(1);
    if (c.eq(0x0)) {
        /* illegal NUL encoding */
        return new U32(0);
    } else if ((c.bitAnd(0x80)).eq(0x0)) {
        // *result = (U_16)c;
        return new U32(1);
    } else if (c.bitAnd(0xE0).eq(0xC0)) {
        /* two byte encoding */
        U16 unicodeC;
        if (bytesRemaining.lt(2)) {
            return new U32(0);
        }
        unicodeC = new U16(c.bitAnd(0x1F).leftShift(6));
        c = cursor.at(0);
        cursor = cursor.add(1);
        unicodeC = unicodeC.add(new U16(unicodeC.add(c.bitAnd(0x3F))));
        if (!c.bitAnd(0xC0).eq(0x80)) {
            return new U32(0);
        }
        // *result = unicodeC;
        return new U32(2);
    } else if (c.bitAnd(0xF0).eq(0xE0)) {
        /* three byte encoding */
        U16 unicodeC;
        if (bytesRemaining.lt(3)) {
            return new U32(0);
        }
        unicodeC = new U16(c.bitAnd(0x0F).leftShift(12));
        c = cursor.at(0);
        cursor = cursor.add(1);
        unicodeC = unicodeC.add(new U16(c.bitAnd(0x3F).leftShift(6)));
        if (!c.bitAnd(0xC0).eq(0x80)) {
            return new U32(0);
        }
        c = cursor.at(0);
        cursor = cursor.add(1);
        unicodeC = unicodeC.add(new U16(c.bitAnd(0x3F)));
        if (!c.bitAnd(0xC0).eq(0x80)) {
            return new U32(0);
        }
        // *result = unicodeC;
        return new U32(3);
    } else {
        return new U32(0);
    }
}
Also used : U8(com.ibm.j9ddr.vm29.types.U8) U32(com.ibm.j9ddr.vm29.types.U32) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) U16(com.ibm.j9ddr.vm29.types.U16)

Example 8 with U16

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

the class RomClassWalker method allSlotsInSpecialSplitMethodRefIndexesDo.

void allSlotsInSpecialSplitMethodRefIndexesDo() throws CorruptDataException {
    int count = romClass.specialSplitMethodRefCount().intValue();
    U16Pointer cursor = romClass.specialSplitMethodRefIndexes();
    if (count > 0) {
        classWalkerCallback.addSection(clazz, cursor, count * U16.SIZEOF, "specialSplitMethodRefIndexes", true);
        for (int i = 0; i < count; i++) {
            classWalkerCallback.addSlot(clazz, SlotType.J9_U16, cursor.add(i), "cpIndex");
        }
    }
}
Also used : U16Pointer(com.ibm.j9ddr.vm29.pointer.U16Pointer)

Example 9 with U16

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

the class ByteCodeDumper method dumpBytecodes.

public static IDATA dumpBytecodes(PrintStream out, J9ROMClassPointer romClass, J9ROMMethodPointer romMethod, U32 flags) throws Exception {
    U16 temp;
    UDATA length;
    out.append(String.format("  Argument Count: %d", romMethod.argCount().intValue()));
    out.append(nl);
    temp = romMethod.tempCount();
    out.append(String.format("  Temp Count: %d", temp.intValue()));
    out.append(nl);
    out.append(nl);
    length = ROMHelp.J9_BYTECODE_SIZE_FROM_ROM_METHOD(romMethod);
    if (length.eq(0)) {
        return new IDATA(BCT_ERR_NO_ERROR);
    /* catch abstract methods */
    }
    return j9bcutil_dumpBytecodes(out, romClass, ROMHelp.J9_BYTECODE_START_FROM_ROM_METHOD(romMethod), new UDATA(0), length.sub(1), flags, "");
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) IDATA(com.ibm.j9ddr.vm29.types.IDATA) U16(com.ibm.j9ddr.vm29.types.U16)

Example 10 with U16

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

the class RomClassWalker method allSlotsInStackMapDo.

private void allSlotsInStackMapDo(U8Pointer stackMap) throws CorruptDataException {
    U8Pointer cursor = stackMap;
    long frameCount;
    int stackMapSize = U16.SIZEOF;
    if (stackMap.isNull()) {
        return;
    }
    /* TODO: Questions?
		 *  - do we want to display the non-flipped value?
		 *  - do we want to flip and display?
		 *  - do we want to have a J9ROM_U16_BE type?
		 *  */
    classWalkerCallback.addSlot(clazz, SlotType.J9_U16, U16Pointer.cast(cursor), "stackMapFrameCount");
    frameCount = U16Pointer.cast(cursor).at(0).longValue();
    frameCount = SWAP2BE((short) frameCount);
    cursor = cursor.add(2);
    stackMapSize += allSlotsInStackMapFramesDo(cursor, frameCount);
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Aggregations

U16 (com.ibm.j9ddr.vm29.types.U16)8 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)3 U16Pointer (com.ibm.j9ddr.vm29.pointer.U16Pointer)2 U32 (com.ibm.j9ddr.vm29.types.U32)2 U8 (com.ibm.j9ddr.vm29.types.U8)2 CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 LocalVariableTable (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTable)1 LocalVariableTableIterator (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator)1 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 J9LineNumberPointer (com.ibm.j9ddr.vm29.pointer.generated.J9LineNumberPointer)1 J9MethodDebugInfoPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodDebugInfoPointer)1 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)1 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)1 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)1 J9ROMStringRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer)1 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)1