public boolean isEntryBB() { return cfg.getEntryBB() == this; }
public boolean isEntryBB() { return cfg.getEntryBB() == this; }
public U getEntryNode() { return getFlowGraphNode(scope.getCFG().getEntryBB()); }
public U getEntryNode() { return getFlowGraphNode(scope.getCFG().getEntryBB()); }
public static List<BasicBlock> linearize(CFG cfg) { List<BasicBlock> list = new ArrayList<BasicBlock>(); BitSet processed = new BitSet(cfg.size()); // Assumes all id's are used linearizeInner(cfg, list, processed, cfg.getEntryBB()); verifyAllBasicBlocksProcessed(cfg, processed); fixupList(cfg, list); return list; }
public static List<BasicBlock> linearize(CFG cfg) { List<BasicBlock> list = new ArrayList<BasicBlock>(); BitSet processed = new BitSet(cfg.size()); // Assumes all id's are used linearizeInner(cfg, list, processed, cfg.getEntryBB()); verifyAllBasicBlocksProcessed(cfg, processed); fixupList(cfg, list); return list; }
/** * Get variables that are live on entry to the cfg. * This is the case for closures which access variables from the parent scope. * * sum = 0; a.each { |i| sum += i }; return sum * * In the code snippet above, 'sum' is live on entry to the closure */ public Collection<LocalVariable> getLocalVarsLiveOnScopeEntry() { List<LocalVariable> liveVars = new ArrayList<LocalVariable>(); BitSet liveIn = getFlowGraphNode(getScope().getCFG().getEntryBB()).getLiveOutBitSet(); for (int i = 0; i < liveIn.size(); i++) { if (!liveIn.get(i)) continue; Variable v = getVariable(i); if (v instanceof LocalVariable) { liveVars.add((LocalVariable)v); } // System.out.println("variable " + v + " is live on entry!"); } return liveVars; }
/** * Get variables that are live on entry to the cfg. * This is the case for closures which access variables from the parent scope. * * sum = 0; a.each { |i| sum += i }; return sum * * In the code snippet above, 'sum' is live on entry to the closure */ public List<Variable> getVarsLiveOnScopeEntry() { List<Variable> liveVars = new ArrayList<Variable>(); BitSet liveIn = ((LiveVariableNode) getFlowGraphNode(getScope().cfg().getEntryBB())).getLiveOutBitSet(); for (int i = 0; i < liveIn.size(); i++) { if (liveIn.get(i) == true) { Variable v = getVariable(i); liveVars.add(v); // System.out.println("variable " + v + " is live on entry!"); } } return liveVars; }
/** * Get variables that are live on entry to the cfg. * This is the case for closures which access variables from the parent scope. * * sum = 0; a.each { |i| sum += i }; return sum * * In the code snippet above, 'sum' is live on entry to the closure */ public List<Variable> getVarsLiveOnScopeEntry() { List<Variable> liveVars = new ArrayList<Variable>(); BitSet liveIn = ((LiveVariableNode) getFlowGraphNode(getScope().cfg().getEntryBB())).getLiveOutBitSet(); for (int i = 0; i < liveIn.size(); i++) { if (liveIn.get(i) == true) { Variable v = getVariable(i); liveVars.add(v); // System.out.println("variable " + v + " is live on entry!"); } } return liveVars; }
/** * Get variables that are live on entry to the cfg. * This is the case for closures which access variables from the parent scope. * * sum = 0; a.each { |i| sum += i }; return sum * * In the code snippet above, 'sum' is live on entry to the closure */ public Collection<LocalVariable> getLocalVarsLiveOnScopeEntry() { List<LocalVariable> liveVars = new ArrayList<LocalVariable>(); BitSet liveIn = getFlowGraphNode(getScope().getCFG().getEntryBB()).getLiveOutBitSet(); for (int i = 0; i < liveIn.size(); i++) { if (!liveIn.get(i)) continue; Variable v = getVariable(i); if (v instanceof LocalVariable) { liveVars.add((LocalVariable)v); } // System.out.println("variable " + v + " is live on entry!"); } return liveVars; }
public static BasicBlock[] linearize(CFG cfg) { BasicBlock[] list = new BasicBlock[cfg.size()]; BitSet processed = new BitSet(cfg.size()); int listSize = linearizeInner(cfg, list, 0, processed, cfg.getEntryBB()); verifyAllBasicBlocksProcessed(cfg, processed); fixupList(cfg, list, listSize); return list; }
public static BasicBlock[] linearize(CFG cfg) { BasicBlock[] list = new BasicBlock[cfg.size()]; BitSet processed = new BitSet(cfg.size()); int listSize = linearizeInner(cfg, list, 0, processed, cfg.getEntryBB()); verifyAllBasicBlocksProcessed(cfg, processed); fixupList(cfg, list, listSize); return list; }
private void processCFG(CFG cfg) { Set<TemporaryVariable> names = new HashSet<TemporaryVariable>(); for (BasicBlock b : cfg.getBasicBlocks()) { for (Instr i : b.getInstrs()) { for (Variable v : i.getUsedVariables()) { if (v instanceof TemporaryVariable) { names.add((TemporaryVariable)v); } } } } BasicBlock bb = cfg.getEntryBB(); int index = 0; TemporaryVariable first = null; for (TemporaryVariable name : names) { if (first == null) { bb.getInstrs().add(index++, new CopyInstr(name, new Nil())); first = name; } else { bb.getInstrs().add(index++, new CopyInstr(name, first)); } } } }
public void addGlobalEnsureBB(BasicBlock geb) { assert globalEnsureBB == null: "CFG for scope " + getScope() + " already has a global ensure block."; addBasicBlock(geb); addEdge(geb, getExitBB(), EdgeType.EXIT); for (BasicBlock b: getBasicBlocks()) { if (b != geb && !bbIsProtected(b) && b != getEntryBB()) { addEdge(b, geb, EdgeType.EXCEPTION); setRescuerBB(b, geb); } } globalEnsureBB = geb; }
public void addGlobalEnsureBB(BasicBlock geb) { assert globalEnsureBB == null: "CFG for scope " + getScope() + " already has a global ensure block."; addBasicBlock(geb); addEdge(geb, getExitBB(), EdgeType.EXIT); for (BasicBlock b: getBasicBlocks()) { if (b != geb && !bbIsProtected(b) && b != getEntryBB()) { addEdge(b, geb, EdgeType.EXCEPTION); setRescuerBB(b, geb); } } globalEnsureBB = geb; }
BasicBlock bb = scope.getCFG().getEntryBB(); for (Variable v : undefinedVars) {
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; }
private CFG cloneSelf(InlinerInfo ii) { CFG selfClone = new CFG(cfg.getScope()); // clone bbs BasicBlock entry = cfg.getEntryBB(); BasicBlock exit = cfg.getExitBB(); for (BasicBlock b : cfg.getBasicBlocks()) { if ((b != entry) && (b != exit)) { selfClone.addBasicBlock(b.cloneForInlinedMethod(ii)); } } // clone edges for (BasicBlock b: cfg.getBasicBlocks()) { if ((b != entry) && (b != exit)) { BasicBlock rb = ii.getRenamedBB(b); for (Edge<BasicBlock> e : cfg.getOutgoingEdges(b)) { BasicBlock destination = e.getDestination().getData(); if (destination != exit) selfClone.addEdge(rb, ii.getRenamedBB(destination), e.getType()); } } } return selfClone; }
private CFG cloneSelf(InlinerInfo ii) { CFG selfClone = new CFG(cfg.getScope()); // clone bbs BasicBlock entry = cfg.getEntryBB(); BasicBlock exit = cfg.getExitBB(); for (BasicBlock b : cfg.getBasicBlocks()) { if ((b != entry) && (b != exit)) { selfClone.addBasicBlock(b.cloneForInlinedMethod(ii)); } } // clone edges for (BasicBlock b: cfg.getBasicBlocks()) { if ((b != entry) && (b != exit)) { BasicBlock rb = ii.getRenamedBB(b); for (Edge<BasicBlock> e : cfg.getOutgoingEdges(b)) { BasicBlock destination = e.getDestination().getData(); if (destination != exit) selfClone.addEdge(rb, ii.getRenamedBB(destination), e.getType()); } } } return selfClone; }