# HG changeset patch # User Thomas Wuerthinger # Date 1306761866 -7200 # Node ID d27bdbec3d679486bc982fae8702bf827c4c56fc # Parent 6fb5a1bf819f5eef421ab17a4b3d863b307acf5d Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block. If a block only consists of a single Merge instruction, we have to schedule this instruction as the first instruction. diff -r 6fb5a1bf819f -r d27bdbec3d67 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:03:04 2011 +0200 +++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Mon May 30 15:24:26 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 6fb5a1bf819f -r d27bdbec3d67 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Mon May 30 15:03:04 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Mon May 30 15:24:26 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 6fb5a1bf819f -r d27bdbec3d67 graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java Mon May 30 15:03:04 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java Mon May 30 15:24:26 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