Skip to content

Commit d0f5815

Browse files
committed
Fix bug in LVA when running on closures directly.
* 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.
1 parent 2c02985 commit d0f5815

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/src/main/java/org/jruby/ir/passes/LiveVariableAnalysis.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.jruby.ir.IRClosure;
44
import org.jruby.ir.IREvalScript;
5+
import org.jruby.ir.IRFlags;
56
import org.jruby.ir.IRScope;
67
import org.jruby.ir.instructions.ClosureAcceptingInstr;
78
import org.jruby.ir.instructions.Instr;
@@ -81,7 +82,7 @@ public Object execute(IRScope scope, Object... data) {
8182
// conservatively assume that any dirtied variables that
8283
// belong to an outer scope are live on exit.
8384
Set<LocalVariable> nlVars = new HashSet<LocalVariable>();
84-
collectNonLocalDirtyVars((IRClosure)scope, nlVars, 0);
85+
collectNonLocalDirtyVars((IRClosure)scope, nlVars, scope.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED) ? -1 : 0);
8586

8687
// Init DF vars from this set
8788
for (Variable v: nlVars) {

0 commit comments

Comments
 (0)