changeset 3056:2e20c39e472f

merge
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 21 Jun 2011 11:16:21 +0200
parents fecdb0a65fb2 (current diff) b7f45b37dd43 (diff)
children 8e9046edb790
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java graal/com.oracle.max.graal.graph/.checkstyle graal/com.oracle.max.graal.graph/.classpath graal/com.oracle.max.graal.graph/.project graal/com.oracle.max.graal.graph/.settings/org.eclipse.jdt.core.prefs graal/com.oracle.max.graal.graph/.settings/org.eclipse.jdt.ui.prefs graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/EdgeType.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Graph.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeArray.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeBitMap.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeFlood.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeIterator.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeMap.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeVisitor.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeWorkList.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Op.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/StartNode.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/VerificationListener.java graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/package-info.java graal/com.oracle.max.graal.graph/test/com/oracle/graal/graph/NodeTest.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotMethodResolvedImpl.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotMethodUnresolved.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java src/share/tools/IdealGraphVisualizer/Maxine/build.xml src/share/tools/IdealGraphVisualizer/Maxine/manifest.mf src/share/tools/IdealGraphVisualizer/Maxine/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/Maxine/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.properties src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.xml src/share/tools/IdealGraphVisualizer/Maxine/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/Maxine/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/Bundle.properties src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/CirGraphToTextConverter.java src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/color.filter src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/structural.filter src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/layer.xml src/share/vm/graal/graalJavaAccess.hpp
diffstat 107 files changed, 1281 insertions(+), 2749 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/.classpath	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/.classpath	Tue Jun 21 11:16:21 2011 +0200
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.asm"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.cri"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graph"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graphviz"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.asm"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.cri"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graphviz"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graph"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Tue Jun 21 11:16:21 2011 +0200
@@ -217,7 +217,7 @@
                 if (t instanceof RuntimeException) {
                     throw (RuntimeException) t;
                 } else {
-                    throw new RuntimeException(t);
+                    throw new RuntimeException("Exception while compiling: " + method, t);
                 }
             }
         } finally {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Tue Jun 21 11:16:21 2011 +0200
@@ -36,6 +36,9 @@
     private static final boolean ____ = false;
     // Checkstyle: resume
 
+
+    public static boolean Lower                              = true;
+
     // inlining settings
     public static boolean Inline                             = true;
     public static boolean CacheGraphs                        = ____;
@@ -135,4 +138,5 @@
     public static boolean PrintLIRWithAssembly               = ____;
 
     public static boolean OptCanonicalizer                   = true;
+    public static boolean OptLoops                           = true;
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Tue Jun 21 11:16:21 2011 +0200
@@ -595,8 +595,8 @@
         // iterate all blocks
         for (int i = 0; i < numBlocks; i++) {
             LIRBlock block = blockAt(i);
-            final CiBitMap liveGen = new CiBitMap(liveSize);
-            final CiBitMap liveKill = new CiBitMap(liveSize);
+            final BitMap liveGen = new BitMap(liveSize);
+            final BitMap liveKill = new BitMap(liveSize);
 
             List<LIRInstruction> instructions = block.lir().instructionsList();
             int numInst = instructions.size();
@@ -697,8 +697,8 @@
 
             block.liveGen = liveGen;
             block.liveKill = liveKill;
-            block.liveIn = new CiBitMap(liveSize);
-            block.liveOut = new CiBitMap(liveSize);
+            block.liveIn = new BitMap(liveSize);
+            block.liveOut = new BitMap(liveSize);
 
             if (GraalOptions.TraceLinearScanLevel >= 4) {
                 TTY.println("liveGen  B%d %s", block.blockID(), block.liveGen);
@@ -709,7 +709,7 @@
         intervalInLoop = localIntervalInLoop;
     }
 
-    private void verifyTemp(CiBitMap liveKill, CiValue operand) {
+    private void verifyTemp(BitMap liveKill, CiValue operand) {
         // fixed intervals are never live at block boundaries, so
         // they need not be processed in live sets
         // process them only in debug mode so that this can be checked
@@ -720,7 +720,7 @@
         }
     }
 
-    private void verifyInput(LIRBlock block, CiBitMap liveKill, CiValue operand) {
+    private void verifyInput(LIRBlock block, BitMap liveKill, CiValue operand) {
         // fixed intervals are never live at block boundaries, so
         // they need not be processed in live sets.
         // this is checked by these assertions to be sure about it.
@@ -742,7 +742,7 @@
         boolean changeOccurred;
         boolean changeOccurredInBlock;
         int iterationCount = 0;
-        CiBitMap liveOut = new CiBitMap(liveSetSize()); // scratch set for calculations
+        BitMap liveOut = new BitMap(liveSetSize()); // scratch set for calculations
 
         // Perform a backward dataflow analysis to compute liveOut and liveIn for each block.
         // The loop is executed until a fixpoint is reached (no changes in an iteration)
@@ -770,7 +770,7 @@
 
                     if (!block.liveOut.isSame(liveOut)) {
                         // A change occurred. Swap the old and new live out sets to avoid copying.
-                        CiBitMap temp = block.liveOut;
+                        BitMap temp = block.liveOut;
                         block.liveOut = liveOut;
                         liveOut = temp;
 
@@ -782,7 +782,7 @@
                 if (iterationCount == 0 || changeOccurredInBlock) {
                     // liveIn(block) is the union of liveGen(block) with (liveOut(block) & !liveKill(block))
                     // note: liveIn has to be computed only in first iteration or if liveOut has changed!
-                    CiBitMap liveIn = block.liveIn;
+                    BitMap liveIn = block.liveIn;
                     liveIn.setFrom(block.liveOut);
                     liveIn.setDifference(block.liveKill);
                     liveIn.setUnion(block.liveGen);
@@ -805,7 +805,7 @@
 
         // check that the liveIn set of the first block is empty
         LIRBlock startBlock = ir.startBlock;
-        CiBitMap liveInArgs = new CiBitMap(startBlock.liveIn.size());
+        BitMap liveInArgs = new BitMap(startBlock.liveIn.size());
         if (!startBlock.liveIn.isSame(liveInArgs)) {
             if (GraalOptions.DetailedAsserts) {
                 reportFailure(numBlocks);
@@ -835,10 +835,10 @@
                 if (instr instanceof Phi) {
                     Phi phi = (Phi) instr;
                     TTY.println("phi block begin: " + phi.merge());
-                    TTY.println("pred count on blockbegin: " + phi.merge().predecessors().size());
+                    TTY.println("pred count on blockbegin: " + phi.merge().phiPredecessorCount());
                     TTY.println("phi values: " + phi.valueCount());
                     TTY.println("phi block preds:");
-                    for (Node n : phi.merge().predecessors()) {
+                    for (Node n : phi.merge().phiPredecessors()) {
                         TTY.println(n.toString());
                     }
                 }
@@ -1183,7 +1183,7 @@
             assert blockTo == instructions.get(instructions.size() - 1).id;
 
             // Update intervals for operands live at the end of this block;
-            CiBitMap live = block.liveOut;
+            BitMap live = block.liveOut;
             for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) {
                 assert live.get(operandNum) : "should not stop here otherwise";
                 CiValue operand = operands.operandFor(operandNum);
@@ -1534,7 +1534,7 @@
         assert moveResolver.checkEmpty();
 
         int numOperands = operands.size();
-        CiBitMap liveAtEdge = toBlock.liveIn;
+        BitMap liveAtEdge = toBlock.liveIn;
 
         // visit all variables for which the liveAtEdge bit is set
         for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 1)) {
@@ -1597,8 +1597,8 @@
     void resolveDataFlow() {
         int numBlocks = blockCount();
         MoveResolver moveResolver = new MoveResolver(this);
-        CiBitMap blockCompleted = new CiBitMap(numBlocks);
-        CiBitMap alreadyResolved = new CiBitMap(numBlocks);
+        BitMap blockCompleted = new BitMap(numBlocks);
+        BitMap alreadyResolved = new BitMap(numBlocks);
 
         int i;
         for (i = 0; i < numBlocks; i++) {
@@ -1768,7 +1768,7 @@
         return new IntervalWalker(this, oopIntervals, nonOopIntervals);
     }
 
-    void computeOopMap(IntervalWalker iw, LIRInstruction op, LIRDebugInfo info, boolean isCallSite, CiBitMap frameRefMap, CiBitMap regRefMap) {
+    void computeOopMap(IntervalWalker iw, LIRInstruction op, LIRDebugInfo info, boolean isCallSite, BitMap frameRefMap, BitMap regRefMap) {
         if (GraalOptions.TraceLinearScanLevel >= 3) {
             TTY.println("creating oop map at opId %d", op.id);
         }
@@ -1817,7 +1817,7 @@
         return attributes(operand.asRegister()).isCallerSave;
     }
 
-    void computeOopMap(IntervalWalker iw, LIRInstruction op, LIRDebugInfo info, CiBitMap frameRefMap, CiBitMap regRefMap) {
+    void computeOopMap(IntervalWalker iw, LIRInstruction op, LIRDebugInfo info, BitMap frameRefMap, BitMap regRefMap) {
         computeOopMap(iw, op, info, op.hasCall, frameRefMap, regRefMap);
         if (op instanceof LIRCall) {
             List<CiValue> pointerSlots = ((LIRCall) op).pointerSlots;
@@ -1884,7 +1884,7 @@
         }
     }
 
-    CiFrame computeFrameForState(FrameState state, int opId, CiBitMap frameRefMap) {
+    CiFrame computeFrameForState(FrameState state, int opId, BitMap frameRefMap) {
         CiValue[] values = new CiValue[state.valuesSize() + state.locksSize()];
         int valueIndex = 0;
 
@@ -1935,18 +1935,18 @@
             if (info.debugInfo == null) {
                 int frameSize = compilation.frameMap().frameSize();
                 int frameWords = frameSize / compilation.target.spillSlotSize;
-                CiBitMap frameRefMap = new CiBitMap(frameWords);
-                CiBitMap regRefMap = !op.hasCall ? new CiBitMap(compilation.target.arch.registerReferenceMapBitCount) : null;
+                BitMap frameRefMap = new BitMap(frameWords);
+                BitMap regRefMap = !op.hasCall ? new BitMap(compilation.target.arch.registerReferenceMapBitCount) : null;
                 CiFrame frame = compilation.placeholderState != null ? null : computeFrame(info.state, op.id, frameRefMap);
                 computeOopMap(iw, op, info, frameRefMap, regRefMap);
                 info.debugInfo = new CiDebugInfo(frame, regRefMap, frameRefMap);
             } else if (GraalOptions.DetailedAsserts) {
-                assert info.debugInfo.frame().equals(computeFrame(info.state, op.id, new CiBitMap(info.debugInfo.frameRefMap.size())));
+                assert info.debugInfo.frame().equals(computeFrame(info.state, op.id, new BitMap(info.debugInfo.frameRefMap.size())));
             }
         }
     }
 
-    CiFrame computeFrame(FrameState state, int opId, CiBitMap frameRefMap) {
+    CiFrame computeFrame(FrameState state, int opId, BitMap frameRefMap) {
         if (GraalOptions.TraceLinearScanLevel >= 3) {
             TTY.println("creating debug information at opId %d", opId);
         }
@@ -2294,7 +2294,7 @@
 
         for (int i = 0; i < numBlocks; i++) {
             LIRBlock block = blockAt(i);
-            CiBitMap liveAtEdge = block.liveIn;
+            BitMap liveAtEdge = block.liveIn;
 
             // visit all operands where the liveAtEdge bit is set
             for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 1)) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java	Tue Jun 21 11:16:21 2011 +0200
@@ -26,6 +26,7 @@
 
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.ir.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 
 /**
@@ -72,17 +73,17 @@
     /**
      * Records which variable operands have the {@link VariableFlag#MustBeByteRegister} flag set.
      */
-    private CiBitMap mustBeByteRegister;
+    private BitMap mustBeByteRegister;
 
     /**
      * Records which variable operands have the {@link VariableFlag#MustStartInMemory} flag set.
      */
-    private CiBitMap mustStartInMemory;
+    private BitMap mustStartInMemory;
 
     /**
      * Records which variable operands have the {@link VariableFlag#MustStayInMemory} flag set.
      */
-    private CiBitMap mustStayInMemory;
+    private BitMap mustStayInMemory;
 
     /**
      * Flags that can be set for {@linkplain CiValue#isVariable() variable} operands.
@@ -108,19 +109,19 @@
         public static final VariableFlag[] VALUES = values();
     }
 
-    private static CiBitMap set(CiBitMap map, CiVariable variable) {
+    private static BitMap set(BitMap map, CiVariable variable) {
         if (map == null) {
-            int length = CiBitMap.roundUpLength(variable.index + 1);
-            map = new CiBitMap(length);
+            int length = BitMap.roundUpLength(variable.index + 1);
+            map = new BitMap(length);
         } else if (map.size() <= variable.index) {
-            int length = CiBitMap.roundUpLength(variable.index + 1);
+            int length = BitMap.roundUpLength(variable.index + 1);
             map.grow(length);
         }
         map.set(variable.index);
         return map;
     }
 
-    private static boolean get(CiBitMap map, CiVariable variable) {
+    private static boolean get(BitMap map, CiVariable variable) {
         if (map == null || map.size() <= variable.index) {
             return false;
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java	Tue Jun 21 11:16:21 2011 +0200
@@ -329,7 +329,7 @@
         }
         if (info.hasStackRefMap()) {
             sb.append("frame-ref-map:");
-            CiBitMap bm = info.frameRefMap;
+            BitMap bm = info.frameRefMap;
             for (int i = bm.nextSetBit(0); i >= 0; i = bm.nextSetBit(i + 1)) {
                 sb.append(' ').append(CiStackSlot.get(CiKind.Object, i));
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Tue Jun 21 11:16:21 2011 +0200
@@ -28,6 +28,7 @@
 
 import com.oracle.max.graal.compiler.ir.*;
 import com.oracle.max.graal.compiler.schedule.*;
+import com.oracle.max.graal.compiler.value.*;
 import com.oracle.max.graal.graph.*;
 
 /**
@@ -87,7 +88,7 @@
      */
     public void beginGroup(String name, String shortName, int bci) {
         stream.println("<group>");
-        stream.printf(" <properties><p name='name'>%s</p></properties>%n", escape(name));
+        stream.printf(" <properties><p name='name'>%s</p><p name='origin'>Graal</p></properties>%n", escape(name));
         stream.printf(" <method name='%s' shortName='%s' bci='%d'/>%n", escape(name), escape(shortName), bci);
     }
 
@@ -131,14 +132,14 @@
         }
         stream.println("  </edges>");
 
-        stream.println("  <controlFlow>");
         if (schedule != null) {
+            stream.println("  <controlFlow>");
             for (Block block : schedule.getBlocks()) {
-                printBlock(graph, block);
+                printBlock(graph, block, schedule.getNodeToBlock());
             }
+            printNoBlock();
+            stream.println("  </controlFlow>");
         }
-        printNoBlock();
-        stream.println("  </controlFlow>");
 
         stream.println(" </graph>");
         flush();
@@ -165,9 +166,13 @@
                 }
                 stream.printf("    <p name='name'>%s</p>%n", escape(name));
             }
+            stream.printf("    <p name='class'>%s</p>%n", escape(node.getClass().getSimpleName()));
             Block block = nodeToBlock == null ? null : nodeToBlock.get(node);
             if (block != null) {
                 stream.printf("    <p name='block'>%d</p>%n", block.blockID());
+                if (!(node instanceof Phi || node instanceof FrameState || node instanceof Local) && !block.getInstructions().contains(node)) {
+                    stream.printf("    <p name='notInOwnBlock'>true</p>%n");
+                }
             } else {
                 stream.printf("    <p name='block'>noBlock</p>%n");
                 noBlockNodes.add(node);
@@ -206,23 +211,36 @@
         stream.printf("   <edge from='%d' fromIndex='%d' to='%d' toIndex='%d'/>%n", edge.from, edge.fromIndex, edge.to, edge.toIndex);
     }
 
-    private void printBlock(Graph graph, Block block) {
+    private void printBlock(Graph graph, Block block, NodeMap<Block> nodeToBlock) {
         stream.printf("   <block name='%d'>%n", block.blockID());
         stream.printf("    <successors>%n");
         for (Block sux : block.getSuccessors()) {
-            if (sux.firstNode() instanceof LoopBegin && block.lastNode() instanceof LoopEnd) {
-                // Skip back edges.
-            } else {
+//            if (sux.firstNode() instanceof LoopBegin && block.lastNode() instanceof LoopEnd) { //TODO gd
+//                // Skip back edges.
+//            } else {
                 stream.printf("     <successor name='%d'/>%n", sux.blockID());
-            }
+//            }
         }
         stream.printf("    </successors>%n");
         stream.printf("    <nodes>%n");
 
-        ArrayList<Node> nodes = new ArrayList<Node>(block.getInstructions());
+        Set<Node> nodes = new HashSet<Node>(block.getInstructions());
+
+        if (nodeToBlock != null) {
+            for (Node n : graph.getNodes()) {
+                if (n == null) {
+                    continue;
+                }
+                Block blk = nodeToBlock.get(n);
+                if (blk == block) {
+                    nodes.add(n);
+                }
+            }
+        }
+
         if (nodes.size() > 0) {
             // if this is the first block: add all locals to this block
-            if (nodes.get(0) == graph.start()) {
+            if (block.getInstructions().size() > 0  && block.getInstructions().get(0) == graph.start()) {
                 for (Node node : graph.getNodes()) {
                     if (node instanceof Local) {
                         nodes.add(node);
@@ -236,8 +254,7 @@
                     nodes.add(((Instruction) node).stateAfter());
                 }
                 if (node instanceof Merge) {
-                    Merge merge = (Merge) node;
-                    for (Node usage : merge.usages()) {
+                    for (Node usage : node.usages()) {
                         if (usage instanceof Phi || usage instanceof LoopCounter) {
                             nodes.add(usage);
                         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Tue Jun 21 11:16:21 2011 +0200
@@ -33,7 +33,7 @@
 import com.oracle.max.asm.*;
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.alloc.*;
-import com.oracle.max.graal.compiler.alloc.OperandPool.*;
+import com.oracle.max.graal.compiler.alloc.OperandPool.VariableFlag;
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.globalstub.*;
 import com.oracle.max.graal.compiler.graph.*;
@@ -43,11 +43,17 @@
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.compiler.value.*;
 import com.oracle.max.graal.graph.*;
+import com.sun.cri.bytecode.Bytecodes.MemoryBarriers;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
-import com.sun.cri.ri.RiType.*;
+import com.sun.cri.ri.RiType.Representation;
+import com.sun.cri.xir.CiXirAssembler.XirConstant;
+import com.sun.cri.xir.CiXirAssembler.XirInstruction;
+import com.sun.cri.xir.CiXirAssembler.XirOperand;
+import com.sun.cri.xir.CiXirAssembler.XirParameter;
+import com.sun.cri.xir.CiXirAssembler.XirRegister;
+import com.sun.cri.xir.CiXirAssembler.XirTemp;
 import com.sun.cri.xir.*;
-import com.sun.cri.xir.CiXirAssembler.*;
 
 /**
  * This class traverses the HIR instructions and generates LIR instructions from them.
@@ -255,7 +261,9 @@
             }
         }
         if (block.blockSuccessors().size() >= 1 && !block.endsWithJump()) {
-            block.lir().jump(getLIRBlock((FixedNode) block.lastInstruction().successors().get(0)));
+            NodeArray successors = block.lastInstruction().successors();
+            assert successors.size() >= 1 : "should have at least one successor : " + block.lastInstruction();
+            block.lir().jump(getLIRBlock((FixedNode) successors.get(0)));
         }
 
         if (GraalOptions.TraceLIRGeneratorLevel >= 1) {
@@ -269,7 +277,9 @@
 
     @Override
     public void visitMerge(Merge x) {
-        // Nothing to do.
+        if (x.next() instanceof LoopBegin) {
+            moveToPhi((LoopBegin) x.next(), x);
+        }
     }
 
     @Override
@@ -407,20 +417,7 @@
 
     @Override
     public void visitGuardNode(GuardNode x) {
-        FrameState state = lastState;
-        assert state != null : "deoptimize instruction always needs a state";
-
-        if (deoptimizationStubs == null) {
-            deoptimizationStubs = new ArrayList<DeoptimizationStub>();
-        }
-
-        DeoptimizationStub stub = new DeoptimizationStub(DeoptAction.InvalidateReprofile, state);
-        deoptimizationStubs.add(stub);
-
-        emitCompare(x.node());
-        //emitBranch(x.node(), stub.label)
-        throw new RuntimeException();
-        //lir.branch(x.condition.negate(), stub.label, stub.info);
+        emitGuardComp(x.node());
     }
 
 
@@ -443,7 +440,14 @@
     @Override
     public void visitExceptionObject(ExceptionObject x) {
         XirSnippet snippet = xir.genExceptionObject(site(x));
-        emitXir(snippet, x, stateFor(x), null, true);
+        emitXir(snippet, x, null, null, true);
+        lastState = lastState.duplicateWithException(lastState.bci, x);
+        if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
+            TTY.println("STATE CHANGE (visitExceptionObject)");
+            if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
+                TTY.println(lastState.toString());
+            }
+        }
     }
 
     @Override
@@ -453,28 +457,38 @@
 
     @Override
     public void visitIf(If x) {
-        emitCompare(x.compare());
-        emitBranch(x.compare(), getLIRBlock(x.trueSuccessor()), getLIRBlock(x.falseSuccessor()));
+        Condition cond = emitBooleanBranch(x.compare());
+        emitBranch(x.compare(), cond, getLIRBlock(x.trueSuccessor()), getLIRBlock(x.falseSuccessor()));
         assert x.defaultSuccessor() == x.falseSuccessor() : "wrong destination above";
         LIRBlock block = getLIRBlock(x.defaultSuccessor());
         assert block != null : x;
         lir.jump(block);
     }
 
-    public void emitBranch(Compare compare, LIRBlock trueSuccessor, LIRBlock falseSucc) {
-        Condition cond = compare.condition();
-        if (compare.x().kind.isFloat() || compare.x().kind.isDouble()) {
-            LIRBlock unorderedSuccBlock = falseSucc;
-            if (compare.unorderedIsTrue()) {
-                unorderedSuccBlock = trueSuccessor;
+    public void emitBranch(BooleanNode n, Condition cond, LIRBlock trueSuccessor, LIRBlock falseSucc) {
+        if (n instanceof Compare) {
+            Compare compare = (Compare) n;
+            if (compare.x().kind.isFloat() || compare.x().kind.isDouble()) {
+                LIRBlock unorderedSuccBlock = falseSucc;
+                if (compare.unorderedIsTrue()) {
+                    unorderedSuccBlock = trueSuccessor;
+                }
+                lir.branch(cond, trueSuccessor, unorderedSuccBlock);
+                return;
             }
-            lir.branch(cond, trueSuccessor, unorderedSuccBlock);
+        }
+        lir.branch(cond, trueSuccessor);
+    }
+
+    public Condition emitBooleanBranch(BooleanNode node) {
+        if (node instanceof Compare) {
+            return emitCompare((Compare) node);
         } else {
-            lir.branch(cond, trueSuccessor);
+            throw Util.unimplemented();
         }
     }
 
-    public void emitCompare(Compare compare) {
+    public Condition emitCompare(Compare compare) {
         CiKind kind = compare.x().kind;
 
         Condition cond = compare.condition();
@@ -505,6 +519,7 @@
         CiValue left = xin.result();
         CiValue right = yin.result();
         lir.cmp(cond, left, right);
+        return cond;
     }
 
     @Override
@@ -700,11 +715,11 @@
 
     @Override
     public void visitFixedGuard(FixedGuard fixedGuard) {
-        Node comp = fixedGuard.node();
+        BooleanNode comp = fixedGuard.node();
         emitGuardComp(comp);
     }
 
-    public void emitGuardComp(Node comp) {
+    public void emitGuardComp(BooleanNode comp) {
         if (comp instanceof IsNonNull) {
             IsNonNull x = (IsNonNull) comp;
             CiValue value = load(x.object());
@@ -717,6 +732,19 @@
             XirArgument clazz = toXirArgument(x.type().getEncoding(Representation.ObjectHub));
             XirSnippet typeCheck = xir.genTypeCheck(site(x), toXirArgument(x.object()), clazz, x.type());
             emitXir(typeCheck, x, info, compilation.method, false);
+        } else {
+            FrameState state = lastState;
+            assert state != null : "deoptimize instruction always needs a state";
+
+            if (deoptimizationStubs == null) {
+                deoptimizationStubs = new ArrayList<DeoptimizationStub>();
+            }
+
+            DeoptimizationStub stub = new DeoptimizationStub(DeoptAction.InvalidateReprofile, state);
+            deoptimizationStubs.add(stub);
+
+            Condition cond = emitBooleanBranch(comp);
+            lir.branch(cond.negate(), stub.label, stub.info);
         }
     }
 
@@ -1021,7 +1049,7 @@
             lastState = fs;
         } else if (block.blockPredecessors().size() == 1) {
             FrameState fs = block.blockPredecessors().get(0).lastState();
-            assert fs != null;
+            assert fs != null; //TODO gd maybe this assert should be removed
             if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
                 TTY.println("STATE CHANGE (singlePred)");
                 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
@@ -1372,7 +1400,7 @@
         }
     }
 
-    void moveToPhi(PhiResolver resolver, Value curVal, Value suxVal, List<Phi> phis, int predIndex) {
+    /*void moveToPhi(PhiResolver resolver, Value curVal, Value suxVal, List<Phi> phis, int predIndex) {
         // move current value to referenced phi function
         if (suxVal instanceof Phi) {
             Phi phi = (Phi) suxVal;
@@ -1398,88 +1426,69 @@
                 resolver.move(operand, operandForPhi(phi));
             }
         }
-    }
-
-    private List<Phi> getPhis(LIRBlock block) {
-        if (block.getInstructions().size() > 0) {
-            Node i = block.firstInstruction();
-            if (i instanceof Merge) {
-                List<Phi> result = new ArrayList<Phi>();
-                for (Node n : i.usages()) {
-                    if (n instanceof Phi) {
-                        result.add((Phi) n);
-                    }
-                }
-                return result;
-            }
-        }
-        return null;
-    }
+    }*/
 
     @Override
     public void visitEndNode(EndNode end) {
         setNoResult(end);
-        Merge merge = end.merge();
-        assert merge != null;
-        moveToPhi(merge, merge.endIndex(end));
+        moveToPhi(end.merge(), end);
         lir.jump(getLIRBlock(end.merge()));
     }
 
     @Override
     public void visitMemoryRead(MemoryRead memRead) {
-        if (memRead.guard() != null) {
-            emitGuardComp(memRead.guard());
-        }
         lir.move(new CiAddress(memRead.valueKind(), load(memRead.location()), memRead.displacement()), createResultVariable(memRead), memRead.valueKind());
     }
 
 
     @Override
+    public void visitMemoryWrite(MemoryWrite memWrite) {
+        lir.move(load(memWrite.location()), new CiAddress(memWrite.valueKind(), load(memWrite.location()), memWrite.displacement()), memWrite.valueKind());
+    }
+
+
+    @Override
     public void visitLoopEnd(LoopEnd x) {
         setNoResult(x);
-        moveToPhi(x.loopBegin(), x.loopBegin().endCount());
+        moveToPhi(x.loopBegin(), x);
         lir.jump(getLIRBlock(x.loopBegin()));
     }
 
-    private void moveToPhi(Merge merge, int nextSuccIndex) {
+    private void moveToPhi(Merge merge, Node pred) {
+        int nextSuccIndex = merge.phiPredecessorIndex(pred);
         PhiResolver resolver = new PhiResolver(this);
-        for (Node n : merge.usages()) {
-            if (n instanceof Phi) {
-                Phi phi = (Phi) n;
-                if (!phi.isDead()) {
-                    Value curVal = phi.valueAt(nextSuccIndex);
-                    if (curVal != null && curVal != phi) {
-                        if (curVal instanceof Phi) {
-                            operandForPhi((Phi) curVal);
-                        }
-                        CiValue operand = curVal.operand();
-                        if (operand.isIllegal()) {
-                            assert curVal instanceof Constant || curVal instanceof Local : "these can be produced lazily" + curVal + "/" + phi;
-                            operand = operandForInstruction(curVal);
-                        }
-                        resolver.move(operand, operandForPhi(phi));
+        for (Phi phi : merge.phis()) {
+            if (!phi.isDead()) {
+                Value curVal = phi.valueAt(nextSuccIndex);
+                if (curVal != null && curVal != phi) {
+                    if (curVal instanceof Phi) {
+                        operandForPhi((Phi) curVal);
                     }
+                    CiValue operand = curVal.operand();
+                    if (operand.isIllegal()) {
+                        assert curVal instanceof Constant || curVal instanceof Local : "these can be produced lazily" + curVal + "/" + phi;
+                        operand = operandForInstruction(curVal);
+                    }
+                    resolver.move(operand, operandForPhi(phi));
                 }
             }
         }
         resolver.dispose();
-        //TODO (gd) remove that later
+        //TODO (gd) remove that later ?
         if (merge instanceof LoopBegin) {
-            for (Node usage : merge.usages()) {
-                if (usage instanceof LoopCounter) {
-                    LoopCounter counter = (LoopCounter) usage;
-                    if (counter.operand().isIllegal()) {
-                        createResultVariable(counter);
-                    }
-                    if (nextSuccIndex == 0) { // (gd) nasty
-                        lir.move(operandForInstruction(counter.init()), counter.operand());
+            LoopBegin loopBegin = (LoopBegin) merge;
+            for (LoopCounter counter : loopBegin.counters()) {
+                if (counter.operand().isIllegal()) {
+                    createResultVariable(counter);
+                }
+                if (nextSuccIndex == 0) {
+                    lir.move(operandForInstruction(counter.init()), counter.operand());
+                } else {
+                    if (counter.kind == CiKind.Int) {
+                        this.arithmeticOpInt(IADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()), CiValue.IllegalValue);
                     } else {
-                        if (counter.kind == CiKind.Int) {
-                            this.arithmeticOpInt(IADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()), CiValue.IllegalValue);
-                        } else {
-                            assert counter.kind == CiKind.Long;
-                            this.arithmeticOpLong(LADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()));
-                        }
+                        assert counter.kind == CiKind.Long;
+                        this.arithmeticOpLong(LADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()));
                     }
                 }
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Tue Jun 21 11:16:21 2011 +0200
@@ -91,20 +91,22 @@
 
         if (GraalOptions.Inline) {
             new InliningPhase(compilation, this, GraalOptions.TraceInlining).apply(compilation.graph);
-            //printGraph("After Ininling", compilation.graph);
         }
 
         Graph graph = compilation.graph;
 
         if (GraalOptions.OptCanonicalizer) {
             new CanonicalizerPhase().apply(graph);
-            new DeadCodeEliminationPhase().apply(compilation.graph);
-            //printGraph("After Canonicalization", graph);
+            new DeadCodeEliminationPhase().apply(graph);
         }
 
-        new LoopPhase().apply(graph);
+        if (GraalOptions.OptLoops) {
+            new LoopPhase().apply(graph);
+        }
 
-        new LoweringPhase().apply(graph);
+        if (GraalOptions.Lower) {
+            new LoweringPhase(compilation.runtime).apply(graph);
+        }
 
         IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true);
         schedule.apply(graph);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Anchor.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Anchor.java	Tue Jun 21 11:16:21 2011 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.max.graal.compiler.ir;
 
+import java.util.*;
+
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
@@ -52,6 +54,42 @@
         out.print("anchor ").print(next());
     }
 
+    public Iterable<GuardNode> happensAfterGuards() {
+        final Iterator<Node> usages = this.usages().iterator();
+        return new Iterable<GuardNode>() {
+            public Iterator<GuardNode> iterator() {
+                return new Iterator<GuardNode>() {
+                    private GuardNode next;
+                    @Override
+                    public boolean hasNext() {
+                        if (next == null) {
+                            while (usages.hasNext()) {
+                                Node cur = usages.next();
+                                if (cur instanceof GuardNode) {
+                                    next = ((GuardNode) cur);
+                                    break;
+                                }
+                            }
+                        }
+                        return next != null;
+                    }
+
+                    @Override
+                    public GuardNode next() {
+                        GuardNode result = next;
+                        next = null;
+                        return result;
+                    }
+
+                    @Override
+                    public void remove() {
+                        throw new IllegalStateException();
+                    }
+                };
+            }
+        };
+    }
+
     @Override
     public Node copy(Graph into) {
         return new Anchor(into);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/BooleanNode.java	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.graal.compiler.ir;
+
+import com.oracle.max.graal.graph.*;
+import com.sun.cri.ci.*;
+
+
+public abstract class BooleanNode extends FloatingNode {
+
+    public BooleanNode(CiKind kind, int inputCount, int successorCount, Graph graph) {
+        super(kind, inputCount, successorCount, graph);
+    }
+
+}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Compare.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Compare.java	Tue Jun 21 11:16:21 2011 +0200
@@ -34,7 +34,7 @@
  * into variants that do not materialize the value (CompareIf, CompareGuard...)
  *
  */
-public final class Compare extends FloatingNode {
+public final class Compare extends BooleanNode {
 
     private static final int INPUT_COUNT = 2;
     private static final int INPUT_X = 0;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ComputeLinearScanOrder.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ComputeLinearScanOrder.java	Tue Jun 21 11:16:21 2011 +0200
@@ -29,6 +29,7 @@
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.util.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 
 public final class ComputeLinearScanOrder {
@@ -40,9 +41,9 @@
 
     List<LIRBlock> linearScanOrder; // the resulting list of blocks in correct order
 
-    final CiBitMap visitedBlocks; // used for recursive processing of blocks
-    final CiBitMap activeBlocks; // used for recursive processing of blocks
-    final CiBitMap dominatorBlocks; // temporary BitMap used for computation of dominator
+    final BitMap visitedBlocks; // used for recursive processing of blocks
+    final BitMap activeBlocks; // used for recursive processing of blocks
+    final BitMap dominatorBlocks; // temporary BitMap used for computation of dominator
     final int[] forwardBranches; // number of incoming forward branches for each block
     final List<LIRBlock> loopEndBlocks; // list of all loop end blocks collected during countEdges
     BitMap2D loopMap; // two-dimensional bit set: a bit is set if a block is contained in a loop
@@ -111,9 +112,9 @@
     public ComputeLinearScanOrder(int maxBlockId, LIRBlock startBlock) {
 
         this.maxBlockId = maxBlockId;
-        visitedBlocks = new CiBitMap(maxBlockId);
-        activeBlocks = new CiBitMap(maxBlockId);
-        dominatorBlocks = new CiBitMap(maxBlockId);
+        visitedBlocks = new BitMap(maxBlockId);
+        activeBlocks = new BitMap(maxBlockId);
+        dominatorBlocks = new BitMap(maxBlockId);
         forwardBranches = new int[maxBlockId];
         loopEndBlocks = new ArrayList<LIRBlock>(8);
         workList = new ArrayList<LIRBlock>(8);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/EndNode.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/EndNode.java	Tue Jun 21 11:16:21 2011 +0200
@@ -30,6 +30,7 @@
 public final class EndNode extends FixedNode {
     public static final int SUCCESSOR_COUNT = 0;
     public static final int INPUT_COUNT = 0;
+
     public EndNode(Graph graph) {
         super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph);
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionEdgeInstruction.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionEdgeInstruction.java	Tue Jun 21 11:16:21 2011 +0200
@@ -24,5 +24,5 @@
 
 
 public interface ExceptionEdgeInstruction {
-    Instruction exceptionEdge();
+    FixedNode exceptionEdge();
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/FixedGuard.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/FixedGuard.java	Tue Jun 21 11:16:21 2011 +0200
@@ -36,12 +36,12 @@
     /**
      * The instruction that produces the object tested against null.
      */
-     public FloatingNode node() {
-        return (FloatingNode) inputs().get(super.inputCount() + INPUT_NODE);
+     public BooleanNode node() {
+        return (BooleanNode) inputs().get(super.inputCount() + INPUT_NODE);
     }
 
-    public FloatingNode setNode(FloatingNode n) {
-        return (FloatingNode) inputs().set(super.inputCount() + INPUT_NODE, n);
+    public void setNode(BooleanNode n) {
+        inputs().set(super.inputCount() + INPUT_NODE, n);
     }
 
     public FixedGuard(Graph graph) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/GuardNode.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/GuardNode.java	Tue Jun 21 11:16:21 2011 +0200
@@ -27,21 +27,30 @@
 import com.sun.cri.ci.*;
 
 
-public final class GuardNode extends Instruction {
-    private static final int INPUT_COUNT = 1;
-    private static final int INPUT_NODE = 0;
+public final class GuardNode extends FloatingNode {
+    private static final int INPUT_COUNT = 2;
+    private static final int INPUT_ANCHOR = 0;
+    private static final int INPUT_NODE = 1;
 
     private static final int SUCCESSOR_COUNT = 0;
 
+    public FixedNode anchor() {
+        return (FixedNode) inputs().get(super.inputCount() + INPUT_ANCHOR);
+    }
+
+    public void setAnchor(FixedNode anchor) {
+        inputs().set(super.inputCount() + INPUT_ANCHOR, anchor);
+    }
+
     /**
      * The instruction that produces the object tested against null.
      */
-     public Compare node() {
-        return (Compare) inputs().get(super.inputCount() + INPUT_NODE);
+    public BooleanNode node() {
+        return (BooleanNode) inputs().get(super.inputCount() + INPUT_NODE);
     }
 
-    public Compare setNode(Compare n) {
-        return (Compare) inputs().set(super.inputCount() + INPUT_NODE, n);
+    public void setNode(BooleanNode n) {
+        inputs().set(super.inputCount() + INPUT_NODE, n);
     }
 
     public GuardNode(Graph graph) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/If.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/If.java	Tue Jun 21 11:16:21 2011 +0200
@@ -50,17 +50,17 @@
     /**
      * The instruction that produces the first input to this comparison.
      */
-     public Compare compare() {
-        return (Compare) inputs().get(super.inputCount() + INPUT_COMPARE);
+     public BooleanNode compare() {
+        return (BooleanNode) inputs().get(super.inputCount() + INPUT_COMPARE);
     }
 
-    public Value setCompare(Compare n) {
-        return (Value) inputs().set(super.inputCount() + INPUT_COMPARE, n);
+    public void setCompare(BooleanNode n) {
+        inputs().set(super.inputCount() + INPUT_COMPARE, n);
     }
 
-    public If(Compare compare, Graph graph) {
+    public If(BooleanNode condition, Graph graph) {
         super(CiKind.Illegal, 2, INPUT_COUNT, SUCCESSOR_COUNT, graph);
-        setCompare(compare);
+        setCompare(condition);
     }
 
     /**
@@ -96,11 +96,7 @@
     @Override
     public void print(LogStream out) {
         out.print("if ").
-        print(compare().x()).
-        print(' ').
-        print(compare().condition().operator).
-        print(' ').
-        print(compare().y()).
+        print(compare()).
         print(" then ").
         print(trueSuccessor()).
         print(" else ").
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java	Tue Jun 21 11:16:21 2011 +0200
@@ -72,12 +72,12 @@
      * The entry to the exception dispatch chain for this invoke.
      */
     @Override
-    public Instruction exceptionEdge() {
-        return (Instruction) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE);
+    public FixedNode exceptionEdge() {
+        return (FixedNode) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE);
     }
 
-    public Instruction setExceptionEdge(Instruction n) {
-        return (Instruction) successors().set(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE, n);
+    public FixedNode setExceptionEdge(FixedNode n) {
+        return (FixedNode) successors().set(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE, n);
     }
 
     public final int opcode;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IsNonNull.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IsNonNull.java	Tue Jun 21 11:16:21 2011 +0200
@@ -32,7 +32,7 @@
 /**
  * The {@code NullCheck} class represents an explicit null check instruction.
  */
-public final class IsNonNull extends FloatingNode {
+public final class IsNonNull extends BooleanNode {
 
     private static final int INPUT_COUNT = 1;
     private static final int INPUT_OBJECT = 0;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IsType.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IsType.java	Tue Jun 21 11:16:21 2011 +0200
@@ -34,7 +34,7 @@
 /**
  * The {@code TypeCheck} class represents an explicit type check instruction.
  */
-public final class IsType extends FloatingNode {
+public final class IsType extends BooleanNode {
 
     private static final int INPUT_COUNT = 1;
     private static final int INPUT_OBJECT = 0;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java	Tue Jun 21 11:16:21 2011 +0200
@@ -25,8 +25,8 @@
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.graph.*;
 import com.oracle.max.graal.compiler.phases.CanonicalizerPhase.CanonicalizerOp;
+import com.oracle.max.graal.compiler.phases.*;
 import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringOp;
-import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringTool;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
@@ -36,7 +36,6 @@
  */
 public final class LoadField extends AccessField {
     private static final LoadFieldCanonicalizerOp CANONICALIZER = new LoadFieldCanonicalizerOp();
-    private static final LoadFieldLoweringOp LOWERING = new LoadFieldLoweringOp();
 
     private static final int INPUT_COUNT = 0;
     private static final int SUCCESSOR_COUNT = 0;
@@ -120,31 +119,11 @@
         if (clazz == CanonicalizerOp.class) {
             return (T) CANONICALIZER;
         } else if (clazz == LoweringOp.class) {
-            return (T) LOWERING;
+            return (T) LoweringPhase.DELEGATE_TO_RUNTIME;
         }
         return super.lookup(clazz);
     }
 
-    private static class LoadFieldLoweringOp implements LoweringOp {
-
-        @Override
-        public Node lower(Node n, LoweringTool tool) {
-            LoadField field = (LoadField) n;
-            if (field.isVolatile()) {
-                return null;
-            }
-            Graph graph = field.graph();
-            int displacement = field.field().offset();
-            assert field.kind != CiKind.Illegal;
-            MemoryRead memoryRead = new MemoryRead(field.field().kind(), displacement, graph);
-            memoryRead.setGuard(new IsNonNull(field.object(), graph));
-            memoryRead.setNext(field.next());
-            memoryRead.setLocation(field.object());
-            return memoryRead;
-        }
-
-    }
-
     private static class LoadFieldCanonicalizerOp implements CanonicalizerOp {
         @Override
         public Node canonical(Node node) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoopBegin.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoopBegin.java	Tue Jun 21 11:16:21 2011 +0200
@@ -22,16 +22,16 @@
  */
 package com.oracle.max.graal.compiler.ir;
 
+import java.util.*;
+
 import com.oracle.max.graal.compiler.debug.*;
+import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.graph.*;
 
-public class LoopBegin extends Merge {
-
-    private static final int INPUT_COUNT = 0;
-    private static final int SUCCESSOR_COUNT = 0;
-
+public class LoopBegin extends Merge{
     public LoopBegin(Graph graph) {
-        super(INPUT_COUNT, SUCCESSOR_COUNT, graph);
+        super(graph);
+        this.addEnd(new EndNode(graph));
     }
 
     public LoopEnd loopEnd() {
@@ -67,4 +67,39 @@
         LoopBegin x = new LoopBegin(into);
         return x;
     }
+
+    @Override
+    public int phiPredecessorCount() {
+        return 2;
+    }
+
+    @Override
+    public int phiPredecessorIndex(Node pred) {
+        if (pred == forwardEdge()) {
+            return 0;
+        } else if (pred == this.loopEnd()) {
+            return 1;
+        }
+        throw Util.shouldNotReachHere("unknown pred : " + pred + "(sp=" + forwardEdge() + ", le=" + this.loopEnd() + ")");
+    }
+
+    public Collection<LoopCounter> counters() {
+        return Util.filter(this.usages(), LoopCounter.class);
+    }
+
+    @Override
+    public List<Node> phiPredecessors() {
+        return Arrays.asList(new Node[]{this.forwardEdge(), this.loopEnd()});
+    }
+
+    public EndNode forwardEdge() {
+        return this.endAt(0);
+    }
+
+    @Override
+    public boolean verify() {
+        assertTrue(loopEnd() != null);
+        assertTrue(forwardEdge() != null);
+        return true;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MemoryAccess.java	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,80 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.graal.compiler.ir;
+
+import com.oracle.max.graal.compiler.debug.*;
+import com.oracle.max.graal.graph.*;
+import com.sun.cri.ci.*;
+
+
+public abstract class MemoryAccess extends Instruction {
+    private static final int INPUT_COUNT = 2;
+    private static final int INPUT_NODE = 0;
+    private static final int INPUT_GUARD = 1;
+
+    private static final int SUCCESSOR_COUNT = 0;
+
+    private int displacement;
+    private CiKind valueKind;
+
+    /**
+     * The instruction that produces the object tested against null.
+     */
+     public Value location() {
+        return (Value) inputs().get(super.inputCount() + INPUT_NODE);
+    }
+
+    public Value setLocation(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_NODE, n);
+    }
+
+    /**
+     * The instruction that produces the object tested against null.
+     */
+     public GuardNode guard() {
+        return (GuardNode) inputs().get(super.inputCount() + INPUT_GUARD);
+    }
+
+    public void setGuard(GuardNode n) {
+        inputs().set(super.inputCount() + INPUT_GUARD, n);
+    }
+
+    public int displacement() {
+        return displacement;
+    }
+
+    public CiKind valueKind() {
+        return valueKind;
+    }
+
+    public MemoryAccess(CiKind kind, int displacement, int inputCount, int successorCount, Graph graph) {
+        super(kind.stackKind(), INPUT_COUNT + inputCount, SUCCESSOR_COUNT + successorCount, graph);
+        this.displacement = displacement;
+        this.valueKind = kind;
+    }
+
+    @Override
+    public void print(LogStream out) {
+        out.print("mem read from ").print(location());
+    }
+}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MemoryRead.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MemoryRead.java	Tue Jun 21 11:16:21 2011 +0200
@@ -27,50 +27,13 @@
 import com.sun.cri.ci.*;
 
 
-public final class MemoryRead extends Instruction {
-    private static final int INPUT_COUNT = 2;
-    private static final int INPUT_NODE = 0;
-    private static final int INPUT_GUARD = 1;
-
+public final class MemoryRead extends MemoryAccess {
+    private static final int INPUT_COUNT = 0;
     private static final int SUCCESSOR_COUNT = 0;
 
-    private int displacement;
-    private CiKind valueKind;
-
-    /**
-     * The instruction that produces the object tested against null.
-     */
-     public Value location() {
-        return (Value) inputs().get(super.inputCount() + INPUT_NODE);
-    }
-
-    public Value setLocation(Value n) {
-        return (Value) inputs().set(super.inputCount() + INPUT_NODE, n);
-    }
-
-    /**
-     * The instruction that produces the object tested against null.
-     */
-     public FloatingNode guard() {
-        return (FloatingNode) inputs().get(super.inputCount() + INPUT_GUARD);
-    }
-
-    public FloatingNode setGuard(FloatingNode n) {
-        return (FloatingNode) inputs().set(super.inputCount() + INPUT_GUARD, n);
-    }
-
-    public int displacement() {
-        return displacement;
-    }
-
-    public CiKind valueKind() {
-        return valueKind;
-    }
 
     public MemoryRead(CiKind kind, int displacement, Graph graph) {
-        super(kind.stackKind(), INPUT_COUNT, SUCCESSOR_COUNT, graph);
-        this.displacement = displacement;
-        this.valueKind = kind;
+        super(kind, displacement, INPUT_COUNT, SUCCESSOR_COUNT, graph);
     }
 
     @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MemoryWrite.java	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,62 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.graal.compiler.ir;
+
+import com.oracle.max.graal.compiler.debug.*;
+import com.oracle.max.graal.graph.*;
+import com.sun.cri.ci.*;
+
+
+public final class MemoryWrite extends MemoryAccess {
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_VALUE = 0;
+    private static final int SUCCESSOR_COUNT = 0;
+
+    public Value value() {
+        return (Value) inputs().get(super.inputCount() + INPUT_VALUE);
+    }
+
+    public void setValue(Value v) {
+        inputs().set(super.inputCount() + INPUT_VALUE, v);
+    }
+
+    public MemoryWrite(CiKind kind, Value value, int displacement, Graph graph) {
+        super(kind, displacement, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+        setValue(value);
+    }
+
+    @Override
+    public void accept(ValueVisitor v) {
+        v.visitMemoryWrite(this);
+    }
+
+    @Override
+    public void print(LogStream out) {
+        out.print("mem write to ").print(location()).print(" with value").print(value());
+    }
+
+    @Override
+    public Node copy(Graph into) {
+        return new MemoryWrite(super.kind, null, displacement(), into);
+    }
+}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Merge.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Merge.java	Tue Jun 21 11:16:21 2011 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.max.graal.compiler.ir;
 
+import java.util.*;
+
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.compiler.value.*;
@@ -33,7 +35,7 @@
  * about the basic block, including the successor and
  * predecessor blocks, exception handlers, liveness information, etc.
  */
-public class Merge extends StateSplit {
+public class Merge extends StateSplit{
 
     private static final int INPUT_COUNT = 0;
 
@@ -90,6 +92,29 @@
         return (EndNode) inputs().variablePart().get(index);
     }
 
+    public Iterable<Node> mergePredecessors() {
+        return new Iterable<Node>() {
+            @Override
+            public Iterator<Node> iterator() {
+                return new Iterator<Node>() {
+                    int i = 0;
+                    @Override
+                    public void remove() {
+                        throw new UnsupportedOperationException();
+                    }
+                    @Override
+                    public Node next() {
+                        return Merge.this.endAt(i++);
+                    }
+                    @Override
+                    public boolean hasNext() {
+                        return i < Merge.this.endCount();
+                    }
+                };
+            }
+        };
+    }
+
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
@@ -296,4 +321,21 @@
             }
         }
     }
+
+    public int phiPredecessorCount() {
+        return endCount();
+    }
+
+    public int phiPredecessorIndex(Node pred) {
+        EndNode end = (EndNode) pred;
+        return endIndex(end);
+    }
+
+    public Collection<Phi> phis() {
+        return Util.filter(this.usages(), Phi.class);
+    }
+
+    public List<Node> phiPredecessors() {
+        return Collections.unmodifiableList(inputs().variablePart());
+    }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java	Tue Jun 21 11:16:21 2011 +0200
@@ -58,7 +58,7 @@
         return (Merge) inputs().get(super.inputCount() + INPUT_MERGE);
     }
 
-    public void setMerge(Value n) {
+    public void setMerge(Merge n) {
         inputs().set(super.inputCount() + INPUT_MERGE, n);
     }
 
@@ -67,11 +67,15 @@
         setMerge(merge);
     }
 
+    Phi(CiKind kind, Graph graph) {
+        super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+    }
+
     @Override
     public boolean verify() {
         assertTrue(merge() != null);
         if (!isDead()) {
-            assertTrue(merge().endCount() + (merge() instanceof LoopBegin ? 1 : 0) == valueCount());
+            assertTrue(merge().phiPredecessorCount() == valueCount());
         }
         return true;
     }
@@ -148,7 +152,7 @@
 
     @Override
     public Node copy(Graph into) {
-        Phi x = new Phi(kind, null, into);
+        Phi x = new Phi(kind, into);
         x.isDead = isDead;
         return x;
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/StoreField.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/StoreField.java	Tue Jun 21 11:16:21 2011 +0200
@@ -23,6 +23,8 @@
 package com.oracle.max.graal.compiler.ir;
 
 import com.oracle.max.graal.compiler.debug.*;
+import com.oracle.max.graal.compiler.phases.*;
+import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringOp;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
@@ -76,6 +78,15 @@
         v.visitStoreField(this);
     }
 
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends Op> T lookup(java.lang.Class<T> clazz) {
+        if (clazz == LoweringOp.class) {
+            return (T) LoweringPhase.DELEGATE_TO_RUNTIME;
+        }
+        return null;
+    };
+
     @Override
     public void print(LogStream out) {
         out.print(object()).
@@ -89,7 +100,6 @@
 
     @Override
     public Node copy(Graph into) {
-        StoreField x = new StoreField(null, field, null, into);
-        return x;
+        return new StoreField(null, field, null, into);
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java	Tue Jun 21 11:16:21 2011 +0200
@@ -154,28 +154,6 @@
     }
 
     /**
-     * Compute the value number of this Instruction. Local and global value numbering
-     * optimizations use a hash map, and the value number provides a hash code.
-     * If the instruction cannot be value numbered, then this method should return
-     * {@code 0}.
-     * @return the hashcode of this instruction
-     */
-    public int valueNumber() {
-        return 0;
-    }
-
-    /**
-     * Checks that this instruction is equal to another instruction for the purposes
-     * of value numbering.
-     * @param i the other instruction
-     * @return {@code true} if this instruction is equivalent to the specified
-     * instruction w.r.t. value numbering
-     */
-    public boolean valueEqual(Node i) {
-        return false;
-    }
-
-    /**
      * This method supports the visitor pattern by accepting a visitor and calling the
      * appropriate {@code visit()} method.
      *
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java	Tue Jun 21 11:16:21 2011 +0200
@@ -52,6 +52,7 @@
     public abstract void visitLogic(Logic i);
     public abstract void visitLookupSwitch(LookupSwitch i);
     public abstract void visitMemoryRead(MemoryRead i);
+    public abstract void visitMemoryWrite(MemoryWrite i);
     public abstract void visitMonitorAddress(MonitorAddress monitorAddress);
     public abstract void visitMonitorEnter(MonitorEnter i);
     public abstract void visitMonitorExit(MonitorExit i);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java	Tue Jun 21 11:16:21 2011 +0200
@@ -30,7 +30,6 @@
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.compiler.value.*;
 import com.oracle.max.graal.graph.*;
-import com.sun.cri.ci.*;
 
 /**
  * The {@code LIRBlock} class definition.
@@ -51,7 +50,7 @@
      * in this block.
      * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}.
      */
-    public CiBitMap liveIn;
+    public BitMap liveIn;
 
     /**
      * Bit map specifying which {@linkplain OperandPool operands} are live upon exit from this block.
@@ -59,20 +58,20 @@
      * upon entry to this block.
      * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}.
      */
-    public CiBitMap liveOut;
+    public BitMap liveOut;
 
     /**
      * Bit map specifying which {@linkplain OperandPool operands} are used (before being defined) in this block.
      * That is, these are the values that are live upon entry to the block.
      * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}.
      */
-    public CiBitMap liveGen;
+    public BitMap liveGen;
 
     /**
      * Bit map specifying which {@linkplain OperandPool operands} are defined/overwritten in this block.
      * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}.
      */
-    public CiBitMap liveKill;
+    public BitMap liveKill;
 
     private int firstLirInstructionID;
     private int lastLirInstructionID;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRDebugInfo.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRDebugInfo.java	Tue Jun 21 11:16:21 2011 +0200
@@ -25,6 +25,7 @@
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.ir.*;
 import com.oracle.max.graal.compiler.value.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 
 /**
@@ -62,7 +63,7 @@
         return new LIRDebugInfo(this);
     }
 
-    public void setOop(CiValue location, GraalCompilation compilation, CiBitMap frameRefMap, CiBitMap regRefMap) {
+    public void setOop(CiValue location, GraalCompilation compilation, BitMap frameRefMap, BitMap regRefMap) {
         CiTarget target = compilation.target;
         if (location.isAddress()) {
             CiAddress stackLocation = (CiAddress) location;
@@ -97,7 +98,7 @@
         return debugInfo != null;
     }
 
-    public static void setBit(CiBitMap refMap, int bit) {
+    public static void setBit(BitMap refMap, int bit) {
         assert !refMap.get(bit) : "Ref map entry " + bit + " is already set.";
         refMap.set(bit);
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRInstruction.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRInstruction.java	Tue Jun 21 11:16:21 2011 +0200
@@ -28,6 +28,7 @@
 
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.lir.LIROperand.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 
 /**
@@ -500,7 +501,7 @@
     protected static String refMapToString(CiDebugInfo debugInfo, OperandFormatter operandFmt) {
         StringBuilder buf = new StringBuilder();
         if (debugInfo.hasStackRefMap()) {
-            CiBitMap bm = debugInfo.frameRefMap;
+            BitMap bm = debugInfo.frameRefMap;
             for (int slot = bm.nextSetBit(0); slot >= 0; slot = bm.nextSetBit(slot + 1)) {
                 if (buf.length() != 0) {
                     buf.append(", ");
@@ -509,7 +510,7 @@
             }
         }
         if (debugInfo.hasRegisterRefMap()) {
-            CiBitMap bm = debugInfo.registerRefMap;
+            BitMap bm = debugInfo.registerRefMap;
             for (int reg = bm.nextSetBit(0); reg >= 0; reg = bm.nextSetBit(reg + 1)) {
                 if (buf.length() != 0) {
                     buf.append(", ");
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -45,7 +45,7 @@
 
         // remove chained Merges
         for (Merge merge : graph.getNodes(Merge.class)) {
-            if (merge.endCount() == 1 && merge.usages().size() == 0 && !(merge instanceof LoopEnd) && !(merge instanceof LoopBegin)) {
+            if (merge.endCount() == 1 && merge.usages().size() == 0 && !(merge instanceof LoopEnd || merge instanceof LoopBegin)) {
                 FixedNode next = merge.next();
                 EndNode endNode = merge.endAt(0);
                 merge.delete();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -31,8 +31,10 @@
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.graph.*;
-import com.oracle.max.graal.compiler.graph.BlockMap.*;
 import com.oracle.max.graal.compiler.graph.BlockMap.Block;
+import com.oracle.max.graal.compiler.graph.BlockMap.BranchOverride;
+import com.oracle.max.graal.compiler.graph.BlockMap.DeoptBlock;
+import com.oracle.max.graal.compiler.graph.BlockMap.ExceptionBlock;
 import com.oracle.max.graal.compiler.ir.*;
 import com.oracle.max.graal.compiler.ir.Deoptimize.DeoptAction;
 import com.oracle.max.graal.compiler.schedule.*;
@@ -42,7 +44,7 @@
 import com.sun.cri.bytecode.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
-import com.sun.cri.ri.RiType.*;
+import com.sun.cri.ri.RiType.Representation;
 
 /**
  * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph.
@@ -281,31 +283,22 @@
     }
 
     public void mergeOrClone(Block target, FrameStateAccess newState) {
-        Instruction first = target.firstInstruction;
+        StateSplit first = (StateSplit) target.firstInstruction;
+
         if (target.isLoopHeader && isVisited(target)) {
-            first = ((LoopBegin) first).loopEnd();
+            first = loopBegin(target).loopEnd();
         }
-        assert first instanceof StateSplit;
 
         int bci = target.startBci;
         if (target instanceof ExceptionBlock) {
             bci = ((ExceptionBlock) target).deoptBci;
         }
 
-        FrameState existingState = ((StateSplit) first).stateAfter();
+        FrameState existingState = first.stateAfter();
 
         if (existingState == null) {
             // copy state because it is modified
-            FrameState duplicate = newState.duplicate(bci);
-
-            // if the block is a loop header, insert all necessary phis
-            if (first instanceof LoopBegin && target.isLoopHeader) {
-                assert first instanceof Merge;
-                insertLoopPhis((Merge) first, duplicate);
-                ((Merge) first).setStateAfter(duplicate);
-            } else {
-                ((StateSplit) first).setStateAfter(duplicate);
-            }
+            first.setStateAfter(newState.duplicate(bci));
         } else {
             if (!GraalOptions.AssumeVerifiedBytecode && !existingState.isCompatibleWith(newState)) {
                 // stacks or locks do not match--bytecodes would not verify
@@ -318,14 +311,14 @@
 
             if (first instanceof Placeholder) {
                 Placeholder p = (Placeholder) first;
-                assert !target.isLoopHeader;
                 if (p.predecessors().size() == 0) {
                     p.setStateAfter(newState.duplicate(bci));
                     return;
                 } else {
                     Merge merge = new Merge(graph);
                     assert p.predecessors().size() == 1 : "predecessors size: " + p.predecessors().size();
-                    assert p.next() == null;
+                    merge.setNext(p.next());
+                    p.setNext(null);
                     EndNode end = new EndNode(graph);
                     p.replace(end);
                     merge.addEnd(end);
@@ -339,20 +332,20 @@
         }
     }
 
-    private void insertLoopPhis(Merge merge, FrameState newState) {
+    private void insertLoopPhis(LoopBegin loopBegin, FrameState newState) {
         int stackSize = newState.stackSize();
         for (int i = 0; i < stackSize; i++) {
             // always insert phis for the stack
             Value x = newState.stackAt(i);
             if (x != null) {
-                newState.setupPhiForStack(merge, i).addInput(x);
+                newState.setupPhiForStack(loopBegin, i).addInput(x);
             }
         }
         int localsSize = newState.localsSize();
         for (int i = 0; i < localsSize; i++) {
             Value x = newState.localAt(i);
             if (x != null) {
-                newState.setupPhiForLocal(merge, i).addInput(x);
+                newState.setupPhiForLocal(loopBegin, i).addInput(x);
             }
         }
     }
@@ -381,7 +374,7 @@
         return handler.catchTypeCPI() == 0;
     }
 
-    private Instruction handleException(Value exceptionObject, int bci) {
+    private FixedNode handleException(Value exceptionObject, int bci) {
         assert bci == Instruction.SYNCHRONIZATION_ENTRY_BCI || bci == bci() : "invalid bci";
 
         if (exceptionObject == null && method.exceptionProbability(bci) == 0) {
@@ -427,23 +420,22 @@
                     dispatchBlock = blockFromBci[handlerBCI];
                 }
             }
-            FrameState entryState = frameState.duplicateWithEmptyStack(bci);
 
-            StateSplit entry = new Placeholder(graph);
-            entry.setStateAfter(entryState);
-
-            Instruction currentNext = entry;
-            Value currentExceptionObject = exceptionObject;
-            if (currentExceptionObject == null) {
-                ExceptionObject exception = new ExceptionObject(graph);
-                entry.setNext(exception);
-                currentNext = exception;
-                currentExceptionObject = exception;
+            Value currentExceptionObject;
+            if (exceptionObject == null) {
+                currentExceptionObject = new ExceptionObject(graph);
+            } else {
+                currentExceptionObject = exceptionObject;
             }
-            FrameState stateWithException = entryState.duplicateWithException(bci, currentExceptionObject);
-
-            currentNext.setNext(createTarget(dispatchBlock, stateWithException));
-            return entry;
+            FrameState stateWithException = frameState.duplicateWithException(bci, currentExceptionObject);
+            FixedNode target = createTarget(dispatchBlock, stateWithException);
+            if (exceptionObject == null) {
+                ExceptionObject eObj = (ExceptionObject) currentExceptionObject;
+                eObj.setNext(target);
+                return eObj;
+            } else {
+                return target;
+            }
         }
         return null;
     }
@@ -717,7 +709,7 @@
         node.setNode(new IsNonNull(exception, graph));
         append(node);
 
-        Instruction entry = handleException(exception, bci);
+        FixedNode entry = handleException(exception, bci);
         if (entry != null) {
             append(entry);
         } else {
@@ -1162,7 +1154,10 @@
                 LoopBegin loopBegin = new LoopBegin(graph);
                 LoopEnd loopEnd = new LoopEnd(graph);
                 loopEnd.setLoopBegin(loopBegin);
-                block.firstInstruction = loopBegin;
+                Placeholder p = new Placeholder(graph);
+                p.setNext(loopBegin.forwardEdge());
+                loopBegin.setStateAfter(stateAfter.duplicate(block.startBci));
+                block.firstInstruction = p;
             } else {
                 block.firstInstruction = new Placeholder(graph);
             }
@@ -1171,8 +1166,8 @@
         addToWorkList(block);
 
         FixedNode result = null;
-        if (block.firstInstruction instanceof LoopBegin && isVisited(block)) {
-            result = ((LoopBegin) block.firstInstruction).loopEnd();
+        if (block.isLoopHeader && isVisited(block)) {
+            result = loopBegin(block).loopEnd();
         } else {
             result = block.firstInstruction;
         }
@@ -1180,11 +1175,15 @@
         assert result instanceof Merge || result instanceof Placeholder : result;
 
         if (result instanceof Merge) {
-            EndNode end = new EndNode(graph);
-            //end.setNext(result);
-            ((Merge) result).addEnd(end);
-            result = end;
+            if (result instanceof LoopBegin) {
+                result = ((LoopBegin) result).forwardEdge();
+            } else {
+                EndNode end = new EndNode(graph);
+                ((Merge) result).addEnd(end);
+                result = end;
+            }
         }
+        assert !(result instanceof LoopBegin || result instanceof Merge);
         return result;
     }
 
@@ -1210,9 +1209,19 @@
             if (!isVisited(block)) {
                 markVisited(block);
                 // now parse the block
-                frameState.initializeFrom(((StateSplit) block.firstInstruction).stateAfter());
-                lastInstr = block.firstInstruction;
-                assert block.firstInstruction.next() == null : "instructions already appended at block " + block.blockID;
+                if (block.isLoopHeader) {
+                    LoopBegin begin = loopBegin(block);
+                    FrameState preLoopState = block.firstInstruction.stateAfter();
+                    assert preLoopState != null;
+                    FrameState duplicate = preLoopState.duplicate(preLoopState.bci);
+                    begin.setStateAfter(duplicate);
+                    insertLoopPhis(begin, duplicate);
+                    lastInstr = begin;
+                } else {
+                    lastInstr = block.firstInstruction;
+                }
+                frameState.initializeFrom(((StateSplit) lastInstr).stateAfter());
+                assert lastInstr.next() == null : "instructions already appended at block " + block.blockID;
 
                 if (block == returnBlock) {
                     createReturnBlock(block);
@@ -1229,8 +1238,8 @@
         }
         for (Block b : blocksVisited) {
             if (b.isLoopHeader) {
-                LoopBegin begin = (LoopBegin) b.firstInstruction;
-                LoopEnd end = begin.loopEnd();
+                LoopBegin begin = loopBegin(b);
+                LoopEnd loopEnd = begin.loopEnd();
 
 //              This can happen with degenerated loops like this one:
 //                for (;;) {
@@ -1239,14 +1248,14 @@
 //                    } catch (UnresolvedException iioe) {
 //                    }
 //                }
-                if (end.stateAfter() != null) {
-                    begin.stateAfter().merge(begin, end.stateAfter());
+                if (loopEnd.stateAfter() != null) {
+                    //loopHeaderMerge.stateBefore().merge(begin, end.stateBefore());
+                    //assert loopHeaderMerge.equals(end.stateBefore());
+                    begin.stateAfter().merge(begin, loopEnd.stateAfter());
                 } else {
-                    end.delete();
+                    loopEnd.delete();
                     Merge merge = new Merge(graph);
-                    for (int i = 0; i < begin.endCount(); ++i) {
-                        merge.addEnd(begin.endAt(i));
-                    }
+                    merge.addEnd(begin.forwardEdge());
                     merge.setNext(begin.next());
                     merge.setStateAfter(begin.stateAfter());
                     begin.replace(merge);
@@ -1255,6 +1264,12 @@
         }
     }
 
+    private static LoopBegin loopBegin(Block block) {
+        EndNode endNode = (EndNode) block.firstInstruction.next();
+        LoopBegin loopBegin = (LoopBegin) endNode.merge();
+        return loopBegin;
+    }
+
     private void createDeoptBlock(DeoptBlock block) {
         storeResultGraph = false;
         append(new Deoptimize(DeoptAction.InvalidateReprofile, graph));
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -279,7 +279,7 @@
 
     private void inlineMethod(Invoke invoke, RiMethod method) {
         FrameState stateAfter = invoke.stateAfter();
-        Instruction exceptionEdge = invoke.exceptionEdge();
+        FixedNode exceptionEdge = invoke.exceptionEdge();
 
         CompilerGraph graph;
         Object stored = GraphBuilderPhase.cachedGraphs.get(method);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -25,6 +25,7 @@
 import java.util.*;
 
 import com.oracle.max.graal.compiler.ir.*;
+import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.compiler.value.*;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
@@ -50,6 +51,7 @@
 
     private void mergeLoopCounters(List<LoopCounter> counters, LoopBegin loopBegin) {
         Graph graph = loopBegin.graph();
+        FrameState stateAfter = loopBegin.stateAfter();
         LoopCounter[] acounters = counters.toArray(new LoopCounter[counters.size()]);
         for (int i = 0; i < acounters.length; i++) {
             LoopCounter c1 = acounters[i];
@@ -59,16 +61,30 @@
             for (int j = i + 1; j < acounters.length; j++) {
                 LoopCounter c2 = acounters[j];
                 if (c2 != null && c1.stride().valueEqual(c2.stride())) {
+                    boolean c1InCompare = Util.filter(c1.usages(), Compare.class).size() > 0;
+                    boolean c2inCompare = Util.filter(c2.usages(), Compare.class).size() > 0;
+                    if (c2inCompare && !c1InCompare) {
+                        c1 = acounters[j];
+                        c2 = acounters[i];
+                        acounters[i] = c2;
+                        acounters[j] = c1;
+                    }
+                    boolean c2InFramestate = stateAfter != null ? stateAfter.inputs().contains(c2) : false;
                     acounters[j] = null;
                     CiKind kind = c1.kind;
-                    IntegerSub sub = new IntegerSub(kind, c2.init(), c1.init(), graph);
-                    IntegerAdd addStride = new IntegerAdd(kind, sub, c1.stride(), graph);
-                    IntegerAdd add = new IntegerAdd(kind, c1, addStride, graph);
-                    Phi phi = new Phi(kind, loopBegin, graph); // TODO (gd) assumes order on loopBegin preds
-                    phi.addInput(c2.init());
-                    phi.addInput(add);
-                    c2.replace(phi);
-                    //System.out.println("--> merged Loop Counters");
+                    if (c2InFramestate) {
+                        IntegerSub sub = new IntegerSub(kind, c2.init(), c1.init(), graph);
+                        IntegerAdd addStride = new IntegerAdd(kind, sub, c1.stride(), graph);
+                        IntegerAdd add = new IntegerAdd(kind, c1, addStride, graph);
+                        Phi phi = new Phi(kind, loopBegin, graph); // TODO (gd) assumes order on loopBegin preds
+                        phi.addInput(c2.init());
+                        phi.addInput(add);
+                        c2.replace(phi);
+                    } else {
+                        IntegerSub sub = new IntegerSub(kind, c2.init(), c1.init(), graph);
+                        IntegerAdd add = new IntegerAdd(kind, c1, sub, graph);
+                        c2.replace(add);
+                    }
                 }
             }
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -24,32 +24,81 @@
 
 import com.oracle.max.graal.compiler.ir.*;
 import com.oracle.max.graal.compiler.schedule.*;
-import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.graph.*;
+import com.sun.cri.ci.*;
+import com.sun.cri.ri.*;
 
 public class LoweringPhase extends Phase {
+
+    public static final LoweringOp DELEGATE_TO_RUNTIME = new LoweringOp() {
+        @Override
+        public Node lower(Node n, CiLoweringTool tool) {
+            return tool.getRuntime().lower(n, tool);
+        }
+    };
+
+    private final RiRuntime runtime;
+
+    public LoweringPhase(RiRuntime runtime) {
+        this.runtime = runtime;
+    }
+
     @Override
     protected void run(final Graph graph) {
         final IdentifyBlocksPhase s = new IdentifyBlocksPhase(false);
         s.apply(graph);
 
         for (Block b : s.getBlocks()) {
-            //final Node firstNode = b.firstNode();
+            final Node[] firstNodeValue = new Node[]{b.firstNode()};
 
-            final LoweringTool loweringTool = new LoweringTool() {
+            final CiLoweringTool loweringTool = new CiLoweringTool() {
                 @Override
-                public Node createStructuredBlockAnchor() {
-                    throw Util.unimplemented();
-//                    if (!(firstNode instanceof Anchor) && !(firstNode instanceof Merge)) {
-//                        Anchor a = new Anchor(graph);
-//                        assert firstNode.predecessors().size() == 1;
-//                        Node pred = firstNode.predecessors().get(0);
-//                        int predIndex = firstNode.predecessorsIndex().get(0);
-//                        a.successors().setAndClear(Instruction.SUCCESSOR_NEXT, pred, predIndex);
-//                        pred.successors().set(predIndex, a);
-//                        return a;
-//                    }
-//                    return firstNode;
+                public Node getGuardAnchor() {
+                    Node firstNode = firstNodeValue[0];
+                    if (firstNode == firstNode.graph().start()) {
+                        Anchor a = new Anchor(graph);
+                        a.setNext((FixedNode) firstNode.graph().start().start());
+                        firstNode.graph().start().setStart(a);
+                        firstNodeValue[0] = a;
+                        return a;
+                    } else if (firstNode instanceof Merge) {
+                        Merge merge = (Merge) firstNode;
+                        Anchor a = new Anchor(graph);
+                        a.setNext(merge.next());
+                        merge.setNext(a);
+                        firstNodeValue[0] = a;
+                        return a;
+                    } else if (!(firstNode instanceof Anchor)) {
+                        Anchor a = new Anchor(graph);
+                        assert firstNode.predecessors().size() == 1 : firstNode;
+                        Node pred = firstNode.predecessors().get(0);
+                        int predIndex = pred.successors().indexOf(firstNode);
+                        pred.successors().set(predIndex, a);
+                        a.setNext((FixedNode) firstNode);
+                        firstNodeValue[0] = a;
+                        return a;
+                    }
+                    return firstNode;
+                }
+
+                @Override
+                public RiRuntime getRuntime() {
+                    return runtime;
+                }
+
+                @Override
+                public Node createGuard(Node condition) {
+                    Anchor anchor = (Anchor) getGuardAnchor();
+                    for (GuardNode guard : anchor.happensAfterGuards()) {
+                        if (guard.node().valueEqual(condition)) {
+                            condition.delete();
+                            return guard;
+                        }
+                    }
+                    GuardNode newGuard = new GuardNode(graph);
+                    newGuard.setAnchor(anchor);
+                    newGuard.setNode((BooleanNode) condition);
+                    return newGuard;
                 }
             };
 
@@ -67,11 +116,7 @@
         }
     }
 
-    public interface LoweringTool {
-        Node createStructuredBlockAnchor();
-    }
-
     public interface LoweringOp extends Op {
-        Node lower(Node n, LoweringTool tool);
+        Node lower(Node n, CiLoweringTool tool);
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -61,7 +61,9 @@
             }
             GraalTimers.get(getName()).start();
         }
+        //System.out.println("Starting Phase " + getName());
         run(graph);
+        //System.out.println("Finished Phase " + getName());
         if (GraalOptions.Time) {
             GraalTimers.get(getName()).stop();
             if (oldCurrentPhase != null) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Tue Jun 21 11:16:21 2011 +0200
@@ -29,7 +29,6 @@
 import com.oracle.max.graal.compiler.phases.*;
 import com.oracle.max.graal.compiler.value.*;
 import com.oracle.max.graal.graph.*;
-import com.sun.cri.ci.*;
 
 
 public class IdentifyBlocksPhase extends Phase {
@@ -93,6 +92,22 @@
         return trueSuccessorCount(n) > 1 || n instanceof Return || n instanceof Unwind || n instanceof Deoptimize;
     }
 
+    private void print() {
+        Block dominatorRoot = nodeToBlock.get(graph.start());
+        System.out.println("Root = " + dominatorRoot);
+        System.out.println("nodeToBlock :");
+        System.out.println(nodeToBlock);
+        System.out.println("Blocks :");
+        for (Block b : blocks) {
+            System.out.println(b + " [S:" + b.getSuccessors() + ", P:" + b.getPredecessors() + ", D:" + b.getDominators());
+            System.out.println("  f " + b.firstNode());
+            for (Node n : b.getInstructions()) {
+                System.out.println("  - " + n);
+            }
+            System.out.println("  l " + b.lastNode());
+        }
+    }
+
     private void identifyBlocks() {
 
         // Identify blocks.
@@ -111,8 +126,7 @@
                             // Either dead code or at a merge node => stop iteration.
                             break;
                         }
-                        assert currentNode.predecessors().size() == 1 : "preds: " + currentNode;
-                        currentNode = currentNode.predecessors().get(0);
+                        currentNode = currentNode.singlePredecessor();
                     }
                 }
             }
@@ -123,9 +137,8 @@
             Node n = block.firstNode();
             if (n instanceof Merge) {
                 Merge m = (Merge) n;
-                for (int i = 0; i < m.endCount(); ++i) {
-                    EndNode end = m.endAt(i);
-                    Block predBlock = nodeToBlock.get(end);
+                for (Node pred : m.mergePredecessors()) {
+                    Block predBlock = nodeToBlock.get(pred);
                     predBlock.addSuccessor(block);
                 }
             } else {
@@ -145,11 +158,11 @@
 
             // Add successors of loop end nodes. Makes the graph cyclic.
             for (Block block : blocks) {
-                Node n = block.firstNode();
-                if (n instanceof LoopBegin) {
-                    LoopBegin loopBegin = (LoopBegin) n;
-                    assert loopBegin.loopEnd() != null;
-                    nodeToBlock.get(loopBegin.loopEnd()).addSuccessor(block);
+                Node n = block.lastNode();
+                if (n instanceof LoopEnd) {
+                    LoopEnd loopEnd = (LoopEnd) n;
+                    assert loopEnd.loopBegin() != null;
+                    block.addSuccessor(nodeToBlock.get(loopEnd.loopBegin()));
                 }
             }
 
@@ -183,7 +196,7 @@
                 for (int i = 1; i < b.getPredecessors().size(); ++i) {
                     dominatorBlock = getCommonDominator(dominatorBlock, b.getPredecessors().get(i));
                 }
-                CiBitMap blockMap = new CiBitMap(blocks.size());
+                BitMap blockMap = new BitMap(blocks.size());
                 markPredecessors(b, dominatorBlock, blockMap);
 
                 Block result = dominatorBlock;
@@ -203,7 +216,7 @@
         return b.javaBlock();
     }
 
-    private void markPredecessors(Block b, Block stopBlock, CiBitMap blockMap) {
+    private void markPredecessors(Block b, Block stopBlock, BitMap blockMap) {
         if (blockMap.get(b.blockID())) {
             return;
         }
@@ -258,7 +271,7 @@
                         if (mergeBlock.getPredecessors().size() == 0) {
                             TTY.println(merge.toString());
                             TTY.println(phi.toString());
-                            TTY.println(merge.predecessors().toString());
+                            TTY.println(merge.phiPredecessors().toString());
                             TTY.println("value count: " + phi.valueCount());
                         }
                         block = getCommonDominator(block, mergeBlock.getPredecessors().get(i));
@@ -266,8 +279,7 @@
                 }
             } else if (usage instanceof FrameState && ((FrameState) usage).block() != null) {
                 Merge merge = ((FrameState) usage).block();
-                for (int i = 0; i < merge.endCount(); ++i) {
-                    EndNode pred = merge.endAt(i);
+                for (Node pred : merge.mergePredecessors()) {
                     block = getCommonDominator(block, nodeToBlock.get(pred));
                 }
             } else if (usage instanceof LoopCounter) {
@@ -322,10 +334,24 @@
         addToSorting(b, b.lastNode(), sortedInstructions, map);
 
         // Make sure that last node gets really last (i.e. when a frame state successor hangs off it).
-        sortedInstructions.remove(b.lastNode());
-        sortedInstructions.add(b.lastNode());
-
-        assert sortedInstructions.get(sortedInstructions.size() - 1) == b.lastNode() : " lastNode=" + b.lastNode() + ", firstNode=" + b.firstNode() + ", sorted(sz-1)=" + sortedInstructions.get(sortedInstructions.size() - 1);
+        Node lastSorted = sortedInstructions.get(sortedInstructions.size() - 1);
+        if (lastSorted != b.lastNode()) {
+            int idx = sortedInstructions.indexOf(b.lastNode());
+            boolean canNotMove = false;
+            for (int i = idx + 1; i < sortedInstructions.size(); i++) {
+                if (sortedInstructions.get(i).inputs().contains(b.lastNode())) {
+                    canNotMove = true;
+                    break;
+                }
+            }
+            if (canNotMove) {
+                assert !(b.lastNode() instanceof ControlSplit);
+                //b.setLastNode(lastSorted);
+            } else {
+                sortedInstructions.remove(b.lastNode());
+                sortedInstructions.add(b.lastNode());
+            }
+        }
         b.setInstructions(sortedInstructions);
     }
 
@@ -368,11 +394,14 @@
     private void computeDominators() {
         Block dominatorRoot = nodeToBlock.get(graph.start());
         assert dominatorRoot.getPredecessors().size() == 0;
-        CiBitMap visited = new CiBitMap(blocks.size());
+        BitMap visited = new BitMap(blocks.size());
         visited.set(dominatorRoot.blockID());
         LinkedList<Block> workList = new LinkedList<Block>();
-        workList.add(dominatorRoot);
-        // TODO: Add all predecessor.size()==0 nodes.
+        for (Block block : blocks) {
+            if (block.getPredecessors().size() == 0) {
+                workList.add(block);
+            }
+        }
 
         while (!workList.isEmpty()) {
             Block b = workList.remove();
@@ -415,7 +444,7 @@
     }
 
     public Block commonDominator(Block a, Block b) {
-        CiBitMap bitMap = new CiBitMap(blocks.size());
+        BitMap bitMap = new BitMap(blocks.size());
         Block cur = a;
         while (cur != null) {
             bitMap.set(cur.blockID());
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Jun 21 11:16:21 2011 +0200
@@ -485,7 +485,7 @@
 
     @Override
     public void visitLoopBegin(LoopBegin x) {
-        visitMerge(x);
+
     }
 
     @Override
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/BitMap2D.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/BitMap2D.java	Tue Jun 21 11:16:21 2011 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.max.graal.compiler.util;
 
-import com.sun.cri.ci.*;
+import com.oracle.max.graal.graph.*;
 
 /**
  * This class implements a two-dimensional bitmap.
@@ -32,7 +32,7 @@
  */
 public final class BitMap2D {
 
-    private CiBitMap map;
+    private BitMap map;
     private final int bitsPerSlot;
 
     private int bitIndex(int slotIndex, int bitWithinSlotIndex)  {
@@ -45,7 +45,7 @@
     }
 
     public BitMap2D(int sizeInSlots, int bitsPerSlot) {
-        map = new CiBitMap(sizeInSlots * bitsPerSlot);
+        map = new BitMap(sizeInSlots * bitsPerSlot);
         this.bitsPerSlot = bitsPerSlot;
     }
 
@@ -84,7 +84,7 @@
            while (size <= slotIndex) {
                size *= 2;
            }
-           CiBitMap newBitMap = new CiBitMap(size * bitsPerSlot);
+           BitMap newBitMap = new BitMap(size * bitsPerSlot);
            newBitMap.setUnion(map);
            map = newBitMap;
        }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/Util.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/Util.java	Tue Jun 21 11:16:21 2011 +0200
@@ -27,6 +27,7 @@
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.ir.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 
@@ -424,4 +425,15 @@
     public static String valueString(Value value) {
         return (value == null) ? "-" : ("" + value.kind.typeChar + value.id());
     }
+
+    @SuppressWarnings("unchecked")
+    public static <T extends Node> Collection<T> filter(Collection<Node> nodes, Class<T> clazz) {
+        ArrayList<T> phis = new ArrayList<T>();
+        for (Node node : nodes) {
+            if (clazz.isInstance(node)) {
+                phis.add((T) node);
+            }
+        }
+        return phis;
+    }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Tue Jun 21 11:16:21 2011 +0200
@@ -130,22 +130,7 @@
         return other;
     }
 
-    /**
-     * Gets a copy of this frame state without the stack.
-     */
     @Override
-    public FrameState duplicateWithEmptyStack(int bci) {
-        FrameState other = new FrameState(method, bci, localsSize, 0, locksSize(), rethrowException, graph());
-        for (int i = 0; i < localsSize; i++) {
-            other.setValueAt(i, localAt(i));
-        }
-        for (int i = 0; i < locksSize; i++) {
-            other.setValueAt(localsSize + i, lockAt(i));
-        }
-        other.setOuterFrameState(outerFrameState());
-        return other;
-    }
-
     public FrameState duplicateWithException(int bci, Value exceptionObject) {
         return duplicateModified(bci, true, CiKind.Void, exceptionObject);
     }
@@ -198,6 +183,28 @@
         return true;
     }
 
+    public boolean equals(FrameStateAccess other) {
+        if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) {
+            return false;
+        }
+        for (int i = 0; i < stackSize(); i++) {
+            Value x = stackAt(i);
+            Value y = other.stackAt(i);
+            if (x != y) {
+                return false;
+            }
+        }
+        for (int i = 0; i < locksSize(); i++) {
+            if (lockAt(i) != other.lockAt(i)) {
+                return false;
+            }
+        }
+        if (other.outerFrameState() != outerFrameState()) {
+            return false;
+        }
+        return true;
+    }
+
     /**
      * Gets the size of the local variables.
      */
@@ -389,7 +396,7 @@
                     }
 
                     if (phi.valueCount() == 0) {
-                        int size = block.endCount();
+                        int size = block.phiPredecessorCount();
                         for (int j = 0; j < size; ++j) {
                             phi.addInput(x);
                         }
@@ -398,11 +405,7 @@
                         phi.addInput((x == y) ? phi : y);
                     }
 
-                    if (block instanceof LoopBegin) {
-//                        assert phi.valueCount() == ((LoopBegin) block).loopEnd().predecessors().size() + 1 : "loop, valueCount=" + phi.valueCount() + " predSize= " + ((LoopBegin) block).loopEnd().predecessors().size();
-                    } else {
-                        assert phi.valueCount() == block.endCount() + 1 : "valueCount=" + phi.valueCount() + " predSize= " + block.endCount();
-                    }
+                    assert phi.valueCount() == block.phiPredecessorCount() + (block instanceof LoopBegin ? 0 : 1) : "valueCount=" + phi.valueCount() + " predSize= " + block.phiPredecessorCount();
                }
             }
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java	Tue Jun 21 11:16:21 2011 +0200
@@ -42,10 +42,10 @@
 
     Value stackAt(int i);
 
-    FrameState duplicateWithEmptyStack(int bci);
-
     void setValueAt(int j, Value v);
 
     Value outerFrameState();
 
+    FrameState duplicateWithException(int bci, Value exceptionObject);
+
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java	Tue Jun 21 11:16:21 2011 +0200
@@ -107,9 +107,8 @@
         return new FrameState(method, bci, locals, stack, stackIndex, locks, false, graph);
     }
 
-    @Override
-    public FrameState duplicateWithEmptyStack(int bci) {
-        FrameState frameState = new FrameState(method, bci, locals, new Value[0], 0, locks, false, graph);
+    public FrameState duplicateWithException(int bci, Value exceptionObject) {
+        FrameState frameState = new FrameState(method, bci, locals, new Value[]{exceptionObject}, 1, locks, true, graph);
         frameState.setOuterFrameState(outerFrameState());
         return frameState;
     }
--- a/graal/com.oracle.max.graal.graph/.checkstyle	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
-  <local-check-config name="C1X Checkstyle checks" location="/com.oracle.max.graal.compiler/.checkstyle_checks.xml" type="project" description="">
-    <additional-data name="protect-config-file" value="false"/>
-  </local-check-config>
-  <fileset name="all" enabled="true" check-config-name="C1X Checkstyle checks" local="true">
-    <file-match-pattern match-pattern="." include-pattern="true"/>
-  </fileset>
-</fileset-config>
--- a/graal/com.oracle.max.graal.graph/.classpath	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="test"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.cri"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
--- a/graal/com.oracle.max.graal.graph/.project	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>com.oracle.max.graal.graph</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
-	</natures>
-</projectDescription>
--- a/graal/com.oracle.max.graal.graph/.settings/org.eclipse.jdt.core.prefs	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,270 +0,0 @@
-#Wed Apr 27 22:10:44 CEST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
-org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
-org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
-org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
-org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_after_package=1
-org.eclipse.jdt.core.formatter.blank_lines_before_field=0
-org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1
-org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
-org.eclipse.jdt.core.formatter.blank_lines_before_method=1
-org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
-org.eclipse.jdt.core.formatter.blank_lines_before_package=0
-org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
-org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
-org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
-org.eclipse.jdt.core.formatter.comment.format_block_comments=true
-org.eclipse.jdt.core.formatter.comment.format_header=true
-org.eclipse.jdt.core.formatter.comment.format_html=true
-org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
-org.eclipse.jdt.core.formatter.comment.format_line_comments=true
-org.eclipse.jdt.core.formatter.comment.format_source_code=true
-org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
-org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
-org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
-org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
-org.eclipse.jdt.core.formatter.comment.line_length=120
-org.eclipse.jdt.core.formatter.compact_else_if=true
-org.eclipse.jdt.core.formatter.continuation_indentation=4
-org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=4
-org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
-org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_empty_lines=false
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
-org.eclipse.jdt.core.formatter.indentation.size=8
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
-org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.join_lines_in_comments=true
-org.eclipse.jdt.core.formatter.join_wrapped_lines=true
-org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true
-org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=200
-org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=true
-org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true
-org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
-org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
-org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
-org.eclipse.jdt.core.formatter.tabulation.char=space
-org.eclipse.jdt.core.formatter.tabulation.size=4
-org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=false
--- a/graal/com.oracle.max.graal.graph/.settings/org.eclipse.jdt.ui.prefs	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-#Wed Apr 27 22:10:44 CEST 2011
-eclipse.preferences.version=1
-formatter_profile=_C1XJavaCodeStyle
-formatter_settings_version=11
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/EdgeType.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-
-public enum EdgeType {
-    INPUTS,
-    USAGES,
-    PREDECESSORS,
-    SUCCESSORS;
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Graph.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class Graph {
-
-    public static final List<VerificationListener> verificationListeners = new ArrayList<VerificationListener>(4);
-
-    private final ArrayList<Node> nodes;
-    private final StartNode start;
-    int nextId;
-    int deletedNodeCount;
-
-    static int nextGraphId = 0;
-    int id = nextGraphId++;
-
-    @Override
-    public String toString() {
-        return "Graph " + id;
-    }
-
-    public Graph() {
-        nodes = new ArrayList<Node>();
-        start = new StartNode(this);
-    }
-
-    public int getDeletedNodeCount() {
-        return deletedNodeCount;
-    }
-
-    public int getNodeCount() {
-        return nodes.size() - getDeletedNodeCount();
-    }
-
-    public List<Node> getNodes() {
-        return Collections.unmodifiableList(nodes);
-    }
-
-    public class TypedNodeIterator<T> implements Iterator<T> {
-        private final Class<T> type;
-        private int index;
-
-        public TypedNodeIterator(Class<T> type) {
-            this.type = type;
-            this.index = -1;
-            forward();
-        }
-
-        private void forward() {
-            if (index < nodes.size()) {
-                do {
-                    index++;
-                } while (index < nodes.size() && !type.isInstance(nodes.get(index)));
-                if (index >= nodes.size()) {
-                    index = Integer.MAX_VALUE;
-                }
-            }
-        }
-
-        @Override
-        public boolean hasNext() {
-            return index < nodes.size();
-        }
-
-        @Override
-        @SuppressWarnings("unchecked")
-        public T next() {
-            try {
-                return (T) nodes.get(index);
-            } finally {
-                forward();
-            }
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-    }
-
-    public <T extends Node> Iterable<T> getNodes(final Class<T> type) {
-        return new Iterable<T>() {
-            @Override
-            public Iterator<T> iterator() {
-                return new TypedNodeIterator<T>(type);
-            }
-        };
-    }
-
-    int register(Node node) {
-        int id = nextId++;
-        nodes.add(id, node);
-        return id;
-    }
-
-    void unregister(Node node) {
-        nodes.set(node.id(), Node.Null);
-        deletedNodeCount++;
-    }
-
-    public StartNode start() {
-        return start;
-    }
-
-    public NodeBitMap createNodeBitMap() {
-        return new NodeBitMap(this);
-    }
-
-    public <T> NodeMap<T> createNodeMap() {
-        return new NodeMap<T>(this);
-    }
-
-    public NodeFlood createNodeFlood() {
-        return new NodeFlood(this);
-    }
-
-    public NodeWorkList createNodeWorkList() {
-        return new NodeWorkList(this);
-    }
-
-    public NodeWorkList createNodeWorkList(boolean fill, int iterationLimitPerNode) {
-        return new NodeWorkList(this, fill, iterationLimitPerNode);
-    }
-
-    public boolean verify() {
-        for (Node n : getNodes()) {
-            assert n == Node.Null || n.verify();
-        }
-        return true;
-    }
-
-    public Map<Node, Node> addDuplicate(Collection<Node> nodes, Map<Node, Node> replacements) {
-        Map<Node, Node> newNodes = new HashMap<Node, Node>();
-        // create node duplicates
-        for (Node node : nodes) {
-            if (node != null && !replacements.containsKey(node)) {
-                assert node.graph != this;
-                assert !node.isDeleted() : "trying to duplicate deleted node";
-                Node newNode = node.copy(this);
-                assert newNode.getClass() == node.getClass();
-                newNodes.put(node, newNode);
-            }
-        }
-        // re-wire inputs
-        for (Entry<Node, Node> entry : newNodes.entrySet()) {
-            Node oldNode = entry.getKey();
-            Node node = entry.getValue();
-            for (int i = 0; i < oldNode.inputs().size(); i++) {
-                Node input = oldNode.inputs().get(i);
-                Node target = replacements.get(input);
-                if (target == null) {
-                    target = newNodes.get(input);
-                }
-                node.inputs().setOrExpand(i, target);
-            }
-        }
-        for (Entry<Node, Node> entry : replacements.entrySet()) {
-            Node oldNode = entry.getKey();
-            Node node = entry.getValue();
-            for (int i = 0; i < oldNode.inputs().size(); i++) {
-                Node input = oldNode.inputs().get(i);
-                if (newNodes.containsKey(input)) {
-                    node.inputs().setOrExpand(i, newNodes.get(input));
-                }
-            }
-        }
-
-        // re-wire successors
-        for (Entry<Node, Node> entry : newNodes.entrySet()) {
-            Node oldNode = entry.getKey();
-            Node node = entry.getValue();
-            for (int i = 0; i < oldNode.successors().size(); i++) {
-                Node succ = oldNode.successors().get(i);
-                Node target = replacements.get(succ);
-                if (target == null) {
-                    target = newNodes.get(succ);
-                }
-                node.successors().setOrExpand(i, target);
-            }
-        }
-        for (Entry<Node, Node> entry : replacements.entrySet()) {
-            Node oldNode = entry.getKey();
-            Node node = entry.getValue();
-            for (int i = 0; i < oldNode.successors().size(); i++) {
-                Node succ = oldNode.successors().get(i);
-                if (newNodes.containsKey(succ)) {
-                    node.successors().setOrExpand(i, newNodes.get(succ));
-                }
-            }
-        }
-        return newNodes;
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class Node {
-
-    public static final Node Null = null;
-    public static final int DeletedID = -1;
-
-    final Graph graph;
-    private int id;
-    final NodeArray inputs;
-    final NodeArray successors;
-    final ArrayList<Node> usages;
-    final ArrayList<Node> predecessors;
-
-    public Node(int inputCount, int successorCount, Graph graph) {
-        assert graph != null : "cannot create a node for a null graph";
-        this.graph = graph;
-        this.id = graph.register(this);
-        this.inputs = new NodeArray(this, inputCount);
-        this.successors = new NodeArray(this, successorCount);
-        this.predecessors = new ArrayList<Node>(1);
-        this.usages = new ArrayList<Node>(4);
-    }
-
-    public List<Node> predecessors() {
-        return Collections.unmodifiableList(predecessors);
-    }
-
-    public List<Node> usages() {
-        return Collections.unmodifiableList(usages);
-    }
-
-    public NodeArray inputs() {
-        return inputs;
-    }
-
-    public NodeArray successors() {
-        return successors;
-    }
-
-    public int id() {
-        return id;
-    }
-
-    public Graph graph() {
-        return graph;
-    }
-
-    public <T extends Op> T lookup(Class<T> clazz) {
-        return null;
-    }
-
-    public String shortName() {
-        return getClass().getSimpleName();
-    }
-
-    public Node replace(Node other) {
-        assert !isDeleted() && (other == null || !other.isDeleted()) : "id: " + id() + ", other: " + other;
-        assert other == null || other.graph == graph;
-        for (Node usage : usages) {
-            usage.inputs.replaceFirstOccurrence(this, other);
-        }
-        int z = 0;
-        for (Node predecessor : predecessors) {
-            for (int i = 0; i < predecessor.successors.size(); i++) {
-                if (predecessor.successors.get(i) == this) {
-                    predecessor.successors.silentSet(i, other);
-                }
-            }
-            ++z;
-        }
-        if (other != null) {
-            other.usages.addAll(usages);
-            other.predecessors.addAll(predecessors);
-        }
-        usages.clear();
-        predecessors.clear();
-        delete();
-        assert other == null || other.verify();
-        return other;
-    }
-
-    public boolean isDeleted() {
-        return id == DeletedID;
-    }
-
-    public void forceDelete() {
-        for (Node n : usages) {
-            n.inputs.silentRemove(this);
-        }
-        for (Node n : predecessors) {
-            n.successors.silentRemove(this);
-        }
-        usages.clear();
-        predecessors.clear();
-    }
-
-    public void unsafeDelete() {
-        graph.unregister(this);
-        id = DeletedID;
-        assert isDeleted();
-    }
-
-    public void delete() {
-        assert !isDeleted();
-        assert checkDeletion() : "Could not delete " + this + " (usages: " + this.usages() + ", predecessors: " + this.predecessors() + ")";
-
-        for (int i = 0; i < inputs.size(); ++i) {
-            inputs.set(i, Null);
-        }
-        for (int i = 0; i < successors.size(); ++i) {
-            successors.set(i, Null);
-        }
-        assert predecessors().size() == 0 && usages().size() == 0;
-        unsafeDelete();
-    }
-
-    private boolean checkDeletion() {
-        if (usages.size() != 0 || predecessors.size() != 0) {
-            System.out.println(this.shortName() + ", id: " + id + ", usages: " + usages.size() + ", predecessors: " + predecessors().size());
-            System.out.println("usages:");
-            for (Node n : usages()) {
-                System.out.print(n.id() + " (" + n.shortName() + ") ");
-            }
-            System.out.println("\npreds:");
-            for (Node n : predecessors()) {
-                System.out.print(n.id() + " (" + n.shortName() + ") ");
-            }
-            System.out.println();
-            return false;
-        }
-        return true;
-    }
-
-    public final Node copy() {
-        return copy(graph);
-    }
-
-    /**
-     * 
-     * @param into
-     * @return
-     */
-    public abstract Node copy(Graph into);
-
-    /**
-     * 
-     * @return
-     */
-    protected int inputCount() {
-        return 0;
-    }
-
-    /**
-     * 
-     * @return
-     */
-    protected int successorCount() {
-        return 0;
-    }
-
-    /**
-     * Provides a {@link Map} of properties of this node for use in debugging (e.g., to view in the ideal graph
-     * visualizer). Subclasses overriding this method should add to the map returned by their superclass.
-     */
-    public Map<Object, Object> getDebugProperties() {
-        Map<Object, Object> map = new HashMap<Object, Object>();
-        map.put("inputCount", inputCount());
-        map.put("usageCount", usages.size());
-        map.put("successorCount", successorCount());
-        map.put("predecessorCount", predecessors.size());
-        return map;
-    }
-
-    @Override
-    public String toString() {
-        return this.getClass().getSimpleName() + "-" + this.id();
-    }
-
-    public boolean verify() {
-        return true;
-    }
-
-    public final void assertTrue(boolean cond) {
-        assert cond || assertionFailure("");
-    }
-
-    public final void assertTrue(boolean cond, String message) {
-        assert cond || assertionFailure(message);
-    }
-
-    public final boolean assertionFailure(String message) {
-        for (VerificationListener l : Graph.verificationListeners) {
-            l.verificationFailed(this, message);
-        }
-        return true;
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeArray.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import java.util.AbstractList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-public class NodeArray extends AbstractList<Node> {
-
-    private final Node node;
-    private Node[] nodes;
-    private final int fixedLength;
-    private int variableLength;
-
-    public NodeArray(Node node, int length) {
-        this.node = node;
-        this.nodes = new Node[length];
-        this.fixedLength = length;
-    }
-
-    @Override
-    public Iterator<Node> iterator() {
-        return Arrays.asList(this.nodes).iterator();
-    }
-
-    private Node self() {
-        return this.node;
-    }
-
-    Node silentSet(int index, Node node) {
-        Node result = nodes[index];
-        nodes[index] = node;
-        return result;
-    }
-
-    public AbstractList<Node> variablePart() {
-        return new AbstractList<Node>() {
-
-            @Override
-            public Node get(int index) {
-                checkIndex(index);
-                return NodeArray.this.get(fixedLength + index);
-            }
-
-            @Override
-            public int size() {
-                return variableLength;
-            }
-
-            public Node set(int index, Node element) {
-                checkIndex(index);
-                return NodeArray.this.set(fixedLength + index, element);
-            }
-
-            public void add(int index, Node element) {
-                variableLength++;
-                checkIndex(index);
-                NodeArray.this.ensureSize();
-                for (int i = size() - 1; i > index; i--) {
-                    NodeArray.this.nodes[fixedLength + i] = NodeArray.this.nodes[fixedLength + i - 1];
-                }
-                set(index, element);
-            }
-
-            private void checkIndex(int index) {
-                if (index < 0 || index >= size()) {
-                    throw new IndexOutOfBoundsException();
-                }
-            }
-
-            @Override
-            public Node remove(int index) {
-                checkIndex(index);
-                Node n = get(index);
-                set(index, Node.Null);
-                for (int i = index; i < size() - 1; i++) {
-                    NodeArray.this.nodes[fixedLength + i] = NodeArray.this.nodes[fixedLength + i + 1];
-                }
-                NodeArray.this.nodes[fixedLength + size() - 1] = Node.Null;
-                variableLength--;
-                assert variableLength >= 0;
-                return n;
-            }
-        };
-    }
-
-    private void ensureSize() {
-        if (size() > nodes.length) {
-            nodes = Arrays.copyOf(nodes, (nodes.length + 1) * 2);
-        }
-    }
-
-    public void setOrExpand(int index, Node node) {
-        if (index < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-
-        while (index >= size()) {
-            variablePart().add(Node.Null);
-        }
-
-        set(index, node);
-    }
-
-    @Override
-    public Node set(int index, Node node) {
-        assert !self().isDeleted() : "trying to set input/successor of deleted node: " + self().shortName();
-        assert node == Node.Null || node.graph == self().graph : "node is from different graph: (this=" + self() + ") and (node=" + node + ")";
-        assert node == Node.Null || node.id() != Node.DeletedID : "inserted node must not be deleted";
-        assert node != self() || node.getClass().toString().contains("Phi") : "No direct circles allowed in the graph! " + node;
-
-        Node old = get(index);
-        if (old != node) {
-            silentSet(index, node);
-            if (self().inputs == this) {
-                if (old != null) {
-                    old.usages.remove(self());
-                }
-                if (node != null) {
-                    node.usages.add(self());
-                }
-            } else {
-                assert self().successors == this;
-                if (old != null) {
-                    old.predecessors.remove(self());
-                }
-                if (node != null) {
-                    node.predecessors.add(self());
-                }
-            }
-        }
-
-        return old;
-    }
-
-    public void setAll(NodeArray other) {
-        assert size() == other.size();
-        for (int i = 0; i < other.size(); i++) {
-            set(i, other.get(i));
-        }
-    }
-
-    private void checkIndex(int index) {
-        if (index < 0 || index >= size()) {
-            throw new IndexOutOfBoundsException();
-        }
-    }
-
-    @Override
-    public Node get(int index) {
-        checkIndex(index);
-        assert !self().isDeleted();
-        return nodes[index];
-    }
-
-    @Override
-    public Node[] toArray() {
-        return Arrays.copyOf(nodes, size());
-    }
-
-    boolean replaceFirstOccurrence(Node toReplace, Node replacement) {
-        for (int i = 0; i < size(); i++) {
-            if (nodes[i] == toReplace) {
-                nodes[i] = replacement;
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public int remove(Node n) {
-        return replace(n, null);
-    }
-
-    public int replace(Node toReplace, Node replacement) {
-        int result = 0;
-        for (int i = 0; i < size(); i++) {
-            if (nodes[i] == toReplace) {
-                set(i, replacement);
-                result++;
-            }
-        }
-        return result;
-    }
-
-    int silentRemove(Node n) {
-        return silentReplace(n, null);
-    }
-
-    int silentReplace(Node toReplace, Node replacement) {
-        int result = 0;
-        for (int i = 0; i < size(); i++) {
-            if (nodes[i] == toReplace) {
-                silentSet(i, replacement);
-                result++;
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public int size() {
-        return fixedLength + variableLength;
-    }
-
-    public void clearAll() {
-        for (int i = 0; i < size(); i++) {
-            set(i, Node.Null);
-        }
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeBitMap.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import com.sun.cri.ci.CiBitMap;
-
-
-public final class NodeBitMap {
-
-    private final CiBitMap bitMap;
-    private final Graph graph;
-
-    NodeBitMap(Graph graph) {
-        this.graph = graph;
-        bitMap = new CiBitMap(graph.nextId);
-    }
-
-    public Graph graph() {
-        return graph;
-    }
-
-    public boolean setIntersect(NodeBitMap other) {
-        return bitMap.setIntersect(other.bitMap);
-    }
-
-    public void setUnion(NodeBitMap other) {
-        bitMap.setUnion(other.bitMap);
-    }
-
-    public boolean isMarked(Node node) {
-        check(node);
-        return bitMap.get(node.id());
-    }
-
-    public boolean isNew(Node node) {
-        return node.id() >= bitMap.size();
-    }
-
-    public void mark(Node node) {
-        check(node);
-        bitMap.set(node.id());
-    }
-
-    public void clear(Node node) {
-        check(node);
-        bitMap.clear(node.id());
-    }
-
-    public void clearAll() {
-        bitMap.clearAll();
-    }
-
-    public void grow(Node node) {
-        bitMap.grow(node.id() + 1);
-    }
-
-    private void check(Node node) {
-        assert node.graph == graph : "this node is not part of the graph";
-        assert !isNew(node) : "this node (" + node.id() + ") was added to the graph after creating the node bitmap (" + bitMap.length() + ")";
-        assert !node.isDeleted() : "node " + node + " is deleted!";
-    }
-
-    @Override
-    public String toString() {
-        return bitMap.toBinaryString(-1);
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeFlood.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import java.util.ArrayDeque;
-import java.util.Iterator;
-import java.util.Queue;
-
-
-public class NodeFlood implements Iterable<Node> {
-    private final NodeBitMap visited;
-    private final Queue<Node> worklist;
-
-    NodeFlood(Graph graph) {
-        visited = graph.createNodeBitMap();
-        worklist = new ArrayDeque<Node>();
-    }
-
-    public void add(Node node) {
-        if (node != null && !visited.isMarked(node)) {
-            visited.mark(node);
-            worklist.add(node);
-        }
-    }
-
-    public boolean isMarked(Node node) {
-        return visited.isMarked(node);
-    }
-
-    private static class QueueConsumingIterator implements Iterator<Node> {
-        private final Queue<Node> queue;
-
-        public QueueConsumingIterator(Queue<Node> queue) {
-            this.queue = queue;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return !queue.isEmpty();
-        }
-
-        @Override
-        public Node next() {
-            return queue.remove();
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-    }
-
-    @Override
-    public Iterator<Node> iterator() {
-        return new QueueConsumingIterator(worklist);
-    }
-
-    private static class UnmarkedNodeIterator implements Iterator<Node> {
-        private final NodeBitMap visited;
-        private Iterator<Node> nodes;
-        private Node nextNode;
-
-        public UnmarkedNodeIterator(NodeBitMap visited, Iterator<Node> nodes) {
-            this.visited = visited;
-            this.nodes = nodes;
-            forward();
-        }
-
-        private void forward() {
-            do {
-                if (!nodes.hasNext()) {
-                    nextNode = null;
-                    return;
-                }
-                nextNode = nodes.next();
-            } while (visited.isMarked(nextNode));
-        }
-
-        @Override
-        public boolean hasNext() {
-            return nextNode != null;
-        }
-
-        @Override
-        public Node next() {
-            try {
-                return nextNode;
-            } finally {
-                forward();
-            }
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-
-    }
-
-    public Iterable<Node> unmarkedNodes() {
-        return new Iterable<Node>() {
-            @Override
-            public Iterator<Node> iterator() {
-                return new UnmarkedNodeIterator(visited, visited.graph().getNodes().iterator());
-            }
-        };
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeIterator.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import java.util.LinkedList;
-import java.util.List;
-
-
-public class NodeIterator {
-    public static NodeBitMap iterate(EdgeType e, Node start, NodeBitMap constraint, NodeVisitor visitor) {
-        LinkedList<Node> nodes = new LinkedList<Node>();
-        NodeBitMap nodeBitMap = start.graph.createNodeBitMap();
-
-        add(nodes, nodeBitMap, start, constraint, null);
-        while (nodes.size() > 0) {
-            Node n = nodes.remove();
-            if (visitor != null) {
-                boolean followEdges = visitor.visit(n);
-                if (!followEdges) {
-                    continue;
-                }
-            }
-            switch(e) {
-                case INPUTS:
-                    for (Node inputs : n.inputs()) {
-                        add(nodes, nodeBitMap, inputs, constraint, n.usages());
-                    }
-                    break;
-                case USAGES:
-                    for (Node usage : n.usages()) {
-                        add(nodes, nodeBitMap, usage, constraint, n.inputs());
-                    }
-                    break;
-                case PREDECESSORS:
-                    for (Node preds : n.predecessors()) {
-                        add(nodes, nodeBitMap, preds, constraint, n.successors());
-                    }
-                    break;
-                case SUCCESSORS:
-                    for (Node succ : n.successors()) {
-                        add(nodes, nodeBitMap, succ, constraint, n.predecessors());
-                    }
-                    break;
-                default:
-                    assert false : "unknown edge type";
-            }
-        }
-
-        return nodeBitMap;
-    }
-
-    private static void add(List<Node> nodes, NodeBitMap nodeBitMap, Node node, NodeBitMap constraint, List<Node> others) {
-        if (node != null && !nodeBitMap.isMarked(node) && (constraint == null || constraint.isMarked(node))) {
-            nodes.add(node);
-            nodeBitMap.mark(node);
-        }
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeMap.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-
-
-public final class NodeMap<T> {
-
-    private final Object[] values;
-    private final Graph graph;
-
-    NodeMap(Graph graph) {
-        this.graph = graph;
-        values = new Object[graph.nextId];
-    }
-
-    @SuppressWarnings("unchecked")
-    public T get(Node node) {
-        check(node);
-        return (T) values[node.id()];
-    }
-
-    public void set(Node node, T value) {
-        check(node);
-        values[node.id()] = value;
-    }
-
-    public int size() {
-        return values.length;
-    }
-
-    private void check(Node node) {
-        assert node.graph == graph : "this node is not part of the graph";
-        assert node.id() < values.length : "this node was added to the graph after creating the node map";
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeVisitor.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-
-public interface NodeVisitor {
-    boolean visit(Node n);
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/NodeWorkList.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-import java.util.ArrayDeque;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Queue;
-
-
-public class NodeWorkList implements Iterable<Node> {
-    private final NodeBitMap visited;
-    private final NodeBitMap inQueue;
-    private final Queue<Node> worklist;
-    private int iterationLimit = Integer.MAX_VALUE;
-
-    NodeWorkList(Graph graph) {
-        this(graph, false, -1);
-    }
-
-    NodeWorkList(Graph graph, boolean fill, int iterationLimitPerNode) {
-        visited = graph.createNodeBitMap();
-        inQueue = graph.createNodeBitMap();
-        if (fill) {
-            ArrayDeque<Node> deque = new ArrayDeque<Node>(graph.getNodeCount());
-            for (Node node : graph.getNodes()) {
-                if (node != null) {
-                    deque.add(node);
-                }
-            }
-            worklist = deque;
-        } else {
-            worklist = new ArrayDeque<Node>();
-        }
-        if (iterationLimitPerNode > 0) {
-            iterationLimit = iterationLimitPerNode * graph.getNodeCount();
-        }
-    }
-
-    public void add(Node node) {
-        if (node != null && !visited.isMarked(node)) {
-            doAdd(node);
-        }
-    }
-
-    private void doAdd(Node node) {
-        if (node != null && !inQueue.isMarked(node)) {
-            visited.mark(node);
-            inQueue.mark(node);
-            worklist.add(node);
-        }
-    }
-
-    public void replaced(Node newNode, Node oldNode, EdgeType... edges) {
-        this.replaced(newNode, oldNode, false, edges);
-    }
-
-    public void replaced(Node newNode, Node oldNode, boolean add, EdgeType... edges) {
-        visited.grow(newNode);
-        inQueue.grow(newNode);
-        worklist.remove(oldNode);
-        assert !worklist.contains(oldNode);
-        if (add) {
-            this.add(newNode);
-        }
-        for (EdgeType type : edges) {
-            switch (type) {
-                case INPUTS:
-                    for (Node n : newNode.inputs()) {
-                        doAdd(n);
-                    }
-                    break;
-                case PREDECESSORS:
-                    for (Node n : newNode.predecessors()) {
-                        doAdd(n);
-                    }
-                    break;
-                case USAGES:
-                    for (Node n : newNode.usages()) {
-                        doAdd(n);
-                    }
-                    break;
-                case SUCCESSORS:
-                    for (Node n : newNode.successors()) {
-                        doAdd(n);
-                    }
-                    break;
-            }
-        }
-    }
-
-    public boolean isMarked(Node node) {
-        return visited.isMarked(node);
-    }
-
-    private class QueueConsumingIterator implements Iterator<Node> {
-        private final Queue<Node> queue;
-
-        public QueueConsumingIterator(Queue<Node> queue) {
-            this.queue = queue;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return iterationLimit > 0 && !queue.isEmpty();
-        }
-
-        @Override
-        public Node next() {
-            if (iterationLimit-- <= 0) {
-                throw new NoSuchElementException();
-            }
-            Node node = queue.remove();
-            inQueue.clear(node);
-            return node;
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-    }
-
-    @Override
-    public Iterator<Node> iterator() {
-        return new QueueConsumingIterator(worklist);
-    }
-
-    private static class UnmarkedNodeIterator implements Iterator<Node> {
-        private final NodeBitMap visited;
-        private Iterator<Node> nodes;
-        private Node nextNode;
-
-        public UnmarkedNodeIterator(NodeBitMap visited, Iterator<Node> nodes) {
-            this.visited = visited;
-            this.nodes = nodes;
-            forward();
-        }
-
-        private void forward() {
-            do {
-                if (!nodes.hasNext()) {
-                    nextNode = null;
-                    return;
-                }
-                nextNode = nodes.next();
-            } while (visited.isMarked(nextNode));
-        }
-
-        @Override
-        public boolean hasNext() {
-            return nextNode != null;
-        }
-
-        @Override
-        public Node next() {
-            try {
-                return nextNode;
-            } finally {
-                forward();
-            }
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-
-    }
-
-    public Iterable<Node> unmarkedNodes() {
-        return new Iterable<Node>() {
-            @Override
-            public Iterator<Node> iterator() {
-                return new UnmarkedNodeIterator(visited, visited.graph().getNodes().iterator());
-            }
-        };
-    }
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Op.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-
-public interface Op {
-
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/StartNode.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-public class StartNode extends Node {
-
-    private static final int INPUT_COUNT = 0;
-
-    private static final int SUCCESSOR_COUNT = 1;
-    private static final int SUCCESSOR_START = 0;
-
-    @Override
-    protected int inputCount() {
-        return super.inputCount() + INPUT_COUNT;
-    }
-
-    @Override
-    protected int successorCount() {
-        return super.successorCount() + SUCCESSOR_COUNT;
-    }
-
-    public Node start() {
-        return successors().get(super.successorCount() + SUCCESSOR_START);
-    }
-
-    public Node setStart(Node next) {
-        return successors().set(super.successorCount() + SUCCESSOR_START, next);
-    }
-
-    StartNode(Graph graph) {
-        super(INPUT_COUNT, SUCCESSOR_COUNT, graph);
-    }
-
-    @Override
-    public Node replace(Node other) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void delete() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Node copy(Graph into) {
-        throw new UnsupportedOperationException();
-    }
-
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/VerificationListener.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.graph;
-
-
-public interface VerificationListener {
-    void verificationFailed(Node n, String message);
-}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/package-info.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/**
- * This package contains the Node base class and the Graph container class of the Graal IR.
- *
- * @author Gilles Duboscq
- * @author Lukas Stadler
- * @author Thomas Wuerthinger
- */
-package com.oracle.max.graal.graph;
--- a/graal/com.oracle.max.graal.graph/test/com/oracle/graal/graph/NodeTest.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2011, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.graph;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import com.oracle.max.graal.graph.Graph;
-import com.oracle.max.graal.graph.Node;
-
-public class NodeTest {
-
-    @Test
-    public void testBasics() {
-
-        Graph g1 = new Graph();
-
-        DummyNode n1 = new DummyNode(2, 1, g1);
-        DummyNode n2 = new DummyNode(1, 1, g1);
-        DummyNode n3 = new DummyNode(0, 0, g1);
-        n2.dummySetInput(0, Node.Null);
-        n2.dummySetSuccessor(0, n3);
-
-        assertSame(Node.Null, n2.inputs().get(0));
-        assertSame(n3, n2.successors().get(0));
-        assertEquals(n1.inputs().size(), 2);
-        assertEquals(n1.successors().size(), 1);
-    }
-
-    @Test
-    public void testReplace() {
-        Graph g2 = new Graph();
-
-        DummyOp2 o1 = new DummyOp2(Node.Null, Node.Null, g2);
-        DummyOp2 o2 = new DummyOp2(o1, Node.Null, g2);
-        DummyOp2 o3 = new DummyOp2(o2, Node.Null, g2);
-        DummyOp2 o4 = new DummyOp2(Node.Null, Node.Null, g2);
-
-        o2.replace(o4);
-
-        assertFalse(o3.inputs().contains(o2));
-        assertTrue(o3.inputs().contains(o4));
-        assertTrue(o4.usages().contains(o3));
-    }
-
-    private static class DummyNode extends Node {
-
-        private final int inputCount;
-        private final int successorCount;
-
-        public DummyNode(int inputCount, int successorCount, Graph graph) {
-            super(inputCount, successorCount, graph);
-            this.inputCount = inputCount;
-            this.successorCount = successorCount;
-        }
-
-        @Override
-        protected int inputCount() {
-            return super.inputCount() + inputCount;
-        }
-
-        @Override
-        protected int successorCount() {
-            return super.inputCount() + successorCount;
-        }
-
-        public void dummySetInput(int idx, Node n) {
-            inputs().set(idx, n);
-        }
-
-        public void dummySetSuccessor(int idx, Node n) {
-            successors().set(idx, n);
-        }
-
-        @Override
-        public Node copy(Graph into) {
-            return new DummyNode(inputCount, successorCount, into);
-        }
-
-    }
-
-    public static class DummyOp2 extends Node {
-
-        public static final int SUCCESSOR_COUNT = 0;
-        public static final int INPUT_COUNT = 2;
-        public static final int INPUT_X = 0;
-        public static final int INPUT_Y = 1;
-
-        public DummyOp2(Node x, Node y, Graph graph) {
-            this(graph);
-            setX(x);
-            setY(y);
-        }
-        public DummyOp2(Graph graph) {
-            super(INPUT_COUNT, SUCCESSOR_COUNT, graph);
-        }
-
-        @Override
-        protected int inputCount() {
-            return super.inputCount() + INPUT_COUNT;
-        }
-
-        public Node x() {
-            return inputs().get(super.inputCount() + INPUT_X);
-        }
-
-        public Node y() {
-            return inputs().get(super.inputCount() + INPUT_Y);
-        }
-
-        public Node setX(Node n) {
-            return inputs().set(super.inputCount() + INPUT_X, n);
-        }
-
-        public Node setY(Node n) {
-            return inputs().set(super.inputCount() + INPUT_Y, n);
-        }
-
-        @Override
-        public Node copy(Graph into) {
-            return new DummyOp2(into);
-        }
-    }
-}
--- a/graal/com.oracle.max.graal.graphviz/.classpath	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.graphviz/.classpath	Tue Jun 21 11:16:21 2011 +0200
@@ -1,9 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="test"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graph"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="test"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graph"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- a/graal/com.oracle.max.graal.runtime/.classpath	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/.classpath	Tue Jun 21 11:16:21 2011 +0200
@@ -7,5 +7,6 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.asmdis"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.cri"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.compiler"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/com.oracle.max.graal.graph"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotMethodResolvedImpl.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotMethodResolvedImpl.java	Tue Jun 21 11:16:21 2011 +0200
@@ -25,6 +25,7 @@
 import java.lang.reflect.*;
 
 import com.oracle.max.graal.compiler.debug.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 
@@ -126,7 +127,7 @@
         throw new UnsupportedOperationException("jniSymbol");
     }
 
-    public CiBitMap[] livenessMap() {
+    public BitMap[] livenessMap() {
         return null;
     }
 
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotMethodUnresolved.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotMethodUnresolved.java	Tue Jun 21 11:16:21 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.max.graal.runtime;
 
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 
@@ -114,7 +115,7 @@
     }
 
     @Override
-    public CiBitMap[] livenessMap() {
+    public BitMap[] livenessMap() {
         return null;
     }
 
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java	Tue Jun 21 11:16:21 2011 +0200
@@ -26,6 +26,8 @@
 import java.lang.reflect.*;
 import java.util.*;
 
+import com.oracle.max.graal.compiler.ir.*;
+import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ci.CiTargetMethod.Call;
 import com.sun.cri.ci.CiTargetMethod.DataPatch;
@@ -135,11 +137,6 @@
         return ((HotSpotTypeResolved) method.holder()).constantPool();
     }
 
-    @Override
-    public RiOsrFrame getOsrFrame(RiMethod method, int bci) {
-        return null;
-    }
-
     public Class<?> getJavaClass(CiConstant c) {
         return null;
     }
@@ -242,4 +239,36 @@
     public Object asJavaObject(CiConstant c) {
         return null;
     }
+
+    @Override
+    public Node lower(Node n, CiLoweringTool tool) {
+        if (n instanceof LoadField) {
+            LoadField field = (LoadField) n;
+            if (field.isVolatile()) {
+                return null;
+            }
+            Graph graph = field.graph();
+            int displacement = ((HotSpotField) field.field()).offset();
+            assert field.kind != CiKind.Illegal;
+            MemoryRead memoryRead = new MemoryRead(field.field().kind(), displacement, graph);
+            memoryRead.setGuard((GuardNode) tool.createGuard(new IsNonNull(field.object(), graph)));
+            memoryRead.setNext(field.next());
+            memoryRead.setLocation(field.object());
+            return memoryRead;
+        } else if (n instanceof StoreField) {
+            return null;
+//            StoreField field = (StoreField) n;
+//            if (field.isVolatile()) {
+//                return null;
+//            }
+//            Graph graph = field.graph();
+//            int displacement = ((HotSpotField) field.field()).offset();
+//            MemoryWrite memoryWrite = new MemoryWrite(field.field().kind(), field.value(), displacement, graph);
+//            memoryWrite.setGuard((GuardNode) tool.createGuard(new IsNonNull(field.object(), graph)));
+//            memoryWrite.setNext(field.next());
+//            memoryWrite.setLocation(field.object());
+//            return memoryWrite;
+        }
+        return null;
+    }
 }
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java	Tue Jun 21 11:13:52 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java	Tue Jun 21 11:16:21 2011 +0200
@@ -157,7 +157,7 @@
                         if (!GraalOptions.QuietBailout && !(result.bailout() instanceof JSRNotSupportedBailout)) {
                             StringWriter out = new StringWriter();
                             result.bailout().printStackTrace(new PrintWriter(out));
-                            TTY.println("Bailout:\n" + out.toString());
+                            TTY.println("Bailout while compiling " + method + " :\n" + out.toString());
                             if (cause != null) {
                                 Logger.info("Trace for cause: ");
                                 for (StackTraceElement e : cause.getStackTrace()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runavrora.sh	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,21 @@
+#!/bin/bash
+if [ -z "${JDK7}" ]; then
+  echo "JDK7 is not defined."
+  exit 1;
+fi
+if [ -z "${MAXINE}" ]; then
+  echo "MAXINE is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ -z "${GRAAL}" ]; then
+  echo "GRAAL is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ -z "${DACAPO}" ]; then
+  echo "DACAPO is not defined. It must point to a Dacapo benchmark directory."
+  exit 1;
+fi
+COMMAND="${JDK7G}/bin/java -client -d64 -graal -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar -XX:-GraalBailoutIsFatal -G:-QuietBailout $* Harness --preserve -n 5 avrora"
+echo $COMMAND
+$COMMAND
+echo $COMMAND
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runfilter.sh	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,21 @@
+#!/bin/bash
+if [ -z "${JDK7}" ]; then
+  echo "JDK7 is not defined."
+  exit 1;
+fi
+if [ -z "${MAXINE}" ]; then
+  echo "MAXINE is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ -z "${GRAAL}" ]; then
+  echo "GRAAL is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ $# -lt 1 ]; then
+  echo "You must provide at least a filter option"
+  exit 1;
+fi
+FILTER=$1
+shift 1
+TESTDIR=${MAXINE}/com.oracle.max.vm/test
+${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $@ test.com.sun.max.vm.compiler.JavaTester -filter=${FILTER} -verbose=1 -gen-run-scheme=false -run-scheme-package=all $@ ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads
--- a/runtests.sh	Tue Jun 21 11:13:52 2011 +0200
+++ b/runtests.sh	Tue Jun 21 11:16:21 2011 +0200
@@ -12,4 +12,4 @@
   exit 1;
 fi
 TESTDIR=${MAXINE}/com.oracle.max.vm/test
-${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -XX:+PrintCompilation -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $@ test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads
+${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -XX:+PrintCompilation -XX:CompileOnly=jtt $@ -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $@ test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/build.xml	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="com.sun.hotspot.igv.graal" default="netbeans" basedir=".">
+    <description>Builds, tests, and runs the project com.sun.hotspot.igv.graal.</description>
+    <import file="nbproject/build-impl.xml"/>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/manifest.mf	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.graal
+OpenIDE-Module-Layer: com/sun/hotspot/igv/graal/layer.xml
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/graal/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
+***         EDIT ../build.xml INSTEAD         ***
+-->
+<project name="com.sun.hotspot.igv.graal-impl" basedir="..">
+    <fail message="Please build using Ant 1.7.1 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.7.1"/>
+            </not>
+        </condition>
+    </fail>
+    <property file="nbproject/private/suite-private.properties"/>
+    <property file="nbproject/suite.properties"/>
+    <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
+    <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
+    <property file="${suite.dir}/nbproject/platform.properties"/>
+    <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+        <attribute name="name"/>
+        <attribute name="value"/>
+        <sequential>
+            <property name="@{name}" value="${@{value}}"/>
+        </sequential>
+    </macrodef>
+    <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
+        <attribute name="property"/>
+        <attribute name="value"/>
+        <sequential>
+            <property name="@{property}" value="@{value}"/>
+        </sequential>
+    </macrodef>
+    <property file="${user.properties.file}"/>
+    <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+    <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+    <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+    <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
+        <condition>
+            <not>
+                <contains string="${cluster.path.evaluated}" substring="platform"/>
+            </not>
+        </condition>
+    </fail>
+    <import file="${harness.dir}/build.xml"/>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=abfbe04d
+build.xml.script.CRC32=3534d355
+build.xml.stylesheet.CRC32=a56c6a5b@1.45.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=abfbe04d
+nbproject/build-impl.xml.script.CRC32=2867f2d5
+nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.apisupport.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+            <code-name-base>com.sun.hotspot.igv.graal</code-name-base>
+            <suite-component/>
+            <module-dependencies>
+                <dependency>
+                    <code-name-base>com.sun.hotspot.igv.data</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.0</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>com.sun.hotspot.igv.graph</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.0</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>com.sun.hotspot.igv.graphtotext</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.0</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.0</specification-version>
+                    </run-dependency>
+                </dependency>
+            </module-dependencies>
+            <public-packages/>
+        </data>
+    </configuration>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/suite.properties	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,1 @@
+suite.dir=${basedir}/..
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,1 @@
+com.sun.hotspot.igv.graal.GraalGraphToTextConverter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/Bundle.properties	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,1 @@
+OpenIDE-Module-Name=Graal Compiler Support
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/GraalGraphToTextConverter.java	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 1998, 2007, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.hotspot.igv.graal;
+
+import com.sun.hotspot.igv.data.InputBlock;
+import com.sun.hotspot.igv.data.InputEdge;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputNode;
+import com.sun.hotspot.igv.data.Properties;
+import com.sun.hotspot.igv.data.Properties.PropertyMatcher;
+import com.sun.hotspot.igv.graph.Diagram;
+import com.sun.hotspot.igv.graph.Figure;
+import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter;
+import com.sun.hotspot.igv.structuredtext.Element;
+import com.sun.hotspot.igv.structuredtext.MultiElement;
+import com.sun.hotspot.igv.structuredtext.SimpleElement;
+import com.sun.hotspot.igv.structuredtext.StructuredText;
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyleContext;
+
+/**
+ * @author Peter Hofer
+ * @author Thomas Wuerthinger
+ */
+public class GraalGraphToTextConverter implements GraphToTextConverter {
+
+    private Map<InputNode, Set<Figure>> map;
+    private Map<InputNode, List<InputEdge>> incomingEdges;
+    private Map<InputNode, List<InputEdge>> outgoingEdges;
+    private InputGraph graph;
+
+    private Collection<InputNode> sortNodes(Collection<InputNode> nodes) {
+        List<InputNode> result = new ArrayList<InputNode>(nodes);
+        Collections.sort(result, InputNode.getPropertyComparator("idx"));
+        return result;
+    }
+
+    public StructuredText convert(InputGraph graph, Diagram diagram) {
+
+        this.graph = graph;
+        map = diagram.calcSourceToFigureRelation();
+
+        incomingEdges = graph.findAllIngoingEdges();
+        outgoingEdges = graph.findAllOutgoingEdges();
+
+        final StructuredText result = new StructuredText(graph.getName());
+
+        for (InputBlock b : graph.getBlocks()) {
+            result.addChild(new SimpleElement("Block " + b.getName() + "\n"));
+            for (InputNode n : sortNodes(b.getNodes())) {
+                result.addChild(getNodeElement(n));
+            }
+        }
+
+        boolean first = true;
+        for (InputNode n : sortNodes(graph.getNodes())) {
+            if (graph.getBlock(n) == null) {
+                if (first) {
+                    first = false;
+                    result.addChild(new SimpleElement("No block: \n"));
+                }
+                result.addChild(getNodeElement(n));
+            }
+        }
+
+        return result;
+    }
+
+    private Element getNodeNameElement(InputNode n) {
+
+        final SimpleElement name = new SimpleElement(n.getProperties().get("idx") + " " + n.getProperties().get("name"), calcStyle(n));
+        name.addSource(n.getId());
+        return name;
+    }
+
+    private Element getNodeShortElement(InputNode n) {
+        final SimpleElement id = new SimpleElement(n.getProperties().get("idx"), calcStyle(n));
+        id.addSource(n.getId());
+        return id;
+    }
+
+    private Element getNodeElement(InputNode n) {
+
+        final MultiElement result = new MultiElement();
+
+        result.print("\t");
+        result.addChild(getNodeNameElement(n));
+
+        result.print(" :::");
+
+        // NOTE: lists in ingoingEdges/outgoingEdges are sorted by from/to slot
+        //       and for slots that are connected with multiple edges, by
+        //       from/to node
+
+        int succCount = Integer.parseInt(n.getProperties().get("successorCount"));
+        InputEdge[] outgoing = outgoingEdges.get(n).toArray(new InputEdge[0]);
+
+        int i = 0;
+        if (outgoing.length > 0 && outgoing[0].getFromIndex() < succCount) {
+            // Node has successors (each connected to a different slot)
+            result.print("  Succ = [");
+            while (i < outgoing.length && outgoing[i].getFromIndex() < succCount) {
+                result.print(" ");
+                result.addChild(getNodeShortElement(graph.getNode(outgoing[i].getTo())));
+                result.print(" ");
+                i++;
+            }
+            result.print("]");
+        }
+        if (i < outgoing.length) {
+            // Node has usages (all connected to a single slot)
+            result.print("  Usages = [");
+            while (i < outgoing.length) {
+                result.print(" ");
+                result.addChild(getNodeShortElement(graph.getNode(outgoing[i].getTo())));
+                result.print(" ");
+                i++;
+            }
+            result.print("]");
+        }
+
+        int predCount = Integer.parseInt(n.getProperties().get("predecessorCount"));
+        InputEdge[] incoming = incomingEdges.get(n).toArray(new InputEdge[0]);
+
+        int j = 0;
+        if (incoming.length > 0 && incoming[0].getToIndex() < predCount) {
+            // Node has predecessors (each connected to a different slot)
+            result.print("  Pred = [");
+            while (j < incoming.length && incoming[j].getToIndex() < predCount) {
+                result.print(" ");
+                result.addChild(getNodeShortElement(graph.getNode(incoming[j].getFrom())));
+                result.print(" ");
+                j++;
+            }
+            result.print("]");
+        }
+        if (j < incoming.length) {
+            // Node has inputs (each connected to a different slot)
+            result.print("  Inputs = [");
+            while (j < incoming.length) {
+                result.print(" ");
+                result.addChild(getNodeShortElement(graph.getNode(incoming[j].getFrom())));
+                result.print(" ");
+                j++;
+            }
+            result.print("]");
+        }
+
+        result.print("\n");
+        return result;
+    }
+    private static final PropertyMatcher MATCHER = new Properties.StringPropertyMatcher("origin", "Graal");
+
+    public boolean canConvert(InputGraph graph) {
+        return graph.getGroup().getProperties().selectSingle(MATCHER) != null;
+    }
+
+    private Color calcColor(InputNode node) {
+        Set<Figure> figureSet = this.map.get(node);
+        if (figureSet != null && figureSet.size() == 1) {
+            return figureSet.iterator().next().getColor();
+        } else {
+            return Color.WHITE;
+        }
+    }
+
+    private Color lessColor(Color c) {
+        return new Color(255 - (255 - c.getRed()) / 4, 255 - (255 - c.getGreen()) / 4, 255 - (255 - c.getBlue()) / 4);
+    }
+
+    private Style calcStyle(InputNode node) {
+        Color c = calcColor(node);
+        Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
+        Style newStyle = StyleContext.getDefaultStyleContext().addStyle(null, defaultStyle);
+
+        StyleConstants.setBackground(newStyle, lessColor(c));
+        return newStyle;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/color.filter	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,9 @@
+colorize("name", ".*", white);
+colorize("name", "StartNode|EndNode|LoopBegin|LoopEnd|Return", red);
+colorize("name", "Phi:.*", magenta);
+colorize("name", "FrameState@.*", new java.awt.Color(0.5, 0.8, 1.0));
+colorize("name", "If", pink);
+colorize("name", "const.*", new java.awt.Color(0.7, 0.7, 0.7));
+colorize("name", "Local", new java.awt.Color(0.85, 0.85, 0.85));
+colorize("name", "\\+|-|\\*|/", cyan);
+colorize("name", "Comp .*", yellow);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/layer.xml	Tue Jun 21 11:16:21 2011 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
+<filesystem>
+    <folder name="Filters">
+        <file name="Graal Coloring" url="filters/color.filter">
+            <attr name="enabled" boolvalue="false"/>
+        </file>
+    </folder>
+</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/Maxine/build.xml	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
-<!-- for some information on what you could do (e.g. targets to override). -->
-<!-- If you delete this file and reopen the project it will be recreated. -->
-<project name="com.sun.hotspot.igv.maxine" default="netbeans" basedir=".">
-    <description>Builds, tests, and runs the project com.sun.hotspot.igv.maxine.</description>
-    <import file="nbproject/build-impl.xml"/>
-</project>
--- a/src/share/tools/IdealGraphVisualizer/Maxine/manifest.mf	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-Manifest-Version: 1.0
-OpenIDE-Module: com.sun.hotspot.igv.maxine
-OpenIDE-Module-Layer: com/sun/hotspot/igv/maxine/layer.xml
-OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/maxine/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.0
-
--- a/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/build-impl.xml	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT  ***
-***         EDIT ../build.xml INSTEAD         ***
--->
-<project name="com.sun.hotspot.igv.maxine-impl" basedir="..">
-    <fail message="Please build using Ant 1.7.1 or higher.">
-        <condition>
-            <not>
-                <antversion atleast="1.7.1"/>
-            </not>
-        </condition>
-    </fail>
-    <property file="nbproject/private/suite-private.properties"/>
-    <property file="nbproject/suite.properties"/>
-    <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
-    <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
-    <property file="${suite.dir}/nbproject/platform.properties"/>
-    <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
-        <attribute name="name"/>
-        <attribute name="value"/>
-        <sequential>
-            <property name="@{name}" value="${@{value}}"/>
-        </sequential>
-    </macrodef>
-    <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
-        <attribute name="property"/>
-        <attribute name="value"/>
-        <sequential>
-            <property name="@{property}" value="@{value}"/>
-        </sequential>
-    </macrodef>
-    <property file="${user.properties.file}"/>
-    <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
-    <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
-    <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
-    <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
-        <condition>
-            <not>
-                <contains string="${cluster.path.evaluated}" substring="platform"/>
-            </not>
-        </condition>
-    </fail>
-    <import file="${harness.dir}/build.xml"/>
-</project>
--- a/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/genfiles.properties	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=44af392c
-nbproject/build-impl.xml.script.CRC32=1a1fcc4d
-nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- a/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.properties	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-javac.source=1.5
-javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.xml	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
-    <type>org.netbeans.modules.apisupport.project</type>
-    <configuration>
-        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
-            <code-name-base>com.sun.hotspot.igv.maxine</code-name-base>
-            <suite-component/>
-            <module-dependencies>
-                <dependency>
-                    <code-name-base>com.sun.hotspot.igv.data</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>1.0</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>com.sun.hotspot.igv.graph</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>1.0</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>com.sun.hotspot.igv.graphtotext</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>1.0</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>1.0</specification-version>
-                    </run-dependency>
-                </dependency>
-            </module-dependencies>
-            <public-packages/>
-        </data>
-    </configuration>
-</project>
--- a/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/suite.properties	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/Maxine/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.sun.hotspot.igv.maxine.CirGraphToTextConverter
\ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/Bundle.properties	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-OpenIDE-Module-Name=Maxine
--- a/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/CirGraphToTextConverter.java	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 1998, 2007, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.hotspot.igv.maxine;
-
-import com.sun.hotspot.igv.data.InputEdge;
-import com.sun.hotspot.igv.data.InputGraph;
-import com.sun.hotspot.igv.data.InputNode;
-import com.sun.hotspot.igv.data.Pair;
-import com.sun.hotspot.igv.data.Properties;
-import com.sun.hotspot.igv.data.Properties.PropertyMatcher;
-import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher;
-import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher;
-import com.sun.hotspot.igv.graph.Diagram;
-import com.sun.hotspot.igv.graph.Figure;
-import com.sun.hotspot.igv.graphtotext.BFSGraphToTextConverter;
-import com.sun.hotspot.igv.graphtotext.services.AbstractGraphToTextVisitor;
-import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter;
-import com.sun.hotspot.igv.graphtotext.services.GraphToTextVisitor;
-import com.sun.hotspot.igv.structuredtext.Element;
-import com.sun.hotspot.igv.structuredtext.MultiElement;
-import com.sun.hotspot.igv.structuredtext.SimpleElement;
-import com.sun.hotspot.igv.structuredtext.StructuredText;
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.swing.text.Style;
-import javax.swing.text.StyleConstants;
-import javax.swing.text.StyleContext;
-
-/**
- *
- * @author Thomas Wuerthinger
- */
-public class CirGraphToTextConverter implements GraphToTextConverter {
-
-    private static final String CALL_OPERATOR = " \u2022 ";
-
-    private Map<InputNode, Set<Figure>> map;
-    private InputGraph graph;
-
-    public StructuredText convert(InputGraph graph, Diagram diagram) {
-        map = diagram.calcSourceToFigureRelation();
-        this.graph = graph;
-        
-        BFSGraphToTextConverter converter = new BFSGraphToTextConverter(nodeVisitor);
-        converter.registerVisitor(localVariableVisitor, new StringPropertyMatcher("type", "LocalVariable"));
-        converter.registerVisitor(parameterVisitor, new StringPropertyMatcher("type", "Parameter"));
-        converter.registerVisitor(closureVisitor, new RegexpPropertyMatcher("type", "Closure"));
-        converter.registerVisitor(continuationVisitor, new RegexpPropertyMatcher("type", "Continuation"));
-        converter.registerVisitor(callVisitor, new RegexpPropertyMatcher("type", "Call"));
-        converter.registerVisitor(blockVisitor, new RegexpPropertyMatcher("type", "Block"));
-        return converter.convert(graph, diagram);
-    }
-    private GraphToTextVisitor nodeVisitor = new NodeVisitor();
-    private GraphToTextVisitor localVariableVisitor = new NodeVisitor();
-    private GraphToTextVisitor parameterVisitor = new NodeVisitor();
-    private GraphToTextVisitor closureVisitor = new ClosureVisitor("proc");
-    private GraphToTextVisitor continuationVisitor = new ClosureVisitor("cont");
-    private GraphToTextVisitor callVisitor = new CallVisitor();
-    private GraphToTextVisitor blockVisitor = new BlockVisitor();
-
-    private void printOffset(List<InputEdge> path, MultiElement elem) {
-        for (int i = 0; i < path.size(); i++) {
-            InputEdge cur = path.get(i);
-            InputNode fromNode = graph.getNode(cur.getFrom());
-            SimpleElement simpleElem = new SimpleElement(" ", calcStyle(fromNode));
-            simpleElem.addSource(fromNode.getId());
-            elem.addChild(simpleElem);
-        }
-    }
-
-    private class NodeVisitor extends AbstractGraphToTextVisitor {
-
-        @Override
-        public Element cyclicVisit(InputNode node, List<InputEdge> path) {
-            SimpleElement elem = new SimpleElement(node.getProperties().get("name"), calcStyle(node));
-            elem.addSource(node.getId());
-            return elem;
-        }
-    }
-    
-    private Color calcColor(InputNode node) {
-        Set<Figure> figureSet = this.map.get(node);
-        if(figureSet != null && figureSet.size() == 1) {
-            return figureSet.iterator().next().getColor();
-        } else {
-            return Color.WHITE;
-        }
-    }
-    
-    private Style calcStyle(InputNode node) {
-        Color c = calcColor(node);
-        Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
-        Style newStyle = StyleContext.getDefaultStyleContext().addStyle(null, defaultStyle);
-        
-        StyleConstants.setBackground(newStyle, c);
-        return newStyle;
-    }
-
-    private class ClosureVisitor extends AbstractGraphToTextVisitor {
-
-        private String label;
-
-        protected String getLabel(InputNode node) {
-                return label;
-        }
-
-        public ClosureVisitor(String label) {
-            this.label = label;
-        }
-
-        @Override
-        public Element cyclicVisit(InputNode node, List<InputEdge> path) {
-            return SimpleElement.EMPTY;
-        }
-
-        @Override
-        public Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children) {
-            MultiElement e = new MultiElement(calcStyle(node));
-            e.print("{", node.getId());
-            e.print(getLabel(node), node.getId());
-
-            e.print("[", node.getId());
-            for (int i = 0; i < children.size() - 1; i++) {
-                Pair<InputEdge, Element> p = children.get(i);
-                e.addChild(p.getRight());
-                if (i != children.size() - 2) {
-                    e.print("|", node.getId());
-                }
-            }
-            e.print("]", node.getId());
-            e.print(CALL_OPERATOR, node.getId());
-            e.println();
-            List<InputEdge> newPath = new ArrayList<InputEdge>(path);
-            newPath.add(children.get(children.size() - 1).getLeft());
-            printOffset(newPath, e);
-            
-            MultiElement childElement = new MultiElement("...");
-            childElement.addChild(children.get(children.size() - 1).getRight());
-            e.addChild(childElement);
-            
-            e.println();
-            printOffset(path, e);
-            e.print("}", node.getId());
-            MultiElement resElem = new MultiElement();
-            resElem.addChild(e);
-            return resElem;
-        }
-    }
-
-    private class CallVisitor extends AbstractGraphToTextVisitor {
-
-        @Override
-        public Element cyclicVisit(InputNode node, List<InputEdge> path) {
-            return SimpleElement.EMPTY;
-        }
-
-        @Override
-        public Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children) {
-            MultiElement e = new MultiElement(calcStyle(node));
-            e.print("(", node.getId());
-            for (int i = 0; i < children.size(); i++) {
-                Pair<InputEdge, Element> p = children.get(i);
-                e.addChild(p.getRight());
-                if (i != children.size() - 1) {
-                    e.print("|", node.getId());
-                }
-            }
-            e.print(")", node.getId());
-            MultiElement resElem = new MultiElement();
-            resElem.addChild(e);
-            return resElem;
-        }
-    }
-
-    private class BlockVisitor extends ClosureVisitor {
-
-        public BlockVisitor() {
-            super("block");
-        }
-        
-        @Override
-        protected String getLabel(InputNode node) {
-            return node.getProperties().get("name");
-        }
-
-        @Override
-        public Element cyclicVisit(InputNode node, List<InputEdge> path) {
-            MultiElement e = new MultiElement(calcStyle(node));
-            e.print(getLabel(node), node);
-            return e;
-        }
-
-        @Override
-        public Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children) {
-            return super.visit(node, path, children);
-        }
-    }
-
-    private static final PropertyMatcher MATCHER = new Properties.RegexpPropertyMatcher("type", ".*CIR.*");
-    public boolean canConvert(InputGraph graph) {
-        return graph.getGroup().getProperties().selectSingle(MATCHER) != null;
-    }
-}
--- a/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/color.filter	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-colorize("name", ".*", white);
-colorize("name", "cont",new  java.awt.Color(1.0, 0.8, 0.8));
-colorize("name", "proc", new  java.awt.Color(0.8, 0.8, 1.0));
-colorize("name", "call", new  java.awt.Color(0.9, 0.9, 0.9));
-colorize("name", "block", new java.awt.Color(1.0, 1.0, 0.6)); 
-colorize("class", ".*Constant", new java.awt.Color(0.7, 1.0, 0.9)); 
-colorize("class", ".*Parameter", new java.awt.Color(0.9, 1.0, 0.7)); 
-colorize("class", ".*Variable", new java.awt.Color(0.7, 1.0, 0.7)); 
-colorize("class", ".*cir\.snippet.*", yellow); 
\ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/structural.filter	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-split("class", ".*Constant");
-split("class", ".*Variable");
-split("class", ".*Parameter");
-split("class", ".*Snippet");
-split("class", ".*Switch");
-split("class", ".*cir\.snippet.*"); 
-split("class", ".*cir\.builtin.*"); 
\ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/layer.xml	Tue Jun 21 11:13:52 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
-<filesystem>
-      <folder name="Filters">
-        <file name="Maxine CIR Coloring" url="filters/color.filter">
-            <attr name="enabled" boolvalue="false"/>
-        </file>
-        <file name="Maxine CIR Structural Filter" url="filters/structural.filter">
-            <attr name="enabled" boolvalue="false"/>
-            <attr name="after" stringvalue="Maxine CIR Coloring"/>
-        </file>
-    </folder>	
-</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties	Tue Jun 21 11:13:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties	Tue Jun 21 11:16:21 2011 +0200
@@ -21,12 +21,12 @@
     ${project.com.sun.hotspot.igv.servercompilerscheduler}:\
     ${project.com.sun.hotspot.igv.filterwindow}:\
     ${project.com.sun.hotspot.igv.graphtotext}:\
-    ${project.com.sun.hotspot.igv.maxine}:\
     ${project.com.sun.hotspot.igv.java6scriptingproxy}:\
     ${project.com.sun.hotspot.igv.graphtexteditor}:\
     ${project.com.sun.hotspot.igv.structuredtext}:\
     ${project.com.sun.hotspot.igv.texteditor}:\
-    ${project.com.sun.hotspot.igv.selectioncoordinator}
+    ${project.com.sun.hotspot.igv.selectioncoordinator}:\
+    ${project.com.sun.hotspot.igv.graal}
 project.com.sun.hotspot.connection=NetworkConnection
 project.com.sun.hotspot.igv.bytecodes=Bytecodes
 project.com.sun.hotspot.igv.controlflow=ControlFlow
@@ -35,13 +35,13 @@
 project.com.sun.hotspot.igv.difference=Difference
 project.com.sun.hotspot.igv.filter=Filter
 project.com.sun.hotspot.igv.filterwindow=FilterWindow
+project.com.sun.hotspot.igv.graal=Graal
 project.com.sun.hotspot.igv.graph=Graph
 project.com.sun.hotspot.igv.graphtexteditor=GraphTextEditor
 project.com.sun.hotspot.igv.graphtotext=GraphToText
 project.com.sun.hotspot.igv.hierarchicallayout=HierarchicalLayout
 project.com.sun.hotspot.igv.java6scriptingproxy=Java6ScriptingProxy
 project.com.sun.hotspot.igv.layout=Layout
-project.com.sun.hotspot.igv.maxine=Maxine
 project.com.sun.hotspot.igv.rhino=RhinoScriptEngineProxy
 project.com.sun.hotspot.igv.selectioncoordinator=SelectionCoordinator
 project.com.sun.hotspot.igv.servercompilerscheduler=ServerCompiler
@@ -52,4 +52,4 @@
 project.com.sun.hotspot.igv.view=View
 project.com.sun.hotspot.igv.util=Util
 project.test=module1
-run.args = -J-client -J-Xms128m -J-Xmx512m -J-ea
+run.args = -J-client -J-Xms128m -J-Xmx1g -J-ea
--- a/src/share/vm/classfile/systemDictionary.hpp	Tue Jun 21 11:13:52 2011 +0200
+++ b/src/share/vm/classfile/systemDictionary.hpp	Tue Jun 21 11:16:21 2011 +0200
@@ -200,7 +200,7 @@
   template(CiTargetMethod_Safepoint_klass, com_sun_cri_ci_CiTargetMethod_Safepoint,                 Opt) \
   template(CiTargetMethod_ExceptionHandler_klass, com_sun_cri_ci_CiTargetMethod_ExceptionHandler,   Opt) \
   template(CiTargetMethod_Mark_klass,    com_sun_cri_ci_CiTargetMethod_Mark,                        Opt) \
-  template(CiBitMap_klass,               com_sun_cri_ci_CiBitMap,                                   Opt) \
+  template(GraalBitMap_klass,            com_oracle_max_graal_graph_BitMap,                         Opt) \
   template(CiDebugInfo_klass,            com_sun_cri_ci_CiDebugInfo,                                Opt) \
   template(CiFrame_klass,                com_sun_cri_ci_CiFrame,                                    Opt) \
   template(CiValue_klass,                com_sun_cri_ci_CiValue,                                    Opt) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Tue Jun 21 11:13:52 2011 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Tue Jun 21 11:16:21 2011 +0200
@@ -286,7 +286,7 @@
   template(com_sun_cri_ci_CiTargetMethod_Safepoint,   "com/sun/cri/ci/CiTargetMethod$Safepoint")                        \
   template(com_sun_cri_ci_CiTargetMethod_ExceptionHandler, "com/sun/cri/ci/CiTargetMethod$ExceptionHandler")            \
   template(com_sun_cri_ci_CiTargetMethod_Mark,        "com/sun/cri/ci/CiTargetMethod$Mark")                             \
-  template(com_sun_cri_ci_CiBitMap,                   "com/sun/cri/ci/CiBitMap")                                        \
+  template(com_oracle_max_graal_graph_BitMap,         "com/oracle/max/graal/graph/BitMap")                              \
   template(com_sun_cri_ci_CiDebugInfo,                "com/sun/cri/ci/CiDebugInfo")                                     \
   template(com_sun_cri_ci_CiFrame,                    "com/sun/cri/ci/CiFrame")                                         \
   template(com_sun_cri_ci_CiValue,                    "com/sun/cri/ci/CiValue")                                         \
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Tue Jun 21 11:13:52 2011 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Tue Jun 21 11:16:21 2011 +0200
@@ -55,11 +55,11 @@
 static bool is_bit_set(oop bit_map, int i) {
   const int MapWordBits = 64;
   if (i < MapWordBits) {
-    jlong low = CiBitMap::low(bit_map);
+    jlong low = GraalBitMap::low(bit_map);
     return (low & (1LL << i)) != 0;
   } else {
     jint extra_idx = (i - MapWordBits) / MapWordBits;
-    arrayOop extra = (arrayOop) CiBitMap::extra(bit_map);
+    arrayOop extra = (arrayOop) GraalBitMap::extra(bit_map);
     assert(extra_idx >= 0 && extra_idx < extra->length(), "unexpected index");
     jlong word = ((jlong*) extra->base(T_LONG))[extra_idx];
     return (word & (1LL << (i % MapWordBits))) != 0;
@@ -73,7 +73,7 @@
   oop frame_map = (oop) CiDebugInfo::frameRefMap(debug_info);
 
   if (register_map != NULL) {
-    assert(CiBitMap::size(register_map) == (unsigned) NUM_CPU_REGS, "unexpected register_map length");
+    assert(GraalBitMap::size(register_map) == (unsigned) NUM_CPU_REGS, "unexpected register_map length");
     for (jint i = 0; i < NUM_CPU_REGS; i++) {
       bool is_oop = is_bit_set(register_map, i);
       VMReg reg = get_hotspot_reg(i);
@@ -87,7 +87,7 @@
   }
 
   if (frame_size > 0) {
-    assert(CiBitMap::size(frame_map) == frame_size / HeapWordSize, "unexpected frame_map length");
+    assert(GraalBitMap::size(frame_map) == frame_size / HeapWordSize, "unexpected frame_map length");
 
     for (jint i = 0; i < frame_size / HeapWordSize; i++) {
       bool is_oop = is_bit_set(frame_map, i);
@@ -100,7 +100,7 @@
       }
     }
   } else {
-    assert(frame_map == NULL || CiBitMap::size(frame_map) == 0, "cannot have frame_map for frames with size 0");
+    assert(frame_map == NULL || GraalBitMap::size(frame_map) == 0, "cannot have frame_map for frames with size 0");
   }
 
   return map;
--- a/src/share/vm/graal/graalJavaAccess.hpp	Tue Jun 21 11:13:52 2011 +0200
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Tue Jun 21 11:16:21 2011 +0200
@@ -139,13 +139,13 @@
   end_class                                                                             \
   start_class(CiDebugInfo)                                                              \
     oop_field(CiDebugInfo, codePos, "Lcom/sun/cri/ci/CiCodePos;")                       \
-    oop_field(CiDebugInfo, registerRefMap, "Lcom/sun/cri/ci/CiBitMap;")                 \
-    oop_field(CiDebugInfo, frameRefMap, "Lcom/sun/cri/ci/CiBitMap;")                    \
+    oop_field(CiDebugInfo, registerRefMap, "Lcom/oracle/max/graal/graph/BitMap;")       \
+    oop_field(CiDebugInfo, frameRefMap, "Lcom/oracle/max/graal/graph/BitMap;")          \
   end_class                                                                             \
-  start_class(CiBitMap)                                                                 \
-    int_field(CiBitMap, size)                                                           \
-    long_field(CiBitMap, low)                                                           \
-    oop_field(CiBitMap, extra, "[J")                                                    \
+  start_class(GraalBitMap)                                                              \
+    int_field(GraalBitMap, size)                                                        \
+    long_field(GraalBitMap, low)                                                        \
+    oop_field(GraalBitMap, extra, "[J")                                                 \
   end_class                                                                             \
   start_class(CiFrame)                                                                  \
     oop_field(CiFrame, values, "[Lcom/sun/cri/ci/CiValue;")                             \
@@ -216,7 +216,7 @@
   /* end*/
 
 #define START_CLASS(name)                       \
-  class name : AllStatic {                      \
+class name : AllStatic {                      \
   private:                                      \
     friend class GraalCompiler;                   \
     static void check(oop obj) { assert(obj != NULL, "NULL field access of class " #name); assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); } \
--- a/src/share/vm/runtime/arguments.cpp	Tue Jun 21 11:13:52 2011 +0200
+++ b/src/share/vm/runtime/arguments.cpp	Tue Jun 21 11:16:21 2011 +0200
@@ -2690,12 +2690,12 @@
       scp_p->add_prefix(temp);
       sprintf(temp, "%s/com.oracle.max.asm/bin", maxine_dir);
       scp_p->add_prefix(temp);
+      sprintf(temp, "%s/com.oracle.max.graal.graph/bin", maxine_dir);
+      scp_p->add_prefix(temp);
       sprintf(temp, "%s/graal/com.oracle.max.graal.compiler/bin", graal_dir);
       scp_p->add_prefix(temp);
       sprintf(temp, "%s/graal/com.oracle.max.graal.runtime/bin", graal_dir);
       scp_p->add_prefix(temp);
-      sprintf(temp, "%s/graal/com.oracle.max.graal.graph/bin", graal_dir);
-      scp_p->add_prefix(temp);
       sprintf(temp, "%s/graal/com.oracle.max.graal.graphviz/bin", graal_dir);
       scp_p->add_prefix(temp);
       *scp_assembly_required_p = true;