changeset 13376:24ae4e7ecf03

fixed wrong redundant move elimination after loop safepoints, re-enabled redundant move elimination
author Erik Eckstein <erik.eckstein@oracle.com>
date Wed, 18 Dec 2013 08:57:34 +0100
parents e8c4a6ea3f77
children 40530019af02
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Dec 17 20:58:58 2013 -0800
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Wed Dec 18 08:57:34 2013 +0100
@@ -1878,14 +1878,7 @@
             printLir("After register number assignment", true);
             EdgeMoveOptimizer.optimize(ir);
             ControlFlowOptimizer.optimize(ir);
-
-            /*
-             * Temporarily disabled because of problem in specjvm2008. TODO: fix the problem and
-             * re-enable it.
-             * 
-             * RedundantMoveElimination.optimize(ir, frameMap, gen.getGraph().method());
-             */
-
+            RedundantMoveElimination.optimize(ir, frameMap, gen.getGraph().method());
             NullCheckOptimizer.optimize(ir, target.implicitNullCheckLimit);
             printLir("After control flow optimization", false);
         } catch (Throwable e) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java	Tue Dec 17 20:58:58 2013 -0800
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java	Wed Dec 18 08:57:34 2013 +0100
@@ -297,6 +297,7 @@
                 int sourceIdx = getStateIdx(moveOp.getInput());
                 int destIdx = getStateIdx(moveOp.getResult());
                 if (sourceIdx >= 0 && destIdx >= 0) {
+                    assert isObjectValue(state[sourceIdx]) || (moveOp.getInput().getKind() != Kind.Object) : "move op moves object but input is not defined as object";
                     state[destIdx] = state[sourceIdx];
                     indent.log("move value %d from %d to %d", state[sourceIdx], sourceIdx, destIdx);
                     return initValueNum;
@@ -342,8 +343,13 @@
             }
 
             OutputValueProc outputValueProc = new OutputValueProc(valueNum);
+
+            op.forEachTemp(outputValueProc);
+            /*
+             * Semantically the output values are written _after_ the temp values
+             */
             op.forEachOutput(outputValueProc);
-            op.forEachTemp(outputValueProc);
+
             valueNum = outputValueProc.opValueNum;
 
             if (op.hasState()) {
@@ -351,6 +357,9 @@
                  * All instructions with framestates (mostly method calls), may do garbage
                  * collection. GC will rewrite all object references which are live at this point.
                  * So we can't rely on their values.
+                 * 
+                 * It would be sufficient to just kill all values which are referenced in the state
+                 * (or all values which are not), but for simplicity we kill all values.
                  */
                 indent.log("kill all object values");
                 clearValuesOfKindObject(state, valueNum);