private static void linearizeInner(CFG cfg, List<BasicBlock> list, BitSet processed, BasicBlock current) { if (processed.get(current.getID())) return; // Cannot lay out current block till its fall-through predecessor has been laid out already BasicBlock source = cfg.getIncomingSourceOfType(current, EdgeType.FALL_THROUGH); if (source != null && !processed.get(source.getID())) return; list.add(current); processed.set(current.getID()); // First, fall-through BB BasicBlock fallThrough = cfg.getOutgoingDestinationOfType(current, EdgeType.FALL_THROUGH); if (fallThrough != null) linearizeInner(cfg, list, processed, fallThrough); // Next, regular edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EdgeType.REGULAR)) { linearizeInner(cfg, list, processed, destination); } // Next, exception edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EdgeType.EXCEPTION)) { linearizeInner(cfg, list, processed, destination); } // Next, exit for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EdgeType.EXIT)) { linearizeInner(cfg, list, processed, destination); } }
private static void linearizeInner(CFG cfg, List<BasicBlock> list, BitSet processed, BasicBlock current) { if (processed.get(current.getID())) return; // Cannot lay out current block till its fall-through predecessor has been laid out already BasicBlock source = cfg.getIncomingSourceOfType(current, EdgeType.FALL_THROUGH); if (source != null && !processed.get(source.getID())) return; list.add(current); processed.set(current.getID()); // First, fall-through BB BasicBlock fallThrough = cfg.getOutgoingDestinationOfType(current, EdgeType.FALL_THROUGH); if (fallThrough != null) linearizeInner(cfg, list, processed, fallThrough); // Next, regular edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EdgeType.REGULAR)) { linearizeInner(cfg, list, processed, destination); } // Next, exception edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EdgeType.EXCEPTION)) { linearizeInner(cfg, list, processed, destination); } // Next, exit for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EdgeType.EXIT)) { linearizeInner(cfg, list, processed, destination); } }
private static int linearizeInner(CFG cfg, BasicBlock[] list, int listSize, BitSet processed, BasicBlock current) { if (processed.get(current.getID())) return listSize; // Cannot lay out current block till its fall-through predecessor has been laid out already BasicBlock source = cfg.getIncomingSourceOfType(current, FALL_THROUGH); if (source != null && !processed.get(source.getID())) return listSize; list[listSize] = current; listSize++; processed.set(current.getID()); // First, fall-through BB BasicBlock fallThrough = cfg.getOutgoingDestinationOfType(current, FALL_THROUGH); if (fallThrough != null) listSize = linearizeInner(cfg, list, listSize, processed, fallThrough); // Next, regular edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, REGULAR)) { listSize = linearizeInner(cfg, list, listSize, processed, destination); } // Next, exception edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EXCEPTION)) { listSize = linearizeInner(cfg, list, listSize, processed, destination); } // Next, exit for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EXIT)) { listSize = linearizeInner(cfg, list, listSize, processed, destination); } return listSize; }
private static int linearizeInner(CFG cfg, BasicBlock[] list, int listSize, BitSet processed, BasicBlock current) { if (processed.get(current.getID())) return listSize; // Cannot lay out current block till its fall-through predecessor has been laid out already BasicBlock source = cfg.getIncomingSourceOfType(current, FALL_THROUGH); if (source != null && !processed.get(source.getID())) return listSize; list[listSize] = current; listSize++; processed.set(current.getID()); // First, fall-through BB BasicBlock fallThrough = cfg.getOutgoingDestinationOfType(current, FALL_THROUGH); if (fallThrough != null) listSize = linearizeInner(cfg, list, listSize, processed, fallThrough); // Next, regular edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, REGULAR)) { listSize = linearizeInner(cfg, list, listSize, processed, destination); } // Next, exception edges for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EXCEPTION)) { listSize = linearizeInner(cfg, list, listSize, processed, destination); } // Next, exit for (BasicBlock destination: cfg.getOutgoingDestinationsOfType(current, EXIT)) { listSize = linearizeInner(cfg, list, listSize, processed, destination); } return listSize; }