use of soot.toDex.instructions.Insn11x in project soot by Sable.
the class StmtVisitor method caseThrowStmt.
@Override
public void caseThrowStmt(ThrowStmt stmt) {
Value exception = stmt.getOp();
constantV.setOrigStmt(stmt);
Register exceptionReg = regAlloc.asImmediate(exception, constantV);
addInsn(new Insn11x(Opcode.THROW, exceptionReg), stmt);
}
use of soot.toDex.instructions.Insn11x in project soot by Sable.
the class ExprVisitor method caseNewMultiArrayExpr.
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr nmae) {
constantV.setOrigStmt(origStmt);
// get array dimensions
if (nmae.getSizeCount() > 255) {
throw new RuntimeException("number of dimensions is too high (> 255) for the filled-new-array* opcodes: " + nmae.getSizeCount());
}
short dimensions = (short) nmae.getSizeCount();
// get array base type
ArrayType arrayType = ArrayType.v(nmae.getBaseType().baseType, dimensions);
TypeReference arrayTypeItem = DexPrinter.toTypeReference(arrayType);
// get the dimension size registers
List<Register> dimensionSizeRegs = new ArrayList<Register>();
for (int i = 0; i < dimensions; i++) {
Value currentDimensionSize = nmae.getSize(i);
Register currentReg = regAlloc.asImmediate(currentDimensionSize, constantV);
dimensionSizeRegs.add(currentReg);
}
// create filled-new-array instruction, depending on the dimension sizes
if (dimensions <= 5) {
Register[] paddedRegs = pad35cRegs(dimensionSizeRegs);
stmtV.addInsn(new Insn35c(Opcode.FILLED_NEW_ARRAY, dimensions, paddedRegs[0], paddedRegs[1], paddedRegs[2], paddedRegs[3], paddedRegs[4], arrayTypeItem), null);
} else {
stmtV.addInsn(new Insn3rc(Opcode.FILLED_NEW_ARRAY_RANGE, dimensionSizeRegs, dimensions, arrayTypeItem), null);
}
// check for > 255 is done already
// move the resulting array into the destination register
stmtV.addInsn(new Insn11x(Opcode.MOVE_RESULT_OBJECT, destinationReg), origStmt);
}
use of soot.toDex.instructions.Insn11x in project soot by Sable.
the class StmtVisitor method caseReturnStmt.
@Override
public void caseReturnStmt(ReturnStmt stmt) {
Value returnValue = stmt.getOp();
constantV.setOrigStmt(stmt);
Register returnReg = regAlloc.asImmediate(returnValue, constantV);
Opcode opc;
Type retType = returnValue.getType();
if (SootToDexUtils.isObject(retType)) {
opc = Opcode.RETURN_OBJECT;
} else if (SootToDexUtils.isWide(retType)) {
opc = Opcode.RETURN_WIDE;
} else {
opc = Opcode.RETURN;
}
addInsn(new Insn11x(opc, returnReg), stmt);
}
use of soot.toDex.instructions.Insn11x in project soot by Sable.
the class StmtVisitor method caseIdentityStmt.
@Override
public void caseIdentityStmt(IdentityStmt stmt) {
Local lhs = (Local) stmt.getLeftOp();
Value rhs = stmt.getRightOp();
if (rhs instanceof CaughtExceptionRef) {
// save the caught exception with move-exception
Register localReg = regAlloc.asLocal(lhs);
addInsn(new Insn11x(Opcode.MOVE_EXCEPTION, localReg), stmt);
this.insnRegisterMap.put(insns.get(insns.size() - 1), LocalRegisterAssignmentInformation.v(localReg, lhs));
} else if (rhs instanceof ThisRef || rhs instanceof ParameterRef) {
/*
* do not save the ThisRef or ParameterRef in a local, because it
* always has a parameter register already. at least use the local
* for further reference in the statements
*/
Local localForThis = lhs;
regAlloc.asParameter(belongingMethod, localForThis);
parameterInstructionsList.add(LocalRegisterAssignmentInformation.v(regAlloc.asLocal(localForThis).clone(), localForThis));
} else {
throw new Error("unknown Value as right-hand side of IdentityStmt: " + rhs);
}
}
use of soot.toDex.instructions.Insn11x in project soot by Sable.
the class StmtVisitor method buildMonitorInsn.
private Insn buildMonitorInsn(MonitorStmt stmt, Opcode opc) {
Value lockValue = stmt.getOp();
constantV.setOrigStmt(stmt);
// When leaving a monitor, we must make sure to re-use the old
// register. If we assign the same class constant to a new register
// before leaving the monitor, Android's bytecode verifier will assume
// that this constant assignment can throw an exception, leaving us
// with a dangling monitor. Imprecise static analyzers ftw.
Register lockReg = null;
if (lockValue instanceof Constant)
if ((lockReg = monitorRegs.get(lockValue)) != null)
lockReg = lockReg.clone();
if (lockReg == null) {
lockReg = regAlloc.asImmediate(lockValue, constantV);
regAlloc.lockRegister(lockReg);
if (lockValue instanceof Constant) {
monitorRegs.put((Constant) lockValue, lockReg);
regAlloc.lockRegister(lockReg);
}
}
return new Insn11x(opc, lockReg);
}
Aggregations