@Nonnull private BuilderInstruction12x newBuilderInstruction12x(@Nonnull Instruction12x instruction) { return new BuilderInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction12x instr = (Instruction12x) location.getInstruction(); int destRegister = instr.getRegisterA(); int srcRegister = instr.getRegisterB(); return new UnaryMathOp(location, child, destRegister, srcRegister); }
@Override public BinaryMathOp create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); BuilderInstruction instruction = (BuilderInstruction) location.getInstruction(); TwoRegisterInstruction instr = (TwoRegisterInstruction) location.getInstruction(); int destRegister = instr.getRegisterA(); int arg1Register = instr.getRegisterB(); ExceptionFactory exceptionFactory = vm.getExceptionFactory(); if (instruction instanceof Instruction23x) { // add-int vAA, vBB, vCC int arg2Register = ((Instruction23x) instruction).getRegisterC(); return new BinaryMathOp(location, child, destRegister, arg1Register, arg2Register, false, exceptionFactory); } else if (instruction instanceof Instruction12x) { // add-int/2addr vAA, vBB arg1Register = instr.getRegisterA(); int arg2Register = ((Instruction12x) instruction).getRegisterB(); return new BinaryMathOp(location, child, destRegister, arg1Register, arg2Register, false, exceptionFactory); } else if (instruction instanceof NarrowLiteralInstruction) { // Instruction22b - add-int/lit8 vAA, vBB, #CC // Instruction22s - add-int/lit16 vAA, vBB, #CCCC int arg2Literal = ((NarrowLiteralInstruction) instruction).getNarrowLiteral(); return new BinaryMathOp(location, child, destRegister, arg1Register, arg2Literal, true, exceptionFactory); } else { return null; } }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction12x instr = (Instruction12x) location.getInstruction(); int destRegister = instr.getRegisterA(); int arrayRegister = instr.getRegisterB(); return new ArrayLengthOp(location, child, destRegister, arrayRegister, vm.getExceptionFactory()); }
public static ImmutableInstruction12x of(Instruction12x instruction) { if (instruction instanceof ImmutableInstruction12x) { return (ImmutableInstruction12x)instruction; } return new ImmutableInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
private BuilderInstruction12x buildInstruction12x(Opcode opcode) { BuilderInstruction12x instruction = mock(BuilderInstruction12x.class); setupInstruction(instruction, opcode); when(((Instruction12x) instruction).getRegisterA()).thenReturn(ARG1_REGISTER); when(((Instruction12x) instruction).getRegisterB()).thenReturn(ARG2_REGISTER); return instruction; }
public static ImmutableInstruction12x of(Instruction12x instruction) { if (instruction instanceof ImmutableInstruction12x) { return (ImmutableInstruction12x)instruction; } return new ImmutableInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
@Override public void jimplify(DexBody body) { if (!(instruction instanceof Instruction12x)) { throw new IllegalArgumentException("Expected Instruction12x but got: " + instruction.getClass()); } Instruction12x binOp2AddrInstr = (Instruction12x) instruction; int dest = binOp2AddrInstr.getRegisterA(); Local source1 = body.getRegisterLocal(binOp2AddrInstr.getRegisterA()); Local source2 = body.getRegisterLocal(binOp2AddrInstr.getRegisterB()); Value expr = getExpression(source1, source2); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr); assign.addTag(getTag()); setUnit(assign); addTags(assign); body.add(assign); /* * if (IDalvikTyper.ENABLE_DVKTYPER) { BinopExpr bexpr = (BinopExpr)expr; short op = instruction.getOpcode().value; * DalvikTyper.v().setType(bexpr.getOp1Box(), op1BinType[op-0xb0], true); DalvikTyper.v().setType(bexpr.getOp2Box(), * op2BinType[op-0xb0], true); DalvikTyper.v().setType(assign.getLeftOpBox(), resBinType[op-0xb0], false); } */ }
public static ImmutableInstruction12x of(Instruction12x instruction) { if (instruction instanceof ImmutableInstruction12x) { return (ImmutableInstruction12x)instruction; } return new ImmutableInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
@Before public void setUp() { vm = mock(VirtualMachine.class); mState = mock(MethodState.class); node = mock(ExecutionNode.class); item = mock(HeapItem.class); when(mState.readRegister(REGISTER_B)).thenReturn(item); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction12x.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction12x) instruction).getRegisterA()).thenReturn(REGISTER_A); when(((Instruction12x) instruction).getRegisterB()).thenReturn(REGISTER_B); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new UnaryMathOpFactory(); }
@Nonnull private BuilderInstruction12x newBuilderInstruction12x(@Nonnull Instruction12x instruction) { return new BuilderInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
@Override public void jimplify(DexBody body) { if (!(instruction instanceof Instruction12x)) { throw new IllegalArgumentException("Expected Instruction12x but got: " + instruction.getClass()); } Instruction12x lengthOfArrayInstruction = (Instruction12x) instruction; int dest = lengthOfArrayInstruction.getRegisterA(); Local arrayReference = body.getRegisterLocal(lengthOfArrayInstruction.getRegisterB()); LengthExpr lengthExpr = Jimple.v().newLengthExpr(arrayReference); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), lengthExpr); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { DalvikTyper.v().setType(assign.getLeftOpBox(), IntType.v(), false); } }
@Nonnull private BuilderInstruction12x newBuilderInstruction12x(@Nonnull Instruction12x instruction) { return new BuilderInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
@Override public void jimplify(DexBody body) { if (!(instruction instanceof Instruction12x)) { throw new IllegalArgumentException("Expected Instruction12x but got: " + instruction.getClass()); } Instruction12x cmpInstr = (Instruction12x) instruction; int dest = cmpInstr.getRegisterA(); Local source = body.getRegisterLocal(cmpInstr.getRegisterB()); Value expr = getExpression(source); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr); assign.addTag(getTag()); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { /* * int op = (int)instruction.getOpcode().value; //DalvikTyper.v().captureAssign((JAssignStmt)assign, op); JAssignStmt * jass = (JAssignStmt)assign; DalvikTyper.v().setType((expr instanceof JCastExpr) ? ((JCastExpr) expr).getOpBox() : * ((UnopExpr) expr).getOpBox(), opUnType[op - 0x7b], true); DalvikTyper.v().setType(jass.leftBox, resUnType[op - * 0x7b], false); */ } }
@Nonnull private BuilderInstruction12x newBuilderInstruction12x(@Nonnull Instruction12x instruction) { return new BuilderInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
case MOVE: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_FROM16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_WIDE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_WIDE_FROM16: case MOVE_OBJECT: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_OBJECT_FROM16: ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NEW_INSTANCE: { OpID.NEGINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NOT_INT: instructions.add(new UnaryOperation(instLoc,
@Nonnull private BuilderInstruction12x newBuilderInstruction12x(@Nonnull Instruction12x instruction) { return new BuilderInstruction12x( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB()); }
case MOVE: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_FROM16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_WIDE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_WIDE_FROM16: case MOVE_OBJECT: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_OBJECT_FROM16: ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NEW_INSTANCE: { OpID.NEGINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NOT_INT: instructions.add(new UnaryOperation(instLoc,
public void write(@Nonnull Instruction12x instruction) { try { writer.write(instruction.getOpcode().value); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction12x instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); } catch (IOException ex) { throw new RuntimeException(ex); } }