Mercurial > hg > truffle
changeset 17297:07d5cf34b3c5
Work around uninitialized variables problem with javac and lambdas.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 01 Oct 2014 13:04:23 +0200 |
parents | e03a25f5a260 |
children | 831e96d0777d 072a25e613ba |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java |
diffstat | 1 files changed, 29 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Mon Sep 29 15:02:18 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Oct 01 13:04:23 2014 +0200 @@ -1693,33 +1693,38 @@ return attributes(asRegister(operand)).isCallerSave(); } - private InstructionValueProcedure debugInfoProc = (op, operand, valueMode, flags) -> { - int tempOpId = op.id(); - OperandMode mode = OperandMode.USE; - AbstractBlock<?> block = blockForId(tempOpId); - if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) { - // 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 - // considered in the live ranges of intervals) - // Solution: use the first opId of the branch target block instead. - final LIRInstruction instr = ir.getLIRforBlock(block).get(ir.getLIRforBlock(block).size() - 1); - if (instr instanceof StandardOp.JumpOp) { - if (blockData.get(block).liveOut.get(operandNumber(operand))) { - tempOpId = getFirstLirInstructionId(block.getSuccessors().iterator().next()); - mode = OperandMode.DEF; + // NOTE that this is an anonymous class rather than a lambda to avoid javac from complaining + // about uninitialized variables. + private InstructionValueProcedure debugInfoProc = new InstructionValueProcedure() { + + public Value doValue(LIRInstruction op, Value operand, OperandMode valueMode, EnumSet<OperandFlag> flags) { + int tempOpId = op.id(); + OperandMode mode = OperandMode.USE; + AbstractBlock<?> block = blockForId(tempOpId); + if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) { + // 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 + // considered in the live ranges of intervals) + // Solution: use the first opId of the branch target block instead. + final LIRInstruction instr = ir.getLIRforBlock(block).get(ir.getLIRforBlock(block).size() - 1); + if (instr instanceof StandardOp.JumpOp) { + if (blockData.get(block).liveOut.get(operandNumber(operand))) { + tempOpId = getFirstLirInstructionId(block.getSuccessors().iterator().next()); + mode = OperandMode.DEF; + } } } + + // Get current location of operand + // The operand must be live because debug information is considered when building + // the intervals + // if the interval is not live, colorLirOperand will cause an assert on failure + Value result = colorLirOperand((Variable) operand, tempOpId, mode); + assert !hasCall(tempOpId) || isStackSlot(result) || isConstant(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls"; + return result; } - - // Get current location of operand - // The operand must be live because debug information is considered when building - // the intervals - // if the interval is not live, colorLirOperand will cause an assert on failure - Value result = colorLirOperand((Variable) operand, tempOpId, mode); - assert !hasCall(tempOpId) || isStackSlot(result) || isConstant(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls"; - return result; }; private void computeDebugInfo(IntervalWalker iw, final LIRInstruction op, LIRFrameState info) {