Mercurial > hg > graal-jvmci-8
changeset 2812:d27bdbec3d67
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.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Mon, 30 May 2011 15:24:26 +0200 |
parents | 6fb5a1bf819f |
children | 32fd5ea3a6cc |
files | graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java |
diffstat | 3 files changed, 44 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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<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/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<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: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