Skip to content

Commit

Permalink
[IR] Fix a RAW-hazard bug in Local Optimization Pass that had never s…
Browse files Browse the repository at this point in the history
…howed up

till now because we were rarely reusing temporary variables in IR generation
so far.
  • Loading branch information
subbuss committed Oct 14, 2011
1 parent 4251d26 commit 7ee5ba0
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.ListIterator;

import org.jruby.RubyInstanceConfig;
import org.jruby.compiler.ir.IRClosure;
import org.jruby.compiler.ir.IRExecutionScope;
import org.jruby.compiler.ir.IRMethod;
Expand Down Expand Up @@ -99,9 +100,15 @@ private static void runLocalOpts(IRExecutionScope s) {
Variable res = i.getResult();
// System.out.println("For " + i + "; dst = " + res + "; val = " + val);
// System.out.println("AFTER: " + i);
if (val != null && res != null && res != val) {

if (res != null && val != null && res != val) {
recordSimplification(res, val, valueMap, simplificationMap);
} else if (res != null && val == null) {
// If we didn't get a simplified value, remove any existing simplifications for the result
// to get rid of RAW hazards!
valueMap.remove(res);
}

// Optimize some core class method calls for constant values
else if (iop.isCall()) {
val = null;
Expand Down

0 comments on commit 7ee5ba0

Please sign in to comment.