# HG changeset patch # User Josef Eisl # Date 1395836108 -3600 # Node ID dd75a505f1b6e937841fcdfb87f09a8c94c14bbb # Parent f2e61bf2a2d810d95888991eec64776726f2c364 Remove currentBlock from NodeLIRGenerator. diff -r f2e61bf2a2d8 -r dd75a505f1b6 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRGenerator.java Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRGenerator.java Wed Mar 26 13:15:08 2014 +0100 @@ -34,8 +34,8 @@ public abstract class AMD64NodeLIRGenerator extends NodeLIRGenerator { - public AMD64NodeLIRGenerator(StructuredGraph graph, CallingConvention cc, LIRGenerationResult res, LIRGenerator gen) { - super(graph, cc, res, gen); + public AMD64NodeLIRGenerator(StructuredGraph graph, LIRGenerationResult res, LIRGenerator gen) { + super(graph, res, gen); } @Override diff -r f2e61bf2a2d8 -r dd75a505f1b6 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 Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Mar 26 13:15:08 2014 +0100 @@ -244,7 +244,7 @@ FrameMap frameMap = backend.newFrameMap(); LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMap, stub); LIRGenerator lirGen = backend.newLIRGenerator(cc, lirGenRes); - NodeLIRGenerator nodeLirGen = backend.newNodeLIRGenerator(graph, cc, lirGenRes, lirGen); + NodeLIRGenerator nodeLirGen = backend.newNodeLIRGenerator(graph, lirGenRes, lirGen); try (Scope s = Debug.scope("LIRGen", lirGen)) { for (Block b : linearScanOrder) { diff -r f2e61bf2a2d8 -r dd75a505f1b6 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed Mar 26 13:15:08 2014 +0100 @@ -607,4 +607,12 @@ public abstract void emitByteSwap(Variable result, Value operand); public abstract void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length); + + public AbstractBlock getCurrentBlock() { + return currentBlock; + } + + void setCurrentBlock(AbstractBlock block) { + currentBlock = block; + } } diff -r f2e61bf2a2d8 -r dd75a505f1b6 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRGenerator.java Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRGenerator.java Wed Mar 26 13:15:08 2014 +0100 @@ -65,12 +65,9 @@ // @formatter:on } - private final CallingConvention cc; - private final NodeMap nodeOperands; private final DebugInfoBuilder debugInfoBuilder; - protected AbstractBlock currentBlock; private final int traceLevel; private final boolean printIRWithLIR; @@ -81,9 +78,8 @@ protected LIRGenerationResult res; - public NodeLIRGenerator(StructuredGraph graph, CallingConvention cc, LIRGenerationResult res, LIRGenerator gen) { + public NodeLIRGenerator(StructuredGraph graph, LIRGenerationResult res, LIRGenerator gen) { this.res = res; - this.cc = cc; this.nodeOperands = graph.createNodeMap(); this.debugInfoBuilder = createDebugInfoBuilder(nodeOperands); this.gen = gen; @@ -127,19 +123,19 @@ gen.constantLoads = new HashMap<>(); } LoadConstant load = gen.constantLoads.get(value); - assert currentBlock instanceof Block; + assert gen.getCurrentBlock() instanceof Block; if (load == null) { - int index = res.getLIR().getLIRforBlock(currentBlock).size(); + int index = res.getLIR().getLIRforBlock(gen.getCurrentBlock()).size(); loadedValue = gen.emitMove(value); - LIRInstruction op = res.getLIR().getLIRforBlock(currentBlock).get(index); - gen.constantLoads.put(value, new LoadConstant(loadedValue, (Block) currentBlock, index, op)); + LIRInstruction op = res.getLIR().getLIRforBlock(gen.getCurrentBlock()).get(index); + gen.constantLoads.put(value, new LoadConstant(loadedValue, (Block) gen.getCurrentBlock(), index, op)); } else { - Block dominator = ControlFlowGraph.commonDominator(load.block, (Block) currentBlock); + Block dominator = ControlFlowGraph.commonDominator(load.block, (Block) gen.getCurrentBlock()); loadedValue = load.variable; if (dominator != load.block) { load.unpin(res.getLIR()); } else { - assert load.block != currentBlock || load.index < res.getLIR().getLIRforBlock(currentBlock).size(); + assert load.block != gen.getCurrentBlock() || load.index < res.getLIR().getLIRforBlock(gen.getCurrentBlock()).size(); } load.block = dominator; } @@ -175,11 +171,11 @@ public LabelRef getLIRBlock(FixedNode b) { assert res.getLIR().getControlFlowGraph() instanceof ControlFlowGraph; Block result = ((ControlFlowGraph) res.getLIR().getControlFlowGraph()).blockFor(b); - int suxIndex = currentBlock.getSuccessors().indexOf(result); + int suxIndex = gen.getCurrentBlock().getSuccessors().indexOf(result); assert suxIndex != -1 : "Block not in successor list of current block"; - assert currentBlock instanceof Block; - return LabelRef.forSuccessor(res.getLIR(), (Block) currentBlock, suxIndex); + assert gen.getCurrentBlock() instanceof Block; + return LabelRef.forSuccessor(res.getLIR(), (Block) gen.getCurrentBlock(), suxIndex); } /** @@ -240,7 +236,7 @@ TTY.println(); } assert LIRVerifier.verify(op); - res.getLIR().getLIRforBlock(currentBlock).add(op); + res.getLIR().getLIRforBlock(gen.getCurrentBlock()).add(op); } public final void doBlockStart(AbstractBlock block) { @@ -248,7 +244,7 @@ TTY.print(block.toString()); } - currentBlock = block; + gen.setCurrentBlock(block); // set up the list of LIR instructions assert res.getLIR().getLIRforBlock(block) == null : "LIR list already computed for this block"; @@ -267,7 +263,7 @@ TTY.println("END Generating LIR for block B" + block.getId()); } - currentBlock = null; + gen.setCurrentBlock(null); if (printIRWithLIR) { TTY.println(); @@ -385,7 +381,7 @@ } protected void emitPrologue(StructuredGraph graph) { - CallingConvention incomingArguments = getCallingConvention(); + CallingConvention incomingArguments = gen.getCallingConvention(); Value[] params = new Value[incomingArguments.getArgumentCount()]; for (int i = 0; i < params.length; i++) { @@ -408,7 +404,7 @@ } protected > void emitPrologue(ResolvedJavaMethod method, BytecodeParser parser) { - CallingConvention incomingArguments = getCallingConvention(); + CallingConvention incomingArguments = gen.getCallingConvention(); Value[] params = new Value[incomingArguments.getArgumentCount()]; for (int i = 0; i < params.length; i++) { @@ -436,7 +432,7 @@ } public void emitIncomingValues(Value[] params) { - ((LabelOp) res.getLIR().getLIRforBlock(currentBlock).get(0)).setIncomingValues(params); + ((LabelOp) res.getLIR().getLIRforBlock(gen.getCurrentBlock()).get(0)).setIncomingValues(params); } @Override @@ -691,10 +687,6 @@ return nodeOperands; } - public CallingConvention getCallingConvention() { - return cc; - } - public DebugInfoBuilder getDebugInfoBuilder() { assert debugInfoBuilder != null; return debugInfoBuilder; diff -r f2e61bf2a2d8 -r dd75a505f1b6 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Wed Mar 26 13:15:08 2014 +0100 @@ -69,7 +69,7 @@ public abstract LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub); - public abstract NodeLIRGenerator newNodeLIRGenerator(StructuredGraph graph, CallingConvention cc, LIRGenerationResult lirGenRes, LIRGenerator lirGen); + public abstract NodeLIRGenerator newNodeLIRGenerator(StructuredGraph graph, LIRGenerationResult lirGenRes, LIRGenerator lirGen); /** * Creates the assembler used to emit the machine code. @@ -91,4 +91,5 @@ * argument can be null. */ public abstract void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner); + } diff -r f2e61bf2a2d8 -r dd75a505f1b6 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Mar 26 13:15:08 2014 +0100 @@ -82,8 +82,8 @@ } @Override - public NodeLIRGenerator newNodeLIRGenerator(StructuredGraph graph, CallingConvention cc, LIRGenerationResult lirGenRes, LIRGenerator lirGen) { - return new AMD64HotSpotNodeLIRGenerator(graph, cc, lirGenRes, lirGen); + public NodeLIRGenerator newNodeLIRGenerator(StructuredGraph graph, LIRGenerationResult lirGenRes, LIRGenerator lirGen) { + return new AMD64HotSpotNodeLIRGenerator(graph, lirGenRes, lirGen); } /** diff -r f2e61bf2a2d8 -r dd75a505f1b6 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRGenerator.java Wed Mar 26 12:14:08 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRGenerator.java Wed Mar 26 13:15:08 2014 +0100 @@ -57,8 +57,8 @@ */ public class AMD64HotSpotNodeLIRGenerator extends AMD64NodeLIRGenerator implements HotSpotNodeLIRGenerator { - public AMD64HotSpotNodeLIRGenerator(StructuredGraph graph, CallingConvention cc, LIRGenerationResult res, LIRGenerator gen) { - super(graph, cc, res, gen); + public AMD64HotSpotNodeLIRGenerator(StructuredGraph graph, LIRGenerationResult res, LIRGenerator gen) { + super(graph, res, gen); } private AMD64HotSpotLIRGenerator getGen() { @@ -82,7 +82,7 @@ @Override protected void emitPrologue(StructuredGraph graph) { - CallingConvention incomingArguments = getCallingConvention(); + CallingConvention incomingArguments = gen.getCallingConvention(); Value[] params = new Value[incomingArguments.getArgumentCount() + 1]; for (int i = 0; i < params.length - 1; i++) { @@ -98,7 +98,7 @@ emitIncomingValues(params); - setSaveRbp(((AMD64HotSpotLIRGenerator) gen).new SaveRbp(new NoOp(currentBlock, res.getLIR().getLIRforBlock(currentBlock).size()))); + setSaveRbp(((AMD64HotSpotLIRGenerator) gen).new SaveRbp(new NoOp(gen.getCurrentBlock(), res.getLIR().getLIRforBlock(gen.getCurrentBlock()).size()))); append(getSaveRbp().placeholder); for (ParameterNode param : graph.getNodes(ParameterNode.class)) {