# HG changeset patch # User Thomas Wuerthinger # Date 1424718809 -3600 # Node ID a33fe10c4d9327e6f751eabc76574c2d93ed35c5 # Parent 94f71c29c016aed935c141b228f8c297e9bed6d2# Parent 30328ac92d833a8eaec0c9de5fd8af7e7c8ac569 Merge. diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Mon Feb 23 20:13:29 2015 +0100 @@ -81,7 +81,7 @@ private static final RegisterValue RCX_I = AMD64.rcx.asValue(LIRKind.value(Kind.Int)); - private class AMD64SpillMoveFactory implements LIR.SpillMoveFactory { + private class AMD64SpillMoveFactory implements LIRGeneratorTool.SpillMoveFactory { @Override public LIRInstruction createMove(AllocatableValue result, Value input) { @@ -91,7 +91,10 @@ public AMD64LIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { super(lirKindTool, providers, cc, lirGenRes); - lirGenRes.getLIR().setSpillMoveFactory(new AMD64SpillMoveFactory()); + } + + public SpillMoveFactory getSpillMoveFactory() { + return new AMD64SpillMoveFactory(); } @Override diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Feb 23 20:13:29 2015 +0100 @@ -70,7 +70,7 @@ private StackSlotValue tmpStackSlot; - private class SPARCSpillMoveFactory implements LIR.SpillMoveFactory { + private class SPARCSpillMoveFactory implements LIRGeneratorTool.SpillMoveFactory { @Override public LIRInstruction createMove(AllocatableValue result, Value input) { @@ -80,7 +80,10 @@ public SPARCLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { super(lirKindTool, providers, cc, lirGenRes); - lirGenRes.getLIR().setSpillMoveFactory(new SPARCSpillMoveFactory()); + } + + public SpillMoveFactory getSpillMoveFactory() { + return new SPARCSpillMoveFactory(); } @Override diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Feb 23 20:13:29 2015 +0100 @@ -355,7 +355,7 @@ PreAllocationOptimizationContext preAllocOptContext = new PreAllocationOptimizationContext(lirGen); lirSuites.getPreAllocationOptimizationStage().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, preAllocOptContext); - AllocationContext allocContext = new AllocationContext(); + AllocationContext allocContext = new AllocationContext(lirGen.getSpillMoveFactory()); lirSuites.getAllocationStage().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, allocContext); PostAllocationOptimizationContext postAllocOptContext = new PostAllocationOptimizationContext(); diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Mon Feb 23 20:13:29 2015 +0100 @@ -24,7 +24,6 @@ import java.util.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.StandardOp.LabelOp; @@ -51,15 +50,8 @@ private int numVariables; - private SpillMoveFactory spillMoveFactory; - private final BlockMap> lirInstructions; - public interface SpillMoveFactory { - - LIRInstruction createMove(AllocatableValue result, Value input); - } - private boolean hasArgInCallerFrame; /** @@ -90,10 +82,6 @@ return false; } - public SpillMoveFactory getSpillMoveFactory() { - return spillMoveFactory; - } - public List getLIRforBlock(AbstractBlockBase block) { return lirInstructions.get(block); } @@ -205,10 +193,6 @@ return true; } - public void setSpillMoveFactory(SpillMoveFactory spillMoveFactory) { - this.spillMoveFactory = spillMoveFactory; - } - public void resetLabels() { for (AbstractBlockBase block : codeEmittingOrder()) { diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Mon Feb 23 20:13:29 2015 +0100 @@ -48,6 +48,7 @@ import com.oracle.graal.lir.alloc.lsra.Interval.SpillState; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.options.*; /** @@ -62,6 +63,7 @@ final LIRGenerationResult res; final LIR ir; final FrameMapBuilder frameMapBuilder; + final SpillMoveFactory spillMoveFactory; final RegisterAttributes[] registerAttributes; final Register[] registers; @@ -161,10 +163,11 @@ */ private final int firstVariableNumber; - LinearScan(TargetDescription target, LIRGenerationResult res) { + LinearScan(TargetDescription target, LIRGenerationResult res, SpillMoveFactory spillMoveFactory) { this.target = target; this.res = res; this.ir = res.getLIR(); + this.spillMoveFactory = spillMoveFactory; this.frameMapBuilder = res.getFrameMapBuilder(); this.sortedBlocks = ir.linearScanOrder(); this.registerAttributes = frameMapBuilder.getRegisterConfig().getAttributesMap(); @@ -191,6 +194,10 @@ return result; } + SpillMoveFactory getSpillMoveFactory() { + return spillMoveFactory; + } + public static boolean isVariableOrRegister(Value value) { return isVariable(value) || isRegister(value); } @@ -571,7 +578,7 @@ assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlotValue(toLocation) : "to operand must be a stack slot"; - insertionBuffer.append(j + 1, ir.getSpillMoveFactory().createMove(toLocation, fromLocation)); + insertionBuffer.append(j + 1, getSpillMoveFactory().createMove(toLocation, fromLocation)); Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); } @@ -1875,7 +1882,7 @@ // insert spill move AllocatableValue fromLocation = interval.getSplitChildAtOpId(spillOpId, OperandMode.DEF, this).location(); AllocatableValue toLocation = canonicalSpillOpr(interval); - LIRInstruction move = ir.getSpillMoveFactory().createMove(toLocation, fromLocation); + LIRInstruction move = getSpillMoveFactory().createMove(toLocation, fromLocation); move.setId(DOMINATOR_SPILL_MOVE_ID); /* * We can use the insertion buffer directly because we always insert diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Mon Feb 23 20:13:29 2015 +0100 @@ -27,13 +27,14 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.lir.phases.*; public final class LinearScanPhase extends AllocationPhase { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { - new LinearScan(target, lirGenRes).allocate(); + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, SpillMoveFactory spillMoveFactory) { + new LinearScan(target, lirGenRes, spillMoveFactory).allocate(); } } diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Mon Feb 23 20:13:29 2015 +0100 @@ -35,6 +35,7 @@ import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.lir.phases.*; import com.oracle.graal.options.*; @@ -52,7 +53,7 @@ } @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, SpillMoveFactory spillMoveFactory) { new Marker(lirGenRes.getLIR(), lirGenRes.getFrameMap()).build(); } diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java Mon Feb 23 20:13:29 2015 +0100 @@ -203,7 +203,7 @@ AllocatableValue fromOpr = fromInterval.operand; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from %s to %s at %d", fromInterval, toInterval, insertIdx); } @@ -213,7 +213,7 @@ assert insertIdx != -1 : "must setup insert position first"; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx); } diff -r 94f71c29c016 -r a33fe10c4d93 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 Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Feb 23 20:13:29 2015 +0100 @@ -291,7 +291,7 @@ // create variable Variable variable = lirGen.newVariable(kind); // create move - LIRInstruction move = lir.getSpillMoveFactory().createMove(variable, constant); + LIRInstruction move = lirGen.getSpillMoveFactory().createMove(variable, constant); // insert instruction getInsertionBuffer(block).append(1, move); Debug.log("new move (%s) and inserted in block %s", move, block); diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Mon Feb 23 20:13:29 2015 +0100 @@ -226,7 +226,7 @@ } public void emitIncomingValues(Value[] params) { - ((LabelOp) res.getLIR().getLIRforBlock(currentBlock).get(0)).setIncomingValues(params); + ((LabelOp) res.getLIR().getLIRforBlock(getCurrentBlock()).get(0)).setIncomingValues(params); } public abstract void emitJump(LabelRef label); @@ -383,10 +383,6 @@ return currentBlock; } - void setCurrentBlock(AbstractBlockBase block) { - currentBlock = block; - } - public LIRGenerationResult getResult() { return res; } diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Mon Feb 23 20:13:29 2015 +0100 @@ -32,6 +32,11 @@ public interface LIRGeneratorTool extends ArithmeticLIRGenerator { + public interface SpillMoveFactory { + + LIRInstruction createMove(AllocatableValue result, Value input); + } + CodeGenProviders getProviders(); TargetDescription target(); @@ -48,6 +53,8 @@ boolean hasBlockEnd(AbstractBlockBase block); + SpillMoveFactory getSpillMoveFactory(); + void doBlockStart(AbstractBlockBase block); void doBlockEnd(AbstractBlockBase block); diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/AllocationPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/AllocationPhase.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/AllocationPhase.java Mon Feb 23 20:13:29 2015 +0100 @@ -27,17 +27,24 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.gen.LIRGeneratorTool.*; public abstract class AllocationPhase extends LIRPhase { public static final class AllocationContext { + private final SpillMoveFactory spillMoveFactory; + + public AllocationContext(SpillMoveFactory spillMoveFactory) { + this.spillMoveFactory = spillMoveFactory; + } } @Override protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, AllocationContext context) { - run(target, lirGenRes, codeEmittingOrder, linearScanOrder); + run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context.spillMoveFactory); } - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, + SpillMoveFactory spillMoveFactory); } diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Mon Feb 23 20:13:29 2015 +0100 @@ -38,6 +38,7 @@ import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.lir.phases.*; import com.oracle.graal.options.*; @@ -68,7 +69,7 @@ private static final DebugTimer AssignSlotsTimer = Debug.timer("LSStackSlotAllocator[AssignSlots]"); @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, SpillMoveFactory spillMoveFactory) { lirGenRes.buildFrameMap(this); } diff -r 94f71c29c016 -r a33fe10c4d93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Mon Feb 23 19:33:03 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Mon Feb 23 20:13:29 2015 +0100 @@ -34,12 +34,13 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.lir.phases.*; public class SimpleStackSlotAllocator extends AllocationPhase implements StackSlotAllocator { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, SpillMoveFactory spillMoveFactory) { lirGenRes.buildFrameMap(this); }