# HG changeset patch # User Lukas Stadler # Date 1305890421 -7200 # Node ID 05c92e53a50d94574be80763a3c68cbd391f048a # Parent 55f1db570dfac05d274f8bef74a2bfae816fdb3d merge and clone before connecting blocks diff -r 55f1db570dfa -r 05c92e53a50d graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 11:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 13:20:21 2011 +0200 @@ -106,8 +106,6 @@ private final FrameStateBuilder frameState; // the current execution state private Instruction lastInstr; // the last instruction added - private Instruction placeholder; - private final LogStream log; @@ -197,14 +195,12 @@ flags |= Flag.HasHandler.mask; } - assert !loopHeaders.contains(startBlock); mergeOrClone(startBlockBegin, frameState, false); // 3. setup internal state for appending instructions lastInstr = startBlockBegin; lastInstr.appendNext(null); - Instruction entryBlock = blockAt(0); BlockBegin syncHandler = null; Block syncBlock = null; if (isSynchronized(rootMethod.accessFlags())) { @@ -212,7 +208,7 @@ rootMethodSynchronizedObject = synchronizedObject(frameState, compilation.method); genMonitorEnter(rootMethodSynchronizedObject, Instruction.SYNCHRONIZATION_ENTRY_BCI); // 4A.2 finish the start block - finishStartBlock(startBlockBegin, entryBlock); + finishStartBlock(startBlock); // 4A.3 setup an exception handler to unlock the root method synchronized object syncBlock = nextBlock(Instruction.SYNCHRONIZATION_ENTRY_BCI); @@ -225,7 +221,7 @@ addExceptionHandler(h); } else { // 4B.1 simply finish the start block - finishStartBlock(startBlockBegin, entryBlock); + finishStartBlock(startBlock); } // 5. SKIPPED: look for intrinsics @@ -268,28 +264,21 @@ return blocksVisited.contains(block); } - private void finishStartBlock(BlockBegin startBlock, Instruction stdEntry) { + private void finishStartBlock(Block startBlock) { assert bci() == 0; FrameState stateAfter = frameState.create(bci()); - Goto base = new Goto((BlockBegin) stdEntry, stateAfter, graph); + Instruction target = createTargetAt(0, stateAfter); + Goto base = new Goto((BlockBegin) target, stateAfter, graph); appendWithBCI(base); - startBlock.setEnd(base); -// assert stdEntry instanceof Placeholder; - assert ((BlockBegin) stdEntry).stateBefore() == null; - prepareTarget(0); - mergeOrClone(stdEntry, stateAfter, loopHeaders.contains(stdEntry)); + ((BlockBegin) startBlock.firstInstruction).setEnd(base); } - private void prepareTarget(int bci) { - } - - public void mergeOrClone(Block target, FrameStateAccess newState) { + assert target.firstInstruction instanceof BlockBegin; if (target.isLoopHeader) { - assert target.firstInstruction instanceof BlockBegin; mergeOrClone(target.firstInstruction, newState, true); - - + } else { + mergeOrClone(target.firstInstruction, newState, false); } } @@ -505,7 +494,7 @@ // fill in exception handler subgraph lazily if (!isVisited(entry)) { if (handler.handlerBCI() != Instruction.SYNCHRONIZATION_ENTRY_BCI) { - addToWorkList(blockList[handler.handlerBCI()]); + addToWorkList(entry); } } else { // This will occur for exception handlers that cover themselves. This code @@ -1082,6 +1071,8 @@ } private Instruction createTarget(Block block, FrameStateAccess stateAfter) { + mergeOrClone(block, stateAfter); + addToWorkList(block); return block.firstInstruction; } @@ -1124,10 +1115,6 @@ assert x.next() == null : "instruction should not have been appended yet"; assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; - if (placeholder != null) { - placeholder = null; - } - lastInstr = lastInstr.appendNext(x); if (++stats.nodeCount >= C1XOptions.MaximumInstructionCount) { // bailout if we've exceeded the maximum inlining size @@ -1203,17 +1190,8 @@ if (!isVisited(block)) { markVisited(block); // now parse the block - if (block.firstInstruction instanceof Placeholder) { - assert false; - placeholder = block.firstInstruction; - frameState.initializeFrom(((Placeholder) placeholder).stateBefore()); - lastInstr = null; - } else { - assert block.firstInstruction instanceof BlockBegin; - placeholder = null; - frameState.initializeFrom(((BlockBegin) block.firstInstruction).stateBefore()); - lastInstr = block.firstInstruction; - } + frameState.initializeFrom(((BlockBegin) block.firstInstruction).stateBefore()); + lastInstr = block.firstInstruction; assert block.firstInstruction.next() == null; iterateBytecodesForBlock(block); @@ -1274,13 +1252,6 @@ if (block.firstInstruction instanceof BlockBegin) { ((BlockBegin) block.firstInstruction).setEnd(end); } - - // propagate the state - for (BlockBegin succ : end.blockSuccessors()) { - assert succ.blockPredecessors().contains(end); - mergeOrClone(succ, stateAtEnd, loopHeaders.contains(succ)); - addToWorkList(blockList[succ.bci()]); - } return end; }