Set<BasicBlock> (BasicBlock jsr, BasicBlock ret) { Set<BasicBlock> blocks = new HashSet<>(); List<BasicBlock> lstNodes = new LinkedList<>(); lstNodes.add(jsr); BasicBlock dom = jsr.getSuccessors().get(0); while (!lstNodes.isEmpty()) { BasicBlock node = lstNodes.remove(0); for (int j = 0; j < 2; j++) { List<BasicBlock> lst; if (j == 0) { if (node.getLastInstruction().opcode == CodeConstants.opc_ret) { if (node.getSuccessors().contains(ret)) { continue; } } lst = node.getSuccessors(); } else { if (node == jsr) { continue; } lst = node.getSuccessorExceptions(); } CHILD: for (int i = lst.size() - 1; i >= 0; i--) { BasicBlock child = lst.get(i); if (!blocks.contains(child)) { if (node != jsr) { for (int k = 0; k < child.getPredecessors().size(); k++) { if (!DeadCodeHelper.isDominator(this, child.getPredecessors().get(k), dom)) { continue CHILD; } } for (int k = 0; k < child.getPredecessorExceptions().size(); k++) { if (!DeadCodeHelper.isDominator(this, child.getPredecessorExceptions().get(k), dom)) { continue CHILD; } } } // last block is a dummy one if (child != last) { blocks.add(child); } lstNodes.add(child); } } } } return blocks; }