/** * Computes reachability for all blocks in the method. * * @return a BitSet of reachable blocks. */ public BitSet computeReachability() { final int size = blocks.size(); BitSet reachableUnvisited = new BitSet(size); BitSet reachableVisited = new BitSet(size); reachableUnvisited.set(getEntryBlock().getIndex()); int index; while ((index = reachableUnvisited.nextSetBit(0)) != -1) { reachableVisited.set(index); reachableUnvisited.or(blocks.get(index).getSuccessors()); reachableUnvisited.andNot(reachableVisited); } return reachableVisited; }
/** * Computes reachability for all blocks in the method. First clears old * values from all blocks, then starts with the entry block and walks down * the control flow graph, marking all blocks it finds as reachable. */ public void computeReachability() { for (SsaBasicBlock block : blocks) { block.setReachable(0); } ArrayList<SsaBasicBlock> blockList = new ArrayList<SsaBasicBlock>(); blockList.add(this.getEntryBlock()); while (!blockList.isEmpty()) { SsaBasicBlock block = blockList.remove(0); if (block.isReachable()) continue; block.setReachable(1); BitSet succs = block.getSuccessors(); for (int i = succs.nextSetBit(0); i >= 0; i = succs.nextSetBit(i + 1)) { blockList.add(blocks.get(i)); } } }
/** * Computes reachability for all blocks in the method. First clears old * values from all blocks, then starts with the entry block and walks down * the control flow graph, marking all blocks it finds as reachable. */ public void computeReachability() { for (SsaBasicBlock block : blocks) { block.setReachable(0); } ArrayList<SsaBasicBlock> blockList = new ArrayList<SsaBasicBlock>(); blockList.add(this.getEntryBlock()); while (!blockList.isEmpty()) { SsaBasicBlock block = blockList.remove(0); if (block.isReachable()) continue; block.setReachable(1); BitSet succs = block.getSuccessors(); for (int i = succs.nextSetBit(0); i >= 0; i = succs.nextSetBit(i + 1)) { blockList.add(blocks.get(i)); } } }
/** * Computes reachability for all blocks in the method. First clears old * values from all blocks, then starts with the entry block and walks down * the control flow graph, marking all blocks it finds as reachable. */ public void computeReachability() { for (SsaBasicBlock block : blocks) { block.setReachable(0); } ArrayList<SsaBasicBlock> blockList = new ArrayList<SsaBasicBlock>(); blockList.add(this.getEntryBlock()); while (!blockList.isEmpty()) { SsaBasicBlock block = blockList.remove(0); if (block.isReachable()) continue; block.setReachable(1); BitSet succs = block.getSuccessors(); for (int i = succs.nextSetBit(0); i >= 0; i = succs.nextSetBit(i + 1)) { blockList.add(blocks.get(i)); } } }
/** * Computes reachability for all blocks in the method. First clears old * values from all blocks, then starts with the entry block and walks down * the control flow graph, marking all blocks it finds as reachable. */ public void computeReachability() { for (SsaBasicBlock block : blocks) { block.setReachable(0); } ArrayList<SsaBasicBlock> blockList = new ArrayList<SsaBasicBlock>(); blockList.add(this.getEntryBlock()); while (!blockList.isEmpty()) { SsaBasicBlock block = blockList.remove(0); if (block.isReachable()) continue; block.setReachable(1); BitSet succs = block.getSuccessors(); for (int i = succs.nextSetBit(0); i >= 0; i = succs.nextSetBit(i + 1)) { blockList.add(blocks.get(i)); } } }
/** * Computes reachability for all blocks in the method. First clears old * values from all blocks, then starts with the entry block and walks down * the control flow graph, marking all blocks it finds as reachable. */ public void computeReachability() { for (SsaBasicBlock block : blocks) { block.setReachable(0); } ArrayList<SsaBasicBlock> blockList = new ArrayList<SsaBasicBlock>(); blockList.add(this.getEntryBlock()); while (!blockList.isEmpty()) { SsaBasicBlock block = blockList.remove(0); if (block.isReachable()) continue; block.setReachable(1); BitSet succs = block.getSuccessors(); for (int i = succs.nextSetBit(0); i >= 0; i = succs.nextSetBit(i + 1)) { blockList.add(blocks.get(i)); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Computes reachability for all blocks in the method. First clears old * values from all blocks, then starts with the entry block and walks down * the control flow graph, marking all blocks it finds as reachable. */ public void computeReachability() { for (SsaBasicBlock block : blocks) { block.setReachable(0); } ArrayList<SsaBasicBlock> blockList = new ArrayList<SsaBasicBlock>(); blockList.add(this.getEntryBlock()); while (!blockList.isEmpty()) { SsaBasicBlock block = blockList.remove(0); if (block.isReachable()) continue; block.setReachable(1); BitSet succs = block.getSuccessors(); for (int i = succs.nextSetBit(0); i >= 0; i = succs.nextSetBit(i + 1)) { blockList.add(blocks.get(i)); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
/** * Visits blocks in dom-tree order, starting at the current node. * The {@code parent} parameter of the Visitor.visitBlock callback * is currently always set to null. * * @param v {@code non-null;} callback interface */ public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v) { BitSet visited = new BitSet(getBlocks().size()); Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>(); stack.add(getEntryBlock()); while (stack.size() > 0) { SsaBasicBlock cur = stack.pop(); ArrayList<SsaBasicBlock> curDomChildren = cur.getDomChildren(); if (!visited.get(cur.getIndex())) { // We walk the tree this way for historical reasons... for (int i = curDomChildren.size() - 1; i >= 0; i--) { SsaBasicBlock child = curDomChildren.get(i); stack.add(child); } visited.set(cur.getIndex()); v.visitBlock(cur, null); } } }
SsaBasicBlock rootBlock = reverse ? getExitBlock() : getEntryBlock();
SsaBasicBlock rootBlock = reverse ? getExitBlock() : getEntryBlock();
SsaBasicBlock rootBlock = reverse ? getExitBlock() : getEntryBlock();
SsaBasicBlock rootBlock = reverse ? getExitBlock() : getEntryBlock();
SsaBasicBlock rootBlock = reverse ? getExitBlock() : getEntryBlock();