Skip to content

Commit

Permalink
Revert "Fixes #3056. java.lang.IncompatibleClassChangeError in 9.0.0.…
Browse files Browse the repository at this point in the history
…0 rc1"

This fixed the issue but @subbuss rightly points out this scope should have
been marked as BINDING_HAS_ESCAPED and thus this pass should not have even
ran.

This reverts commit 467e2f7.
  • Loading branch information
enebo committed Jun 30, 2015
1 parent 01a3f68 commit 11bbc8a
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions core/src/main/java/org/jruby/ir/passes/OptimizeDelegationPass.java
Expand Up @@ -18,6 +18,16 @@ public String getLabel() {

@Override
public Object execute(IRScope s, Object... data) {
/**
* SSS FIXME: too late at night to think straight if this
* is required to run on all nested scopes or not. Doesn't
* look like it, but leaving behind in case it is.
*
for (IRClosure c: s.getClosures()) {
run(c, false, true);
}
**/

if (s.getFlags().contains(IRFlags.BINDING_HAS_ESCAPED)) return null;
if (!s.getFlags().contains(IRFlags.RECEIVES_CLOSURE_ARG)) return null;

Expand All @@ -32,7 +42,9 @@ public boolean invalidate(IRScope s) {
return false;
}

private static void calculateBlockUsage(IRScope s, Map<Operand, Operand> unusedExplicitBlocks) {
private static void optimizeDelegatedVars(IRScope s) {
Map<Operand, Operand> unusedExplicitBlocks = new HashMap<>();

for (BasicBlock bb: s.getCFG().getBasicBlocks()) {
for (Instr i: bb.getInstrs()) {
if (i instanceof ReifyClosureInstr) {
Expand All @@ -50,12 +62,6 @@ private static void calculateBlockUsage(IRScope s, Map<Operand, Operand> unusedE
}
}

for (IRScope child: s.getClosures()) {
calculateBlockUsage(child, unusedExplicitBlocks);
}
}

private static void replaceBlockUsage(IRScope s, Map<Operand, Operand> unusedExplicitBlocks) {
for (BasicBlock bb: s.getCFG().getBasicBlocks()) {
ListIterator<Instr> instrs = bb.getInstrs().listIterator();
while (instrs.hasNext()) {
Expand All @@ -72,16 +78,6 @@ private static void replaceBlockUsage(IRScope s, Map<Operand, Operand> unusedExp
}
}
}

for (IRScope child: s.getClosures()) {
replaceBlockUsage(child, unusedExplicitBlocks);
}
}
private static void optimizeDelegatedVars(IRScope s) {
Map<Operand, Operand> unusedExplicitBlocks = new HashMap<>();

calculateBlockUsage(s, unusedExplicitBlocks);
replaceBlockUsage(s, unusedExplicitBlocks);
}

private static boolean usesVariableAsNonClosureArg(Instr i, Variable v) {
Expand Down

0 comments on commit 11bbc8a

Please sign in to comment.