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: 03bc9c6043b4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0dbe1b27549e
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 4, 2015

  1. CFG.toStringInstrs: Don't dump CFG of nested scopes

    * This can be extremely distracting in debugging output.
    * Users of CFG debug output that need output from nested scopes
      should explicitly do it where required.
    subbuss committed Mar 4, 2015
    Copy the full SHA
    2e4c5f9 View commit details
  2. Build full interpreter contexts for closures on demand

    * No need to build full ICs for closures eagerly.
    
    * Had to add some null checks for access to ICs in a couple
      places when I experimented turning off passes on nested scopes
      (LocalOptimizationPass, AddLocalVarLoadStoreInstructionsPass).
      Keeps that code more robust and usable in different lifecycles.
    subbuss committed Mar 4, 2015
    Copy the full SHA
    6a8701b View commit details
  3. Make LVA dependent on OptimizeDynScopesPass

    * If LVA is to run independently on closures (without parent scopes),
      it needs info about whether dyn scopes have been eliminated or not
      (see access to IRFlags.DYNSCOPE_ELIMINATED in the code).
      So, making that dependency explicit.
    subbuss committed Mar 4, 2015
    Copy the full SHA
    0dbe1b2 View commit details
6 changes: 1 addition & 5 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -474,14 +474,10 @@ protected void prepareFullBuildCommon() {
cloneInstrs();

// This is a complicating pseudo-pass which needs to be run before CFG is generated. This
// neccesitates us needing a clonedInstrs field on IRScope. If we can rewrite this to a full
// necessitates us needing a clonedInstrs field on IRScope. If we can rewrite this to a full
// CFG using pass we can eliminate this intermediate save and field.
getManager().optimizeTemporaryVariablesIfEnabled(this);

for (IRClosure cl: getClosures()) {
if (cl.fullInterpreterContext == null) cl.fullInterpreterContext = new FullInterpreterContext(cl, cl.getClonedInstrs());
}

fullInterpreterContext = new FullInterpreterContext(this, clonedInstrs);

setClonedInstrs(null); // boo. vestigial temporal field...because of opt tmp vars pass.
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.jruby.ir.instructions.ClosureAcceptingInstr;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.instructions.ResultInstr;
import org.jruby.ir.interpreter.FullInterpreterContext;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
@@ -106,7 +107,11 @@ public void applyTransferFunction(Instr i) {
// System.out.println("Processing closure: " + o + "-------");
if (o != null && o instanceof WrappedIRClosure) {
IRClosure cl = ((WrappedIRClosure)o).getClosure();
LiveVariablesProblem cl_lvp = (LiveVariablesProblem) cl.getFullInterpreterContext().getDataFlowProblems().get(DataFlowConstants.LVP_NAME);
FullInterpreterContext ic = cl.getFullInterpreterContext();
if (ic == null) {
ic = cl.prepareFullBuild();
}
LiveVariablesProblem cl_lvp = (LiveVariablesProblem) ic.getDataFlowProblems().get(DataFlowConstants.LVP_NAME);
boolean needsInit = false;
if (cl_lvp == null) {
cl_lvp = new LiveVariablesProblem(cl, problem.getNonSelfLocalVars());
Original file line number Diff line number Diff line change
@@ -19,6 +19,11 @@
import java.util.List;

public class LiveVariableAnalysis extends CompilerPass {
// For LVA to run independently on closures (without parent scopes), it needs info about whether
// dyn scopes have been eliminated or not (see access to IRFlags.DYNSCOPE_ELIMINATED below).
// So, making that dependency explicit.
public static List<Class<? extends CompilerPass>> DEPENDENCIES = Arrays.<Class<? extends CompilerPass>>asList(OptimizeDynScopesPass.class);

@Override
public String getLabel() {
return "Live Variable Analysis";
@@ -91,7 +96,9 @@ public Object execute(IRScope scope, Object... data) {
@Override
public boolean invalidate(IRScope scope) {
super.invalidate(scope);
scope.getFullInterpreterContext().getDataFlowProblems().put(LiveVariablesProblem.NAME, null);
if (scope.getFullInterpreterContext() != null) {
scope.getFullInterpreterContext().getDataFlowProblems().put(LiveVariablesProblem.NAME, null);
}
return true;
}
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/ir/representations/CFG.java
Original file line number Diff line number Diff line change
@@ -624,6 +624,7 @@ public String toStringInstrs() {
buf.append("BB ").append(bb.getID()).append(" --> BB ").append(rescuerMap.get(bb).getID()).append("\n");
}

/*
Collection<IRClosure> closures = scope.getClosures();
if (!closures.isEmpty()) {
buf.append("\n\n------ Closures encountered in this scope ------\n");
@@ -632,6 +633,7 @@ public String toStringInstrs() {
}
buf.append("------------------------------------------------\n");
}
*/

return buf.toString();
}