# HG changeset patch # User Josef Eisl # Date 1411994911 -7200 # Node ID ae0496f76ccea1b9c51743fe79308670cddb6619 # Parent 6d85dfeb6981f15db53bb34eb74b0b47a6a0e691 LIRIntrospection: use Lambdas wherever possible. diff -r 6d85dfeb6981 -r ae0496f76cce graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Mon Sep 29 14:40:39 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Mon Sep 29 14:48:31 2014 +0200 @@ -38,8 +38,6 @@ import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.LIRInstruction.OperandFlag; -import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.StandardOp.MoveOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodes.*; @@ -81,16 +79,12 @@ } } - private ValueProcedure collectStatsProc = new ValueProcedure() { - - @Override - public Value doValue(Value value, OperandMode mode, EnumSet flags) { - if (ValueUtil.isRegister(value)) { - final Register reg = ValueUtil.asRegister(value); - registers.add(reg); - } - return value; + private ValueProcedure collectStatsProc = (value, mode, flags) -> { + if (ValueUtil.isRegister(value)) { + final Register reg = ValueUtil.asRegister(value); + registers.add(reg); } + return value; }; private void collectStats(final LIRInstruction instr) { diff -r 6d85dfeb6981 -r ae0496f76cce graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java Mon Sep 29 14:40:39 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java Mon Sep 29 14:48:31 2014 +0200 @@ -202,18 +202,14 @@ } }; - InstructionValueConsumer defConsumer = new InstructionValueConsumer() { + InstructionValueConsumer defConsumer = (op, operand, mode, flags) -> { + if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) { + Interval interval = intervalAt(operand); + if (op.id() != -1) { + interval = interval.getSplitChildAtOpId(op.id(), mode, allocator); + } - @Override - public void visitValue(LIRInstruction op, Value operand, OperandMode mode, EnumSet flags) { - if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) { - Interval interval = intervalAt(operand); - if (op.id() != -1) { - interval = interval.getSplitChildAtOpId(op.id(), mode, allocator); - } - - statePut(inputState, interval.location(), interval.splitParent()); - } + statePut(inputState, interval.location(), interval.splitParent()); } }; diff -r 6d85dfeb6981 -r ae0496f76cce graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Sep 29 14:40:39 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Sep 29 14:48:31 2014 +0200 @@ -49,8 +49,6 @@ import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.LIRInstruction.OperandFlag; -import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.gen.*; @@ -347,16 +345,13 @@ private final Set inputs = new HashSet<>(10); private boolean overlap = false; - private final InstructionValueConsumer valueConsumer = new InstructionValueConsumer() { - @Override - public void visitValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet flags) { - Object valueObject = value; - if (isRegister(value)) { // Canonicalize registers - valueObject = asRegister(value); - } - if (!inputs.add(valueObject)) { - overlap = true; - } + private final InstructionValueConsumer valueConsumer = (instruction, value, mode, flags) -> { + Object valueObject = value; + if (isRegister(value)) { // Canonicalize registers + valueObject = asRegister(value); + } + if (!inputs.add(valueObject)) { + overlap = true; } }; diff -r 6d85dfeb6981 -r ae0496f76cce graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Mon Sep 29 14:40:39 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Mon Sep 29 14:48:31 2014 +0200 @@ -61,21 +61,13 @@ return isRegister(value) && frameMap.registerConfig.getAttributesMap()[asRegister(value).number].isAllocatable(); } - private static InstructionValueConsumer allowedConsumer = new InstructionValueConsumer() { - - @Override - public void visitValue(LIRInstruction op, Value value, OperandMode mode, EnumSet flags) { - allowed(op, value, mode, flags); - } - }; - public static boolean verify(final LIRInstruction op) { - op.visitEachInput(allowedConsumer); - op.visitEachAlive(allowedConsumer); - op.visitEachState(allowedConsumer); - op.visitEachTemp(allowedConsumer); - op.visitEachOutput(allowedConsumer); + op.visitEachInput(LIRVerifier::allowed); + op.visitEachAlive(LIRVerifier::allowed); + op.visitEachState(LIRVerifier::allowed); + op.visitEachTemp(LIRVerifier::allowed); + op.visitEachOutput(LIRVerifier::allowed); op.verify(); return true; diff -r 6d85dfeb6981 -r ae0496f76cce graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Sep 29 14:40:39 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Sep 29 14:48:31 2014 +0200 @@ -163,55 +163,46 @@ private void analyzeBlock(AbstractBlock block) { try (Indent indent = Debug.logAndIndent("Block: %s", block)) { - InstructionValueConsumer loadConsumer = new InstructionValueConsumer() { - @Override - public void visitValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet flags) { - if (isVariable(value)) { - Variable var = (Variable) value; + InstructionValueConsumer loadConsumer = (instruction, value, mode, flags) -> { + if (isVariable(value)) { + Variable var = (Variable) value; - if (!phiConstants.get(var.index)) { - if (!defined.get(var.index)) { - defined.set(var.index); - if (isConstantLoad(instruction)) { - Debug.log("constant load: %s", instruction); - map.put(var, new DefUseTree(instruction, block)); - constantsTotal.increment(); - } - } else { - // Variable is redefined, this only happens for constant loads - // introduced by phi resolution -> ignore. - DefUseTree removed = map.remove(var); - if (removed != null) { - phiConstantsSkipped.increment(); - } - phiConstants.set(var.index); - Debug.log(3, "Removing phi variable: %s", var); + if (!phiConstants.get(var.index)) { + if (!defined.get(var.index)) { + defined.set(var.index); + if (isConstantLoad(instruction)) { + Debug.log("constant load: %s", instruction); + map.put(var, new DefUseTree(instruction, block)); + constantsTotal.increment(); } } else { - assert defined.get(var.index) : "phi but not defined? " + var; + // Variable is redefined, this only happens for constant loads + // introduced by phi resolution -> ignore. + DefUseTree removed = map.remove(var); + if (removed != null) { + phiConstantsSkipped.increment(); + } + phiConstants.set(var.index); + Debug.log(3, "Removing phi variable: %s", var); } - + } else { + assert defined.get(var.index) : "phi but not defined? " + var; } } - }; - ValuePositionProcedure useProcedure = new ValuePositionProcedure() { - @Override - public void doValue(LIRInstruction instruction, ValuePosition position) { - Value value = position.get(instruction); - if (isVariable(value)) { - Variable var = (Variable) value; - if (!phiConstants.get(var.index)) { - DefUseTree tree = map.get(var); - if (tree != null) { - tree.addUsage(block, instruction, position); - Debug.log("usage of %s : %s", var, instruction); - } + ValuePositionProcedure useProcedure = (instruction, position) -> { + Value value = position.get(instruction); + if (isVariable(value)) { + Variable var = (Variable) value; + if (!phiConstants.get(var.index)) { + DefUseTree tree = map.get(var); + if (tree != null) { + tree.addUsage(block, instruction, position); + Debug.log("usage of %s : %s", var, instruction); } } } - }; int opId = 0;