use of jadx.core.dex.instructions.args.SSAVar in project jadx by skylot.
the class ConstInlineVisitor method checkInsn.
private static boolean checkInsn(MethodNode mth, InsnNode insn) {
if (insn.getType() != InsnType.CONST || insn.contains(AFlag.DONT_INLINE)) {
return false;
}
InsnArg arg = insn.getArg(0);
if (!arg.isLiteral()) {
return false;
}
long lit = ((LiteralArg) arg).getLiteral();
SSAVar sVar = insn.getResult().getSVar();
if (lit == 0 && checkObjectInline(sVar)) {
if (sVar.getUseCount() == 1) {
InsnNode assignInsn = insn.getResult().getAssignInsn();
if (assignInsn != null) {
assignInsn.add(AFlag.DONT_INLINE);
}
}
return false;
}
ArgType resType = insn.getResult().getType();
// make sure arg has correct type
if (!arg.getType().isTypeKnown()) {
arg.merge(mth.dex(), resType);
}
return replaceConst(mth, insn, lit);
}
use of jadx.core.dex.instructions.args.SSAVar in project jadx by skylot.
the class MethodNode method getNextSVarVersion.
public int getNextSVarVersion(int regNum) {
int v = -1;
for (SSAVar sVar : sVars) {
if (sVar.getRegNum() == regNum) {
v = Math.max(v, sVar.getVersion());
}
}
v++;
return v;
}
use of jadx.core.dex.instructions.args.SSAVar in project jadx by skylot.
the class MethodNode method makeNewSVar.
public SSAVar makeNewSVar(int regNum, int version, @NotNull RegisterArg assignArg) {
SSAVar var = new SSAVar(regNum, version, assignArg);
if (sVars.isEmpty()) {
sVars = new ArrayList<SSAVar>();
}
sVars.add(var);
return var;
}
use of jadx.core.dex.instructions.args.SSAVar in project jadx by skylot.
the class DebugInfoParser method startVar.
private void startVar(LocalVar var, int addr, int line) {
int regNum = var.getRegNum();
LocalVar prev = locals[regNum];
if (prev != null && !prev.isEnd()) {
prev.end(addr, line);
setVar(prev);
}
InsnArg activeReg = activeRegisters[var.getRegNum()];
if (activeReg instanceof RegisterArg) {
SSAVar ssaVar = ((RegisterArg) activeReg).getSVar();
if (ssaVar != null && ssaVar.getStartAddr() != -1) {
InsnNode parentInsn = ssaVar.getAssign().getParentInsn();
if (parentInsn != null && parentInsn.getOffset() >= 0) {
addr = parentInsn.getOffset();
}
}
}
var.start(addr, line);
locals[regNum] = var;
}
use of jadx.core.dex.instructions.args.SSAVar in project jadx by skylot.
the class SSATransform method inlinePhiInsn.
private static boolean inlinePhiInsn(MethodNode mth, BlockNode block, PhiInsn phi) {
SSAVar resVar = phi.getResult().getSVar();
if (resVar == null) {
return false;
}
RegisterArg arg = phi.getArg(0);
if (arg.getSVar() == null) {
return false;
}
List<RegisterArg> useList = resVar.getUseList();
for (RegisterArg useArg : new ArrayList<RegisterArg>(useList)) {
InsnNode useInsn = useArg.getParentInsn();
if (useInsn == null || useInsn == phi) {
return false;
}
useArg.getSVar().removeUse(useArg);
RegisterArg inlArg = arg.duplicate();
if (!useInsn.replaceArg(useArg, inlArg)) {
return false;
}
inlArg.getSVar().use(inlArg);
inlArg.setName(useArg.getName());
inlArg.setType(useArg.getType());
}
if (block.contains(AType.EXC_HANDLER)) {
// don't inline into exception handler
InsnNode assignInsn = arg.getAssignInsn();
if (assignInsn != null) {
assignInsn.add(AFlag.DONT_INLINE);
}
}
InstructionRemover.unbindInsn(mth, phi);
return true;
}
Aggregations