LittleEndian.setInt32(code, ofs, (extraIndex - ofs) - 4);
ofs += 4;
// Create extra field
for (int k = 0; k < arrLength; k++) {
final VmMethod method = (VmMethod) arr[k];
if (k + 1 == arrLength) {
// Last entry, jump directly
// JMP [statics+method_statics_index]
extraIndex = genJmpStaticsCodeOfs(code, extraIndex,
method.getSharedStaticsIndex());
} else {
// Non-last entry, compare and jump of select match
// CMP selectorReg, imm32_selector
code[extraIndex++] = (byte) 0x81;
code[extraIndex++] = (byte) 0xFA;
LittleEndian.setInt32(code, extraIndex, method
.getSelector());
extraIndex += 4;
// JNE labelAfterJump
code[extraIndex++] = (byte) 0x75;
code[extraIndex++] = (byte) 0x06;
// JMP [statics+method_statics_index]
extraIndex = genJmpStaticsCodeOfs(code, extraIndex,
method.getSharedStaticsIndex());
}
}
} else if (imt[i] != null) {
// Simple route
// JMP [STATICS+staticsOfs]
final VmMethod method = (VmMethod) imt[i];
ofs = genJmpStaticsCodeOfs(code, ofs, method.getSharedStaticsIndex());
} else {
// Empty IMT slot
// INT ABSTRACT_METHOD
code[ofs++] = (byte) 0xCD;
code[ofs++] = (byte) X86CompilerConstants.ABSTRACT_METHOD_INTNO;