# HG changeset patch # User Lukas Stadler # Date 1306762000 -7200 # Node ID 878bbf7dbf3166f4f6a9a27e3858daa744a858d7 # Parent 31e0786a986cf19d614e7a94b974b2d38d0f33ca# Parent 32fd5ea3a6ccbe7fb7d5a9892edc05e563b22637 merge diff -r 31e0786a986c -r 878bbf7dbf31 graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java --- 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 instructions = b.getInstructions(); List sortedInstructions = new ArrayList(); 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) { diff -r 31e0786a986c -r 878bbf7dbf31 graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinterObserver.java --- 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); } } } diff -r 31e0786a986c -r 878bbf7dbf31 graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java --- 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(" %n", block.blockID()); stream.printf(" %n"); for (Block sux : block.getSuccessors()) { - stream.printf(" %n", sux.blockID()); + if (sux.firstNode() instanceof LoopBegin && block.lastNode() instanceof LoopEnd) { + // Skip back edges. + } else { + stream.printf(" %n", sux.blockID()); + } } stream.printf(" %n"); stream.printf(" %n"); diff -r 31e0786a986c -r 878bbf7dbf31 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- 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 pointerSlots) { + protected CiValue emitXir(XirSnippet snippet, Value instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod method, boolean setInstructionResult, List pointerSlots) { if (C1XOptions.PrintXirTemplates) { TTY.println("Emit XIR template " + snippet.template.name); } diff -r 31e0786a986c -r 878bbf7dbf31 graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java --- 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