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; }
private BasicBlock createPrologueBlock(CFG cfg) { BasicBlock entryBB = cfg.getEntryBB(); BasicBlock oldStart = cfg.getOutgoingDestinationOfType(entryBB, CFG.EdgeType.FALL_THROUGH); BasicBlock prologueBB = new BasicBlock(cfg, cfg.getScope().getNewLabel()); cfg.removeEdge(entryBB, oldStart); cfg.addBasicBlock(prologueBB); cfg.addEdge(entryBB, prologueBB, CFG.EdgeType.FALL_THROUGH); cfg.addEdge(prologueBB, oldStart, CFG.EdgeType.FALL_THROUGH); // If there's already a GEB, make sure we have an edge to it and use it to rescue these instrs if (cfg.getGlobalEnsureBB() != null) { BasicBlock geb = cfg.getGlobalEnsureBB(); cfg.addEdge(prologueBB, geb, CFG.EdgeType.EXCEPTION); cfg.setRescuerBB(prologueBB, geb); } return prologueBB; }
private BasicBlock createPrologueBlock(CFG cfg) { BasicBlock entryBB = cfg.getEntryBB(); BasicBlock oldStart = cfg.getOutgoingDestinationOfType(entryBB, CFG.EdgeType.FALL_THROUGH); BasicBlock prologueBB = new BasicBlock(cfg, cfg.getScope().getNewLabel()); cfg.removeEdge(entryBB, oldStart); cfg.addBasicBlock(prologueBB); cfg.addEdge(entryBB, prologueBB, CFG.EdgeType.FALL_THROUGH); cfg.addEdge(prologueBB, oldStart, CFG.EdgeType.FALL_THROUGH); // If there's already a GEB, make sure we have an edge to it and use it to rescue these instrs if (cfg.getGlobalEnsureBB() != null) { BasicBlock geb = cfg.getGlobalEnsureBB(); cfg.addEdge(prologueBB, geb, CFG.EdgeType.EXCEPTION); cfg.setRescuerBB(prologueBB, geb); } return prologueBB; }