changeset 3060:f08a810b8449

Graph.getNodes() is Iterable<Node>, doesn't return null nodes and doesn't throw ConcurrentModificationException
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 21 Jun 2011 14:32:12 +0200
parents 8c67295934ff
children 848dd57066ad 02e2c1c4ac53
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DuplicationPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java graal/com.oracle.max.graal.graphviz/src/com/oracle/max/graal/graphviz/GraphvizPrinter.java
diffstat 8 files changed, 37 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Tue Jun 21 14:32:12 2011 +0200
@@ -145,11 +145,11 @@
         flush();
     }
 
-    private List<Edge> printNodes(Collection<Node> nodes, boolean shortNames, NodeMap<Block> nodeToBlock) {
+    private List<Edge> printNodes(Iterable<Node> nodes, boolean shortNames, NodeMap<Block> nodeToBlock) {
         ArrayList<Edge> edges = new ArrayList<Edge>();
 
         for (Node node : nodes) {
-            if (node == Node.Null || omittedClasses.contains(node.getClass())) {
+            if (omittedClasses.contains(node.getClass())) {
                 continue;
             }
 
@@ -228,9 +228,6 @@
 
         if (nodeToBlock != null) {
             for (Node n : graph.getNodes()) {
-                if (n == null) {
-                    continue;
-                }
                 Block blk = nodeToBlock.get(n);
                 if (blk == block) {
                     nodes.add(n);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Tue Jun 21 14:32:12 2011 +0200
@@ -99,6 +99,8 @@
             new CanonicalizerPhase().apply(graph);
             new DeadCodeEliminationPhase().apply(graph);
         }
+//
+//        new EscapeAnalysisPhase().apply(graph);
 
         if (GraalOptions.OptLoops) {
             new LoopPhase().apply(graph);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Tue Jun 21 14:32:12 2011 +0200
@@ -104,7 +104,7 @@
 
     private void disconnectCFGNodes() {
         for (Node node : graph.getNodes()) {
-            if (node != Node.Null && !flood.isMarked(node)) {
+            if (!flood.isMarked(node)) {
                 if (node instanceof EndNode) {
                     EndNode end = (EndNode) node;
                     Merge merge = end.merge();
@@ -131,7 +131,7 @@
 
     private void deleteNodes() {
         for (Node node : graph.getNodes()) {
-            if (node != Node.Null && !flood.isMarked(node)) {
+            if (!flood.isMarked(node)) {
                 node.unsafeDelete();
             }
         }
@@ -142,7 +142,7 @@
             if (node instanceof Local) {
                 flood.add(node);
             }
-            if (node != Node.Null && flood.isMarked(node)) {
+            if (flood.isMarked(node)) {
                 for (Node input : node.inputs()) {
                     flood.add(input);
                 }
@@ -157,7 +157,7 @@
 
     private void disconnectNodes() {
         for (Node node : graph.getNodes()) {
-            if (node != Node.Null && !flood.isMarked(node)) {
+            if (!flood.isMarked(node)) {
                 for (int i = 0; i < node.inputs().size(); i++) {
                     Node input = node.inputs().get(i);
                     if (input != Node.Null && flood.isMarked(input)) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DuplicationPhase.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DuplicationPhase.java	Tue Jun 21 14:32:12 2011 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
 
         // Delete nodes in original graph.
         for (Node n : graph.getNodes()) {
-            if (n != null && n != graph.start()) {
+            if (n != graph.start()) {
                 n.forceDelete();
             }
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Tue Jun 21 14:32:12 2011 +0200
@@ -319,20 +319,18 @@
         Unwind unwindNode = null;
         StartNode startNode = graph.start();
         for (Node node : graph.getNodes()) {
-            if (node != null) {
-                if (node instanceof StartNode) {
-                    assert startNode == node;
-                } else if (node instanceof Local) {
-                    replacements.put(node, parameters[((Local) node).index()]);
-                } else {
-                    nodes.add(node);
-                    if (node instanceof Return) {
-                        returnNode = (Return) node;
-                    } else if (node instanceof Unwind) {
-                        unwindNode = (Unwind) node;
-                    } else if (node instanceof FrameState) {
-                        frameStates.add(node);
-                    }
+            if (node instanceof StartNode) {
+                assert startNode == node;
+            } else if (node instanceof Local) {
+                replacements.put(node, parameters[((Local) node).index()]);
+            } else {
+                nodes.add(node);
+                if (node instanceof Return) {
+                    returnNode = (Return) node;
+                } else if (node instanceof Unwind) {
+                    unwindNode = (Unwind) node;
+                } else if (node instanceof FrameState) {
+                    frameStates.add(node);
                 }
             }
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java	Tue Jun 21 14:32:12 2011 +0200
@@ -35,8 +35,7 @@
 
     @Override
     protected void run(Graph graph) {
-        List<Node> nodes = new ArrayList<Node>(graph.getNodes());
-        for (Node n : nodes) {
+        for (Node n : graph.getNodes()) {
             if (n instanceof LoopBegin) {
                 doLoop((LoopBegin) n);
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Tue Jun 21 14:32:12 2011 +0200
@@ -112,22 +112,20 @@
 
         // Identify blocks.
         for (Node n : graph.getNodes()) {
-            if (n != null) {
-                if (n instanceof EndNode || n instanceof Return || n instanceof Unwind || n instanceof LoopEnd || n instanceof Deoptimize) {
-                    Block block = null;
-                    Node currentNode = n;
-                    while (nodeToBlock.get(currentNode) == null) {
-                        if (block != null && (currentNode instanceof ControlSplit || trueSuccessorCount(currentNode) > 1)) {
-                            // We are at a split node => start a new block.
-                            block = null;
-                        }
-                        block = assignBlockNew(currentNode, block);
-                        if (currentNode.predecessors().size() == 0) {
-                            // Either dead code or at a merge node => stop iteration.
-                            break;
-                        }
-                        currentNode = currentNode.singlePredecessor();
+            if (n instanceof EndNode || n instanceof Return || n instanceof Unwind || n instanceof LoopEnd || n instanceof Deoptimize) {
+                Block block = null;
+                Node currentNode = n;
+                while (nodeToBlock.get(currentNode) == null) {
+                    if (block != null && (currentNode instanceof ControlSplit || trueSuccessorCount(currentNode) > 1)) {
+                        // We are at a split node => start a new block.
+                        block = null;
                     }
+                    block = assignBlockNew(currentNode, block);
+                    if (currentNode.predecessors().size() == 0) {
+                        // Either dead code or at a merge node => stop iteration.
+                        break;
+                    }
+                    currentNode = currentNode.singlePredecessor();
                 }
             }
         }
--- a/graal/com.oracle.max.graal.graphviz/src/com/oracle/max/graal/graphviz/GraphvizPrinter.java	Tue Jun 21 12:15:38 2011 +0200
+++ b/graal/com.oracle.max.graal.graphviz/src/com/oracle/max/graal/graphviz/GraphvizPrinter.java	Tue Jun 21 14:32:12 2011 +0200
@@ -92,9 +92,7 @@
     public void print(Graph graph, boolean shortNames) {
         // graph.getNodes() returns all the graph's nodes, not just "roots"
         for (Node n : graph.getNodes()) {
-            if (n != null) {
-                printNode(n, shortNames);
-            }
+            printNode(n, shortNames);
         }
     }