changeset 16344:6f70e0b85e91

Merge.
author Doug Simon <doug.simon@oracle.com>
date Tue, 01 Jul 2014 15:45:14 +0200
parents a415b3990811 (current diff) 2cc0fea0cff6 (diff)
children d0c5f9bc7d98
files
diffstat 8 files changed, 66 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Tue Jul 01 15:45:14 2014 +0200
@@ -59,10 +59,10 @@
     static final int ALIVE_ID_START = 0;
 
     /**
-     * Denotes a non-optional node input. This should be applied to exactly the fields of a node
-     * that are of type {@link Node} or {@link NodeInputList}. Nodes that update fields of type
-     * {@link Node} outside of their constructor should call {@link Node#updateUsages(Node, Node)}
-     * just prior to doing the update of the input.
+     * Denotes a non-optional (non-null) node input. This should be applied to exactly the fields of
+     * a node that are of type {@link Node} or {@link NodeInputList}. Nodes that update fields of
+     * type {@link Node} outside of their constructor should call
+     * {@link Node#updateUsages(Node, Node)} just prior to doing the update of the input.
      */
     @Retention(RetentionPolicy.RUNTIME)
     @Target(ElementType.FIELD)
@@ -71,8 +71,8 @@
     }
 
     /**
-     * Denotes an optional node input. This should be applied to exactly the fields of a node that
-     * are of type {@link Node} or {@link NodeInputList}. Nodes that update fields of type
+     * Denotes an optional (nullable) node input. This should be applied to exactly the fields of a
+     * node that are of type {@link Node} or {@link NodeInputList}. Nodes that update fields of type
      * {@link Node} outside of their constructor should call {@link Node#updateUsages(Node, Node)}
      * just prior to doing the update of the input.
      */
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Tue Jul 01 15:45:14 2014 +0200
@@ -624,6 +624,32 @@
         }
     }
 
+    private class NodeClassAllSuccessorsIterator extends NodeClassSuccessorsIterator {
+        NodeClassAllSuccessorsIterator(Node node) {
+            super(node, true);
+        }
+
+        @Override
+        void forward() {
+            if (index < getDirectCount()) {
+                index++;
+                if (index < getDirectCount()) {
+                    return;
+                }
+            } else {
+                subIndex++;
+            }
+            while (index < getOffsets().length) {
+                NodeList<Node> list = getNodeList(node, getOffsets()[index]);
+                if (subIndex < list.size()) {
+                    return;
+                }
+                subIndex = 0;
+                index++;
+            }
+        }
+    }
+
     private final class NodeClassInputsWithModCountIterator extends NodeClassInputsIterator {
         private final int modCount;
 
@@ -1172,6 +1198,10 @@
                 }
             }
 
