short opcodeUnit = (short) opcode; codeOut.write( InstructionCodec.codeUnit( opcodeUnit, InstructionCodec.makeByte(a, InstructionCodec.getLiteralNibble(literal)) case Opcodes.MONITOR_EXIT: case Opcodes.THROW: { codeOut.write(InstructionCodec.codeUnit(opcode, a)); break; case Opcodes.IF_GTZ: case Opcodes.IF_LEZ: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, a), relativeTarget); break; codeOut.write(InstructionCodec.codeUnit(opcode, a), InstructionCodec.getLiteralUnit(literal)); break; int shift = (opcode == Opcodes.CONST_HIGH16) ? 16 : 48; short literalShifted = (short) (literal >> shift); codeOut.write(InstructionCodec.codeUnit(opcode, a), literalShifted); break; if (index > 0xFFFF) { codeOut.write( InstructionCodec.codeUnit(Opcodes.CONST_STRING_JUMBO, a), InstructionCodec.unit0(index),
short opcodeUnit = (short) opcode; codeOut.write( InstructionCodec.codeUnit( opcodeUnit, InstructionCodec.makeByte(a, b) case Opcodes.MOVE_OBJECT_FROM16: { codeOut.write( InstructionCodec.codeUnit(opcode, a), InstructionCodec.getBUnit(b) ); break; case Opcodes.USHR_INT_LIT8: { codeOut.write( InstructionCodec.codeUnit(opcode, a), InstructionCodec.codeUnit(b, InstructionCodec.getLiteralByte(literal)) ); break; case Opcodes.IF_GT: case Opcodes.IF_LE: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write( InstructionCodec.codeUnit( opcode, InstructionCodec.makeByte(a, b) ), relativeTarget
public void visitFillArrayDataPayloadInsn(int currentAddress, int opcode, Object data, int size, int elementWidth) { FillArrayDataPayloadInstructionHolder insnHolder = new FillArrayDataPayloadInstructionHolder(); insnHolder.insnFormat = InstructionCodec.getInstructionFormat(opcode); insnHolder.address = currentAddress; insnHolder.opcode = opcode; insnHolder.data = data; insnHolder.size = size; insnHolder.elementWidth = elementWidth; result[currentAddress] = insnHolder; } });
public void visitFourRegisterInsn(int currentAddress, int opcode, int index, int indexType, int target, long literal, int a, int b, int c, int d) { switch (opcode) { case Opcodes.FILLED_NEW_ARRAY: case Opcodes.INVOKE_VIRTUAL: case Opcodes.INVOKE_SUPER: case Opcodes.INVOKE_DIRECT: case Opcodes.INVOKE_STATIC: case Opcodes.INVOKE_INTERFACE: { short indexUnit = (short) index; codeOut.write( InstructionCodec.codeUnit( opcode, InstructionCodec.makeByte(0, 4) ), indexUnit, InstructionCodec.codeUnit(a, b, c, d) ); break; } default: { throw new IllegalStateException("unexpected opcode: " + Hex.u2or4(opcode)); } } }
public void visitRegisterRangeInsn(int currentAddress, int opcode, int index, int indexType, int target, long literal, int a, int registerCount) { switch (opcode) { case Opcodes.FILLED_NEW_ARRAY_RANGE: case Opcodes.INVOKE_VIRTUAL_RANGE: case Opcodes.INVOKE_SUPER_RANGE: case Opcodes.INVOKE_DIRECT_RANGE: case Opcodes.INVOKE_STATIC_RANGE: case Opcodes.INVOKE_INTERFACE_RANGE: { short indexUnit = (short) index; codeOut.write( InstructionCodec.codeUnit(opcode, registerCount), indexUnit, InstructionCodec.getAUnit(a)); break; } default: { throw new IllegalStateException("unexpected opcode: " + Hex.u2or4(opcode)); } } }
int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (byte) relativeTarget) { if (relativeTarget != (short) relativeTarget) { short opcodeUnit = (short) Opcodes.GOTO_32; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget)); } else { short shortRelativeTarget = (short) relativeTarget; codeOut.write(InstructionCodec.codeUnit(opcode, relativeTarget)); int relativeTarget = InstructionCodec.getTargetByte(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, relativeTarget)); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (short) relativeTarget) { short opcodeUnit = (short) Opcodes.GOTO_32; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget)); } else { short shortRelativeTarget = (short) relativeTarget; short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, relativeTarget); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget)); break;
int opcode = InstructionCodec.byte0(opcodeUnit); int target = (byte) InstructionCodec.byte1(opcodeUnit); // sign-extend iv.visitZeroRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, currentAddress + target, 0L); break; int opcode = InstructionCodec.byte0(opcodeUnit); int literal = InstructionCodec.byte1(opcodeUnit); // should be zero iv.visitZeroRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, literal); break; int opcode = InstructionCodec.byte0(opcodeUnit); int a = InstructionCodec.nibble2(opcodeUnit); int literal = (InstructionCodec.nibble3(opcodeUnit) << 28) >> 28; // sign-extend iv.visitOneRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, literal, a); break; case Opcodes.MONITOR_EXIT: case Opcodes.THROW: { int opcode = InstructionCodec.byte0(opcodeUnit); int a = InstructionCodec.byte1(opcodeUnit); iv.visitOneRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, 0L, a); break; case Opcodes.DIV_DOUBLE_2ADDR: case Opcodes.REM_DOUBLE_2ADDR: { int opcode = InstructionCodec.byte0(opcodeUnit); int a = InstructionCodec.nibble2(opcodeUnit); int b = InstructionCodec.nibble3(opcodeUnit); iv.visitTwoRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, 0L, a, b);
public void visitPackedSwitchPayloadInsn(int currentAddress, int opcode, int firstKey, int[] targets) { int baseAddress = codeOut.baseAddressForCursor(); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit); codeOut.write(InstructionCodec.asUnsignedUnit(targets.length)); codeOut.writeInt(firstKey); if (this.hasPromoter) { for (int target : targets) { target = this.insnPromoter.getPromotedAddress(target); codeOut.writeInt(target - baseAddress); } } else { for (int target : targets) { codeOut.writeInt(target - baseAddress); } } }
private boolean compareIndex(int opcode, int index1, int index2) { switch (InstructionCodec.getInstructionIndexType(opcode)) { case InstructionCodec.INDEX_TYPE_STRING_REF: { return compareString(index1, index2); } case InstructionCodec.INDEX_TYPE_TYPE_REF: { return compareType(index1, index2); } case InstructionCodec.INDEX_TYPE_FIELD_REF: { return compareField(index1, index2); } case InstructionCodec.INDEX_TYPE_METHOD_REF: { return compareMethod(index1, index2); } default: { return index1 == index2; } } }
int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (byte) relativeTarget) { if (relativeTarget != (short) relativeTarget) { short opcodeUnit = (short) Opcodes.GOTO_32; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget)); } else { short shortRelativeTarget = (short) relativeTarget; codeOut.write(InstructionCodec.codeUnit(opcode, relativeTarget)); int relativeTarget = InstructionCodec.getTargetByte(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, relativeTarget)); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (short) relativeTarget) { short opcodeUnit = (short) Opcodes.GOTO_32; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget)); } else { short shortRelativeTarget = (short) relativeTarget; short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, relativeTarget); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget)); break;
int opcode = InstructionCodec.byte0(opcodeUnit); int target = (byte) InstructionCodec.byte1(opcodeUnit); // sign-extend iv.visitZeroRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, currentAddress + target, 0L); break; int opcode = InstructionCodec.byte0(opcodeUnit); int literal = InstructionCodec.byte1(opcodeUnit); // should be zero iv.visitZeroRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, literal); break; int opcode = InstructionCodec.byte0(opcodeUnit); int a = InstructionCodec.nibble2(opcodeUnit); int literal = (InstructionCodec.nibble3(opcodeUnit) << 28) >> 28; // sign-extend iv.visitOneRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, literal, a); break; case Opcodes.MONITOR_EXIT: case Opcodes.THROW: { int opcode = InstructionCodec.byte0(opcodeUnit); int a = InstructionCodec.byte1(opcodeUnit); iv.visitOneRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, 0L, a); break; case Opcodes.DIV_DOUBLE_2ADDR: case Opcodes.REM_DOUBLE_2ADDR: { int opcode = InstructionCodec.byte0(opcodeUnit); int a = InstructionCodec.nibble2(opcodeUnit); int b = InstructionCodec.nibble3(opcodeUnit); iv.visitTwoRegisterInsn(currentAddress, opcode, 0, InstructionCodec.INDEX_TYPE_NONE, 0, 0L, a, b);
public void visitFiveRegisterInsn(int currentAddress, int opcode, int index, int indexType, int target, long literal, int a, int b, int c, int d, int e) { switch (opcode) { case Opcodes.FILLED_NEW_ARRAY: case Opcodes.INVOKE_VIRTUAL: case Opcodes.INVOKE_SUPER: case Opcodes.INVOKE_DIRECT: case Opcodes.INVOKE_STATIC: case Opcodes.INVOKE_INTERFACE: { short indexUnit = (short) index; codeOut.write( InstructionCodec.codeUnit( opcode, InstructionCodec.makeByte(e, 5) ), indexUnit, InstructionCodec.codeUnit(a, b, c, d) ); break; } default: { throw new IllegalStateException("unexpected opcode: " + Hex.u2or4(opcode)); } } }
public void visitRegisterRangeInsn(int currentAddress, int opcode, int index, int indexType, int target, long literal, int a, int registerCount) { switch (opcode) { case Opcodes.FILLED_NEW_ARRAY_RANGE: case Opcodes.INVOKE_VIRTUAL_RANGE: case Opcodes.INVOKE_SUPER_RANGE: case Opcodes.INVOKE_DIRECT_RANGE: case Opcodes.INVOKE_STATIC_RANGE: case Opcodes.INVOKE_INTERFACE_RANGE: { short indexUnit = (short) index; codeOut.write( InstructionCodec.codeUnit(opcode, registerCount), indexUnit, InstructionCodec.getAUnit(a)); break; } default: { throw new IllegalStateException("unexpected opcode: " + Hex.u2or4(opcode)); } } }
public void visitSparseSwitchPayloadInsn(int currentAddress, int opcode, int[] keys, int[] targets) { int baseAddress = codeOut.baseAddressForCursor(); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit); codeOut.write(InstructionCodec.asUnsignedUnit(targets.length)); for (int key : keys) { codeOut.writeInt(key); } if (this.hasPromoter) { for (int target : targets) { target = this.insnPromoter.getPromotedAddress(target); codeOut.writeInt(target - baseAddress); } } else { for (int target : targets) { codeOut.writeInt(target - baseAddress); } } }
private boolean compareIndex(int opcode, int index1, int index2) { switch (InstructionCodec.getInstructionIndexType(opcode)) { case InstructionCodec.INDEX_TYPE_STRING_REF: { return compareString(index1, index2); } case InstructionCodec.INDEX_TYPE_TYPE_REF: { return compareType(index1, index2); } case InstructionCodec.INDEX_TYPE_FIELD_REF: { return compareField(index1, index2); } case InstructionCodec.INDEX_TYPE_METHOD_REF: { return compareMethod(index1, index2); } default: { return index1 == index2; } } }
short opcodeUnit = (short) opcode; codeOut.write( InstructionCodec.codeUnit( opcodeUnit, InstructionCodec.makeByte(a, InstructionCodec.getLiteralNibble(literal)) case Opcodes.MONITOR_EXIT: case Opcodes.THROW: { codeOut.write(InstructionCodec.codeUnit(opcode, a)); break; case Opcodes.IF_GTZ: case Opcodes.IF_LEZ: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, a), relativeTarget); break; codeOut.write(InstructionCodec.codeUnit(opcode, a), InstructionCodec.getLiteralUnit(literal)); break; int shift = (opcode == Opcodes.CONST_HIGH16) ? 16 : 48; short literalShifted = (short) (literal >> shift); codeOut.write(InstructionCodec.codeUnit(opcode, a), literalShifted); break; if (index > 0xFFFF) { codeOut.write( InstructionCodec.codeUnit(Opcodes.CONST_STRING_JUMBO, a), InstructionCodec.unit0(index),
short opcodeUnit = (short) opcode; codeOut.write( InstructionCodec.codeUnit( opcodeUnit, InstructionCodec.makeByte(a, b) case Opcodes.MOVE_OBJECT_FROM16: { codeOut.write( InstructionCodec.codeUnit(opcode, a), InstructionCodec.getBUnit(b) ); break; case Opcodes.USHR_INT_LIT8: { codeOut.write( InstructionCodec.codeUnit(opcode, a), InstructionCodec.codeUnit(b, InstructionCodec.getLiteralByte(literal)) ); break; case Opcodes.IF_GT: case Opcodes.IF_LE: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write( InstructionCodec.codeUnit( opcode, InstructionCodec.makeByte(a, b) ), relativeTarget
public void visitZeroRegisterInsn(int currentAddress, int opcode, int index, int indexType, int target, long literal) { InstructionHolder insnHolder = new InstructionHolder(); insnHolder.insnFormat = InstructionCodec.getInstructionFormat(opcode); insnHolder.address = currentAddress; insnHolder.opcode = opcode; insnHolder.index = index; insnHolder.target = target; insnHolder.literal = literal; result[currentAddress] = insnHolder; }
public void visitPackedSwitchPayloadInsn(int currentAddress, int opcode, int firstKey, int[] targets) { int baseAddress = codeOut.baseAddressForCursor(); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit); codeOut.write(InstructionCodec.asUnsignedUnit(targets.length)); codeOut.writeInt(firstKey); if (this.hasPromoter) { for (int target : targets) { target = this.insnPromoter.getPromotedAddress(target); codeOut.writeInt(target - baseAddress); } } else { for (int target : targets) { codeOut.writeInt(target - baseAddress); } } }