Skip to content

Commit

Permalink
Change LVA.previouslyRun check to return null if it has never made a …
Browse files Browse the repository at this point in the history
…CFG before vs making on demand.

  The basic mechanics of CompilerPass on a null return will naturally run the pass on it which will
  generate the CFG on demand along with the data.
Add comment in getCFG explaining when fic will be null.
Comment out child closure passing from LOP because we don't want it but left it comments out because
  it exposes some lifecycle problems.  Once we stabilize hypernugget and merge back to master we
  will dig into this problem more.
  • Loading branch information
enebo committed Mar 5, 2015
1 parent 566a3b6 commit 0c83a8c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 11 additions & 3 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -3,6 +3,8 @@
import org.jruby.ParseResult;
import org.jruby.RubyInstanceConfig;
import org.jruby.RubyModule;
import org.jruby.ir.dataflow.DataFlowProblem;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
import org.jruby.ir.instructions.*;
import org.jruby.ir.interpreter.FullInterpreterContext;
import org.jruby.ir.interpreter.InterpreterContext;
Expand Down Expand Up @@ -387,10 +389,16 @@ public boolean canReceiveNonlocalReturns() {
return flags.contains(CAN_RECEIVE_NONLOCAL_RETURNS);
}

public DataFlowProblem getLiveVariablesProblem() {
if (fullInterpreterContext == null) return null; // no fic so no pass-related info

return fullInterpreterContext.getDataFlowProblems().get(LiveVariablesProblem.NAME);
}

public CFG getCFG() {
if (getFullInterpreterContext() == null) {
prepareFullBuildCommon();
}
// A child scope may not have been prepared yet so we advance it to point of have a fresh CFG.
if (getFullInterpreterContext() == null) prepareFullBuildCommon();

return fullInterpreterContext.getCFG();
}

Expand Down
Expand Up @@ -31,11 +31,7 @@ public String getLabel() {

@Override
public Object previouslyRun(IRScope scope) {
if (scope.getFullInterpreterContext() == null) {
scope.prepareFullBuildCommon();
}

return scope.getFullInterpreterContext().getDataFlowProblems().get(LiveVariablesProblem.NAME);
return scope.getLiveVariablesProblem();
}

private void collectNonLocalDirtyVars(IRClosure cl, Set<LocalVariable> vars, int minDepth) {
Expand Down
Expand Up @@ -21,15 +21,11 @@ public String getLabel() {

@Override
public Object execute(IRScope s, Object... data) {
// This let us compute execute scope flags for a method based on what all nested closures do
for (IRClosure c: s.getClosures()) {
if (c.getFullInterpreterContext() == null) c.prepareFullBuildCommon();
run(c, false, true);
}

/* FIXME: Ultimately we want to just delete this snippet but is left here so we can debug lifecycle issues with compiler passes
for (BasicBlock b: s.getCFG().getBasicBlocks()) {
runLocalOptsOnInstrList(s, b.getInstrs().listIterator(), false);
}
*/

// SSS FIXME: What is this about?
// Why 'Only after running local opts'? Figure out and document.
Expand Down

0 comments on commit 0c83a8c

Please sign in to comment.