+            public NodeClassIterator withNullIterator() {
+                return new NodeClassAllSuccessorsIterator(node);
+            }
+
             @Override
             public boolean contains(Node other) {
                 return successorContains(node, other);
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClassIterable.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClassIterable.java	Tue Jul 01 15:45:14 2014 +0200
@@ -32,10 +32,14 @@
  */
 public interface NodeClassIterable extends NodeIterable<Node> {
 
+    /**
+     * Returns an iterator that produces all non-null values.
+     */
     @Override
     NodeClassIterator iterator();
 
-    default NodeClassIterator withNullIterator() {
-        return iterator();
-    }
+    /**
+     * Returns an iterator that produces all values, including null values.
+     */
+    NodeClassIterator withNullIterator();
 }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/Canonicalizable.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/Canonicalizable.java	Tue Jul 01 15:45:14 2014 +0200
@@ -68,7 +68,7 @@
      * This sub-interface of {@link Canonicalizable} is intended for nodes that have exactly one
      * input. It has an additional {@link #canonical(CanonicalizerTool, Node)} method that looks at
      * the given input instead of the current input of the node - which can be used to ask
-     * "what if this input is change to this node" - questions.
+     * "what if this input is changed to this node" - questions.
      *
      * @param <T> the common supertype of all inputs of this node
      */
@@ -97,7 +97,7 @@
      * This sub-interface of {@link Canonicalizable} is intended for nodes that have exactly two
      * inputs. It has an additional {@link #canonical(CanonicalizerTool, Node, Node)} method that
      * looks at the given inputs instead of the current inputs of the node - which can be used to
-     * ask "what if this input is change to this node" - questions.
+     * ask "what if this input is changed to this node" - questions.
      *
      * @param <T> the common supertype of all inputs of this node
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Tue Jul 01 15:45:14 2014 +0200
@@ -61,7 +61,7 @@
      */
     @OptionalInput private final NodeInputList<ValueNode> values;
 
-    @Input(InputType.Association) private final NodeInputList<MonitorIdNode> monitorIds;
+    @OptionalInput(InputType.Association) private final NodeInputList<MonitorIdNode> monitorIds;
 
     @Input(InputType.State) private final NodeInputList<EscapeObjectState> virtualObjectMappings;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Tue Jul 01 15:45:14 2014 +0200
@@ -66,10 +66,26 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
+        if (usages().isEmpty()) {
+            GuardingNode guard = getGuard();
+            if (guard != null && !(guard instanceof FixedNode)) {
+                // The guard is necessary even if the read goes away.
+                return new ValueAnchorNode((ValueNode) guard);
+            } else {
+                // Read without usages or guard can be safely removed.
+                return null;
+            }
+        }
         if (object() instanceof PiNode && ((PiNode) object()).getGuard() == getGuard()) {
             return new ReadNode(((PiNode) object()).getOriginalNode(), location(), stamp(), getGuard(), getBarrierType(), getNullCheck(), stateBefore());
         }
-        return canonicalizeRead(this, location(), object(), tool);
+        if (!getNullCheck()) {
+            return canonicalizeRead(this, location(), object(), tool);
+        } else {
+            // if this read is a null check, then replacing it with the value is incorrect for
+            // guard-type usages
+            return this;
+        }
     }
 
     @Override
@@ -84,16 +100,6 @@
 
     public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool) {
         MetaAccessProvider metaAccess = tool.getMetaAccess();
-        if (read.usages().isEmpty()) {
-            GuardingNode guard = ((Access) read).getGuard();
-            if (guard != null && !(guard instanceof FixedNode)) {
-                // The guard is necessary even if the read goes away.
-                return new ValueAnchorNode((ValueNode) guard);
-            } else {
-                // Read without usages or guard can be safely removed.
-                return null;
-            }
-        }
         if (tool.canonicalizeReads()) {
             if (metaAccess != null && object != null && object.isConstant()) {
                 if ((location.getLocationIdentity() == LocationIdentity.FINAL_LOCATION || location.getLocationIdentity() == LocationIdentity.ARRAY_LENGTH_LOCATION) &&
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Tue Jul 01 15:45:14 2014 +0200
@@ -239,11 +239,7 @@
                                     node.graph().getNewNodes(mark).snapshot();
                 };
             } else {
-                return new AutoCloseable() {
-                    public void close() throws Exception {
-                        // nothing to do
-                    }
-                };
+                return null;
             }
         }
 
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java	Tue Jul 01 15:42:59 2014 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java	Tue Jul 01 15:45:14 2014 +0200
@@ -36,6 +36,8 @@
  */
 public final class WordCastNode extends FixedWithNextNode implements LIRLowerable, Canonicalizable {
 
+    @Input private ValueNode input;
+
     public static WordCastNode wordToObject(ValueNode input, Kind wordKind) {
         assert input.getKind() == wordKind;
         return new WordCastNode(StampFactory.object(), input);
@@ -46,8 +48,6 @@
         return new WordCastNode(StampFactory.forKind(wordKind), input);
     }
 
-    @Input private ValueNode input;
-
     private WordCastNode(Stamp stamp, ValueNode input) {
         super(stamp);
         this.input = input;