Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eae149341fa8
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 22b7ca8a6b26
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 22, 2016

  1. Remove dead code from LVA

    * alwaysLiveVars wasn't being used anywhere and was dead
      since 818f746. I am arguing below that there was nothing
      broken about it.
    
    * Vars cannot cross eval boundaries anymore.
      So, the n = 0 case for alwaysLiveVars isn't relevant.
    
    * Since we analyze scopes independent of one another now,
      lvars that are defined outside the current scope are always
      marked live on exit already. So, there is nothing special
      about eval scripts. So, n > 0 case for alwaysLiveVars
      isn't relevant either.
    subbuss committed May 22, 2016
    Copy the full SHA
    65e6f5b View commit details
  2. Fix #3891: Fix bug in setting up lvars that a scope defines

    * The test was missing a check for 'scopeDepth == 0'
    * TODO: Add specs to catch future regressions.
    subbuss committed May 22, 2016
    Copy the full SHA
    22b7ca8 View commit details
Showing with 4 additions and 18 deletions.
  1. +3 −1 core/src/main/java/org/jruby/ir/IRScope.java
  2. +1 −17 core/src/main/java/org/jruby/ir/dataflow/analyses/LiveVariablesProblem.java
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -948,7 +948,9 @@ public void setUpUseDefLocalVarMaps() {
if (i instanceof ResultInstr) {
Variable v = ((ResultInstr) i).getResult();

if (v instanceof LocalVariable) definedLocalVars.add((LocalVariable) v);
if (v instanceof LocalVariable && ((LocalVariable)v).getScopeDepth() == 0) {
definedLocalVars.add((LocalVariable) v);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -14,8 +14,7 @@ public class LiveVariablesProblem extends DataFlowProblem<LiveVariablesProblem,

public LiveVariablesProblem(IRScope scope) {
super(DataFlowProblem.DF_Direction.BACKWARD);
alwaysLiveVars = new ArrayList<LocalVariable>();
varsLiveOnScopeExit = new ArrayList<LocalVariable>(alwaysLiveVars);
varsLiveOnScopeExit = new ArrayList<LocalVariable>();
setup(scope);
}

@@ -43,18 +42,6 @@ public void addDFVar(Variable v) {

if (v instanceof LocalVariable && !v.isSelf()) {
//System.out.println("Adding df var for " + v + ":" + dfv.id);
IRScope s = getScope();
for (int n = ((LocalVariable) v).getScopeDepth(); s != null && n >= 0; n--) {
if (s instanceof IREvalScript) {
// If a variable is at the topmost scope of the eval OR crosses an eval boundary,
// it is going to be marked always live since it could be used by other evals (n = 0)
// or by enclosing scopes (n > 0)
alwaysLiveVars.add((LocalVariable) v);
break;
}

s = s.getLexicalParent();
}
localVars.add((LocalVariable) v);
}
}
@@ -125,8 +112,5 @@ public String getName() {
private HashMap<Variable, Integer> dfVarMap = new HashMap<Variable, Integer>();
private HashMap<Integer, Variable> varDfVarMap = new HashMap<Integer, Variable>();
private HashSet<LocalVariable> localVars = new HashSet<LocalVariable>(); // Local variables that can be live across dataflow barriers

// Variables that cross eval boundaries and are always live in this scope
private List<LocalVariable> alwaysLiveVars;
private Collection<LocalVariable> varsLiveOnScopeExit;
}