# HG changeset patch # User Doug Simon # Date 1363626393 -3600 # Node ID 4e7a668054ea01e1a71a3a30111e9a337366570b # Parent 2286bae19255ea4094078edc5755c57a79abf43d 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 diff -r 2286bae19255 -r 4e7a668054ea graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java --- 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"); } diff -r 2286bae19255 -r 4e7a668054ea graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- 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(); } diff -r 2286bae19255 -r 4e7a668054ea graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java --- 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);