# HG changeset patch # User Lukas Stadler # Date 1305892437 -7200 # Node ID 861449bd8b862e7a089b23a540c870b39335d149 # Parent 84f4c7dceb1465ea0f38d0e059ddf0c1db440829# Parent 114fc809462f7bb9c7cf05c59e0e7f1da45929a5 merge diff -r 114fc809462f -r 861449bd8b86 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 12:08:58 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 13:53:57 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 @@ -1059,6 +1048,7 @@ private void genTableswitch() { int bci = bci(); + Value value = frameState.ipop(); BytecodeTableSwitch ts = new BytecodeTableSwitch(stream(), bci); int max = ts.numberOfCases(); List list = new ArrayList(max + 1); @@ -1074,7 +1064,7 @@ list.add(createTargetAt(bci + offset, frameState)); boolean isSafepoint = isBackwards && !noSafepoints(); FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null; - append(new TableSwitch(frameState.ipop(), (List) list, ts.lowKey(), stateAfter, graph)); + append(new TableSwitch(value, (List) list, ts.lowKey(), stateAfter, graph)); } private Instruction createTargetAt(int bci, FrameStateAccess stateAfter) { @@ -1082,11 +1072,14 @@ } private Instruction createTarget(Block block, FrameStateAccess stateAfter) { + mergeOrClone(block, stateAfter); + addToWorkList(block); return block.firstInstruction; } private void genLookupswitch() { int bci = bci(); + Value value = frameState.ipop(); BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); int max = ls.numberOfCases(); List list = new ArrayList(max + 1); @@ -1104,7 +1097,7 @@ list.add(createTargetAt(bci + offset, frameState)); boolean isSafepoint = isBackwards && !noSafepoints(); FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null; - append(new LookupSwitch(frameState.ipop(), (List) list, keys, stateAfter, graph)); + append(new LookupSwitch(value, (List) list, keys, stateAfter, graph)); } private Value appendConstant(CiConstant constant) { @@ -1124,10 +1117,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 +1192,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); @@ -1235,7 +1215,8 @@ Block nextBlock = blockList[bci]; if (nextBlock != null && nextBlock != block) { // we fell through to the next block, add a goto and break - end = new Goto((BlockBegin) nextBlock.firstInstruction, null, graph); + Instruction next = createTarget(nextBlock, frameState); + end = new Goto((BlockBegin) next, null, graph); lastInstr = lastInstr.appendNext(end); break; } @@ -1274,13 +1255,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; }