# HG changeset patch # User Thomas Wuerthinger # Date 1308229340 -7200 # Node ID 775881292ddb99641b611ba516e597e33f691370 # Parent a100e097a6757cf247e78175e8ef1b73aa844f0d Made Deoptimize instruction into FixedNode instead of Instruction. diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java Thu Jun 16 15:02:20 2011 +0200 @@ -105,7 +105,7 @@ assert instructions.get(0).code == LIROpcode.Label : "first instruction must always be a label"; assert instructions.get(instructions.size() - 1) instanceof LIRBranch : "last instruction must always be a branch but is " + instructions.get(instructions.size() - 1); assert ((LIRBranch) instructions.get(instructions.size() - 1)).cond() == Condition.TRUE : "branch must be unconditional"; - assert ((LIRBranch) instructions.get(instructions.size() - 1)).block() == block.suxAt(0) : "branch target must be the successor"; + assert ((LIRBranch) instructions.get(instructions.size() - 1)).block() == block.suxAt(0) : "branch target must be the successor " + ((LIRBranch) instructions.get(instructions.size() - 1)).block(); // block must have exactly one successor diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Thu Jun 16 15:02:20 2011 +0200 @@ -285,10 +285,6 @@ // Nothing to do. } - private static boolean jumpsToNextBlock(Node node) { - return node instanceof BlockEnd || node instanceof EndNode || node instanceof LoopEnd; - } - @Override public void visitArrayLength(ArrayLength x) { emitArrayLength(x); @@ -1433,6 +1429,7 @@ public void visitEndNode(EndNode end) { setNoResult(end); Merge merge = end.merge(); + assert merge != null; moveToPhi(merge, merge.endIndex(end)); lir.jump(getLIRBlock(end.merge())); } diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Deoptimize.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Deoptimize.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Deoptimize.java Thu Jun 16 15:02:20 2011 +0200 @@ -28,7 +28,7 @@ import com.oracle.max.graal.graph.*; import com.sun.cri.ci.*; -public class Deoptimize extends Instruction { +public class Deoptimize extends FixedNode { private static final int INPUT_COUNT = 0; private static final int SUCCESSOR_COUNT = 0; diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBranch.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBranch.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBranch.java Thu Jun 16 15:02:20 2011 +0200 @@ -110,6 +110,7 @@ public void changeBlock(LIRBlock b) { assert block != null : "must have old block"; assert block.label() == label() : "must be equal"; + assert b != null; this.block = b; this.label = b.label(); @@ -146,6 +147,7 @@ } public void substitute(LIRBlock oldBlock, LIRBlock newBlock) { + assert newBlock != null; if (block == oldBlock) { block = newBlock; LIRInstruction instr = newBlock.lir().instructionsList().get(0); diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRList.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRList.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRList.java Thu Jun 16 15:02:20 2011 +0200 @@ -245,6 +245,7 @@ } public void jump(LIRBlock block) { + assert block != null; append(new LIRBranch(Condition.TRUE, block)); } diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Thu Jun 16 15:02:20 2011 +0200 @@ -299,17 +299,12 @@ if (first instanceof Placeholder) { assert !target.isLoopHeader; Merge merge = new Merge(graph); - - - Placeholder p = (Placeholder) first; assert p.predecessors().size() == 1; assert p.next() == null; - EndNode end = new EndNode(graph); p.replace(end); merge.addEnd(end); - //end.setNext(merge); target.firstInstruction = merge; merge.setStateBefore(existingState); first = merge; @@ -1089,6 +1084,12 @@ return append(new Constant(constant, graph)); } + private Value append(FixedNode fixed) { + lastInstr.setNext(fixed); + lastInstr = null; + return fixed; + } + private Value append(Instruction x) { return appendWithBCI(x); } @@ -1211,9 +1212,13 @@ } else { end.delete(); Merge merge = new Merge(graph); + for (int i = 0; i < begin.endCount(); ++i) { + merge.addEnd(begin.endAt(i)); + } merge.setNext(begin.next()); begin.setNext(null); begin.replace(merge); + TTY.println("replace loop"); } } } @@ -1270,7 +1275,9 @@ } private void appendGoto(FixedNode target) { - lastInstr.setNext(target); + if (lastInstr != null) { + lastInstr.setNext(target); + } } private void iterateBytecodesForBlock(Block block) { @@ -1295,7 +1302,7 @@ traceInstruction(bci, opcode, bci == block.startBci); processBytecode(bci, opcode); - if (IdentifyBlocksPhase.isBlockEnd(lastInstr) || lastInstr.next() != null) { + if (lastInstr == null || IdentifyBlocksPhase.isBlockEnd(lastInstr) || lastInstr.next() != null) { break; } diff -r a100e097a675 -r 775881292ddb graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Thu Jun 16 14:21:40 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Thu Jun 16 15:02:20 2011 +0200 @@ -90,7 +90,7 @@ } public static boolean isBlockEnd(Node n) { - return trueSuccessorCount(n) > 1 || n instanceof Anchor || n instanceof Return || n instanceof Unwind; + return trueSuccessorCount(n) > 1 || n instanceof Return || n instanceof Unwind || n instanceof Deoptimize; } private void identifyBlocks() {