changeset 16337:67f3267a8846

code and javadoc cleanups in Canonicalizable and NodeClassIterable
author Lukas Stadler <lukas.stadler@oracle.com>
date Tue, 01 Jul 2014 12:14:58 +0200
parents c88a9e432faf
children 2cc0fea0cff6
files graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClassIterable.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/Canonicalizable.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java
diffstat 4 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Tue Jul 01 11:37:17 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Tue Jul 01 12:14:58 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 11:37:17 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClassIterable.java	Tue Jul 01 12:14:58 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 11:37:17 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/Canonicalizable.java	Tue Jul 01 12:14:58 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.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Tue Jul 01 11:37:17 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Tue Jul 01 12:14:58 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;
             }
         }