# HG changeset patch # User Thomas Wuerthinger # Date 1305816965 -7200 # Node ID c379183d1c548ca12894b731f7e7f6b2228a9b45 # Parent e2d20fc3760fdb7d0ceb3051018342d7b0164495 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator. diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 16:56:05 2011 +0200 @@ -157,9 +157,9 @@ private static final class SwitchRange { final int lowKey; int highKey; - final BlockBegin sux; + final LIRBlock sux; - SwitchRange(int lowKey, BlockBegin sux) { + SwitchRange(int lowKey, LIRBlock sux) { this.lowKey = lowKey; this.highKey = lowKey; this.sux = sux; @@ -412,7 +412,7 @@ // describing the state at the safepoint. moveToPhi(x.stateAfter()); - lir.jump(x.defaultSuccessor()); + lir.jump(getLIRBlock(x.defaultSuccessor())); } @Override @@ -590,14 +590,18 @@ int len = x.numberOfCases(); for (int i = 0; i < len; i++) { lir.cmp(Condition.EQ, tag, x.keyAt(i)); - lir.branch(Condition.EQ, CiKind.Int, x.blockSuccessor(i)); + lir.branch(Condition.EQ, CiKind.Int, getLIRBlock(x.blockSuccessor(i))); } - lir.jump(x.defaultSuccessor()); + lir.jump(getLIRBlock(x.defaultSuccessor())); } else { - visitSwitchRanges(createLookupRanges(x), tag, x.defaultSuccessor()); + visitSwitchRanges(createLookupRanges(x), tag, getLIRBlock(x.defaultSuccessor())); } } + private LIRBlock getLIRBlock(BlockBegin b) { + return b.lirBlock(); + } + @Override public void visitNullCheck(NullCheck x) { CiValue value = load(x.object()); @@ -847,18 +851,21 @@ int len = x.numberOfCases(); for (int i = 0; i < len; i++) { lir.cmp(Condition.EQ, tag, i + loKey); - lir.branch(Condition.EQ, CiKind.Int, x.blockSuccessor(i)); + lir.branch(Condition.EQ, CiKind.Int, getLIRBlock(x.blockSuccessor(i))); } - lir.jump(x.defaultSuccessor()); + lir.jump(getLIRBlock(x.defaultSuccessor())); } else { SwitchRange[] switchRanges = createLookupRanges(x); int rangeDensity = x.numberOfCases() / switchRanges.length; if (rangeDensity >= C1XOptions.RangeTestsSwitchDensity) { - visitSwitchRanges(switchRanges, tag, x.defaultSuccessor()); + visitSwitchRanges(switchRanges, tag, getLIRBlock(x.defaultSuccessor())); } else { List nonDefaultSuccessors = x.blockSuccessors().subList(0, x.numberOfCases()); - BlockBegin[] targets = nonDefaultSuccessors.toArray(new BlockBegin[nonDefaultSuccessors.size()]); - lir.tableswitch(tag, x.lowKey(), x.defaultSuccessor(), targets); + LIRBlock[] targets = new LIRBlock[nonDefaultSuccessors.size()]; + for (int i = 0; i < nonDefaultSuccessors.size(); ++i) { + targets[i] = getLIRBlock(nonDefaultSuccessors.get(i)); + } + lir.tableswitch(tag, x.lowKey(), getLIRBlock(x.defaultSuccessor()), targets); } } } @@ -980,12 +987,12 @@ setNoResult(x); } - private void visitSwitchRanges(SwitchRange[] x, CiValue value, BlockBegin defaultSux) { + private void visitSwitchRanges(SwitchRange[] x, CiValue value, LIRBlock defaultSux) { for (int i = 0; i < x.length; i++) { SwitchRange oneRange = x[i]; int lowKey = oneRange.lowKey; int highKey = oneRange.highKey; - BlockBegin dest = oneRange.sux; + LIRBlock dest = oneRange.sux; if (lowKey == highKey) { lir.cmp(Condition.EQ, value, lowKey); lir.branch(Condition.EQ, CiKind.Int, dest); @@ -1153,13 +1160,13 @@ List res = new ArrayList(x.numberOfCases()); int len = x.numberOfCases(); if (len > 0) { - BlockBegin defaultSux = x.defaultSuccessor(); + LIRBlock defaultSux = getLIRBlock(x.defaultSuccessor()); int key = x.keyAt(0); - BlockBegin sux = x.blockSuccessor(0); + LIRBlock sux = getLIRBlock(x.blockSuccessor(0)); SwitchRange range = new SwitchRange(key, sux); for (int i = 1; i < len; i++) { int newKey = x.keyAt(i); - BlockBegin newSux = x.blockSuccessor(i); + LIRBlock newSux = getLIRBlock(x.blockSuccessor(i)); if (key + 1 == newKey && sux == newSux) { // still in same range range.highKey = newKey; @@ -1185,12 +1192,12 @@ List res = new ArrayList(x.numberOfCases()); int len = x.numberOfCases(); if (len > 0) { - BlockBegin sux = x.blockSuccessor(0); + LIRBlock sux = getLIRBlock(x.blockSuccessor(0)); int key = x.lowKey(); - BlockBegin defaultSux = x.defaultSuccessor(); + LIRBlock defaultSux = getLIRBlock(x.defaultSuccessor()); SwitchRange range = new SwitchRange(key, sux); for (int i = 0; i < len; i++, key++) { - BlockBegin newSux = x.blockSuccessor(i); + LIRBlock newSux = getLIRBlock(x.blockSuccessor(i)); if (sux == newSux) { // still in same range range.highKey = key; diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRAssembler.java Thu May 19 16:56:05 2011 +0200 @@ -49,7 +49,7 @@ public int registerRestoreEpilogueOffset = -1; protected final List xirSlowPath; - protected final List branchTargetBlocks; + protected final List branchTargetBlocks; private int lastDecodeStart; @@ -70,7 +70,7 @@ this.tasm = compilation.assembler(); this.asm = tasm.asm; this.frameMap = compilation.frameMap(); - this.branchTargetBlocks = new ArrayList(); + this.branchTargetBlocks = new ArrayList(); this.xirSlowPath = new ArrayList(); } @@ -166,7 +166,7 @@ boolean checkNoUnboundLabels() { for (int i = 0; i < branchTargetBlocks.size() - 1; i++) { if (!branchTargetBlocks.get(i).label().isBound()) { - TTY.println(String.format("label of block B%d is not bound", branchTargetBlocks.get(i).blockID)); + TTY.println(String.format("label of block B%d is not bound", branchTargetBlocks.get(i).blockID())); assert false : "unbound label"; } } diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/lir/LIRBranch.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBranch.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBranch.java Thu May 19 16:56:05 2011 +0200 @@ -40,12 +40,12 @@ /** * The target block of this branch. */ - private BlockBegin block; + private LIRBlock block; /** * This is the unordered block for a float branch. */ - private BlockBegin unorderedBlock; + private LIRBlock unorderedBlock; public LIRBranch(Condition cond, Label label) { @@ -73,7 +73,7 @@ * @param block * */ - public LIRBranch(Condition cond, CiKind kind, BlockBegin block) { + public LIRBranch(Condition cond, CiKind kind, LIRBlock block) { super(LIROpcode.Branch, CiValue.IllegalValue, null, false); this.cond = cond; this.kind = kind; @@ -82,7 +82,7 @@ this.unorderedBlock = null; } - public LIRBranch(Condition cond, CiKind kind, BlockBegin block, BlockBegin ublock) { + public LIRBranch(Condition cond, CiKind kind, LIRBlock block, LIRBlock ublock) { super(LIROpcode.CondFloatBranch, CiValue.IllegalValue, null, false); this.cond = cond; this.kind = kind; @@ -102,15 +102,15 @@ return label; } - public BlockBegin block() { + public LIRBlock block() { return block; } - public BlockBegin unorderedBlock() { + public LIRBlock unorderedBlock() { return unorderedBlock; } - public void changeBlock(BlockBegin b) { + public void changeBlock(LIRBlock b) { assert block != null : "must have old block"; assert block.label() == label() : "must be equal"; @@ -118,7 +118,7 @@ this.label = b.label(); } - public void changeUblock(BlockBegin b) { + public void changeUblock(LIRBlock b) { assert unorderedBlock != null : "must have old block"; this.unorderedBlock = b; } @@ -136,19 +136,19 @@ public String operationString(OperandFormatter operandFmt) { StringBuilder buf = new StringBuilder(cond().operator).append(' '); if (block() != null) { - buf.append("[B").append(block.blockID).append(']'); + buf.append("[B").append(block.blockID()).append(']'); } else if (label().isBound()) { buf.append("[label:0x").append(Integer.toHexString(label().position())).append(']'); } else { buf.append("[label:??]"); } if (unorderedBlock() != null) { - buf.append("unordered: [B").append(unorderedBlock().blockID).append(']'); + buf.append("unordered: [B").append(unorderedBlock().blockID()).append(']'); } return buf.toString(); } - public void substitute(BlockBegin oldBlock, BlockBegin newBlock) { + public void substitute(LIRBlock oldBlock, LIRBlock newBlock) { if (block == oldBlock) { block = newBlock; LIRInstruction instr = newBlock.lir().instructionsList().get(0); diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRList.java Thu May 19 16:56:05 2011 +0200 @@ -248,7 +248,7 @@ append(new LIROp2(LIROpcode.Rem, left, right, res, info)); } - public void jump(BlockBegin block) { + public void jump(LIRBlock block) { append(new LIRBranch(Condition.TRUE, CiKind.Illegal, block)); } @@ -260,17 +260,17 @@ append(new LIRBranch(cond, lbl, info)); } - public void branch(Condition cond, CiKind kind, BlockBegin block) { + public void branch(Condition cond, CiKind kind, LIRBlock block) { assert kind != CiKind.Float && kind != CiKind.Double : "no fp comparisons"; append(new LIRBranch(cond, kind, block)); } - public void branch(Condition cond, CiKind kind, BlockBegin block, BlockBegin unordered) { + public void branch(Condition cond, CiKind kind, LIRBlock block, LIRBlock unordered) { assert kind == CiKind.Float || kind == CiKind.Double : "fp comparisons only"; append(new LIRBranch(cond, kind, block, unordered)); } - public void tableswitch(CiValue index, int lowKey, BlockBegin defaultTargets, BlockBegin[] targets) { + public void tableswitch(CiValue index, int lowKey, LIRBlock defaultTargets, LIRBlock[] targets) { append(new LIRTableSwitch(index, lowKey, defaultTargets, targets)); } diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/lir/LIRTableSwitch.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRTableSwitch.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRTableSwitch.java Thu May 19 16:56:05 2011 +0200 @@ -30,13 +30,13 @@ */ public class LIRTableSwitch extends LIRInstruction { - public BlockBegin defaultTarget; + public LIRBlock defaultTarget; - public final BlockBegin[] targets; + public final LIRBlock[] targets; public final int lowKey; - public LIRTableSwitch(CiValue value, int lowKey, BlockBegin defaultTarget, BlockBegin[] targets) { + public LIRTableSwitch(CiValue value, int lowKey, LIRBlock defaultTarget, LIRBlock[] targets) { super(LIROpcode.TableSwitch, CiValue.IllegalValue, null, false, 1, 0, value); this.lowKey = lowKey; this.targets = targets; @@ -58,10 +58,10 @@ @Override public String operationString(OperandFormatter operandFmt) { StringBuilder buf = new StringBuilder(super.operationString(operandFmt)); - buf.append("\ndefault: [B").append(defaultTarget.blockID).append(']'); + buf.append("\ndefault: [B").append(defaultTarget.blockID()).append(']'); int key = lowKey; - for (BlockBegin b : targets) { - buf.append("\ncase ").append(key).append(": [B").append(b.blockID).append(']'); + for (LIRBlock b : targets) { + buf.append("\ncase ").append(key).append(": [B").append(b.blockID()).append(']'); key++; } return buf.toString(); diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java --- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java Thu May 19 16:56:05 2011 +0200 @@ -451,7 +451,7 @@ private boolean assertEmitTableSwitch(LIRTableSwitch op) { assert op.defaultTarget != null; branchTargetBlocks.add(op.defaultTarget); - for (BlockBegin target : op.targets) { + for (LIRBlock target : op.targets) { assert target != null; branchTargetBlocks.add(target); } @@ -502,7 +502,7 @@ buf.setPosition(jumpTablePos); // Emit jump table entries - for (BlockBegin target : op.targets) { + for (LIRBlock target : op.targets) { Label label = target.label(); int offsetToJumpTableBase = buf.position() - jumpTablePos; if (label.isBound()) { diff -r e2d20fc3760f -r c379183d1c54 graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Thu May 19 16:46:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Thu May 19 16:56:05 2011 +0200 @@ -506,12 +506,16 @@ lir.cmp(cond, left, right); moveToPhi(); if (x.x().kind.isFloat() || x.x().kind.isDouble()) { - lir.branch(cond, right.kind, x.trueSuccessor(), x.unorderedSuccessor()); + lir.branch(cond, right.kind, getLIRBlock(x.trueSuccessor()), getLIRBlock(x.unorderedSuccessor())); } else { - lir.branch(cond, right.kind, x.trueSuccessor()); + lir.branch(cond, right.kind, getLIRBlock(x.trueSuccessor())); } assert x.defaultSuccessor() == x.falseSuccessor() : "wrong destination above"; - lir.jump(x.defaultSuccessor()); + lir.jump(getLIRBlock(x.defaultSuccessor())); + } + + private LIRBlock getLIRBlock(BlockBegin b) { + return b.lirBlock(); } @Override @@ -527,9 +531,9 @@ CiValue result = emitXir(snippet, x, stateFor(x), null, true); lir.cmp(Condition.EQ, result, CiConstant.TRUE); - lir.branch(Condition.EQ, CiKind.Boolean, x.catchSuccessor()); + lir.branch(Condition.EQ, CiKind.Boolean, getLIRBlock(x.catchSuccessor())); - lir.jump(x.otherSuccessor()); + lir.jump(getLIRBlock(x.otherSuccessor())); } }