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

Commits on Oct 9, 2014

  1. Add LVA invalidation after more other passes.

    * OptimizeDynScopes changes local vars to tmps!
    * LocalOptimizePass shouldn't technically modify LVA state,
      since it is "local", but late at night, and I want to be
      conservative for now.
    subbuss committed Oct 9, 2014
    Copy the full SHA
    449c114 View commit details
  2. Tweak pass ordering to minimize LVA invalidations.

    * Tweak pass ordering so that we can reuse LVA information
      for passes without having to rerun it.
    subbuss committed Oct 9, 2014
    Copy the full SHA
    5ab309a View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRManager.java
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
public class IRManager {
public static String SAFE_COMPILER_PASSES = "";
public static String DEFAULT_COMPILER_PASSES = "OptimizeTempVarsPass,LocalOptimizationPass";
public static String DEFAULT_JIT_PASSES = "AddLocalVarLoadStoreInstructions,AddCallProtocolInstructions,EnsureTempsAssigned";
public static String DEFAULT_JIT_PASSES = "DeadCodeElimination,AddLocalVarLoadStoreInstructions,OptimizeDynScopesPass,AddCallProtocolInstructions,EnsureTempsAssigned";
public static String DEFAULT_INLINING_COMPILER_PASSES = "LocalOptimizationPass";

private int dummyMetaClassCount = 0;
19 changes: 11 additions & 8 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -584,14 +584,15 @@ private void runCompilerPasses(List<CompilerPass> passes) {
private void optimizeSimpleScopes() {
// For safe scopes that don't require a dynamic scope,
// run DCE since the analysis is less likely to be
// stymied by escaped bindings.
// stymied by escaped bindings. We can also eliminate
// dynscopes for these scopes.
if (!isUnsafeScope() && !flags.contains(REQUIRES_DYNSCOPE)) {
(new DeadCodeElimination()).run(this);
(new OptimizeDynScopesPass()).run(this);
}
}

public void initScope(boolean isLambda) {
private void initScope(boolean isLambda, boolean jitMode) {
// Reset linearization, if any exists
resetLinearizationData();

@@ -611,17 +612,19 @@ public void initScope(boolean isLambda) {

runCompilerPasses(getManager().getCompilerPasses(this));

if (RubyInstanceConfig.IR_COMPILER_PASSES == null) {
// Run DCE and var load/store passes where applicable
// But, if we have been passed in a list of passes to run
// on the commandline, skip this opt.
if (!jitMode && RubyInstanceConfig.IR_COMPILER_PASSES == null) {
// Skip this if:
// * we are in JIT mode since they are being run as part
// of JIT passes in a way that minimizes LVA invalidations.
// * we have been passed in a list of passes to run on the
// commandline (so as to honor the commandline request).
optimizeSimpleScopes();
}
}

/** Run any necessary passes to get the IR ready for interpretation */
public synchronized Instr[] prepareForInterpretation(boolean isLambda) {
initScope(isLambda);
initScope(isLambda, false);

checkRelinearization();

@@ -643,7 +646,7 @@ public synchronized List<BasicBlock> prepareForCompilation() {
// mark all closures lambdas always. But, check if there are
// other smarts available to us and eliminate adding
// this code to every closure there is.
initScope(this instanceof IRClosure);
initScope(this instanceof IRClosure, true);

runCompilerPasses(getManager().getJITPasses(this));

3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/ir/passes/CompilerPass.java
Original file line number Diff line number Diff line change
@@ -64,14 +64,17 @@ public Object previouslyRun(IRScope scope) {
* @returns true if invalidation succeeded, false otherwise.
*/
public boolean invalidate(IRScope scope) {
// System.out.println("--- INVALIDATING " + this.getLabel() + " on scope: " + scope);
scope.getExecutedPasses().remove(this);
return true;
}

// Run the pass on the passed in scope!
protected Object run(IRScope scope, boolean force, boolean childScope) {
// System.out.println("--- RUNNING " + this.getLabel() + " on scope: " + scope);
Object prevData = null;
if (!force && (prevData = previouslyRun(scope)) != null) {
// System.out.println("--- RETURNING OLD RESULT ---");
return prevData;
}

Original file line number Diff line number Diff line change
@@ -42,6 +42,12 @@ public Object execute(IRScope s, Object... data) {
// Only after running local opts, compute various execution scope flags.
s.computeScopeFlags();

// LVA information is no longer valid after this pass
// Currently, we don't run this after LVA, but just in case ...
//
// FIXME: Grrr ... this seems broken to have to create a new object to invalidate
(new LiveVariableAnalysis()).invalidate(s);

return null;
}

Original file line number Diff line number Diff line change
@@ -109,6 +109,10 @@ public void eliminateLocalVars(IRScope s) {
for (BasicBlock b: s.getCFG().getBasicBlocks()) {
for (Instr i: b.getInstrs()) i.renameVars(varRenameMap);
}

// 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);
}

@Override