# HG changeset patch # User Thomas Wuerthinger # Date 1305731087 -7200 # Node ID 42450f536d24ae002aaf4b4106fa60e792c264b6 # Parent 618f545fcac56bb73dbc34b2e38cbe8958df4267 More cleanup towards separation of graphbuilding<>graph<>lirgeneration diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java Wed May 18 17:04:47 2011 +0200 @@ -563,7 +563,7 @@ for (int i = 0; i < numBlocks; i++) { BlockBegin block = blockAt(i); - block.setFirstLirInstructionId(opId); + block.lirBlock.setFirstLirInstructionId(opId); List instructions = block.lir().instructionsList(); int numInst = instructions.size(); @@ -578,7 +578,7 @@ index++; opId += 2; // numbering of lirOps by two } - block.setLastLirInstructionId(opId - 2); + block.lirBlock.setLastLirInstructionId((opId - 2)); } assert index == numInstructions : "must match"; assert (index << 1) == opId : "must match: " + (index << 1); @@ -1174,8 +1174,8 @@ for (int i = blockCount() - 1; i >= 0; i--) { BlockBegin block = blockAt(i); List instructions = block.lir().instructionsList(); - final int blockFrom = block.firstLirInstructionId(); - int blockTo = block.lastLirInstructionId(); + final int blockFrom = block.lirBlock.firstLirInstructionId(); + int blockTo = block.lirBlock.lastLirInstructionId(); assert blockFrom == instructions.get(0).id; assert blockTo == instructions.get(instructions.size() - 1).id; @@ -1527,14 +1527,14 @@ assert operand.isVariable() : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; - return splitChildAtOpId(intervalFor(operand), block.firstLirInstructionId(), LIRInstruction.OperandMode.Output); + return splitChildAtOpId(intervalFor(operand), block.lirBlock.firstLirInstructionId(), LIRInstruction.OperandMode.Output); } Interval intervalAtBlockEnd(BlockBegin block, CiValue operand) { assert operand.isVariable() : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; - return splitChildAtOpId(intervalFor(operand), block.lastLirInstructionId() + 1, LIRInstruction.OperandMode.Output); + return splitChildAtOpId(intervalFor(operand), block.lirBlock.lastLirInstructionId() + 1, LIRInstruction.OperandMode.Output); } Interval intervalAtOpId(CiValue operand, int opId) { @@ -1695,7 +1695,7 @@ // this is not allowed because of the complicated fpu stack handling on Intel // range that will be spilled to memory - int fromOpId = block.firstLirInstructionId(); + int fromOpId = block.lirBlock.firstLirInstructionId(); int toOpId = fromOpId + 1; // short live range of length 1 assert interval.from() <= fromOpId && interval.to() >= toOpId : "no split allowed between exception entry and first instruction"; @@ -1928,7 +1928,7 @@ if (opId != -1) { if (C1XOptions.DetailedAsserts) { BlockBegin block = blockForId(opId); - if (block.numberOfSux() <= 1 && opId == block.lastLirInstructionId()) { + if (block.numberOfSux() <= 1 && opId == block.lirBlock.lastLirInstructionId()) { // check if spill moves could have been appended at the end of this block, but // before the branch instruction. So the split child information for this branch would // be incorrect. @@ -2048,7 +2048,7 @@ if (operand.isVariable()) { OperandMode mode = OperandMode.Input; BlockBegin block = blockForId(opId); - if (block.numberOfSux() == 1 && opId == block.lastLirInstructionId()) { + if (block.numberOfSux() == 1 && opId == block.lirBlock.lastLirInstructionId()) { // generating debug information for the last instruction of a block. // if this instruction is a branch, spill moves are inserted before this branch // and so the wrong operand would be returned (spill moves at block boundaries are not @@ -2057,7 +2057,7 @@ final LIRInstruction instr = block.lir().instructionsList().get(block.lir().instructionsList().size() - 1); if (instr instanceof LIRBranch) { if (block.lirBlock.liveOut.get(operandNumber(operand))) { - opId = block.suxAt(0).firstLirInstructionId(); + opId = block.suxAt(0).lirBlock.firstLirInstructionId(); mode = OperandMode.Output; } } @@ -2308,7 +2308,7 @@ TTY.println("--- Basic Blocks ---"); for (i = 0; i < blockCount(); i++) { BlockBegin block = blockAt(i); - TTY.print("B%d [%d, %d, %d, %d] ", block.blockID, block.firstLirInstructionId(), block.lastLirInstructionId(), block.loopIndex(), block.loopDepth()); + TTY.print("B%d [%d, %d, %d, %d] ", block.blockID, block.lirBlock.firstLirInstructionId(), block.lirBlock.lastLirInstructionId(), block.loopIndex(), block.loopDepth()); } TTY.println(); TTY.println(); diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScanWalker.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScanWalker.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScanWalker.java Wed May 18 17:04:47 2011 +0200 @@ -262,9 +262,9 @@ // Try to split at end of maxBlock. If this would be after // maxSplitPos, then use the begin of maxBlock - int optimalSplitPos = maxBlock.lastLirInstructionId() + 2; + int optimalSplitPos = maxBlock.lirBlock.lastLirInstructionId() + 2; if (optimalSplitPos > maxSplitPos) { - optimalSplitPos = maxBlock.firstLirInstructionId(); + optimalSplitPos = maxBlock.lirBlock.firstLirInstructionId(); } int minLoopDepth = maxBlock.loopDepth(); @@ -274,7 +274,7 @@ if (cur.loopDepth() < minLoopDepth) { // block with lower loop-depth found . split at the end of this block minLoopDepth = cur.loopDepth(); - optimalSplitPos = cur.lastLirInstructionId() + 2; + optimalSplitPos = cur.lirBlock.lastLirInstructionId() + 2; } } assert optimalSplitPos > allocator.maxOpId() || allocator.isBlockBegin(optimalSplitPos) : "algorithm must move split pos to block boundary"; @@ -334,7 +334,7 @@ if (doLoopOptimization) { // Loop optimization: if a loop-end marker is found between min- and max-position : // then split before this loop - int loopEndPos = interval.nextUsageExact(RegisterPriority.LiveAtLoopEnd, minBlock.lastLirInstructionId() + 2); + int loopEndPos = interval.nextUsageExact(RegisterPriority.LiveAtLoopEnd, minBlock.lirBlock.lastLirInstructionId() + 2); if (C1XOptions.TraceLinearScanLevel >= 4) { TTY.println(" loop optimization: loop end found at pos %d", loopEndPos); } @@ -353,8 +353,8 @@ } assert loopBlock != minBlock : "loopBlock and minBlock must be different because block boundary is needed between"; - optimalSplitPos = findOptimalSplitPos(minBlock, loopBlock, loopBlock.lastLirInstructionId() + 2); - if (optimalSplitPos == loopBlock.lastLirInstructionId() + 2) { + optimalSplitPos = findOptimalSplitPos(minBlock, loopBlock, loopBlock.lirBlock.lastLirInstructionId() + 2); + if (optimalSplitPos == loopBlock.lirBlock.lastLirInstructionId() + 2) { optimalSplitPos = -1; if (C1XOptions.TraceLinearScanLevel >= 4) { TTY.println(" loop optimization not necessary"); diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Wed May 18 17:04:47 2011 +0200 @@ -153,12 +153,6 @@ if (block.isExceptionEntry()) { out.print("\"ex\" "); } - if (block.isBackwardBranchTarget()) { - out.print("\"bb\" "); - } - if (block.isParserLoopHeader()) { - out.print("\"plh\" "); - } if (block.isCriticalEdgeSplit()) { out.print("\"ces\" "); } diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed May 18 17:04:47 2011 +0200 @@ -1046,12 +1046,12 @@ lastInstr = b; b.appendNext(null, -1); - iterateBytecodesForBlock(b.bci(), false); + iterateBytecodesForBlock(b.bci()); } } } - private BlockEnd iterateBytecodesForBlock(int bci, boolean inliningIntoCurrentBlock) { + private BlockEnd iterateBytecodesForBlock(int bci) { assert frameState != null; stream.setBCI(bci); @@ -1064,14 +1064,6 @@ while (bci < endBCI) { BlockBegin nextBlock = blockAtOrNull(bci); - if (bci == 0 && inliningIntoCurrentBlock) { - if (!nextBlock.isParserLoopHeader()) { - // Ignore the block boundary of the entry block of a method - // being inlined unless the block is a loop header. - nextBlock = null; - blockStart = false; - } - } if (nextBlock != null && nextBlock != block) { // we fell through to the next block, add a goto and break end = new Goto(nextBlock, null, false, graph); diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Wed May 18 17:04:47 2011 +0200 @@ -460,14 +460,6 @@ } } - public boolean isBackwardBranchTarget() { - return checkBlockFlag(BlockFlag.BackwardBranchTarget); - } - - public void setBackwardBranchTarget(boolean value) { - setBlockFlag(BlockFlag.BackwardBranchTarget, value); - } - public boolean isCriticalEdgeSplit() { return checkBlockFlag(BlockFlag.CriticalEdgeSplit); } @@ -512,18 +504,10 @@ return checkBlockFlag(BlockFlag.LinearScanLoopHeader); } - public void setLinearScanLoopHeader(boolean value) { - setBlockFlag(BlockFlag.LinearScanLoopHeader, value); - } - public boolean isLinearScanLoopEnd() { return checkBlockFlag(BlockFlag.LinearScanLoopEnd); } - public void setLinearScanLoopEnd(boolean value) { - setBlockFlag(BlockFlag.LinearScanLoopEnd, value); - } - private void setBlockFlag(BlockFlag flag, boolean value) { if (value) { setBlockFlag(flag); @@ -532,12 +516,6 @@ } } - public void copyBlockFlags(BlockBegin other) { - copyBlockFlag(other, BlockBegin.BlockFlag.ParserLoopHeader); - copyBlockFlag(other, BlockBegin.BlockFlag.ExceptionEntry); - copyBlockFlag(other, BlockBegin.BlockFlag.WasVisited); - } - @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -641,22 +619,6 @@ return predecessors.get(j); } - public int firstLirInstructionId() { - return lirBlock.firstLirInstructionID; - } - - public void setFirstLirInstructionId(int firstLirInstructionId) { - lirBlock.firstLirInstructionID = firstLirInstructionId; - } - - public int lastLirInstructionId() { - return lirBlock.lastLirInstructionID; - } - - public void setLastLirInstructionId(int lastLirInstructionId) { - lirBlock.lastLirInstructionID = lastLirInstructionId; - } - public boolean isPredecessor(BlockEnd block) { // assert predecessors.contains(block) == predecessors().contains(block); return predecessors.contains(block); @@ -675,9 +637,6 @@ if (isParserLoopHeader()) { sb.append("LH"); } - if (isBackwardBranchTarget()) { - sb.append('b'); - } if (wasVisited()) { sb.append('V'); } diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java Wed May 18 17:04:47 2011 +0200 @@ -229,8 +229,8 @@ if (C1XOptions.TraceLinearScanLevel >= 3) { TTY.println("Processing loop from B%d to B%d (loop %d):", loopStart.blockID, loopEnd.blockID, loopIdx); } - assert loopEnd.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd) : "loop end flag must be set"; - assert loopStart.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) : "loop header flag must be set"; + assert loopEnd.isLinearScanLoopEnd() : "loop end flag must be set"; + assert loopStart.isLinearScanLoopHeader() : "loop header flag must be set"; assert loopIdx >= 0 && loopIdx < numLoops : "loop index not set"; assert workList.isEmpty() : "work list must be empty before processing"; @@ -341,14 +341,14 @@ // this is necessary for the (very rare) case that two successive blocks have // the same loop depth, but a different loop index (can happen for endless loops // with exception handlers) - if (!cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader)) { + if (!cur.isLinearScanLoopHeader()) { weight |= (1 << curBit); } curBit--; // loop end blocks (blocks that end with a backward branch) are added // after all other blocks of the loop. - if (!cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd)) { + if (!cur.isLinearScanLoopEnd()) { weight |= (1 << curBit); } curBit--; @@ -505,8 +505,8 @@ TTY.print(cur.isExceptionEntry() ? " ex" : " "); TTY.print(cur.isCriticalEdgeSplit() ? " ce" : " "); - TTY.print(cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) ? " lh" : " "); - TTY.print(cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd) ? " le" : " "); + TTY.print(cur.isLinearScanLoopHeader() ? " lh" : " "); + TTY.print(cur.isLinearScanLoopEnd() ? " le" : " "); if (cur.numberOfPreds() > 0) { TTY.print(" preds: "); diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java Wed May 18 17:04:47 2011 +0200 @@ -138,10 +138,6 @@ } void emitBlock(BlockBegin block) { - if (block.checkBlockFlag(BlockBegin.BlockFlag.BackwardBranchTarget)) { - emitAlignment(); - } - // if this block is the start of an exception handler, record the // PC offset of the first instruction for later construction of // the ExceptionHandlerTable diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Wed May 18 17:04:47 2011 +0200 @@ -67,10 +67,25 @@ */ public CiBitMap liveKill; - public int firstLirInstructionID; - public int lastLirInstructionID; + private int firstLirInstructionID; + private int lastLirInstructionID; public int exceptionHandlerPCO; + public int firstLirInstructionId() { + return firstLirInstructionID; + } + + public void setFirstLirInstructionId(int firstLirInstructionId) { + this.firstLirInstructionID = firstLirInstructionId; + } + + public int lastLirInstructionId() { + return lastLirInstructionID; + } + + public void setLastLirInstructionId(int lastLirInstructionId) { + this.lastLirInstructionID = lastLirInstructionId; + } public int loopDepth; public int loopIndex; diff -r 618f545fcac5 -r 42450f536d24 graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java Wed May 18 16:25:33 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java Wed May 18 17:04:47 2011 +0200 @@ -397,13 +397,10 @@ if (x.checkBlockFlag(BlockBegin.BlockFlag.ExceptionEntry)) { TTY.print("ex "); } - if (x.checkBlockFlag(BlockBegin.BlockFlag.BackwardBranchTarget)) { - TTY.print("bb "); - } - if (x.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader)) { + if (x.isLinearScanLoopHeader()) { TTY.print("lh "); } - if (x.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd)) { + if (x.isLinearScanLoopEnd()) { TTY.print("le "); }