# HG changeset patch # User Gilles Duboscq # Date 1306503670 -7200 # Node ID 530366123e46cb24c45abd4f01305b0ecc4e8c91 # Parent 58e65eb6bb5d54d7a9ccec498bf8e849c8309fb7 Invoke is a block end diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java --- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Fri May 27 15:41:10 2011 +0200 @@ -72,10 +72,14 @@ return b; } - private boolean isCFG(Node n) { + private static boolean isCFG(Node n) { return n != null && ((n instanceof Instruction) || n == n.graph().start()); } + public static boolean isBlockEnd(Node n) { + return trueSuccessorCount(n) > 1 || n instanceof Anchor || n instanceof Return || n instanceof Throw; + } + private void identifyBlocks() { // Identify blocks. final ArrayList blockBeginNodes = new ArrayList(); @@ -106,27 +110,7 @@ blockBeginNodes.add(n); } else { // We have a single predecessor => check its successor count. - int successorCount = 0; - for (Node succ : singlePred.successors()) { - if (isCFG(succ)) { - successorCount++; - if (successorCount > 1) { - // Our predecessor is a split => we need a new block. - if (singlePred instanceof ExceptionEdgeInstruction) { - ExceptionEdgeInstruction e = (ExceptionEdgeInstruction) singlePred; - if (e.exceptionEdge() != n) { - break; - } - } - Block b = assignBlock(n); - b.setExceptionEntry(singlePred instanceof ExceptionEdgeInstruction); - blockBeginNodes.add(n); - return true; - } - } - } - - if (singlePred instanceof BlockEnd) { + if (isBlockEnd(singlePred)) { Block b = assignBlock(n); b.setExceptionEntry(singlePred instanceof Throw); blockBeginNodes.add(n); @@ -207,4 +191,14 @@ } }*/ } + + public static int trueSuccessorCount(Node n) { + int i = 0; + for (Node s : n.successors()) { + if (isCFG(s)) { + i++; + } + } + return i; + } } diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java --- a/graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java Fri May 27 15:41:10 2011 +0200 @@ -29,6 +29,7 @@ import com.oracle.max.asm.*; import com.sun.c1x.alloc.*; import com.sun.c1x.asm.*; +import com.sun.c1x.debug.*; import com.sun.c1x.gen.*; import com.sun.c1x.gen.LIRGenerator.*; import com.sun.c1x.graph.*; @@ -253,6 +254,10 @@ C1XTimers.LIR_CREATE.stop(); } + if (C1XOptions.PrintLIR && !TTY.isSuppressed()) { + LIRList.printLIR(hir.linearScanOrder()); + } + new LinearScan(this, hir, lirGenerator, frameMap()).allocate(); } } diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Fri May 27 15:41:10 2011 +0200 @@ -34,7 +34,7 @@ import com.oracle.max.asm.*; import com.sun.c1x.*; import com.sun.c1x.alloc.*; -import com.sun.c1x.alloc.OperandPool.*; +import com.sun.c1x.alloc.OperandPool.VariableFlag; import com.sun.c1x.debug.*; import com.sun.c1x.globalstub.*; import com.sun.c1x.graph.*; @@ -43,10 +43,16 @@ import com.sun.c1x.util.*; import com.sun.c1x.value.*; import com.sun.cri.bytecode.*; +import com.sun.cri.bytecode.Bytecodes.MemoryBarriers; import com.sun.cri.ci.*; import com.sun.cri.ri.*; +import com.sun.cri.xir.CiXirAssembler.XirConstant; +import com.sun.cri.xir.CiXirAssembler.XirInstruction; +import com.sun.cri.xir.CiXirAssembler.XirOperand; +import com.sun.cri.xir.CiXirAssembler.XirParameter; +import com.sun.cri.xir.CiXirAssembler.XirRegister; +import com.sun.cri.xir.CiXirAssembler.XirTemp; import com.sun.cri.xir.*; -import com.sun.cri.xir.CiXirAssembler.*; /** * This class traverses the HIR instructions and generates LIR instructions from them. @@ -253,7 +259,7 @@ } } } - if (block.blockSuccessors().size() == 1 && (block.getInstructions().size() == 0 || !(block.getInstructions().get(block.getInstructions().size() - 1) instanceof BlockEnd))) { + if (block.blockSuccessors().size() >= 1 && (block.getInstructions().size() == 0 || !jumpsToNextBlock(block.getInstructions().get(block.getInstructions().size() - 1)))) { moveToPhi(); block.lir().jump(block.blockSuccessors().get(0)); } @@ -267,6 +273,10 @@ blockDoEpilog(); } + private static boolean jumpsToNextBlock(Instruction instr) { + return instr instanceof BlockEnd; + } + @Override public void visitArrayLength(ArrayLength x) { emitArrayLength(x); @@ -400,7 +410,7 @@ } @Override - public void visitGoto(Anchor x) { + public void visitAnchor(Anchor x) { setNoResult(x); // emit phi-instruction moves after safepoint since this simplifies diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 27 15:41:10 2011 +0200 @@ -29,6 +29,7 @@ import java.util.*; import com.oracle.graal.graph.*; +import com.oracle.max.graal.schedule.Schedule; import com.sun.c1x.*; import com.sun.c1x.debug.*; import com.sun.c1x.graph.BlockMap.*; @@ -421,7 +422,7 @@ FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception); Instruction successor = createTarget(dispatchBlock, stateWithException); - BlockEnd end = new Anchor(successor, graph); + Anchor end = new Anchor(successor, graph); exception.appendNext(end); if (x instanceof Invoke) { @@ -1204,7 +1205,7 @@ traceInstruction(bci, opcode, blockStart); processBytecode(bci, opcode); - if (lastInstr instanceof BlockEnd || lastInstr.next() != null) { + if (Schedule.isBlockEnd(lastInstr) || lastInstr.next() != null) { break; } diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/sun/c1x/ir/Anchor.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Anchor.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Anchor.java Fri May 27 15:41:10 2011 +0200 @@ -47,11 +47,11 @@ @Override public void accept(ValueVisitor v) { - v.visitGoto(this); + v.visitAnchor(this); } @Override public void print(LogStream out) { - out.print("goto ").print(defaultSuccessor()); + out.print("anchor ").print(defaultSuccessor()); } } diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java Fri May 27 15:41:10 2011 +0200 @@ -99,6 +99,9 @@ builder.append(" -> "); boolean hasSucc = false; for (Node s : this.successors()) { + if (s == null) { + continue; + } if (hasSucc) { builder.append(", "); } diff -r 58e65eb6bb5d -r 530366123e46 graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java Fri May 27 14:20:30 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java Fri May 27 15:41:10 2011 +0200 @@ -40,7 +40,7 @@ public abstract void visitConvert(Convert i); public abstract void visitExceptionObject(ExceptionObject i); public abstract void visitFrameState(FrameState i); - public abstract void visitGoto(Anchor i); + public abstract void visitAnchor(Anchor i); public abstract void visitIf(If i); public abstract void visitIfOp(IfOp i); public abstract void visitInstanceOf(InstanceOf i);