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;
}
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);
}
}
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");
}
}
}
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, "");
}
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);
}
Aggregations