changeset 9005:7c1b70aeb0c7

post-merge fixes, test improvements
author Michael Haupt <michael.haupt@oracle.com>
date Thu, 11 Apr 2013 16:52:54 +0200
parents 9f3a77848ea2
children 4f3f35f5d811
files graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java
diffstat 3 files changed, 44 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Thu Apr 11 11:26:38 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Thu Apr 11 16:52:54 2013 +0200
@@ -68,13 +68,7 @@
 import com.oracle.graal.lir.ptx.PTXMove.MoveFromRegOp;
 import com.oracle.graal.lir.ptx.PTXMove.MoveToRegOp;
 import com.oracle.graal.lir.ptx.PTXMove.StoreOp;
-import com.oracle.graal.nodes.BreakpointNode;
-import com.oracle.graal.nodes.DeoptimizingNode;
-import com.oracle.graal.nodes.DirectCallTargetNode;
-import com.oracle.graal.nodes.IndirectCallTargetNode;
-import com.oracle.graal.nodes.SafepointNode;
-import com.oracle.graal.nodes.StructuredGraph;
-import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.Condition;
 import com.oracle.graal.nodes.calc.ConvertNode;
 import com.oracle.graal.nodes.java.CompareAndSwapNode;
@@ -400,7 +394,7 @@
             case Double:
                 append(new Op2Stack(DMUL, result, a, loadNonConst(b)));
                 break;
-           default:
+            default:
                 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
         }
         return result;
@@ -415,17 +409,17 @@
     @Override
     public Value emitDiv(Value a, Value b, DeoptimizingNode deopting) {
         Variable result = newVariable(a.getKind());
-       switch (a.getKind()) {
-           case Int:
-             append(new Op2Reg(IDIV, result, a, loadNonConst(b)));
-               break;
+        switch (a.getKind()) {
+            case Int:
+                append(new Op2Reg(IDIV, result, a, loadNonConst(b)));
+                break;
             case Long:
                 append(new Op2Reg(LDIV, result, a, loadNonConst(b)));
-               break;
+                break;
             case Float:
                 append(new Op2Stack(FDIV, result, a, loadNonConst(b)));
                 break;
-           case Double:
+            case Double:
                 append(new Op2Stack(DDIV, result, a, loadNonConst(b)));
                 break;
             default:
@@ -488,7 +482,7 @@
                 append(new Op2Stack(LOR, result, a, loadNonConst(b)));
                 break;
             default:
-               throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
+                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
         }
         return result;
     }
@@ -507,7 +501,7 @@
                 throw GraalInternalError.shouldNotReachHere();
         }
         return result;
-     }
+    }
 
     @Override
     public Variable emitShl(Value a, Value b) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java	Thu Apr 11 11:26:38 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java	Thu Apr 11 16:52:54 2013 +0200
@@ -24,6 +24,7 @@
 
 import static org.junit.Assert.*;
 
+import java.lang.reflect.*;
 import java.util.concurrent.*;
 
 import org.junit.*;
@@ -45,12 +46,6 @@
         assertInlined(getGraph("invokeStaticOnInstanceSnippet", false));
     }
 
