# HG changeset patch # User Thomas Wuerthinger # Date 1305895905 -7200 # Node ID bfcdda4fdd7318e571e70e4709c6e2d8baaec782 # Parent e91608c2daff4cb74dc9434ed8e136618b43c965 Removed the direct connection between BlockBegin and BlockEnd. diff -r e91608c2daff -r bfcdda4fdd73 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 14:34:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 20 14:51:45 2011 +0200 @@ -257,7 +257,6 @@ Instruction target = createTargetAt(0, stateAfter); Goto base = new Goto(target, stateAfter, graph); appendWithBCI(base); - ((BlockBegin) startBlock.firstInstruction).setEnd(base); } public void mergeOrClone(Block target, FrameStateAccess newState) { @@ -375,7 +374,6 @@ unwindBlock = new BlockBegin(bci, ir.nextBlockNumber(), graph); Unwind unwind = new Unwind(null, graph); unwindBlock.appendNext(unwind); - unwindBlock.setEnd(unwind); } successor = unwindBlock; } @@ -403,13 +401,11 @@ ExceptionDispatch end = new ExceptionDispatch(null, entry, null, handler, null, graph); end.setBlockSuccessor(0, successor); dispatchEntry.appendNext(end); - dispatchEntry.setEnd(end); } else { Deoptimize deopt = new Deoptimize(graph); dispatchEntry.appendNext(deopt); Goto end = new Goto(successor, null, graph); deopt.appendNext(end); - dispatchEntry.setEnd(end); } newBlocks.add(dispatchEntry); @@ -426,7 +422,6 @@ FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception); BlockEnd end = new Goto(successor, stateWithException, graph); exception.appendNext(end); - entry.setEnd(end); if (x instanceof Invoke) { ((Invoke) x).setExceptionEdge(entry); @@ -1165,7 +1160,6 @@ genThrow(bci); BlockEnd end = (BlockEnd) lastInstr; - ((BlockBegin) syncHandler.firstInstruction).setEnd(end); end.setStateAfter(frameState.create(bci())); frameState.initializeFrom(origState); @@ -1178,7 +1172,8 @@ while ((block = removeFromWorkList()) != null) { // remove blocks that have no predecessors by the time it their bytecodes are parsed - if (block.firstInstruction.predecessors().size() == 0) { + Instruction firstInstruction = block.firstInstruction; + if (firstInstruction.predecessors().size() == 0) { markVisited(block); continue; } @@ -1186,9 +1181,9 @@ if (!isVisited(block)) { markVisited(block); // now parse the block - frameState.initializeFrom(((BlockBegin) block.firstInstruction).stateBefore()); - lastInstr = block.firstInstruction; - assert block.firstInstruction.next() == null; + frameState.initializeFrom(((BlockBegin) firstInstruction).stateBefore()); + lastInstr = firstInstruction; + assert firstInstruction.next() == null; iterateBytecodesForBlock(block); } @@ -1246,9 +1241,6 @@ assert end != null : "end should exist after iterating over bytecodes"; FrameState stateAtEnd = frameState.create(bci()); end.setStateAfter(stateAtEnd); - if (block.firstInstruction instanceof BlockBegin) { - ((BlockBegin) block.firstInstruction).setEnd(end); - } return end; } diff -r e91608c2daff -r bfcdda4fdd73 graal/GraalCompiler/src/com/sun/c1x/graph/IR.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Fri May 20 14:34:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Fri May 20 14:51:45 2011 +0200 @@ -200,7 +200,6 @@ // This goto is not a safepoint. Goto e = new Goto(target, null, compilation.graph); newSucc.appendNext(e); - newSucc.setEnd(e); e.reorderSuccessor(0, backEdgeIndex); // setup states FrameState s = source.end().stateAfter(); diff -r e91608c2daff -r bfcdda4fdd73 graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Fri May 20 14:34:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Fri May 20 14:51:45 2011 +0200 @@ -41,8 +41,7 @@ private static final int INPUT_COUNT = 1; private static final int INPUT_STATE_BEFORE = 0; - private static final int SUCCESSOR_COUNT = 1; - private static final int SUCCESSOR_END = 0; + private static final int SUCCESSOR_COUNT = 0; @Override protected int inputCount() { @@ -58,7 +57,11 @@ * The last node in the block (which contains the successors). */ public BlockEnd end() { - return (BlockEnd) successors().get(super.successorCount() + SUCCESSOR_END); + Instruction next = next(); + while (!(next instanceof BlockEnd)) { + next = next.next(); + } + return (BlockEnd) next; } @Override @@ -66,11 +69,6 @@ return false; } - public void setEnd(BlockEnd end) { - assert end != null; - successors().set(super.successorCount() + SUCCESSOR_END, end); - } - /** * A unique id used in tracing. */ diff -r e91608c2daff -r bfcdda4fdd73 graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Fri May 20 14:34:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Fri May 20 14:51:45 2011 +0200 @@ -22,6 +22,8 @@ */ package com.sun.c1x.ir; +import java.util.*; + import com.oracle.graal.graph.*; import com.sun.c1x.*; import com.sun.c1x.value.*; @@ -112,10 +114,11 @@ @Override public BlockBegin block() { Instruction cur = this; - while (!(cur instanceof BlockEnd)) { - cur = cur.next(); + while (!(cur instanceof BlockBegin)) { + List preds = cur.predecessors(); + cur = (Instruction) preds.get(0); } - return ((BlockEnd) cur).begin(); + return (BlockBegin) cur; } /**