# HG changeset patch # User Thomas Wuerthinger # Date 1306317898 -7200 # Node ID 9bc0c2eb00d633ec0e785e73b843c33490ac94ab # Parent 915456e4959e0f08a93fd28e01748a8a519ce9ed Made graph builder removal of BlockBegin work. diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java --- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Wed May 25 12:04:58 2011 +0200 @@ -55,7 +55,6 @@ } private Block assignBlock(Node n) { - assert n instanceof BlockBegin : n; Block curBlock = nodeToBlock.get(n); if (curBlock == null) { curBlock = createBlock(); diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed May 25 12:04:58 2011 +0200 @@ -27,6 +27,7 @@ import static com.sun.cri.ci.CiCallingConvention.Type.*; import static com.sun.cri.ci.CiValue.*; +import java.lang.reflect.*; import java.util.*; import com.oracle.graal.graph.*; @@ -257,6 +258,7 @@ TTY.println("END Generating LIR for block B" + block.blockID()); } + block.setLastState(lastState); this.currentBlock = null; blockDoEpilog(); } @@ -273,12 +275,18 @@ return x.operand(); } - private void setOperandsForLocals() { + private FrameState setOperandsForLocals() { CiCallingConvention args = compilation.frameMap().incomingArguments(); + int bci = 0; + if (Modifier.isSynchronized(compilation.method.accessFlags())) { + bci = Instruction.SYNCHRONIZATION_ENTRY_BCI; + } + FrameState fs = new FrameState(bci, compilation.method.maxLocals(), 0, 0, compilation.graph); for (Node node : compilation.graph.start().usages()) { if (node instanceof Local) { Local local = (Local) node; int i = local.index(); + fs.storeLocal(i, local); CiValue src = args.locations[i]; assert src.isLegal() : "check"; @@ -290,6 +298,7 @@ setResult(local, dest); } } + return fs; } @Override @@ -892,7 +901,12 @@ if (prologue != null) { emitXir(prologue, null, null, null, false); } - setOperandsForLocals(); + FrameState fs = setOperandsForLocals(); + lastState = fs; + } else if (block.blockPredecessors().size() == 1) { + FrameState fs = block.blockPredecessors().get(0).lastState(); + assert fs != null; + lastState = fs; } } diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed May 25 12:04:58 2011 +0200 @@ -221,9 +221,9 @@ if (n instanceof Placeholder) { Placeholder p = (Placeholder) n; - if (p == graph.start().successors().get(0)) { + /*if (p == graph.start().successors().get(0)) { // nothing to do... - } else if (p.blockPredecessors().size() == 0) { + } else*/ if (p.blockPredecessors().size() == 0) { assert p.next() == null; p.delete(); } else { @@ -236,6 +236,12 @@ } } } + + for (Node n : graph.getNodes()) { + assert !(n instanceof Placeholder); + } + + for (Node n : graph.getNodes()) { if (n instanceof FrameState) { boolean delete = false; @@ -1089,7 +1095,9 @@ // go forward to the end of the block lastInstr = lastInstr.next(); } - frameState.initializeFrom(((BlockBegin) syncHandler.firstInstruction).stateBefore()); + +// TTY.println("first instruction: " + syncHandler.firstInstruction); + frameState.initializeFrom(((StateSplit) syncHandler.firstInstruction).stateBefore()); int bci = Instruction.SYNCHRONIZATION_ENTRY_BCI; diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/graph/IR.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Wed May 25 12:04:58 2011 +0200 @@ -165,7 +165,7 @@ TTY.println("IR for " + compilation.method); final InstructionPrinter ip = new InstructionPrinter(TTY.out()); final BlockPrinter bp = new BlockPrinter(this, ip, cfgOnly); - getHIRStartBlock().iteratePreOrder(bp); + //getHIRStartBlock().iteratePreOrder(bp); } } diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionEdgeInstruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionEdgeInstruction.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionEdgeInstruction.java Wed May 25 12:04:58 2011 +0200 @@ -24,5 +24,5 @@ public interface ExceptionEdgeInstruction { - StateSplit exceptionEdge(); + Instruction exceptionEdge(); } diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Wed May 25 12:04:58 2011 +0200 @@ -117,11 +117,11 @@ */ @SuppressWarnings({ "unchecked", "rawtypes" }) public List blockPredecessors() { - if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { + /*if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { return Collections.EMPTY_LIST; - } else { + } else {)*/ return (List) Collections.unmodifiableList(predecessors()); - } + //} } /** @@ -130,11 +130,11 @@ */ public int numberOfPreds() { // ignore the graph root - if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { + /*if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { return 0; - } else { + } else {*/ return predecessors().size(); - } + //} } public Instruction predAt(int j) { diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Wed May 25 12:04:58 2011 +0200 @@ -70,8 +70,8 @@ * The entry to the exception dispatch chain for this invoke. */ @Override - public BlockBegin exceptionEdge() { - return (BlockBegin) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE); + public Instruction exceptionEdge() { + return (Instruction) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE); } public Instruction setExceptionEdge(Instruction n) { diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java Wed May 25 12:04:58 2011 +0200 @@ -76,8 +76,8 @@ * TODO ls: this needs more cleanup - throw should either unwind or jump to the exception dispatch chain */ @Override - public StateSplit exceptionEdge() { - return (StateSplit) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE); + public Instruction exceptionEdge() { + return (Instruction) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE); } public Instruction setExceptionEdge(Instruction n) { diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Wed May 25 12:04:58 2011 +0200 @@ -29,6 +29,7 @@ import com.sun.c1x.debug.*; import com.sun.c1x.ir.*; import com.sun.c1x.util.*; +import com.sun.c1x.value.*; import com.sun.cri.ci.*; /** @@ -39,6 +40,7 @@ public final Label label = new Label(); private LIRList lir; private final int blockID; + private FrameState lastState; private List instructions = new ArrayList(4); private List predecessors = new ArrayList(4); private List successors = new ArrayList(4); @@ -265,4 +267,12 @@ } } } + + public void setLastState(FrameState fs) { + lastState = fs; + } + + public FrameState lastState() { + return lastState; + } } diff -r 915456e4959e -r 9bc0c2eb00d6 graal/GraalGraph/src/com/oracle/graal/graph/NodeArray.java --- a/graal/GraalGraph/src/com/oracle/graal/graph/NodeArray.java Wed May 25 11:15:24 2011 +0200 +++ b/graal/GraalGraph/src/com/oracle/graal/graph/NodeArray.java Wed May 25 12:04:58 2011 +0200 @@ -142,14 +142,6 @@ return nodes.length; } - public void replace(Node node, Node with) { - for (int i = 0; i < nodes.length; i++) { - if (get(i) == node) { - set(i, with); - } - } - } - public void clearAll() { for (int i = 0; i < nodes.length; i++) { set(i, Node.Null);