changeset 8270:1112adb28f82

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 12 Mar 2013 11:04:00 +0100
parents 985a97ba083c (current diff) 2c5df42999dd (diff)
children f5e26f69f164
files
diffstat 3 files changed, 40 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/AMD64AllocatorTest.java	Tue Mar 12 11:02:07 2013 +0100
+++ b/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/AMD64AllocatorTest.java	Tue Mar 12 11:04:00 2013 +0100
@@ -37,7 +37,6 @@
         return x + 5;
     }
 
-    @Ignore
     @Test
     public void test2() {
         test("test2snippet", 2, 0, 0);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Tue Mar 12 11:02:07 2013 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Tue Mar 12 11:04:00 2013 +0100
@@ -43,7 +43,7 @@
 
     protected void test(String snippet, final int expectedRegisters, final int expectedRegRegMoves, final int expectedSpillMoves) {
         final StructuredGraph graph = parse(snippet);
-        Debug.scope("AllocatorTest", new Object[]{graph, graph.method(), backend.target}, new Runnable() {
+        Debug.scope("AllocatorTest", new Object[]{graph, graph.method(), runtime}, new Runnable() {
 
             @Override
             public void run() {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Mar 12 11:02:07 2013 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Mar 12 11:04:00 2013 +0100
@@ -347,6 +347,15 @@
         return intervals[operandNumber];
     }
 
+    Interval getOrCreateInterval(Value operand) {
+        Interval ret = intervalFor(operand);
+        if (ret == null) {
+            return createInterval(operand);
+        } else {
+            return ret;
+        }
+    }
+
     /**
      * Gets the highest instruction id allocated by this object.
      */
@@ -968,11 +977,7 @@
             TTY.println(" use %s from %d to %d (%s)", operand, from, to, registerPriority.name());
         }
 
-        Interval interval = intervalFor(operand);
-        if (interval == null) {
-            interval = createInterval(operand);
-        }
-
+        Interval interval = getOrCreateInterval(operand);
         if (kind != Kind.Illegal) {
             interval.setKind(kind);
         }
@@ -990,11 +995,8 @@
         if (GraalOptions.TraceLinearScanLevel >= 2) {
             TTY.println(" temp %s tempPos %d (%s)", operand, tempPos, RegisterPriority.MustHaveRegister.name());
         }
-        Interval interval = intervalFor(operand);
-        if (interval == null) {
-            interval = createInterval(operand);
-        }
 
+        Interval interval = getOrCreateInterval(operand);
         if (kind != Kind.Illegal) {
             interval.setKind(kind);
         }
@@ -1014,42 +1016,26 @@
         if (GraalOptions.TraceLinearScanLevel >= 2) {
             TTY.println(" def %s defPos %d (%s)", operand, defPos, registerPriority.name());
         }
-        Interval interval = intervalFor(operand);
-        if (interval != null) {
 
-            if (kind != Kind.Illegal) {
-                interval.setKind(kind);
-            }
+        Interval interval = getOrCreateInterval(operand);
+        if (kind != Kind.Illegal) {
+            interval.setKind(kind);
+        }
 
-            Range r = interval.first();
-            if (r.from <= defPos) {
-                // Update the starting point (when a range is first created for a use, its
-                // start is the beginning of the current block until a def is encountered.)
-                r.from = defPos;
-                interval.addUsePos(defPos, registerPriority);
-
-            } else {
-                // Dead value - make vacuous interval
-                // also add register priority for dead intervals
-                interval.addRange(defPos, defPos + 1);
-                interval.addUsePos(defPos, registerPriority);
-                if (GraalOptions.TraceLinearScanLevel >= 2) {
-                    TTY.println("Warning: def of operand %s at %d occurs without use", operand, defPos);
-                }
-            }
+        Range r = interval.first();
+        if (r.from <= defPos) {
+            // Update the starting point (when a range is first created for a use, its
+            // start is the beginning of the current block until a def is encountered.)
+            r.from = defPos;
+            interval.addUsePos(defPos, registerPriority);
 
         } else {
             // Dead value - make vacuous interval
             // also add register priority for dead intervals
-            interval = createInterval(operand);
-            if (kind != Kind.Illegal) {
-                interval.setKind(kind);
-            }
-
             interval.addRange(defPos, defPos + 1);
             interval.addUsePos(defPos, registerPriority);
             if (GraalOptions.TraceLinearScanLevel >= 2) {
-                TTY.println("Warning: dead value %s at %d in live intervals", operand, defPos);
+                TTY.println("Warning: def of operand %s at %d occurs without use", operand, defPos);
             }
         }
 
@@ -1114,7 +1100,7 @@
         }
     }
 
-    void addRegisterHint(final LIRInstruction op, final Value targetValue, OperandMode mode, EnumSet<OperandFlag> flags) {
+    void addRegisterHint(final LIRInstruction op, final Value targetValue, OperandMode mode, EnumSet<OperandFlag> flags, final boolean hintAtDef) {
         if (flags.contains(OperandFlag.HINT) && isVariableOrRegister(targetValue)) {
 
             op.forEachRegisterHint(targetValue, mode, new ValueProcedure() {
@@ -1122,15 +1108,20 @@
                 @Override
                 protected Value doValue(Value registerHint) {
                     if (isVariableOrRegister(registerHint)) {
-                        Interval from = intervalFor(registerHint);
-                        Interval to = intervalFor(targetValue);
-                        if (from != null && to != null) {
+                        Interval from = getOrCreateInterval(registerHint);
+                        Interval to = getOrCreateInterval(targetValue);
+
+                        // hints always point from def to use
+                        if (hintAtDef) {
                             to.setLocationHint(from);
-                            if (GraalOptions.TraceLinearScanLevel >= 4) {
-                                TTY.println("operation at opId %d: added hint from interval %d to %d", op.id(), from.operandNumber, to.operandNumber);
-                            }
-                            return registerHint;
+                        } else {
+                            from.setLocationHint(to);
                         }
+
+                        if (GraalOptions.TraceLinearScanLevel >= 4) {
+                            TTY.println("operation at opId %d: added hint from interval %d to %d", op.id(), from.operandNumber, to.operandNumber);
+                        }
+                        return registerHint;
                     }
                     return null;
                 }
@@ -1201,7 +1192,7 @@
                     public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
                         if (isVariableOrRegister(operand)) {
                             addDef(operand, opId, registerPriorityOfOutputOperand(op), operand.getKind().getStackKind());
-                            addRegisterHint(op, operand, mode, flags);
+                            addRegisterHint(op, operand, mode, flags, true);
                         }
                         return operand;
                     }
@@ -1212,7 +1203,7 @@
                     public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
                         if (isVariableOrRegister(operand)) {
                             addTemp(operand, opId, RegisterPriority.MustHaveRegister, operand.getKind().getStackKind());
-                            addRegisterHint(op, operand, mode, flags);
+                            addRegisterHint(op, operand, mode, flags, false);
                         }
                         return operand;
                     }
@@ -1224,7 +1215,7 @@
                         if (isVariableOrRegister(operand)) {
                             RegisterPriority p = registerPriorityOfInputOperand(flags);
                             addUse(operand, blockFrom, opId + 1, p, operand.getKind().getStackKind());
-                            addRegisterHint(op, operand, mode, flags);
+                            addRegisterHint(op, operand, mode, flags, false);
                         }
                         return operand;
                     }
@@ -1236,7 +1227,7 @@
                         if (isVariableOrRegister(operand)) {
                             RegisterPriority p = registerPriorityOfInputOperand(flags);
                             addUse(operand, blockFrom, opId, p, operand.getKind().getStackKind());
-                            addRegisterHint(op, operand, mode, flags);
+                            addRegisterHint(op, operand, mode, flags, false);
                         }
                         return operand;
                     }