changeset 2815:878bbf7dbf31

merge
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 30 May 2011 15:26:40 +0200
parents 31e0786a986c (current diff) 32fd5ea3a6cc (diff)
children 774d2bc06148
files graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java
diffstat 5 files changed, 60 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java	Mon May 30 15:19:26 2011 +0200
+++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java	Mon May 30 15:26:40 2011 +0200
@@ -283,7 +283,16 @@
         List<Node> instructions = b.getInstructions();
         List<Node> sortedInstructions = new ArrayList<Node>();
         assert !map.isMarked(b.firstNode()) && nodeToBlock.get(b.firstNode()) == b;
-        if (b.firstNode() != b.lastNode()) {
+
+        boolean scheduleFirst = true;
+
+        if (b.firstNode() == b.lastNode()) {
+            Node node = b.firstNode();
+            if (!(node instanceof Merge)) {
+                scheduleFirst = false;
+            }
+        }
+        if (scheduleFirst) {
             addToSorting(b, b.firstNode(), sortedInstructions, map);
         }
         for (Node i : instructions) {
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinterObserver.java	Mon May 30 15:19:26 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinterObserver.java	Mon May 30 15:26:40 2011 +0200
@@ -39,8 +39,14 @@
     private C1XCompilation currentCompilation;
     private CFGPrinter cfgPrinter;
     private ByteArrayOutputStream buffer = null;
+    private final OutputStream stream;
 
     public CFGPrinterObserver() {
+        this(CFGPrinter.cfgFileStream());
+    }
+
+    public CFGPrinterObserver(OutputStream stream) {
+        this.stream = stream;
     }
 
     @Override
@@ -96,13 +102,13 @@
 
         cfgPrinter.flush();
 
-        OutputStream cfgFileStream = CFGPrinter.cfgFileStream();
-        if (cfgFileStream != null) {
-            synchronized (cfgFileStream) {
+        if (stream != null) {
+            synchronized (stream) {
                 try {
-                    cfgFileStream.write(buffer.toByteArray());
+                    stream.write(buffer.toByteArray());
+                    stream.flush();
                 } catch (IOException e) {
-                    TTY.println("WARNING: Error writing CFGPrinter output for %s to disk: %s", event.getMethod(), e);
+                    TTY.println("WARNING: Error writing CFGPrinter output for %s: %s", event.getMethod(), e);
                 }
             }
         }
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java	Mon May 30 15:19:26 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java	Mon May 30 15:26:40 2011 +0200
@@ -200,7 +200,11 @@
         stream.printf("   <block name='%d'>%n", block.blockID());
         stream.printf("    <successors>%n");
         for (Block sux : block.getSuccessors()) {
-            stream.printf("     <successor name='%d'/>%n", sux.blockID());
+            if (sux.firstNode() instanceof LoopBegin && block.lastNode() instanceof LoopEnd) {
+                // Skip back edges.
+            } else {
+                stream.printf("     <successor name='%d'/>%n", sux.blockID());
+            }
         }
         stream.printf("    </successors>%n");
         stream.printf("    <nodes>%n");
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Mon May 30 15:19:26 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Mon May 30 15:26:40 2011 +0200
@@ -222,6 +222,10 @@
             TTY.println("BEGIN Generating LIR for block B" + block.blockID());
         }
 
+        if (block.blockPredecessors().size() > 1) {
+            lastState = null;
+        }
+
         for (Node instr : block.getInstructions()) {
             FrameState stateAfter = null;
             if (instr instanceof Instruction) {
@@ -686,11 +690,11 @@
         }
     }
 
-    protected CiValue emitXir(XirSnippet snippet, Instruction x, LIRDebugInfo info, RiMethod method, boolean setInstructionResult) {
+    protected CiValue emitXir(XirSnippet snippet, Value x, LIRDebugInfo info, RiMethod method, boolean setInstructionResult) {
         return emitXir(snippet, x, info, null, method, setInstructionResult, null);
     }
 
-    protected CiValue emitXir(XirSnippet snippet, Instruction instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod method, boolean setInstructionResult, List<CiValue> pointerSlots) {
+    protected CiValue emitXir(XirSnippet snippet, Value instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod method, boolean setInstructionResult, List<CiValue> pointerSlots) {
         if (C1XOptions.PrintXirTemplates) {
             TTY.println("Emit XIR template " + snippet.template.name);
         }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java	Mon May 30 15:19:26 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java	Mon May 30 15:26:40 2011 +0200
@@ -31,10 +31,33 @@
 /**
  * The {@code ArrayLength} instruction gets the length of an array.
  */
-public final class ArrayLength extends AccessArray {
+public final class ArrayLength extends Value {
+
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_ARRAY = 0;
+
+    private static final int SUCCESSOR_COUNT = 0;
+
+    @Override
+    protected int inputCount() {
+        return super.inputCount() + INPUT_COUNT;
+    }
 
-    private static final int INPUT_COUNT = 0;
-    private static final int SUCCESSOR_COUNT = 0;
+    @Override
+    protected int successorCount() {
+        return super.successorCount() + SUCCESSOR_COUNT;
+    }
+
+    /**
+     * The instruction that produces the array object.
+     */
+     public Value array() {
+        return (Value) inputs().get(super.inputCount() + INPUT_ARRAY);
+    }
+
+    public Value setArray(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_ARRAY, n);
+    }
 
     /**
      * Constructs a new ArrayLength instruction.
@@ -42,7 +65,8 @@
      * @param newFrameState the state after executing this instruction
      */
     public ArrayLength(Value array, Graph graph) {
-        super(CiKind.Int, array, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+        super(CiKind.Int, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+        setArray(array);
     }
 
     @Override