Skip to content

Commit

Permalink
Fix bug in LVA when running on closures directly.
Browse files Browse the repository at this point in the history
* LVA usually runs on method scopes and in that context, runs on
  all scopes nested in it.

* But, 2689915 relaxed the constraint of running LVA on method
  scopes only as part of the series of commits to do more aggressive
  opts on blocks.

* This patch fixes a bug in LVA when LVA runs on a closure directly
  after its dynscope has been eliminated.

* We can now reorder DeadCodeElimination and OptimizeDynScopesPass
  in IRScope:optimizeSimpleScopes without crashing.
  • Loading branch information
subbuss committed Oct 8, 2014
1 parent 2c02985 commit d0f5815
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -2,6 +2,7 @@

import org.jruby.ir.IRClosure;
import org.jruby.ir.IREvalScript;
import org.jruby.ir.IRFlags;
import org.jruby.ir.IRScope;
import org.jruby.ir.instructions.ClosureAcceptingInstr;
import org.jruby.ir.instructions.Instr;
Expand Down Expand Up @@ -81,7 +82,7 @@ public Object execute(IRScope scope, Object... data) {
// conservatively assume that any dirtied variables that
// belong to an outer scope are live on exit.
Set<LocalVariable> nlVars = new HashSet<LocalVariable>();
collectNonLocalDirtyVars((IRClosure)scope, nlVars, 0);
collectNonLocalDirtyVars((IRClosure)scope, nlVars, scope.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED) ? -1 : 0);

// Init DF vars from this set
for (Variable v: nlVars) {
Expand Down

0 comments on commit d0f5815

Please sign in to comment.