Mercurial > hg > graal-compiler
diff graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java @ 3160:8044bdfaab06
Lowering of array accesses.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 06 Jul 2011 16:15:15 +0200 |
parents | eb120717a534 |
children | ce7e5b3798f7 |
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Wed Jul 06 13:28:51 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Wed Jul 06 16:15:15 2011 +0200 @@ -484,6 +484,8 @@ emitCompare((Compare) node, trueSuccessor, falseSuccessor); } else if (node instanceof InstanceOf) { emitInstanceOf((TypeCheck) node, trueSuccessor, falseSuccessor, info); + } else if (node instanceof Constant) { + emitConstantBranch(((Constant) node).asConstant().asBoolean(), trueSuccessor, falseSuccessor, info); } else { throw Util.unimplemented(node.toString()); } @@ -498,6 +500,21 @@ instr.setFalseSuccessor(falseSuccessor); } + + public void emitConstantBranch(boolean value, LIRBlock trueSuccessorBlock, LIRBlock falseSuccessorBlock, LIRDebugInfo info) { + if (value) { + emitConstantBranch(trueSuccessorBlock, info); + } else { + emitConstantBranch(falseSuccessorBlock, info); + } + } + + private void emitConstantBranch(LIRBlock block, LIRDebugInfo info) { + if (block != null) { + lir.jump(block); + } + } + public void emitCompare(Compare compare, LIRBlock trueSuccessorBlock, LIRBlock falseSuccessorBlock) { CiKind kind = compare.x().kind; @@ -761,13 +778,17 @@ FrameState state = lastState; assert state != null : "deoptimize instruction always needs a state"; - if (deoptimizationStubs == null) { - deoptimizationStubs = new ArrayList<DeoptimizationStub>(); + if (comp instanceof Constant && comp.asConstant().asBoolean()) { + // Nothing to emit. + } else { + if (deoptimizationStubs == null) { + deoptimizationStubs = new ArrayList<DeoptimizationStub>(); + } + + DeoptimizationStub stub = new DeoptimizationStub(DeoptAction.InvalidateReprofile, state); + deoptimizationStubs.add(stub); + emitBooleanBranch(comp, null, new LIRBlock(stub.label, stub.info), stub.info); } - DeoptimizationStub stub = new DeoptimizationStub(DeoptAction.InvalidateReprofile, state); - deoptimizationStubs.add(stub); - - emitBooleanBranch(comp, null, new LIRBlock(stub.label, stub.info), stub.info); } }