changeset 8345:4e7a668054ea

added field to ValueAnchorNode to prevent canonicalization and virtualization; used new field to fix issue with return value materialization floating below the final monitorexit of a synchronized method
author Doug Simon <doug.simon@oracle.com>
date Mon, 18 Mar 2013 18:06:33 +0100
parents 2286bae19255
children 63f909f4ba3a d2fef63dfec8
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java
diffstat 3 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java	Mon Mar 18 18:05:33 2013 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java	Mon Mar 18 18:06:33 2013 +0100
@@ -54,7 +54,7 @@
         return 1;
     }
 
-    @Test(expected = AssertionError.class)
+    @Test
     public void test1() {
         test("test1Snippet");
     }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Mar 18 18:05:33 2013 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Mar 18 18:06:33 2013 +0100
@@ -1568,9 +1568,8 @@
         ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind);
         assert frameState.stackSize() == 0;
 
-        // TODO (gdub) remove this when FloatingRead can handle this case
         if (Modifier.isSynchronized(method.getModifiers())) {
-            append(currentGraph.add(new ValueAnchorNode(x)));
+            append(currentGraph.add(new ValueAnchorNode(true, x)));
             assert !frameState.rethrowException();
         }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java	Mon Mar 18 18:05:33 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java	Mon Mar 18 18:06:33 2013 +0100
@@ -28,7 +28,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
@@ -38,9 +37,16 @@
 public final class ValueAnchorNode extends FixedWithNextNode implements Canonicalizable, LIRLowerable, Node.IterableNodeType, Virtualizable {
 
     public ValueAnchorNode(ValueNode... values) {
+        this(false, values);
+    }
+
+    public ValueAnchorNode(boolean permanent, ValueNode... values) {
         super(StampFactory.dependency(), values);
+        this.permanent = permanent;
     }
 
+    private final boolean permanent;
+
     @Override
     public void generate(LIRGeneratorTool gen) {
         // Nothing to emit, since this node is used for structural purposes only.
@@ -54,6 +60,9 @@
 
     @Override
     public ValueNode canonical(CanonicalizerTool tool) {
+        if (permanent) {
+            return this;
+        }
         if (this.predecessor() instanceof ValueAnchorNode) {
             ValueAnchorNode previousAnchor = (ValueAnchorNode) this.predecessor();
             if (previousAnchor.usages().isEmpty()) { // avoid creating cycles
@@ -88,12 +97,8 @@
 
     @Override
     public void virtualize(VirtualizerTool tool) {
-        // don't process this node if it is anchoring the return value
-        if (next() instanceof MonitorExitNode) {
-            MonitorExitNode monitorExit = (MonitorExitNode) next();
-            if (monitorExit.stateAfter() != null && monitorExit.stateAfter().bci == FrameState.AFTER_BCI && monitorExit.next() instanceof ReturnNode) {
-                return;
-            }
+        if (permanent) {
+            return;
         }
         for (ValueNode node : dependencies().nonNull().and(isNotA(BeginNode.class))) {
             State state = tool.getObjectState(node);