# HG changeset patch # User Thomas Wuerthinger # Date 1305813942 -7200 # Node ID c1ce2a53d6c375139ddb3ac7b979f581addc7e38 # Parent bd85cf08720a3d4845cd28e2fe5cf996ea049ddf Attempt to remove dependency between backend and BlockBegin. diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java --- a/graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java Thu May 19 16:05:42 2011 +0200 @@ -247,7 +247,7 @@ lirGenerator = compiler.backend.newLIRGenerator(this); - for (BlockBegin begin : hir.linearScanOrder()) { + for (LIRBlock begin : hir.linearScanOrder()) { lirGenerator.doBlock(begin); } @@ -284,7 +284,8 @@ } if (compiler.isObserved()) { - compiler.fireCompilationEvent(new CompilationEvent(this, "After code generation", hir.startBlock, false, true, targetMethod)); + // TODO(tw): FIXME + // compiler.fireCompilationEvent(new CompilationEvent(this, "After code generation", hir.startBlock, false, true, targetMethod)); } if (C1XOptions.PrintTimers) { diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/alloc/EdgeMoveOptimizer.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/EdgeMoveOptimizer.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/EdgeMoveOptimizer.java Thu May 19 16:05:42 2011 +0200 @@ -59,12 +59,12 @@ * * @param blockList a list of blocks whose moves should be optimized */ - public static void optimize(List blockList) { + public static void optimize(List blockList) { EdgeMoveOptimizer optimizer = new EdgeMoveOptimizer(); // ignore the first block in the list (index 0 is not processed) for (int i = blockList.size() - 1; i >= 1; i--) { - BlockBegin block = blockList.get(i); + LIRBlock block = blockList.get(i); if (block.numberOfPreds() > 1) { optimizer.optimizeMovesAtBlockEnd(block); @@ -111,8 +111,8 @@ * Moves the longest {@linkplain #same common} subsequence at the end all * predecessors of {@code block} to the start of {@code block}. */ - private void optimizeMovesAtBlockEnd(BlockBegin block) { - if (block.isPredecessor(block.end())) { + private void optimizeMovesAtBlockEnd(LIRBlock block) { + if (block.isPredecessor(block)) { // currently we can't handle this correctly. return; } @@ -125,7 +125,7 @@ // setup a list with the LIR instructions of all predecessors for (int i = 0; i < numPreds; i++) { - BlockBegin pred = block.predAt(i).block(); + LIRBlock pred = block.predAt(i); List predInstructions = pred.lir().instructionsList(); if (pred.numberOfSux() != 1) { @@ -180,7 +180,7 @@ * successors of {@code block} to the end of {@code block} just prior to the * branch instruction ending {@code block}. */ - private void optimizeMovesAtBlockBegin(BlockBegin block) { + private void optimizeMovesAtBlockBegin(LIRBlock block) { edgeInstructionSeqences.clear(); int numSux = block.numberOfSux(); @@ -220,7 +220,7 @@ // setup a list with the lir-instructions of all successors for (int i = 0; i < numSux; i++) { - BlockBegin sux = block.suxAt(i); + LIRBlock sux = block.suxAt(i); List suxInstructions = sux.lir().instructionsList(); assert suxInstructions.get(0).code == LIROpcode.Label : "block must start with label"; @@ -230,7 +230,7 @@ // the same blocks. return; } - assert sux.predAt(0).block() == block : "invalid control flow"; + assert sux.predAt(0) == block : "invalid control flow"; // ignore the label at the beginning of the block List seq = suxInstructions.subList(1, suxInstructions.size()); diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java Thu May 19 16:05:42 2011 +0200 @@ -67,7 +67,7 @@ /** * List of blocks in linear-scan order. This is only correct as long as the CFG does not change. */ - final BlockBegin[] sortedBlocks; + final LIRBlock[] sortedBlocks; final OperandPool operands; @@ -113,7 +113,7 @@ * BlockBegin block} containing the instruction. Entries should be retrieved with * {@link #blockForId(int)} as the id is not simply an index into this array. */ - BlockBegin[] opIdToBlockMap; + LIRBlock[] opIdToBlockMap; /** * Bit set for each variable that is contained in each loop. @@ -127,7 +127,7 @@ this.frameMap = frameMap; this.maxSpills = frameMap.initialSpillSlot(); this.unusedSpillSlot = null; - this.sortedBlocks = ir.linearScanOrder().toArray(new BlockBegin[ir.linearScanOrder().size()]); + this.sortedBlocks = ir.linearScanOrder().toArray(new LIRBlock[ir.linearScanOrder().size()]); CiRegister[] allocatableRegisters = compilation.registerConfig.getAllocatableRegisters(); this.registers = new CiRegister[CiRegister.maxRegisterNumber(allocatableRegisters) + 1]; for (CiRegister reg : allocatableRegisters) { @@ -265,7 +265,7 @@ return sortedBlocks.length; } - BlockBegin blockAt(int index) { + LIRBlock blockAt(int index) { assert sortedBlocks[index] == ir.linearScanOrder().get(index) : "invalid cached block list"; return sortedBlocks[index]; } @@ -329,7 +329,7 @@ * @param opId an instruction {@linkplain LIRInstruction#id id} * @return the block containing the instruction denoted by {@code opId} */ - BlockBegin blockForId(int opId) { + LIRBlock blockForId(int opId) { assert opIdToBlockMap.length > 0 && opId >= 0 && opId <= maxOpId() + 1 : "opId out of range"; return opIdToBlockMap[opIdToIndex(opId)]; } @@ -453,7 +453,7 @@ LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer(); int numBlocks = blockCount(); for (int i = 0; i < numBlocks; i++) { - BlockBegin block = blockAt(i); + LIRBlock block = blockAt(i); List instructions = block.lir().instructionsList(); int numInst = instructions.size(); boolean hasNew = false; @@ -556,14 +556,14 @@ // initialize with correct length opIdToInstructionMap = new LIRInstruction[numInstructions]; - opIdToBlockMap = new BlockBegin[numInstructions]; + opIdToBlockMap = new LIRBlock[numInstructions]; int opId = 0; int index = 0; for (int i = 0; i < numBlocks; i++) { - BlockBegin block = blockAt(i); - block.lirBlock.setFirstLirInstructionId(opId); + LIRBlock block = blockAt(i); + block.setFirstLirInstructionId(opId); List instructions = block.lir().instructionsList(); int numInst = instructions.size(); @@ -578,7 +578,7 @@ index++; opId += 2; // numbering of lirOps by two } - block.lirBlock.setLastLirInstructionId((opId - 2)); + block.setLastLirInstructionId((opId - 2)); } assert index == numInstructions : "must match"; assert (index << 1) == opId : "must match: " + (index << 1); @@ -595,7 +595,7 @@ // iterate all blocks for (int i = 0; i < numBlocks; i++) { - BlockBegin block = blockAt(i); + LIRBlock block = blockAt(i); final CiBitMap liveGen = new CiBitMap(liveSize); final CiBitMap liveKill = new CiBitMap(liveSize); @@ -696,15 +696,14 @@ } } // end of instruction iteration - LIRBlock lirBlock = block.lirBlock(); - lirBlock.liveGen = liveGen; - lirBlock.liveKill = liveKill; - lirBlock.liveIn = new CiBitMap(liveSize); - lirBlock.liveOut = new CiBitMap(liveSize); + block.liveGen = liveGen; + block.liveKill = liveKill; + block.liveIn = new CiBitMap(liveSize); + block.liveOut = new CiBitMap(liveSize); if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println("liveGen B%d %s", block.blockID, block.lirBlock.liveGen); - TTY.println("liveKill B%d %s", block.blockID, block.lirBlock.liveKill); + TTY.println("liveGen B%d %s", block.blockID(), block.liveGen); + TTY.println("liveKill B%d %s", block.blockID(), block.liveKill); } } // end of block iteration @@ -722,13 +721,13 @@ } } - private void verifyInput(BlockBegin block, CiBitMap liveKill, CiValue operand) { + private void verifyInput(LIRBlock block, CiBitMap liveKill, CiValue operand) { // fixed intervals are never live at block boundaries, so // they need not be processed in live sets. // this is checked by these assertions to be sure about it. // the entry block may have incoming // values in registers, which is ok. - if (!operand.isVariable() && block != ir.startBlock) { + if (!operand.isVariable() /*&& block != ir.startBlock*/) { if (isProcessed(operand)) { assert liveKill.get(operandNumber(operand)) : "using fixed register that is not defined in this block"; } @@ -755,8 +754,7 @@ // iterate all blocks in reverse order for (int i = numBlocks - 1; i >= 0; i--) { - BlockBegin block = blockAt(i); - LIRBlock lirBlock = block.lirBlock(); + LIRBlock block = blockAt(i); changeOccurredInBlock = false; @@ -765,18 +763,18 @@ if (n > 0) { // block has successors if (n > 0) { - liveOut.setFrom(block.suxAt(0).lirBlock.liveIn); + liveOut.setFrom(block.suxAt(0).liveIn); for (int j = 1; j < n; j++) { - liveOut.setUnion(block.suxAt(j).lirBlock.liveIn); + liveOut.setUnion(block.suxAt(j).liveIn); } } else { liveOut.clearAll(); } - if (!lirBlock.liveOut.isSame(liveOut)) { + if (!block.liveOut.isSame(liveOut)) { // A change occurred. Swap the old and new live out sets to avoid copying. - CiBitMap temp = lirBlock.liveOut; - lirBlock.liveOut = liveOut; + CiBitMap temp = block.liveOut; + block.liveOut = liveOut; liveOut = temp; changeOccurred = true; @@ -787,10 +785,10 @@ if (iterationCount == 0 || changeOccurredInBlock) { // liveIn(block) is the union of liveGen(block) with (liveOut(block) & !liveKill(block)) // note: liveIn has to be computed only in first iteration or if liveOut has changed! - CiBitMap liveIn = lirBlock.liveIn; - liveIn.setFrom(lirBlock.liveOut); - liveIn.setDifference(lirBlock.liveKill); - liveIn.setUnion(lirBlock.liveGen); + CiBitMap liveIn = block.liveIn; + liveIn.setFrom(block.liveOut); + liveIn.setDifference(block.liveKill); + liveIn.setUnion(block.liveGen); } if (C1XOptions.TraceLinearScanLevel >= 4) { @@ -809,8 +807,9 @@ } // check that the liveIn set of the first block is empty - CiBitMap liveInArgs = new CiBitMap(ir.startBlock.lirBlock.liveIn.size()); - if (!ir.startBlock.lirBlock.liveIn.isSame(liveInArgs)) { + LIRBlock startBlock = ir.startBlock; + CiBitMap liveInArgs = new CiBitMap(startBlock.liveIn.size()); + if (!startBlock.liveIn.isSame(liveInArgs)) { if (C1XOptions.DetailedAsserts) { reportFailure(numBlocks); } @@ -823,22 +822,22 @@ private void reportFailure(int numBlocks) { TTY.println("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined)"); TTY.print("affected registers:"); - TTY.println(ir.startBlock.lirBlock.liveIn.toString()); + TTY.println(ir.startBlock.liveIn.toString()); // print some additional information to simplify debugging - for (int operandNum = 0; operandNum < ir.startBlock.lirBlock.liveIn.size(); operandNum++) { - if (ir.startBlock.lirBlock.liveIn.get(operandNum)) { + for (int operandNum = 0; operandNum < ir.startBlock.liveIn.size(); operandNum++) { + if (ir.startBlock.liveIn.get(operandNum)) { CiValue operand = operands.operandFor(operandNum); Value instr = operand.isVariable() ? gen.operands.instructionForResult(((CiVariable) operand)) : null; TTY.println(" var %d (HIR instruction %s)", operandNum, instr == null ? " " : instr.toString()); for (int j = 0; j < numBlocks; j++) { - BlockBegin block = blockAt(j); - if (block.lirBlock.liveGen.get(operandNum)) { - TTY.println(" used in block B%d", block.blockID); + LIRBlock block = blockAt(j); + if (block.liveGen.get(operandNum)) { + TTY.println(" used in block B%d", block.blockID()); } - if (block.lirBlock.liveKill.get(operandNum)) { - TTY.println(" defined in block B%d", block.blockID); + if (block.liveKill.get(operandNum)) { + TTY.println(" defined in block B%d", block.blockID()); } } } @@ -849,21 +848,21 @@ // check that fixed intervals are not live at block boundaries // (live set must be empty at fixed intervals) for (int i = 0; i < numBlocks; i++) { - BlockBegin block = blockAt(i); + LIRBlock block = blockAt(i); for (int j = 0; j <= operands.maxRegisterNumber(); j++) { - assert !block.lirBlock.liveIn.get(j) : "liveIn set of fixed register must be empty"; - assert !block.lirBlock.liveOut.get(j) : "liveOut set of fixed register must be empty"; - assert !block.lirBlock.liveGen.get(j) : "liveGen set of fixed register must be empty"; + assert !block.liveIn.get(j) : "liveIn set of fixed register must be empty"; + assert !block.liveOut.get(j) : "liveOut set of fixed register must be empty"; + assert !block.liveGen.get(j) : "liveGen set of fixed register must be empty"; } } } - private void traceLiveness(boolean changeOccurredInBlock, int iterationCount, BlockBegin block) { + private void traceLiveness(boolean changeOccurredInBlock, int iterationCount, LIRBlock block) { char c = iterationCount == 0 || changeOccurredInBlock ? '*' : ' '; - TTY.print("(%d) liveIn%c B%d ", iterationCount, c, block.blockID); - TTY.println(block.lirBlock.liveIn.toString()); - TTY.print("(%d) liveOut%c B%d ", iterationCount, c, block.blockID); - TTY.println(block.lirBlock.liveOut.toString()); + TTY.print("(%d) liveIn%c B%d ", iterationCount, c, block.blockID()); + TTY.println(block.liveIn.toString()); + TTY.print("(%d) liveOut%c B%d ", iterationCount, c, block.blockID()); + TTY.println(block.liveOut.toString()); } Interval addUse(CiValue operand, int from, int to, RegisterPriority registerPriority, CiKind kind) { @@ -1157,16 +1156,16 @@ // iterate all blocks in reverse order for (int i = blockCount() - 1; i >= 0; i--) { - BlockBegin block = blockAt(i); + LIRBlock block = blockAt(i); List instructions = block.lir().instructionsList(); - final int blockFrom = block.lirBlock.firstLirInstructionId(); - int blockTo = block.lirBlock.lastLirInstructionId(); + final int blockFrom = block.firstLirInstructionId(); + int blockTo = block.lastLirInstructionId(); assert blockFrom == instructions.get(0).id; assert blockTo == instructions.get(instructions.size() - 1).id; // Update intervals for operands live at the end of this block; - CiBitMap live = block.lirBlock.liveOut; + CiBitMap live = block.liveOut; for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) { assert live.get(operandNum) : "should not stop here otherwise"; CiValue operand = operands.operandFor(operandNum); @@ -1180,7 +1179,7 @@ // interval is used anywhere inside this loop. It's possible // that the block was part of a non-natural loop, so it might // have an invalid loop index. - if (block.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd) && block.loopIndex() != -1 && isIntervalInLoop(operandNum, block.loopIndex())) { + if (block.isLinearScanLoopEnd() && block.loopIndex() != -1 && isIntervalInLoop(operandNum, block.loopIndex())) { intervalFor(operand).addUsePos(blockTo + 1, RegisterPriority.LiveAtLoopEnd); } } @@ -1508,18 +1507,18 @@ throw new CiBailout("LinearScan: interval is null"); } - Interval intervalAtBlockBegin(BlockBegin block, CiValue operand) { + Interval intervalAtBlockBegin(LIRBlock block, CiValue operand) { assert operand.isVariable() : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; - return splitChildAtOpId(intervalFor(operand), block.lirBlock.firstLirInstructionId(), LIRInstruction.OperandMode.Output); + return splitChildAtOpId(intervalFor(operand), block.firstLirInstructionId(), LIRInstruction.OperandMode.Output); } - Interval intervalAtBlockEnd(BlockBegin block, CiValue operand) { + Interval intervalAtBlockEnd(LIRBlock block, CiValue operand) { assert operand.isVariable() : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; - return splitChildAtOpId(intervalFor(operand), block.lirBlock.lastLirInstructionId() + 1, LIRInstruction.OperandMode.Output); + return splitChildAtOpId(intervalFor(operand), block.lastLirInstructionId() + 1, LIRInstruction.OperandMode.Output); } Interval intervalAtOpId(CiValue operand, int opId) { @@ -1529,16 +1528,16 @@ return splitChildAtOpId(intervalFor(operand), opId, LIRInstruction.OperandMode.Input); } - void resolveCollectMappings(BlockBegin fromBlock, BlockBegin toBlock, MoveResolver moveResolver) { + void resolveCollectMappings(LIRBlock fromBlock, LIRBlock toBlock, MoveResolver moveResolver) { assert moveResolver.checkEmpty(); int numOperands = operands.size(); - CiBitMap liveAtEdge = toBlock.lirBlock.liveIn; + CiBitMap liveAtEdge = toBlock.liveIn; // visit all variables for which the liveAtEdge bit is set for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 1)) { assert operandNum < numOperands : "live information set for not exisiting interval"; - assert fromBlock.lirBlock.liveOut.get(operandNum) && toBlock.lirBlock.liveIn.get(operandNum) : "interval not live at this edge"; + assert fromBlock.liveOut.get(operandNum) && toBlock.liveIn.get(operandNum) : "interval not live at this edge"; CiValue liveOperand = operands.operandFor(operandNum); Interval fromInterval = intervalAtBlockEnd(fromBlock, liveOperand); @@ -1551,10 +1550,10 @@ } } - void resolveFindInsertPos(BlockBegin fromBlock, BlockBegin toBlock, MoveResolver moveResolver) { + void resolveFindInsertPos(LIRBlock fromBlock, LIRBlock toBlock, MoveResolver moveResolver) { if (fromBlock.numberOfSux() <= 1) { if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println("inserting moves at end of fromBlock B%d", fromBlock.blockID); + TTY.println("inserting moves at end of fromBlock B%d", fromBlock.blockID()); } List instructions = fromBlock.lir().instructionsList(); @@ -1570,7 +1569,7 @@ } else { if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println("inserting moves at beginning of toBlock B%d", toBlock.blockID); + TTY.println("inserting moves at beginning of toBlock B%d", toBlock.blockID()); } if (C1XOptions.DetailedAsserts) { @@ -1581,7 +1580,7 @@ // may have be more than one predecessor but it will be guaranteed // that all predecessors will be the same. for (int i = 0; i < toBlock.numberOfPreds(); i++) { - assert fromBlock == toBlock.predAt(i).block() : "all critical edges must be broken"; + assert fromBlock == toBlock.predAt(i) : "all critical edges must be broken"; } } @@ -1601,7 +1600,7 @@ int i; for (i = 0; i < numBlocks; i++) { - BlockBegin block = blockAt(i); + LIRBlock block = blockAt(i); // check if block has only one predecessor and only one successor if (block.numberOfPreds() == 1 && block.numberOfSux() == 1) { @@ -1612,13 +1611,13 @@ // check if block is empty (only label and branch) if (instructions.size() == 2) { - BlockBegin pred = block.predAt(0).block(); - BlockBegin sux = block.suxAt(0); + LIRBlock pred = block.predAt(0); + LIRBlock sux = block.suxAt(0); // prevent optimization of two consecutive blocks if (!blockCompleted.get(pred.linearScanNumber()) && !blockCompleted.get(sux.linearScanNumber())) { if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println(" optimizing empty block B%d (pred: B%d, sux: B%d)", block.blockID, pred.blockID, sux.blockID); + TTY.println(" optimizing empty block B%d (pred: B%d, sux: B%d)", block.blockID(), pred.blockID(), sux.blockID()); } blockCompleted.set(block.linearScanNumber()); @@ -1635,17 +1634,17 @@ for (i = 0; i < numBlocks; i++) { if (!blockCompleted.get(i)) { - BlockBegin fromBlock = blockAt(i); + LIRBlock fromBlock = blockAt(i); alreadyResolved.setFrom(blockCompleted); int numSux = fromBlock.numberOfSux(); for (int s = 0; s < numSux; s++) { - BlockBegin toBlock = fromBlock.suxAt(s); + LIRBlock toBlock = fromBlock.suxAt(s); // check for duplicate edges between the same blocks (can happen with switch blocks) if (!alreadyResolved.get(toBlock.linearScanNumber())) { if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println(" processing edge between B%d and B%d", fromBlock.blockID, toBlock.blockID); + TTY.println(" processing edge between B%d and B%d", fromBlock.blockID(), toBlock.blockID()); } alreadyResolved.set(toBlock.linearScanNumber()); @@ -1727,15 +1726,15 @@ if (opId != -1) { if (C1XOptions.DetailedAsserts) { - BlockBegin block = blockForId(opId); - if (block.numberOfSux() <= 1 && opId == block.lirBlock.lastLirInstructionId()) { + LIRBlock block = blockForId(opId); + if (block.numberOfSux() <= 1 && opId == block.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. LIRInstruction instr = block.lir().instructionsList().get(block.lir().instructionsList().size() - 1); if (instr instanceof LIRBranch) { LIRBranch branch = (LIRBranch) instr; - if (block.lirBlock.liveOut.get(operandNumber(operand))) { + if (block.liveOut.get(operandNumber(operand))) { assert branch.cond() == Condition.TRUE : "block does not end with an unconditional jump"; throw new CiBailout("can't get split child for the last branch of a block because the information would be incorrect (moves are inserted before the branch in resolveDataFlow)"); } @@ -1847,8 +1846,8 @@ if (operand.isVariable()) { OperandMode mode = OperandMode.Input; - BlockBegin block = blockForId(opId); - if (block.numberOfSux() == 1 && opId == block.lirBlock.lastLirInstructionId()) { + LIRBlock block = blockForId(opId); + if (block.numberOfSux() == 1 && opId == block.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 @@ -1856,8 +1855,8 @@ // Solution: use the first opId of the branch target block instead. 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).lirBlock.firstLirInstructionId(); + if (block.liveOut.get(operandNumber(operand))) { + opId = block.suxAt(0).firstLirInstructionId(); mode = OperandMode.Output; } } @@ -2015,7 +2014,7 @@ private void assignLocations() { IntervalWalker iw = initComputeOopMaps(); - for (BlockBegin block : sortedBlocks) { + for (LIRBlock block : sortedBlocks) { assignLocations(block.lir().instructionsList(), iw); } } @@ -2102,8 +2101,8 @@ TTY.println(); 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.lirBlock.firstLirInstructionId(), block.lirBlock.lastLirInstructionId(), block.loopIndex(), block.loopDepth()); + LIRBlock block = blockAt(i); + TTY.print("B%d [%d, %d, %d, %d] ", block.blockID(), block.firstLirInstructionId(), block.lastLirInstructionId(), block.loopIndex(), block.loopDepth()); } TTY.println(); TTY.println(); @@ -2123,7 +2122,8 @@ } if (compilation.compiler.isObserved()) { - compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, label, compilation.hir().startBlock, hirValid, true)); + // TODO(tw): FIXME + //compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, label, compilation.hir().startBlock, hirValid, true)); } } @@ -2249,7 +2249,7 @@ IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals); for (int i = 0; i < blockCount(); i++) { - BlockBegin block = blockAt(i); + LIRBlock block = blockAt(i); List instructions = block.lir().instructionsList(); @@ -2294,13 +2294,13 @@ int numBlocks = blockCount(); for (int i = 0; i < numBlocks; i++) { - BlockBegin block = blockAt(i); - CiBitMap liveAtEdge = block.lirBlock.liveIn; + LIRBlock block = blockAt(i); + CiBitMap liveAtEdge = block.liveIn; // visit all operands where the liveAtEdge bit is set for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 1)) { if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println("checking interval %d of block B%d", operandNum, block.blockID); + TTY.println("checking interval %d of block B%d", operandNum, block.blockID()); } CiValue operand = operands.operandFor(operandNum); assert operand.isVariable() : "value must have variable operand"; diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScanWalker.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScanWalker.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScanWalker.java Thu May 19 16:05:42 2011 +0200 @@ -58,11 +58,11 @@ return allocator.blockCount(); } - BlockBegin blockAt(int idx) { + LIRBlock blockAt(int idx) { return allocator.blockAt(idx); } - BlockBegin blockOfOpWithId(int opId) { + LIRBlock blockOfOpWithId(int opId) { return allocator.blockForId(opId); } @@ -228,7 +228,7 @@ // optimized away later in assignRegNums opId = (opId + 1) & ~1; - BlockBegin opBlock = allocator.blockForId(opId); + LIRBlock opBlock = allocator.blockForId(opId); assert opId > 0 && allocator.blockForId(opId - 2) == opBlock : "cannot insert move at block boundary"; // calculate index of instruction inside instruction list of current block @@ -252,7 +252,7 @@ moveResolver.addMapping(srcIt, dstIt); } - int findOptimalSplitPos(BlockBegin minBlock, BlockBegin maxBlock, int maxSplitPos) { + int findOptimalSplitPos(LIRBlock minBlock, LIRBlock maxBlock, int maxSplitPos) { int fromBlockNr = minBlock.linearScanNumber(); int toBlockNr = maxBlock.linearScanNumber(); @@ -262,19 +262,19 @@ // Try to split at end of maxBlock. If this would be after // maxSplitPos, then use the begin of maxBlock - int optimalSplitPos = maxBlock.lirBlock.lastLirInstructionId() + 2; + int optimalSplitPos = maxBlock.lastLirInstructionId() + 2; if (optimalSplitPos > maxSplitPos) { - optimalSplitPos = maxBlock.lirBlock.firstLirInstructionId(); + optimalSplitPos = maxBlock.firstLirInstructionId(); } int minLoopDepth = maxBlock.loopDepth(); for (int i = toBlockNr - 1; i >= fromBlockNr; i--) { - BlockBegin cur = blockAt(i); + LIRBlock cur = blockAt(i); if (cur.loopDepth() < minLoopDepth) { // block with lower loop-depth found . split at the end of this block minLoopDepth = cur.loopDepth(); - optimalSplitPos = cur.lirBlock.lastLirInstructionId() + 2; + optimalSplitPos = cur.lastLirInstructionId() + 2; } } assert optimalSplitPos > allocator.maxOpId() || allocator.isBlockBegin(optimalSplitPos) : "algorithm must move split pos to block boundary"; @@ -298,13 +298,13 @@ // reason for using minSplitPos - 1: when the minimal split pos is exactly at the // beginning of a block, then minSplitPos is also a possible split position. // Use the block before as minBlock, because then minBlock.lastLirInstructionId() + 2 == minSplitPos - BlockBegin minBlock = allocator.blockForId(minSplitPos - 1); + LIRBlock minBlock = allocator.blockForId(minSplitPos - 1); // reason for using maxSplitPos - 1: otherwise there would be an assert on failure // when an interval ends at the end of the last block of the method // (in this case, maxSplitPos == allocator().maxLirOpId() + 2, and there is no // block at this opId) - BlockBegin maxBlock = allocator.blockForId(maxSplitPos - 1); + LIRBlock maxBlock = allocator.blockForId(maxSplitPos - 1); assert minBlock.linearScanNumber() <= maxBlock.linearScanNumber() : "invalid order"; if (minBlock == maxBlock) { @@ -328,13 +328,13 @@ } else { // seach optimal block boundary between minSplitPos and maxSplitPos if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println(" moving split pos to optimal block boundary between block B%d and B%d", minBlock.blockID, maxBlock.blockID); + TTY.println(" moving split pos to optimal block boundary between block B%d and B%d", minBlock.blockID(), maxBlock.blockID()); } 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.lirBlock.lastLirInstructionId() + 2); + int loopEndPos = interval.nextUsageExact(RegisterPriority.LiveAtLoopEnd, minBlock.lastLirInstructionId() + 2); if (C1XOptions.TraceLinearScanLevel >= 4) { TTY.println(" loop optimization: loop end found at pos %d", loopEndPos); } @@ -346,15 +346,15 @@ // the max-position to this loop block. // Desired result: uses tagged as shouldHaveRegister inside a loop cause a reloading // of the interval (normally, only mustHaveRegister causes a reloading) - BlockBegin loopBlock = allocator.blockForId(loopEndPos); + LIRBlock loopBlock = allocator.blockForId(loopEndPos); if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println(" interval is used in loop that ends in block B%d, so trying to move maxBlock back from B%d to B%d", loopBlock.blockID, maxBlock.blockID, loopBlock.blockID); + TTY.println(" interval is used in loop that ends in block B%d, so trying to move maxBlock back from B%d to B%d", loopBlock.blockID(), maxBlock.blockID(), loopBlock.blockID()); } assert loopBlock != minBlock : "loopBlock and minBlock must be different because block boundary is needed between"; - optimalSplitPos = findOptimalSplitPos(minBlock, loopBlock, loopBlock.lirBlock.lastLirInstructionId() + 2); - if (optimalSplitPos == loopBlock.lirBlock.lastLirInstructionId() + 2) { + optimalSplitPos = findOptimalSplitPos(minBlock, loopBlock, loopBlock.lastLirInstructionId() + 2); + if (optimalSplitPos == loopBlock.lastLirInstructionId() + 2) { optimalSplitPos = -1; if (C1XOptions.TraceLinearScanLevel >= 4) { TTY.println(" loop optimization not necessary"); diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/alloc/RegisterVerifier.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/RegisterVerifier.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/RegisterVerifier.java Thu May 19 16:05:42 2011 +0200 @@ -38,7 +38,7 @@ final class RegisterVerifier { LinearScan allocator; - List workList; // all blocks that must be processed + List workList; // all blocks that must be processed ArrayMap savedStates; // saved information of previous check // simplified access to methods of LinearScan @@ -56,15 +56,15 @@ } // accessors - Interval[] stateForBlock(BlockBegin block) { - return savedStates.get(block.blockID); + Interval[] stateForBlock(LIRBlock block) { + return savedStates.get(block.blockID()); } - void setStateForBlock(BlockBegin block, Interval[] savedState) { - savedStates.put(block.blockID, savedState); + void setStateForBlock(LIRBlock block, Interval[] savedState) { + savedStates.put(block.blockID(), savedState); } - void addToWorkList(BlockBegin block) { + void addToWorkList(LIRBlock block) { if (!workList.contains(block)) { workList.add(block); } @@ -72,12 +72,12 @@ RegisterVerifier(LinearScan allocator) { this.allocator = allocator; - workList = new ArrayList(16); + workList = new ArrayList(16); this.savedStates = new ArrayMap(); } - void verify(BlockBegin start) { + void verify(LIRBlock start) { // setup input registers (method arguments) for first block Interval[] inputState = new Interval[stateSize()]; CiCallingConvention args = compilation().frameMap().incomingArguments(); @@ -95,17 +95,17 @@ // main loop for verification do { - BlockBegin block = workList.get(0); + LIRBlock block = workList.get(0); workList.remove(0); processBlock(block); } while (!workList.isEmpty()); } - void processBlock(BlockBegin block) { + void processBlock(LIRBlock block) { if (C1XOptions.TraceLinearScanLevel >= 2) { TTY.println(); - TTY.println("processBlock B%d", block.blockID); + TTY.println("processBlock B%d", block.blockID()); } // must copy state because it is modified @@ -129,14 +129,14 @@ processOperations(block.lir(), inputState); // iterate all successors - for (BlockBegin succ : block.end().blockSuccessors()) { + for (LIRBlock succ : block.blockSuccessors()) { processSuccessor(succ, inputState); } } - void processXhandler(BlockBegin xhandler, Interval[] inputState) { + void processXhandler(LIRBlock xhandler, Interval[] inputState) { if (C1XOptions.TraceLinearScanLevel >= 2) { - TTY.println("processXhandler B%d", xhandler.blockID); + TTY.println("processXhandler B%d", xhandler.blockID()); } // must copy state because it is modified @@ -148,7 +148,7 @@ processSuccessor(xhandler, inputState); } - void processSuccessor(BlockBegin block, Interval[] inputState) { + void processSuccessor(LIRBlock block, Interval[] inputState) { Interval[] savedState = stateForBlock(block); if (savedState != null) { @@ -168,7 +168,7 @@ savedState[i] = null; if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println("processSuccessor B%d: invalidating slot %d", block.blockID, i); + TTY.println("processSuccessor B%d: invalidating slot %d", block.blockID(), i); } } } @@ -177,12 +177,12 @@ if (savedStateCorrect) { // already processed block with correct inputState if (C1XOptions.TraceLinearScanLevel >= 2) { - TTY.println("processSuccessor B%d: previous visit already correct", block.blockID); + TTY.println("processSuccessor B%d: previous visit already correct", block.blockID()); } } else { // must re-visit this block if (C1XOptions.TraceLinearScanLevel >= 2) { - TTY.println("processSuccessor B%d: must re-visit because input state changed", block.blockID); + TTY.println("processSuccessor B%d: must re-visit because input state changed", block.blockID()); } addToWorkList(block); } @@ -190,7 +190,7 @@ } else { // block was not processed before, so set initial inputState if (C1XOptions.TraceLinearScanLevel >= 2) { - TTY.println("processSuccessor B%d: initial visit", block.blockID); + TTY.println("processSuccessor B%d: initial visit", block.blockID()); } setStateForBlock(block, copy(inputState)); diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/asm/ExceptionInfo.java --- a/graal/GraalCompiler/src/com/sun/c1x/asm/ExceptionInfo.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/asm/ExceptionInfo.java Thu May 19 16:05:42 2011 +0200 @@ -22,19 +22,15 @@ */ package com.sun.c1x.asm; -import com.sun.c1x.ir.*; +import com.sun.c1x.lir.*; -/** - * - * @author Thomas Wuerthinger - */ public class ExceptionInfo { public final int codeOffset; - public final BlockBegin exceptionEdge; + public final LIRBlock exceptionEdge; public final int bci; - public ExceptionInfo(int pcOffset, BlockBegin exceptionEdge, int bci) { + public ExceptionInfo(int pcOffset, LIRBlock exceptionEdge, int bci) { this.codeOffset = pcOffset; this.exceptionEdge = exceptionEdge; this.bci = bci; diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/asm/TargetMethodAssembler.java --- a/graal/GraalCompiler/src/com/sun/c1x/asm/TargetMethodAssembler.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/asm/TargetMethodAssembler.java Thu May 19 16:05:42 2011 +0200 @@ -64,7 +64,7 @@ if (exceptionInfoList != null) { for (ExceptionInfo ei : exceptionInfoList) { int codeOffset = ei.codeOffset; - targetMethod.recordExceptionHandler(codeOffset, -1, 0, ei.exceptionEdge.lirBlock.blockEntryPco, -1, null); + targetMethod.recordExceptionHandler(codeOffset, -1, 0, ei.exceptionEdge.blockEntryPco, -1, null); } } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Thu May 19 16:05:42 2011 +0200 @@ -158,10 +158,8 @@ } out.println(); - if (block.loopIndex() != -1) { - out.print("loop_index ").println(block.loopIndex()); - out.print("loop_depth ").println(block.loopDepth()); - } + out.print("loop_index ").println(-1); + out.print("loop_depth ").println(-1); if (printHIR) { printState(block); diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 16:05:42 2011 +0200 @@ -56,11 +56,6 @@ /** * This class traverses the HIR instructions and generates LIR instructions from them. - * - * @author Thomas Wuerthinger - * @author Ben L. Titzer - * @author Marcelo Cintra - * @author Doug Simon */ public abstract class LIRGenerator extends ValueVisitor { @@ -177,7 +172,7 @@ protected final RiXirGenerator xir; protected final boolean isTwoOperand; - private BlockBegin currentBlock; + private LIRBlock currentBlock; public final OperandPool operands; @@ -227,15 +222,15 @@ } } - public void doBlock(BlockBegin block) { + public void doBlock(LIRBlock block) { blockDoProlog(block); this.currentBlock = block; if (C1XOptions.TraceLIRGeneratorLevel >= 1) { - TTY.println("BEGIN Generating LIR for block B" + block.blockID); + TTY.println("BEGIN Generating LIR for block B" + block.blockID()); } - for (Instruction instr = block; instr != null; instr = instr.next()) { + for (Instruction instr : block.getInstructions()) { FrameState stateAfter = instr.stateAfter(); FrameState stateBefore = null; if (instr instanceof StateSplit && ((StateSplit) instr).stateBefore() != null) { @@ -266,11 +261,11 @@ } if (C1XOptions.TraceLIRGeneratorLevel >= 1) { - TTY.println("END Generating LIR for block B" + block.blockID); + TTY.println("END Generating LIR for block B" + block.blockID()); } this.currentBlock = null; - blockDoEpilog(block); + blockDoEpilog(); } @Override @@ -395,11 +390,10 @@ @Override public void visitExceptionObject(ExceptionObject x) { - assert currentBlock.next() == x : "ExceptionObject must be first instruction of block"; // no moves are created for phi functions at the begin of exception // handlers, so assign operands manually here - currentBlock.stateBefore().forEachLivePhi(currentBlock, new PhiProcedure() { + currentBlock.stateBefore().forEachLivePhi(currentBlock.blockID(), new PhiProcedure() { public boolean doPhi(Phi phi) { operandForPhi(phi); return true; @@ -890,7 +884,7 @@ lir.branch(Condition.TRUE, stub.label, stub.info); } - private void blockDoEpilog(BlockBegin block) { + private void blockDoEpilog() { if (C1XOptions.PrintIRWithLIR) { TTY.println(); } @@ -900,7 +894,7 @@ variablesForConstants.clear(); } - private void blockDoProlog(BlockBegin block) { + private void blockDoProlog(LIRBlock block) { if (C1XOptions.PrintIRWithLIR) { TTY.print(block.toString()); } @@ -915,7 +909,7 @@ if (prologue != null) { emitXir(prologue, null, null, null, false); } - setOperandsForLocals(block.end().stateAfter()); + setOperandsForLocals(ir.getHIRStartBlock().end().stateAfter()); } } @@ -1287,9 +1281,9 @@ protected void moveToPhi(FrameState curState) { // Moves all stack values into their phi position - BlockBegin bb = currentBlock; + LIRBlock bb = currentBlock; if (bb.numberOfSux() == 1) { - BlockBegin sux = bb.suxAt(0); + LIRBlock sux = bb.suxAt(0); assert sux.numberOfPreds() > 0 : "invalid CFG"; // a block with only one predecessor never has phi functions @@ -1437,7 +1431,14 @@ } assert state != null; - return new LIRDebugInfo(state, (x instanceof ExceptionEdgeInstruction) ? ((ExceptionEdgeInstruction) x).exceptionEdge() : null); + LIRBlock exceptionEdge = null; + if (x instanceof ExceptionEdgeInstruction) { + BlockBegin begin = ((ExceptionEdgeInstruction) x).exceptionEdge(); + if (begin != null) { + exceptionEdge = begin.lirBlock(); + } + } + return new LIRDebugInfo(state, exceptionEdge); } List visitInvokeArguments(CiCallingConvention cc, Invoke x, List pointerSlots) { diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 19 16:05:42 2011 +0200 @@ -163,8 +163,7 @@ // 1. create the start block - ir.startBlock = new BlockBegin(0, ir.nextBlockNumber(), graph); - BlockBegin startBlock = ir.startBlock; + BlockBegin startBlock = new BlockBegin(0, ir.nextBlockNumber(), graph); graph.root().setStart(startBlock); curBlock = startBlock; diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/graph/IR.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Thu May 19 16:05:42 2011 +0200 @@ -24,9 +24,11 @@ import java.util.*; +import com.oracle.graal.graph.*; import com.sun.c1x.*; import com.sun.c1x.debug.*; import com.sun.c1x.ir.*; +import com.sun.c1x.lir.*; import com.sun.c1x.observer.*; import com.sun.c1x.value.*; @@ -47,14 +49,14 @@ /** * The start block of this IR. */ - public BlockBegin startBlock; + public LIRBlock startBlock; private int maxLocks; /** * The linear-scan ordered list of blocks. */ - private List orderedBlocks; + private List orderedBlocks; /** * Creates a new IR instance for the specified compilation. @@ -106,10 +108,51 @@ private void makeLinearScanOrder() { if (orderedBlocks == null) { CriticalEdgeFinder finder = new CriticalEdgeFinder(this); - startBlock.iteratePreOrder(finder); + getHIRStartBlock().iteratePreOrder(finder); finder.splitCriticalEdges(); - ComputeLinearScanOrder computeLinearScanOrder = new ComputeLinearScanOrder(compilation.stats.blockCount, startBlock); - orderedBlocks = computeLinearScanOrder.linearScanOrder(); + ComputeLinearScanOrder computeLinearScanOrder = new ComputeLinearScanOrder(compilation.stats.blockCount, getHIRStartBlock()); + List blocks = computeLinearScanOrder.linearScanOrder(); + orderedBlocks = new ArrayList(); + + for (BlockBegin bb : blocks) { + LIRBlock lirBlock = new LIRBlock(bb.blockID); + bb.setLIRBlock(lirBlock); + lirBlock.setLinearScanNumber(bb.linearScanNumber()); + if (bb.isLinearScanLoopHeader()) { + lirBlock.setLinearScanLoopHeader(); + } + if (bb.isLinearScanLoopEnd()) { + lirBlock.setLinearScanLoopEnd(); + } + lirBlock.setStateBefore(bb.stateBefore()); + orderedBlocks.add(lirBlock); + } + + for (BlockBegin bb : blocks) { + LIRBlock lirBlock = bb.lirBlock(); + for (Node n : bb.predecessors()) { + if (n instanceof BlockEnd) { + BlockEnd end = (BlockEnd) n; + lirBlock.blockPredecessors().add(end.block().lirBlock()); + } + } + + for (Node n : bb.successors()) { + if (n instanceof BlockBegin) { + BlockBegin begin = (BlockBegin) n; + lirBlock.blockSuccessors().add(begin.lirBlock()); + } + } + + Instruction first = bb; + while (first != null) { + lirBlock.getInstructions().add(first); + first = first.next(); + } + } + + startBlock = getHIRStartBlock().lirBlock(); + assert startBlock != null; compilation.stats.loopCount = computeLinearScanOrder.numLoops(); computeLinearScanOrder.printBlocks(); } @@ -119,7 +162,7 @@ * Gets the linear scan ordering of blocks as a list. * @return the blocks in linear scan order */ - public List linearScanOrder() { + public List linearScanOrder() { return orderedBlocks; } @@ -128,7 +171,7 @@ TTY.println("IR for " + compilation.method); final InstructionPrinter ip = new InstructionPrinter(TTY.out()); final BlockPrinter bp = new BlockPrinter(this, ip, cfgOnly); - startBlock.iteratePreOrder(bp); + getHIRStartBlock().iteratePreOrder(bp); } } @@ -143,7 +186,8 @@ } if (compilation.compiler.isObserved()) { - compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, startBlock, true, false)); + // TODO(tw): FIXME + // compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, startBlock, true, false)); } } @@ -219,4 +263,8 @@ public final int maxLocks() { return maxLocks; } + + public BlockBegin getHIRStartBlock() { + return (BlockBegin) compilation.graph.root().successors().get(0); + } } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Thu May 19 16:05:42 2011 +0200 @@ -105,7 +105,11 @@ private BlockBegin dominator; // LIR block - public final LIRBlock lirBlock = new LIRBlock(); + private LIRBlock lirBlock; + + public void setLIRBlock(LIRBlock block) { + this.lirBlock = block; + } /** * Index of bytecode that generated this node when appended in a basic block. @@ -164,22 +168,6 @@ return linearScanNumber; } - /** - * Gets the loop depth of this block. - * @return the loop depth - */ - public int loopDepth() { - return lirBlock.loopDepth; - } - - /** - * Gets the loop index of this block. - * @return the loop index - */ - public int loopIndex() { - return lirBlock.loopIndex; - } - public void setDepthFirstNumber(int depthFirstNumber) { assert depthFirstNumber >= 0; this.depthFirstNumber = depthFirstNumber; @@ -189,14 +177,6 @@ this.linearScanNumber = linearScanNumber; } - public void setLoopDepth(int loopDepth) { - this.lirBlock.loopDepth = loopDepth; - } - - public void setLoopIndex(int loopIndex) { - this.lirBlock.loopIndex = loopIndex; - } - /** * Set a flag on this block. * @param flag the flag to set @@ -512,10 +492,6 @@ return lirBlock().label; } - public void setLir(LIRList lir) { - lirBlock().setLir(lir); - } - public LIRList lir() { return lirBlock().lir(); } @@ -524,14 +500,6 @@ return lirBlock; } - public int blockEntryPco() { - return lirBlock == null ? 0 : lirBlock.blockEntryPco; - } - - public void setBlockEntryPco(int codeOffset) { - lirBlock().blockEntryPco = codeOffset; - } - public Instruction predAt(int j) { return (Instruction) predecessors().get(j); } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java Thu May 19 16:05:42 2011 +0200 @@ -41,7 +41,6 @@ final CiBitMap visitedBlocks; // used for recursive processing of blocks final CiBitMap activeBlocks; // used for recursive processing of blocks - final CiBitMap dominatorBlocks; // temporary BitMap used for computation of dominator final int[] forwardBranches; // number of incoming forward branches for each block final List loopEndBlocks; // list of all loop end blocks collected during countEdges BitMap2D loopMap; // two-dimensional bit set: a bit is set if a block is contained in a loop @@ -112,7 +111,6 @@ this.maxBlockId = maxBlockId; visitedBlocks = new CiBitMap(maxBlockId); activeBlocks = new CiBitMap(maxBlockId); - dominatorBlocks = new CiBitMap(maxBlockId); forwardBranches = new int[maxBlockId]; loopEndBlocks = new ArrayList(8); workList = new ArrayList(8); @@ -122,7 +120,6 @@ if (numLoops > 0) { markLoops(); clearNonNaturalLoops(startBlock); - assignLoopDepth(startBlock); } computeOrder(startBlock); @@ -188,15 +185,15 @@ // innermost loop has the lowest number. This is guaranteed by setting // the loop number after the recursive calls for the successors above // have returned. - if (cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader)) { - assert cur.loopIndex() == -1 : "cannot set loop-index twice"; - if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println("Block B%d is loop header of loop %d", cur.blockID, numLoops); - } - - cur.setLoopIndex(numLoops); - numLoops++; - } +// if (cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader)) { +// // assert cur.loopIndex() == -1 : "cannot set loop-index twice"; +// if (C1XOptions.TraceLinearScanLevel >= 3) { +// TTY.println("Block B%d is loop header of loop %d", cur.blockID, numLoops); +// } +// +// cur.setLoopIndex(numLoops); +// numLoops++; +// } if (C1XOptions.TraceLinearScanLevel >= 3) { TTY.println("Finished counting edges for block B%d", cur.blockID); @@ -204,115 +201,73 @@ } private void markLoops() { - if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println("----- marking loops"); - } - - loopMap = new BitMap2D(numLoops, maxBlockId); - - for (int i = loopEndBlocks.size() - 1; i >= 0; i--) { - BlockBegin loopEnd = loopEndBlocks.get(i); - BlockBegin loopStart = loopEnd.suxAt(0); - int loopIdx = loopStart.loopIndex(); - - if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println("Processing loop from B%d to B%d (loop %d):", loopStart.blockID, loopEnd.blockID, loopIdx); - } - 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"; - - // add the end-block of the loop to the working list - workList.add(loopEnd); - setBlockInLoop(loopIdx, loopEnd); - do { - BlockBegin cur = workList.remove(workList.size() - 1); - - if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println(" processing B%d", cur.blockID); - } - assert isBlockInLoop(loopIdx, cur) : "bit in loop map must be set when block is in work list"; - - // recursive processing of all predecessors ends when start block of loop is reached - if (cur != loopStart) { - for (int j = cur.numberOfPreds() - 1; j >= 0; j--) { - BlockBegin pred = cur.predAt(j).block(); - - if (!isBlockInLoop(loopIdx, pred)) { - // this predecessor has not been processed yet, so add it to work list - if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println(" pushing B%d", pred.blockID); - } - workList.add(pred); - setBlockInLoop(loopIdx, pred); - } - } - } - } while (!workList.isEmpty()); - } +// if (C1XOptions.TraceLinearScanLevel >= 3) { +// TTY.println("----- marking loops"); +// } +// +// loopMap = new BitMap2D(numLoops, maxBlockId); +// +// for (int i = loopEndBlocks.size() - 1; i >= 0; i--) { +// BlockBegin loopEnd = loopEndBlocks.get(i); +// BlockBegin loopStart = loopEnd.suxAt(0); +// int loopIdx = loopStart.loopIndex(); +// +// if (C1XOptions.TraceLinearScanLevel >= 3) { +// TTY.println("Processing loop from B%d to B%d (loop %d):", loopStart.blockID, loopEnd.blockID, loopIdx); +// } +// 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"; +// +// // add the end-block of the loop to the working list +// workList.add(loopEnd); +// setBlockInLoop(loopIdx, loopEnd); +// do { +// BlockBegin cur = workList.remove(workList.size() - 1); +// +// if (C1XOptions.TraceLinearScanLevel >= 3) { +// TTY.println(" processing B%d", cur.blockID); +// } +// //assert isBlockInLoop(loopIdx, cur) : "bit in loop map must be set when block is in work list"; +// +// // recursive processing of all predecessors ends when start block of loop is reached +// if (cur != loopStart) { +// for (int j = cur.numberOfPreds() - 1; j >= 0; j--) { +// BlockBegin pred = cur.predAt(j).block(); +// +// if (!isBlockInLoop(loopIdx, pred)) { +// // this predecessor has not been processed yet, so add it to work list +// if (C1XOptions.TraceLinearScanLevel >= 3) { +// TTY.println(" pushing B%d", pred.blockID); +// } +// workList.add(pred); +// setBlockInLoop(loopIdx, pred); +// } +// } +// } +// } while (!workList.isEmpty()); +// } } // check for non-natural loops (loops where the loop header does not dominate // all other loop blocks = loops with multiple entries). // such loops are ignored private void clearNonNaturalLoops(BlockBegin startBlock) { - for (int i = numLoops - 1; i >= 0; i--) { - if (isBlockInLoop(i, startBlock)) { - // loop i contains the entry block of the method. - // this is not a natural loop, so ignore it - if (C1XOptions.TraceLinearScanLevel >= 2) { - TTY.println("Loop %d is non-natural, so it is ignored", i); - } - - for (int blockId = maxBlockId - 1; blockId >= 0; blockId--) { - clearBlockInLoop(i, blockId); - } - iterativeDominators = true; - } - } - } - - private void assignLoopDepth(BlockBegin startBlock) { - if (C1XOptions.TraceLinearScanLevel >= 3) { - TTY.println("----- computing loop-depth and weight"); - } - initVisited(); - - assert workList.isEmpty() : "work list must be empty before processing"; - workList.add(startBlock); - - do { - BlockBegin cur = workList.remove(workList.size() - 1); - - if (!isVisited(cur)) { - setVisited(cur); - if (C1XOptions.TraceLinearScanLevel >= 4) { - TTY.println("Computing loop depth for block B%d", cur.blockID); - } - - // compute loop-depth and loop-index for the block - assert cur.loopDepth() == 0 : "cannot set loop-depth twice"; - int i; - int loopDepth = 0; - int minLoopIdx = -1; - for (i = numLoops - 1; i >= 0; i--) { - if (isBlockInLoop(i, cur)) { - loopDepth++; - minLoopIdx = i; - } - } - cur.setLoopDepth(loopDepth); - cur.setLoopIndex(minLoopIdx); - - // append all unvisited successors to work list - cur.allSuccessorsDo(true, new BlockClosure() { - public void apply(BlockBegin block) { - workList.add(block); - } - }); - } - } while (!workList.isEmpty()); +// for (int i = numLoops - 1; i >= 0; i--) { +// if (isBlockInLoop(i, startBlock)) { +// // loop i contains the entry block of the method. +// // this is not a natural loop, so ignore it +// if (C1XOptions.TraceLinearScanLevel >= 2) { +// TTY.println("Loop %d is non-natural, so it is ignored", i); +// } +// +// for (int blockId = maxBlockId - 1; blockId >= 0; blockId--) { +// clearBlockInLoop(i, blockId); +// } +// iterativeDominators = true; +// } +// } } private int computeWeight(BlockBegin cur) { @@ -322,7 +277,8 @@ } // limit loop-depth to 15 bit (only for security reason, it will never be so big) - int weight = (cur.loopDepth() & 0x7FFF) << 16; + int loopDepth = 0; // TODO(tw): Assign loop depth + int weight = (loopDepth & 0x7FFF) << 16; int curBit = 15; @@ -457,17 +413,17 @@ TTY.println("----- loop information:"); for (BlockBegin cur : linearScanOrder) { TTY.print(String.format("%4d: B%02d: ", cur.linearScanNumber(), cur.blockID)); - for (int loopIdx = 0; loopIdx < numLoops; loopIdx++) { - TTY.print(String.format("%d = %b ", loopIdx, isBlockInLoop(loopIdx, cur))); - } - TTY.println(String.format(" . loopIndex: %2d, loopDepth: %2d", cur.loopIndex(), cur.loopDepth())); +// for (int loopIdx = 0; loopIdx < numLoops; loopIdx++) { +// TTY.print(String.format("%d = %b ", loopIdx, isBlockInLoop(loopIdx, cur))); +// } + TTY.println(String.format(" . loopIndex: %2d, loopDepth: %2d", -1, -1)); } } if (C1XOptions.TraceLinearScanLevel >= 1) { TTY.println("----- linear-scan block order:"); for (BlockBegin cur : linearScanOrder) { - TTY.print(String.format("%4d: B%02d loop: %2d depth: %2d", cur.linearScanNumber(), cur.blockID, cur.loopIndex(), cur.loopDepth())); + TTY.print(String.format("%4d: B%02d loop: %2d depth: %2d", cur.linearScanNumber(), cur.blockID, -1, -1)); TTY.print(cur.isLinearScanLoopHeader() ? " lh" : " "); TTY.print(cur.isLinearScanLoopEnd() ? " le" : " "); @@ -514,9 +470,9 @@ if (!cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd)) { assert cur.linearScanNumber() < sux.linearScanNumber() : "invalid order"; } - if (cur.loopDepth() == sux.loopDepth()) { - assert cur.loopIndex() == sux.loopIndex() || sux.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) : "successing blocks with same loop depth must have same loop index"; - } + //if (cur.loopDepth() == sux.loopDepth()) { + // assert cur.loopIndex() == sux.loopIndex() || sux.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) : "successing blocks with same loop depth must have same loop index"; + //} } for (Instruction pred : cur.blockPredecessors()) { @@ -525,31 +481,31 @@ if (!cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader)) { assert cur.linearScanNumber() > begin.linearScanNumber() : "invalid order"; } - if (cur.loopDepth() == begin.loopDepth()) { - assert cur.loopIndex() == begin.loopIndex() || cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) : "successing blocks with same loop depth must have same loop index"; - } + //if (cur.loopDepth() == begin.loopDepth()) { + // assert cur.loopIndex() == begin.loopIndex() || cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) : "successing blocks with same loop depth must have same loop index"; + //} } } // check that all loops are continuous - for (int loopIdx = 0; loopIdx < numLoops; loopIdx++) { - int blockIdx = 0; - assert !isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx)) : "the first block must not be present in any loop"; - - // skip blocks before the loop - while (blockIdx < numBlocks && !isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx))) { - blockIdx++; - } - // skip blocks of loop - while (blockIdx < numBlocks && isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx))) { - blockIdx++; - } - // after the first non-loop block : there must not be another loop-block - while (blockIdx < numBlocks) { - assert !isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx)) : "loop not continuous in linear-scan order"; - blockIdx++; - } - } +// for (int loopIdx = 0; loopIdx < numLoops; loopIdx++) { +// int blockIdx = 0; +// assert !isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx)) : "the first block must not be present in any loop"; +// +// // skip blocks before the loop +// while (blockIdx < numBlocks && !isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx))) { +// blockIdx++; +// } +// // skip blocks of loop +// while (blockIdx < numBlocks && isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx))) { +// blockIdx++; +// } +// // after the first non-loop block : there must not be another loop-block +// while (blockIdx < numBlocks) { +// assert !isBlockInLoop(loopIdx, linearScanOrder.get(blockIdx)) : "loop not continuous in linear-scan order"; +// blockIdx++; +// } +// } return true; } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java Thu May 19 16:05:42 2011 +0200 @@ -96,19 +96,19 @@ public abstract void emitTraps(); - public void emitCode(List hir) { + public void emitCode(List hir) { if (C1XOptions.PrintLIR && !TTY.isSuppressed()) { LIRList.printLIR(hir); } - for (BlockBegin b : hir) { + for (LIRBlock b : hir) { emitBlock(b); } assert checkNoUnboundLabels(); } - void emitBlock(BlockBegin block) { + void emitBlock(LIRBlock block) { block.setBlockEntryPco(codePos()); @@ -118,7 +118,7 @@ assert block.lir() != null : "must have LIR"; if (C1XOptions.CommentedAssembly) { - String st = String.format(" block B%d", block.blockID); + String st = String.format(" block B%d", block.blockID()); tasm.blockComment(st); } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Thu May 19 16:05:42 2011 +0200 @@ -22,8 +22,13 @@ */ package com.sun.c1x.lir; +import java.util.*; + import com.oracle.max.asm.*; import com.sun.c1x.alloc.*; +import com.sun.c1x.debug.*; +import com.sun.c1x.ir.*; +import com.sun.c1x.value.*; import com.sun.cri.ci.*; /** @@ -31,12 +36,12 @@ */ public final class LIRBlock { - public LIRBlock() { - loopIndex = -1; - } - public final Label label = new Label(); private LIRList lir; + private final int blockID; + private List instructions = new ArrayList(4); + private List predecessors = new ArrayList(); + private List successors = new ArrayList(); /** * Bit map specifying which {@linkplain OperandPool operands} are live upon entry to this block. @@ -71,6 +76,15 @@ private int lastLirInstructionID; public int blockEntryPco; + public LIRBlock(int blockID) { + this.blockID = blockID; + loopIndex = -1; + } + + public List getInstructions() { + return instructions; + } + public int firstLirInstructionId() { return firstLirInstructionID; } @@ -97,4 +111,95 @@ public void setLir(LIRList lir) { this.lir = lir; } + + public void setBlockEntryPco(int codePos) { + this.blockEntryPco = codePos; + } + + public void printWithoutPhis(LogStream out) { + out.println("LIR Block " + blockID()); + } + + public int blockID() { + return blockID; + } + + public int numberOfPreds() { + return predecessors.size(); + } + + public int numberOfSux() { + return successors.size(); + } + + public boolean isPredecessor(LIRBlock block) { + return predecessors.contains(block); + } + + public LIRBlock predAt(int i) { + return predecessors.get(i); + } + + public LIRBlock suxAt(int i) { + return successors.get(i); + } + + public List blockSuccessors() { + return successors; + } + + public List blockPredecessors() { + return predecessors; + } + + public int loopDepth() { + // TODO(tw): Set correct loop depth. + return 0; + } + + public int loopIndex() { + // TODO(tw): Set correct loop index. + return -1; + } + + public Label label() { + return label; + } + + private int linearScanNumber = -1; + private boolean linearScanLoopEnd; + private boolean linearScanLoopHeader; + private FrameState stateBefore; + + public void setLinearScanNumber(int v) { + linearScanNumber = v; + } + + public int linearScanNumber() { + return linearScanNumber; + } + + public void setLinearScanLoopEnd() { + linearScanLoopEnd = true; + } + + public boolean isLinearScanLoopEnd() { + return linearScanLoopEnd; + } + + public void setLinearScanLoopHeader() { + this.linearScanLoopHeader = true; + } + + public boolean isLinearScanLoopHeader() { + return linearScanLoopHeader; + } + + public void setStateBefore(FrameState stateBefore) { + this.stateBefore = stateBefore; + } + + public FrameState stateBefore() { + return stateBefore; + } } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/lir/LIRDebugInfo.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRDebugInfo.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRDebugInfo.java Thu May 19 16:05:42 2011 +0200 @@ -37,10 +37,10 @@ } public final FrameState state; - public final BlockBegin exceptionEdge; + public final LIRBlock exceptionEdge; public CiDebugInfo debugInfo; - public LIRDebugInfo(FrameState state, BlockBegin exceptionEdge) { + public LIRDebugInfo(FrameState state, LIRBlock exceptionEdge) { assert state != null; this.state = state; this.exceptionEdge = exceptionEdge; diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/lir/LIRInstruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRInstruction.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRInstruction.java Thu May 19 16:05:42 2011 +0200 @@ -483,7 +483,7 @@ } } - public final BlockBegin exceptionEdge() { + public final LIRBlock exceptionEdge() { return info.exceptionEdge; } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java Thu May 19 16:05:42 2011 +0200 @@ -388,9 +388,9 @@ append(new LIROp1(LIROpcode.Move, src, dst, src.kind, info)); } - public static void printBlock(BlockBegin x) { + public static void printBlock(LIRBlock x) { // print block id - TTY.print("B%d ", x.blockID); + TTY.print("B%d ", x.blockID()); // print flags if (x.isLinearScanLoopHeader()) { @@ -407,28 +407,28 @@ if (x.numberOfPreds() > 0) { TTY.print("preds: "); for (int i = 0; i < x.numberOfPreds(); i++) { - TTY.print("B%d ", x.predAt(i).block().blockID); + TTY.print("B%d ", x.predAt(i).blockID()); } } if (x.numberOfSux() > 0) { TTY.print("sux: "); for (int i = 0; i < x.numberOfSux(); i++) { - TTY.print("B%d ", x.suxAt(i).blockID); + TTY.print("B%d ", x.suxAt(i).blockID()); } } TTY.println(); } - public static void printLIR(List blocks) { + public static void printLIR(List blocks) { if (TTY.isSuppressed()) { return; } TTY.println("LIR:"); int i; for (i = 0; i < blocks.size(); i++) { - BlockBegin bb = blocks.get(i); + LIRBlock bb = blocks.get(i); printBlock(bb); TTY.println("__id_Instruction___________________________________________"); bb.lir().printInstructions(); diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/lir/LIRTableSwitch.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRTableSwitch.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRTableSwitch.java Thu May 19 16:05:42 2011 +0200 @@ -66,24 +66,4 @@ } return buf.toString(); } - - private BlockBegin substitute(BlockBegin block, BlockBegin oldBlock, BlockBegin newBlock) { - if (block == oldBlock) { - LIRInstruction instr = newBlock.lir().instructionsList().get(0); - assert instr instanceof LIRLabel : "first instruction of block must be label"; - return newBlock; - } - return oldBlock; - } - - public void substitute(BlockBegin oldBlock, BlockBegin newBlock) { - if (substitute(defaultTarget, oldBlock, newBlock) == newBlock) { - defaultTarget = newBlock; - } - for (int i = 0; i < targets.length; i++) { - if (substitute(targets[i], oldBlock, newBlock) == newBlock) { - targets[i] = newBlock; - } - } - } } diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/opt/PhiSimplifier.java --- a/graal/GraalCompiler/src/com/sun/c1x/opt/PhiSimplifier.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/opt/PhiSimplifier.java Thu May 19 16:05:42 2011 +0200 @@ -37,7 +37,7 @@ public PhiSimplifier(IR ir) { this.ir = ir; - ir.startBlock.iterateAnyOrder(this, false); + ir.getHIRStartBlock().iterateAnyOrder(this, false); } /** diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Thu May 19 16:05:42 2011 +0200 @@ -140,12 +140,8 @@ } public boolean livesLonger(Value x, Value y) { - BlockBegin bx = x.block(); - BlockBegin by = y.block(); - if (bx == null || by == null) { - return false; - } - return bx.loopDepth() < by.loopDepth(); + // TODO(tw): Estimate which value will live longer. + return false; } public void visitArithmeticOpFloat(ArithmeticOp x) { diff -r bd85cf08720a -r c1ce2a53d6c3 graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java --- a/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java Thu May 19 14:31:03 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java Thu May 19 16:05:42 2011 +0200 @@ -386,12 +386,12 @@ * @param block only phis {@linkplain Phi#block() associated} with this block are traversed * @param proc the call back invoked for each live phi traversed */ - public final boolean forEachLivePhi(BlockBegin block, PhiProcedure proc) { + public final boolean forEachLivePhi(int blockID, PhiProcedure proc) { for (int i = 0; i < valuesSize(); i++) { Value instr = valueAt(i); if (instr instanceof Phi && !instr.isDeadPhi()) { Phi phi = (Phi) instr; - if (block == null || phi.block() == block) { + if (phi.block().blockID == blockID) { if (!proc.doPhi(phi)) { return false; } diff -r bd85cf08720a -r c1ce2a53d6c3 rundacapo.sh --- a/rundacapo.sh Thu May 19 14:31:03 2011 +0200 +++ b/rundacapo.sh Thu May 19 16:05:42 2011 +0200 @@ -15,4 +15,4 @@ echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." exit 1; fi -${JDK7}/bin/java -client -d64 -graal -XX:-C1XBailoutIsFatal -XX:-PrintCompilation -C1X:+QuietBailout -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar Harness $* +${JDK7}/bin/java -client -d64 -graal -XX:-C1XBailoutIsFatal -XX:+PrintCompilation -C1X:+QuietBailout -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar Harness $* diff -r bd85cf08720a -r c1ce2a53d6c3 runtests.sh --- a/runtests.sh Thu May 19 14:31:03 2011 +0200 +++ b/runtests.sh Thu May 19 16:05:42 2011 +0200 @@ -12,4 +12,4 @@ exit 1; fi TESTDIR=${MAXINE}/com.oracle.max.vm/test -${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -XX:+PrintCompilation -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $1 test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads +${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -XX:+TraceDeoptimization -XX:-TraceExceptions -XX:+PrintCompilation -XX:CompileOnly=jtt/except/BC_dastore -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -C1X:+PrintAssembly -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $1 test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads