@Override public void visit(InvokeDynamicInstruction insn) { if (insn.getInstance() != null) { escaping[insn.getInstance().getIndex()] = true; } for (Variable arg : insn.getArguments()) { escaping[arg.getIndex()] = true; } }
private void renameVariables(final Program program, final int[] varMap) { InstructionVariableMapper mapper = new InstructionVariableMapper(var -> program.variableAt(varMap[var.getIndex()])); for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock block = program.basicBlockAt(i); mapper.apply(block); } String[][] originalNames = new String[program.variableCount()][]; for (int i = 0; i < program.variableCount(); ++i) { Variable var = program.variableAt(i); originalNames[i] = var.getDebugNames().toArray(new String[0]); var.getDebugNames().clear(); } for (int i = 0; i < program.variableCount(); ++i) { program.variableAt(varMap[i]).getDebugNames().addAll(Arrays.asList(originalNames[i])); } }
private DisjointSet buildPhiCongruenceClasses(Program program) { DisjointSet classes = new DisjointSet(); for (int i = 0; i < program.variableCount(); ++i) { classes.create(); } for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock block = program.basicBlockAt(i); for (Phi phi : block.getPhis()) { for (Incoming incoming : phi.getIncomings()) { classes.union(phi.getReceiver().getIndex(), incoming.getValue().getIndex()); } } for (TryCatchJoint joint : block.getTryCatchJoints()) { for (Variable sourceVar : joint.getSourceVariables()) { classes.union(sourceVar.getIndex(), joint.getReceiver().getIndex()); } } } return classes; }
private Expr compare(BinaryOperation op, Variable value) { Expr expr = Expr.binary(op, Expr.var(value.getIndex()), Expr.constant(0)); expr.setLocation(currentLocation); return expr; }
private void assign(Expr source, Variable target) { AssignmentStatement stmt = Statement.assign(Expr.var(target.getIndex()), source); stmt.setLocation(currentLocation); stmt.getDebugNames().addAll(target.getDebugNames()); statements.add(stmt); }