-    @Test
-    public void testInvokeStaticInliningIP() {
-        assertInlineInfopoints(assertInlined(getGraph("invokeStaticSnippet", true)));
-        assertInlineInfopoints(assertInlined(getGraph("invokeStaticOnInstanceSnippet", true)));
-    }
-
     @SuppressWarnings("all")
     public static Boolean invokeStaticSnippet(boolean value) {
         return Boolean.valueOf(value);
@@ -70,9 +65,9 @@
 
     @Test
     public void testStaticBindableInliningIP() {
-        assertInlineInfopoints(assertInlined(getGraph("invokeConstructorSnippet", true)));
-        assertInlineInfopoints(assertInlined(getGraph("invokeFinalMethodSnippet", true)));
-        assertInlineInfopoints(assertInlined(getGraph("invokeMethodOnFinalClassSnippet", true)));
+        assertManyMethodInfopoints(assertInlined(getGraph("invokeConstructorSnippet", true)));
+        assertManyMethodInfopoints(assertInlined(getGraph("invokeFinalMethodSnippet", true)));
+        assertManyMethodInfopoints(assertInlined(getGraph("invokeMethodOnFinalClassSnippet", true)));
     }
 
     @SuppressWarnings("all")
@@ -106,16 +101,16 @@
 
     @Test
     public void testClassHierarchyAnalysisIP() {
-        assertInlineInfopoints(assertInlined(getGraph("invokeLeafClassMethodSnippet", true)));
-        assertInlineInfopoints(assertInlined(getGraph("invokeConcreteMethodSnippet", true)));
-        assertInlineInfopoints(assertInlined(getGraph("invokeSingleImplementorInterfaceSnippet", true)));
+        assertManyMethodInfopoints(assertInlined(getGraph("invokeLeafClassMethodSnippet", true)));
+        assertManyMethodInfopoints(assertInlined(getGraph("invokeConcreteMethodSnippet", true)));
+        assertManyMethodInfopoints(assertInlined(getGraph("invokeSingleImplementorInterfaceSnippet", true)));
         //@formatter:off
         // assertInlineInfopoints(assertInlined(getGraph("invokeConcreteInterfaceMethodSnippet", true)));
         //@formatter:on
 
-        assertNoInlineInfopoints(assertNotInlined(getGraph("invokeOverriddenPublicMethodSnippet", true)));
-        assertNoInlineInfopoints(assertNotInlined(getGraph("invokeOverriddenProtectedMethodSnippet", true)));
-        assertNoInlineInfopoints(assertNotInlined(getGraph("invokeOverriddenInterfaceMethodSnippet", true)));
+        assertFewMethodInfopoints(assertNotInlined(getGraph("invokeOverriddenPublicMethodSnippet", true)));
+        assertFewMethodInfopoints(assertNotInlined(getGraph("invokeOverriddenProtectedMethodSnippet", true)));
+        assertFewMethodInfopoints(assertNotInlined(getGraph("invokeOverriddenInterfaceMethodSnippet", true)));
     }
 
     @SuppressWarnings("all")
@@ -158,7 +153,8 @@
 
             @Override
             public StructuredGraph call() {
-                StructuredGraph graph = parse(snippet);
+                Method method = getMethod(snippet);
+                StructuredGraph graph = eagerInfopointMode ? parseDebug(method) : parse(method);
                 PhasePlan phasePlan = getDefaultPhasePlan(eagerInfopointMode);
                 Assumptions assumptions = new Assumptions(true);
                 new ComputeProbabilityPhase().apply(graph);
@@ -199,7 +195,7 @@
         return graph;
     }
 
-    private static StructuredGraph assertInlineInfopoints(StructuredGraph graph) {
+    private static int[] countMethodInfopoints(StructuredGraph graph) {
         int start = 0;
         int end = 0;
         for (InfopointNode ipn : graph.getNodes(InfopointNode.class)) {
@@ -209,17 +205,21 @@
                 ++end;
             }
         }
-        if (start < 1 || end < 1) {
-            fail(String.format("Graph does not contain required inline infopoints: %d starts, %d ends.", start, end));
+        return new int[]{start, end};
+    }
+
+    private static StructuredGraph assertManyMethodInfopoints(StructuredGraph graph) {
+        int[] counts = countMethodInfopoints(graph);
+        if (counts[0] <= 1 || counts[1] <= 1) {
+            fail(String.format("Graph contains too few required method boundary infopoints: %d starts, %d ends.", counts[0], counts[1]));
         }
         return graph;
     }
 
-    private static StructuredGraph assertNoInlineInfopoints(StructuredGraph graph) {
-        for (InfopointNode ipn : graph.getNodes(InfopointNode.class)) {
-            if (ipn.reason == InfopointReason.METHOD_START || ipn.reason == InfopointReason.METHOD_END) {
-                fail("Graph contains inline infopoints.");
-            }
+    private static StructuredGraph assertFewMethodInfopoints(StructuredGraph graph) {
+        int[] counts = countMethodInfopoints(graph);
+        if (counts[0] > 1 || counts[1] > 1) {
+            fail(String.format("Graph contains too many method boundary infopoints: %d starts, %d ends.", counts[0], counts[1]));
         }
         return graph;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java	Thu Apr 11 11:26:38 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java	Thu Apr 11 16:52:54 2013 +0200
@@ -49,4 +49,14 @@
         return false;
     }
 
+    @Override
+    public void setStateAfter(FrameState state) {
+        // shield this node from frame state removal
+        // TODO turn InfopointNode into a FixedWithNextNode subclass with a self-maintained
+        // FrameState that is correctly dealt with by scheduling and partial escape analysis
+        if (state != null) {
+            super.setStateAfter(state);
+        }
+    }
+
 }