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: 72dc8b41996d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 967477f1c60e
Choose a head ref
  • 5 commits
  • 11 files changed
  • 1 contributor

Commits on Oct 8, 2014

  1. Fix minor issue with CompilerPass.java

    * This doesn't affect correctness, but use the right signature.
    subbuss committed Oct 8, 2014
    Copy the full SHA
    a7e6f8b View commit details
  2. Change signature of CompilerPass.invalidate

    * Return true/false depending on whether invalidation is possible
      or not.
    subbuss committed Oct 8, 2014
    Copy the full SHA
    6c4f956 View commit details
  3. Fixes to resetState in IRScope + invalidation in compiler passes.

    * Use the new shiny invalidation method to reset state properly.
    subbuss committed Oct 8, 2014
    Copy the full SHA
    2c02985 View commit details
  4. Copy the full SHA
    201ba1c View commit details
  5. Minor tweak.

    * That last computeScopeFlags in prepareForCompilation should not
      be necessary.
    subbuss committed Oct 8, 2014
    Copy the full SHA
    967477f View commit details
20 changes: 11 additions & 9 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -651,8 +651,6 @@ public synchronized List<BasicBlock> prepareForCompilation() {

prepareInstructions();

computeScopeFlags();

return buildLinearization();
}

@@ -1100,11 +1098,6 @@ public CFG cfg() {
return cfg;
}

public void resetDFProblemsState() {
dfProbs = new HashMap<String, DataFlowProblem>();
for (IRClosure c: nestedClosures) c.resetDFProblemsState();
}

public void resetState() {
relinearizeCFG = true;
linearizedInstrArray = null;
@@ -1123,8 +1116,17 @@ public void resetState() {
flags.remove(CAN_RECEIVE_NONLOCAL_RETURNS);
rescueMap = null;

// Reset dataflow problems state
resetDFProblemsState();
// Invalidate compiler pass state.
//
// SSS FIXME: This is to get around concurrent-modification issues
// since CompilerPass.invalidate modifies this, but some passes
// cannot be invalidated.
int i = 0;
while (i < executedPasses.size()) {
if (!executedPasses.get(i).invalidate(this)) {
i++;
}
}
}

public void inlineMethod(IRScope method, RubyModule implClass, int classToken, BasicBlock basicBlock, CallBase call, boolean cloneHost) {
Original file line number Diff line number Diff line change
@@ -156,13 +156,15 @@ public Object execute(IRScope scope, Object... data) {
for (IRClosure c: scope.getClosures()) execute(c);

// LVA information is no longer valid after the pass
scope.setDataFlowSolution(LiveVariablesProblem.NAME, null);
// FIXME: Grrr ... this seems broken to have to create a new object to invalidate
(new LiveVariableAnalysis()).invalidate(scope);

return null;
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
// Cannot add call protocol instructions after we've added them once.
return false;
}
}
Original file line number Diff line number Diff line change
@@ -67,15 +67,15 @@ public Object execute(IRScope s, Object... data) {
// Run on all nested closures.
//
// In the current implementation, nested scopes are processed independently (unlike Live Variable Analysis)
// However, since this pass requires LVA information, in reality, we cannot run
for (IRClosure c: s.getClosures()) execute(c);

// LVA information is no longer valid after this pass
// FIXME: Grrr ... this seems broken to have to create a new object to invalidate
(new LiveVariableAnalysis()).invalidate(s);
}

s.setDataFlowSolution(StoreLocalVarPlacementProblem.NAME, slvp);

// LVA information is no longer valid after the pass
s.setDataFlowSolution(LiveVariablesProblem.NAME, null);

return slvp;
}

@@ -85,8 +85,9 @@ public Object previouslyRun(IRScope scope) {
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
super.invalidate(scope);
scope.setDataFlowSolution(StoreLocalVarPlacementProblem.NAME, null);
return true;
}
}
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/passes/CFGBuilder.java
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@ public Object execute(IRScope scope, Object... data) {
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
// CFG is primal information to a scope and cannot be recreated once generated.
return false;
}
}
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/ir/passes/CompilerPass.java
Original file line number Diff line number Diff line change
@@ -61,9 +61,11 @@ public Object previouslyRun(IRScope scope) {
* all compiler passes list their dependencies.
*
* @param scope is where the pass stores its data.
* @returns true if invalidation succeeded, false otherwise.
*/
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
scope.getExecutedPasses().remove(this);
return true;
}

// Run the pass on the passed in scope!
@@ -109,7 +111,7 @@ private Object makeSureDependencyHasRunOnce(Class<? extends CompilerPass> passCl
Object data = pass.previouslyRun(scope);

if (data == null) {
data = pass.run(scope, childScope);
data = pass.run(scope, false, childScope);
} else {
for (CompilerPassListener listener: scope.getManager().getListeners()) {
listener.alreadyExecuted(pass, scope, data, childScope);
Original file line number Diff line number Diff line change
@@ -36,8 +36,9 @@ public Object execute(IRScope scope, Object... data) {
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
// FIXME: We never store our dominator tree anywhere right?
return false;
}

public void buildDominatorTree(CFG cfg, LinkedList<BasicBlock> postOrderList, int maxNodeId) {
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/passes/LinearizeCFG.java
Original file line number Diff line number Diff line change
@@ -26,8 +26,9 @@ public Object execute(IRScope scope, Object... data) {
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
super.invalidate(scope);
scope.resetLinearizationData();
return true;
}
}
Original file line number Diff line number Diff line change
@@ -97,8 +97,9 @@ public Object execute(IRScope scope, Object... data) {
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
super.invalidate(scope);
scope.setDataFlowSolution(LiveVariablesProblem.NAME, null);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -126,8 +126,9 @@ public Object execute(IRScope scope, Object... data) {
}

@Override
public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
// No invalidation for this right now.
// But, if necessary, we can reverse this operation.
return false;
}
}
Original file line number Diff line number Diff line change
@@ -27,9 +27,10 @@ public Object execute(IRScope s, Object... data) {
}

@Override
public void invalidate(IRScope s) {
public boolean invalidate(IRScope s) {
// This runs after IR is built and before CFG is built.
// Not reversible in the form it is written right now.
return false;
}

private static void allocVar(Operand oldVar, IRScope s, List<TemporaryVariable> freeVarsList, Map<Operand, Operand> newVarMap) {
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/passes/UnboxingPass.java
Original file line number Diff line number Diff line change
@@ -28,8 +28,9 @@ public Object execute(IRScope scope, Object... data) {
return true;
}

public void invalidate(IRScope scope) {
public boolean invalidate(IRScope scope) {
// FIXME: Can we reset this?
// Not right now.
return false;
}
}