private static boolean usesVariableAsNonClosureArg(Instr i, Variable v) { List<Variable> usedVariables = i.getUsedVariables(); return usedVariables.contains(v) && (!(i instanceof ClosureAcceptingInstr) || usedVariables.indexOf(v) != usedVariables.lastIndexOf(v) || v != ((ClosureAcceptingInstr) i).getClosureArg()); } }
private static boolean usesVariableAsNonClosureArg(Instr i, Variable v) { List<Variable> usedVariables = i.getUsedVariables(); return usedVariables.contains(v) && (!(i instanceof ClosureAcceptingInstr) || usedVariables.indexOf(v) != usedVariables.lastIndexOf(v) || v != ((ClosureAcceptingInstr) i).getClosureArg()); } }
@Override public void applyTransferFunction(Instr i) { // v is defined if (i instanceof ResultInstr) { tmp.set(problem.getDFVar(((ResultInstr) i).getResult())); } // Variables that belong to outer scopes should always // be considered defined. for (Variable v: i.getUsedVariables()) { if (v instanceof LocalVariable && ((LocalVariable)v).isOuterScopeVar()) { tmp.set(problem.getDFVar(v)); } } }
@Override public void applyTransferFunction(Instr i) { // v is defined if (i instanceof ResultInstr) { tmp.set(problem.getDFVar(((ResultInstr) i).getResult())); } // Variables that belong to outer scopes should always // be considered defined. for (Variable v: i.getUsedVariables()) { if (v instanceof LocalVariable && ((LocalVariable)v).isOuterScopeVar()) { tmp.set(problem.getDFVar(v)); } } }
@Override public void buildDataFlowVars(Instr i) { if (i instanceof ResultInstr) addDFVar(((ResultInstr) i).getResult()); for (Variable x: i.getUsedVariables()) { addDFVar(x); } }
@Override public void buildDataFlowVars(Instr i) { if (i instanceof ResultInstr) addDFVar(((ResultInstr) i).getResult()); for (Variable x: i.getUsedVariables()) { addDFVar(x); } }
public void buildDataFlowVars(Instr i) { if (i instanceof ResultInstr) addDFVar(((ResultInstr) i).getResult()); for (Variable x: i.getUsedVariables()) { addDFVar(x); } }
public void buildDataFlowVars(Instr i) { if (i instanceof ResultInstr) addDFVar(((ResultInstr) i).getResult()); for (Variable x: i.getUsedVariables()) { addDFVar(x); } }
@Override public void buildDataFlowVars(Instr i) { // FIXME: We could potentially have used a Set<Variable> to represent live variables // rather than use a BitSet. BitSet operations (meet/set/get) could be more // efficient. However, given that we have to getDFVar(..) for every variable // in every instruction when analysing it before accessing the BitSet, unsure // if the bitset really buys us anything! // // StoreLocalVarPlacement and LoadLocalVarPlacement analyses use // Set<LocalVariable> rather than BitSets. if (i instanceof ResultInstr) addDFVar(((ResultInstr) i).getResult()); for (Variable x: i.getUsedVariables()) { addDFVar(x); } }
state.unboxedDirtyVars.removeAll(i.getUsedVariables());
public void setUpUseDefLocalVarMaps() { definedLocalVars = new java.util.HashSet<Variable>(); usedLocalVars = new java.util.HashSet<Variable>(); for (BasicBlock bb : cfg().getBasicBlocks()) { for (Instr i : bb.getInstrs()) { for (Variable v : i.getUsedVariables()) { if (v instanceof LocalVariable) usedLocalVars.add(v); } if (i instanceof ResultInstr) { Variable v = ((ResultInstr) i).getResult(); if (v instanceof LocalVariable) definedLocalVars.add(v); } } } for (IRClosure cl : getClosures()) { cl.setUpUseDefLocalVarMaps(); } }
public void setUpUseDefLocalVarMaps() { definedLocalVars = new java.util.HashSet<Variable>(); usedLocalVars = new java.util.HashSet<Variable>(); for (BasicBlock bb : cfg().getBasicBlocks()) { for (Instr i : bb.getInstrs()) { for (Variable v : i.getUsedVariables()) { if (v instanceof LocalVariable) usedLocalVars.add(v); } if (i instanceof ResultInstr) { Variable v = ((ResultInstr) i).getResult(); if (v instanceof LocalVariable) definedLocalVars.add(v); } } } for (IRClosure cl : getClosures()) { cl.setUpUseDefLocalVarMaps(); } }
@Override public void buildDataFlowVars(Instr i) { // FIXME: We could potentially have used a Set<Variable> to represent live variables // rather than use a BitSet. BitSet operations (meet/set/get) could be more // efficient. However, given that we have to getDFVar(..) for every variable // in every instruction when analysing it before accessing the BitSet, unsure // if the bitset really buys us anything! // // StoreLocalVarPlacement and LoadLocalVarPlacement analyses use // Set<LocalVariable> rather than BitSets. if (i instanceof ResultInstr) addDFVar(((ResultInstr) i).getResult()); for (Variable x: i.getUsedVariables()) { addDFVar(x); } }
public void setUpUseDefLocalVarMaps() { definedLocalVars = new HashSet<>(1); usedLocalVars = new HashSet<>(1); for (BasicBlock bb : getCFG().getBasicBlocks()) { for (Instr i : bb.getInstrs()) { for (Variable v : i.getUsedVariables()) { if (v instanceof LocalVariable) usedLocalVars.add((LocalVariable) v); } if (i instanceof ResultInstr) { Variable v = ((ResultInstr) i).getResult(); if (v instanceof LocalVariable && !((LocalVariable)v).isOuterScopeVar()) { definedLocalVars.add((LocalVariable) v); } } } } for (IRClosure cl : getClosures()) { cl.setUpUseDefLocalVarMaps(); } }
public void setUpUseDefLocalVarMaps() { definedLocalVars = new HashSet<>(1); usedLocalVars = new HashSet<>(1); for (BasicBlock bb : getCFG().getBasicBlocks()) { for (Instr i : bb.getInstrs()) { for (Variable v : i.getUsedVariables()) { if (v instanceof LocalVariable) usedLocalVars.add((LocalVariable) v); } if (i instanceof ResultInstr) { Variable v = ((ResultInstr) i).getResult(); if (v instanceof LocalVariable && !((LocalVariable)v).isOuterScopeVar()) { definedLocalVars.add((LocalVariable) v); } } } } for (IRClosure cl : getClosures()) { cl.setUpUseDefLocalVarMaps(); } }
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)); } } } }
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)); } } } }
for (Variable v: i.getUsedVariables()) { if (!v.isSelf()) { if (v instanceof LocalVariable) {
markAllVariablesLive(problem, i.getUsedVariables());
markAllVariablesLive(problem, i.getUsedVariables());