# HG changeset patch # User Lukas Stadler # Date 1305893368 -7200 # Node ID 36440e516e44e49124bfa108c7bcef44f1778b84 # Parent 861449bd8b862e7a089b23a540c870b39335d149 block entry instructions created on-demand diff -r 861449bd8b86 -r 36440e516e44 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 13:53:57 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 14:09:28 2011 +0200 @@ -115,8 +115,6 @@ private BlockBegin unwindBlock; - private final Set loopHeaders = new HashSet(); - /** * Creates a new, initialized, {@code GraphBuilder} instance for a given compilation. * @@ -156,23 +154,12 @@ blockList = new Block[rootMethod.code().length]; for (int i = 0; i < blockMap.blocks.size(); i++) { + int blockID = ir.nextBlockNumber(); + assert blockID == i; Block block = blockMap.blocks.get(i); - -// if (block.isLoopHeader) { - BlockBegin blockBegin = new BlockBegin(block.startBci, ir.nextBlockNumber(), graph); - - block.firstInstruction = blockBegin; - blockList[block.startBci] = block; - - if (block.isLoopHeader) { - loopHeaders.add(blockBegin); - } -// } else { -// blockList[block.startBci] = new Placeholder(graph); -// } + blockList[block.startBci] = block; } - // 1. create the start block Block startBlock = nextBlock(Instruction.SYNCHRONIZATION_ENTRY_BCI); BlockBegin startBlockBegin = new BlockBegin(0, startBlock.blockID, graph); @@ -381,7 +368,7 @@ int current = exceptionHandlers.size() - 1; if (exceptionHandlers.get(current).isCatchAll()) { - successor = exceptionHandlers.get(current).entryBlock().firstInstruction; + successor = createTarget(exceptionHandlers.get(current).entryBlock(), null); current--; } else { if (unwindBlock == null) { @@ -412,6 +399,7 @@ BlockBegin dispatchEntry = new BlockBegin(handler.handlerBCI(), ir.nextBlockNumber(), graph); if (handler.handler.catchType().isResolved()) { + Instruction entry = createTarget(handler.entryBlock(), null); ExceptionDispatch end = new ExceptionDispatch(null, (BlockBegin) handler.entryBlock().firstInstruction, null, handler, null, graph); end.setBlockSuccessor(0, (BlockBegin) successor); dispatchEntry.appendNext(end); @@ -1072,7 +1060,13 @@ } private Instruction createTarget(Block block, FrameStateAccess stateAfter) { - mergeOrClone(block, stateAfter); + if (block.firstInstruction == null) { + BlockBegin blockBegin = new BlockBegin(block.startBci, block.blockID, graph); + block.firstInstruction = blockBegin; + } + if (stateAfter != null) { + mergeOrClone(block, stateAfter); + } addToWorkList(block); return block.firstInstruction; }