changeset 2624:8e44074058af

remove explicit pointer from BlockEnd to BlockBegin
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 10 May 2011 14:29:40 +0200
parents dd115f80acf8
children 62ff4a70f07e
files graal/GraalCompiler/src/com/sun/c1x/graph/BlockMap.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java graal/GraalGraphviz/src/com/oracle/graal/graph/vis/GraphvizPrinter.java
diffstat 5 files changed, 12 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/BlockMap.java	Tue May 10 11:55:12 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/BlockMap.java	Tue May 10 14:29:40 2011 +0200
@@ -265,7 +265,7 @@
         return null;
     }
 
-    BlockBegin make(int bci) {
+    private BlockBegin make(int bci) {
         BlockBegin block = blockMap[bci];
         if (block == null) {
             block = new BlockBegin(bci, blockNum++, graph);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Tue May 10 11:55:12 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Tue May 10 14:29:40 2011 +0200
@@ -82,15 +82,12 @@
         BlockEnd old = this.end();
         if (old != end) {
             if (old != null) {
-                // disconnect this block from the old end
-                old.setBegin(null);
                 // disconnect this block from its current successors
                 for (BlockBegin s : old.blockSuccessors()) {
                     s.blockPredecessors().remove(this);
                 }
             }
             successors().set(super.successorCount() + SUCCESSOR_END, end);
-            end.setBegin(this);
             for (BlockBegin s : end.blockSuccessors()) {
                 s.addPredecessor(this);
             }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java	Tue May 10 11:55:12 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java	Tue May 10 14:29:40 2011 +0200
@@ -79,8 +79,7 @@
         return blockSuccessorCount;
     }
 
-    BlockBegin begin;
-    boolean isSafepoint;
+    private boolean isSafepoint;
 
     /**
      * Constructs a new block end with the specified value type.
@@ -120,17 +119,12 @@
      * @return the beginning of this basic block
      */
     public BlockBegin begin() {
-        return begin;
-    }
-
-    /**
-     * Sets the basic block beginning for this block end. This should only
-     * be called from {@link BlockBegin}.
-     *
-     * @param block the beginning of this basic block
-     */
-    void setBegin(BlockBegin block) {
-        begin = block;
+        for (Node n : predecessors()) {
+            if (n instanceof BlockBegin) {
+                return (BlockBegin) n;
+            }
+        }
+        return null;
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java	Tue May 10 11:55:12 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java	Tue May 10 14:29:40 2011 +0200
@@ -181,7 +181,7 @@
         while (!(cur instanceof BlockEnd)) {
             cur = cur.next();
         }
-        return ((BlockEnd) cur).begin;
+        return ((BlockEnd) cur).begin();
     }
 
     /**
--- a/graal/GraalGraphviz/src/com/oracle/graal/graph/vis/GraphvizPrinter.java	Tue May 10 11:55:12 2011 +0200
+++ b/graal/GraalGraphviz/src/com/oracle/graal/graph/vis/GraphvizPrinter.java	Tue May 10 14:29:40 2011 +0200
@@ -80,7 +80,9 @@
     public void print(Graph graph, boolean shortNames) {
         // graph.getNodes() returns all the graph's nodes, not just "roots"
         for (Node n : graph.getNodes()) {
-            printNode(n, shortNames);
+            if (n != null) {
+                printNode(n, shortNames);
+            }
         }
     }