# HG changeset patch # User Josef Eisl # Date 1394611032 -3600 # Node ID cf6092d510c6812696781d96d34094a7870af6f8 # Parent ff423834a2dc0f76249a438ecb98a45f2d172e3f# Parent f97c5ec83832c39d8f0eeee0f0f6f1ffcf73e009 merge diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java --- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Wed Mar 12 08:57:12 2014 +0100 @@ -67,10 +67,10 @@ * * @return sorted list of blocks */ - public static List computeLinearScanOrder(int blockCount, Block startBlock, NodesToDoubles nodeProbabilities) { - List order = new ArrayList<>(); + public static > List computeLinearScanOrder(int blockCount, T startBlock, NodesToDoubles nodeProbabilities) { + List order = new ArrayList<>(); BitSet visitedBlocks = new BitSet(blockCount); - PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); + PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); computeLinearScanOrder(order, worklist, visitedBlocks, nodeProbabilities); assert checkOrder(order, blockCount); return order; @@ -81,10 +81,10 @@ * * @return sorted list of blocks */ - public static List computeCodeEmittingOrder(int blockCount, Block startBlock, NodesToDoubles nodeProbabilities) { - List order = new ArrayList<>(); + public static > List computeCodeEmittingOrder(int blockCount, T startBlock, NodesToDoubles nodeProbabilities) { + List order = new ArrayList<>(); BitSet visitedBlocks = new BitSet(blockCount); - PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); + PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); computeCodeEmittingOrder(order, worklist, visitedBlocks, nodeProbabilities); assert checkOrder(order, blockCount); return order; @@ -93,9 +93,9 @@ /** * Iteratively adds paths to the code emission block order. */ - private static void computeCodeEmittingOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + private static > void computeCodeEmittingOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { while (!worklist.isEmpty()) { - Block nextImportantPath = worklist.poll(); + T nextImportantPath = worklist.poll(); addPathToCodeEmittingOrder(nextImportantPath, order, worklist, visitedBlocks, nodeProbabilities); } } @@ -103,9 +103,9 @@ /** * Iteratively adds paths to the linear scan block order. */ - private static void computeLinearScanOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + private static > void computeLinearScanOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { while (!worklist.isEmpty()) { - Block nextImportantPath = worklist.poll(); + T nextImportantPath = worklist.poll(); addPathToLinearScanOrder(nextImportantPath, order, worklist, visitedBlocks, nodeProbabilities); } } @@ -113,8 +113,9 @@ /** * Initializes the priority queue used for the work list of blocks and adds the start block. */ - private static PriorityQueue initializeWorklist(Block startBlock, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { - PriorityQueue result = new PriorityQueue<>(INITIAL_WORKLIST_CAPACITY, new BlockOrderComparator(nodeProbabilities)); + @SuppressWarnings("unchecked") + private static > PriorityQueue initializeWorklist(T startBlock, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + PriorityQueue result = new PriorityQueue<>(INITIAL_WORKLIST_CAPACITY, new BlockOrderComparator(nodeProbabilities)); result.add(startBlock); visitedBlocks.set(startBlock.getId()); return result; @@ -123,17 +124,17 @@ /** * Add a linear path to the linear scan order greedily following the most likely successor. */ - private static void addPathToLinearScanOrder(Block block, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + private static > void addPathToLinearScanOrder(T block, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { block.setLinearScanNumber(order.size()); order.add(block); - Block mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); + T mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); enqueueSuccessors(block, worklist, visitedBlocks); if (mostLikelySuccessor != null) { if (!mostLikelySuccessor.isLoopHeader() && mostLikelySuccessor.getPredecessorCount() > 1) { // We are at a merge. Check probabilities of predecessors that are not yet // scheduled. double unscheduledSum = 0.0; - for (Block pred : mostLikelySuccessor.getPredecessors()) { + for (T pred : mostLikelySuccessor.getPredecessors()) { if (pred.getLinearScanNumber() == -1) { unscheduledSum += nodeProbabilities.get(pred.getBeginNode()); } @@ -152,8 +153,9 @@ /** * Add a linear path to the code emission order greedily following the most likely successor. */ - private static void addPathToCodeEmittingOrder(Block initialBlock, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { - Block block = initialBlock; + @SuppressWarnings("unchecked") + private static > void addPathToCodeEmittingOrder(T initialBlock, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + T block = initialBlock; while (block != null) { // Skip loop headers if there is only a single loop end block to // make the backward jump be a conditional jump. @@ -171,7 +173,7 @@ // This is the only loop end of a skipped loop header. // Add the header immediately afterwards. - addBlock(loop.header, order); + addBlock((T) loop.header, order); // Make sure the loop successors of the loop header are aligned // as they are the target @@ -183,7 +185,7 @@ } } - Block mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); + T mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); enqueueSuccessors(block, worklist, visitedBlocks); block = mostLikelySuccessor; } @@ -192,7 +194,7 @@ /** * Adds a block to the ordering. */ - private static void addBlock(Block header, List order) { + private static > void addBlock(T header, List order) { assert !order.contains(header) : "Cannot insert block twice"; order.add(header); } @@ -200,9 +202,9 @@ /** * Find the highest likely unvisited successor block of a given block. */ - private static Block findAndMarkMostLikelySuccessor(Block block, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { - Block result = null; - for (Block successor : block.getSuccessors()) { + private static > T findAndMarkMostLikelySuccessor(T block, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + T result = null; + for (T successor : block.getSuccessors()) { assert nodeProbabilities.get(successor.getBeginNode()) >= 0.0 : "Probabilities must be positive"; if (!visitedBlocks.get(successor.getId()) && successor.getLoopDepth() >= block.getLoopDepth() && (result == null || nodeProbabilities.get(successor.getBeginNode()) >= nodeProbabilities.get(result.getBeginNode()))) { @@ -218,8 +220,8 @@ /** * Add successor blocks into the given work list if they are not already marked as visited. */ - private static void enqueueSuccessors(Block block, PriorityQueue worklist, BitSet visitedBlocks) { - for (Block successor : block.getSuccessors()) { + private static > void enqueueSuccessors(T block, PriorityQueue worklist, BitSet visitedBlocks) { + for (T successor : block.getSuccessors()) { if (!visitedBlocks.get(successor.getId())) { visitedBlocks.set(successor.getId()); worklist.add(successor); @@ -231,14 +233,14 @@ * Skip the loop header block if the loop consists of more than one block and it has only a * single loop end block. */ - private static boolean skipLoopHeader(Block block) { + private static boolean skipLoopHeader(AbstractBlock block) { return (block.isLoopHeader() && !block.isLoopEnd() && block.getLoop().loopBegin().loopEnds().count() == 1); } /** * Checks that the ordering contains the expected number of blocks. */ - private static boolean checkOrder(List order, int expectedBlockCount) { + private static boolean checkOrder(List order, int expectedBlockCount) { assert order.size() == expectedBlockCount : String.format("Number of blocks in ordering (%d) does not match expected block count (%d)", order.size(), expectedBlockCount); return true; } @@ -246,7 +248,7 @@ /** * Comparator for sorting blocks based on loop depth and probability. */ - private static class BlockOrderComparator implements Comparator { + private static class BlockOrderComparator> implements Comparator { private final NodesToDoubles probabilities; @@ -255,7 +257,7 @@ } @Override - public int compare(Block a, Block b) { + public int compare(T a, T b) { // Loop blocks before any loop exit block. int diff = b.getLoopDepth() - a.getLoopDepth(); if (diff != 0) { diff -r f97c5ec83832 -r cf6092d510c6 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 Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -89,7 +89,7 @@ public AMD64LIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new AMD64SpillMoveFactory(); + lir.setSpillMoveFactory(new AMD64SpillMoveFactory()); } @Override diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java --- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -78,7 +78,7 @@ public HSAILLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new HSAILSpillMoveFactory(); + lir.setSpillMoveFactory(new HSAILSpillMoveFactory()); } @Override diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -91,7 +91,7 @@ public PTXLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new PTXSpillMoveFactory(); + lir.setSpillMoveFactory(new PTXSpillMoveFactory()); int callVariables = cc.getArgumentCount() + (cc.getReturn().equals(Value.ILLEGAL) ? 0 : 1); lir.setFirstVariableNumber(callVariables); nextPredRegNum = 0; @@ -135,7 +135,7 @@ } @Override - public void emitPrologue() { + public void emitPrologue(StructuredGraph graph) { // Need to emit .param directives based on incoming arguments and return value CallingConvention incomingArguments = cc; Object returnObject = incomingArguments.getReturn(); diff -r f97c5ec83832 -r cf6092d510c6 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 Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -80,7 +80,7 @@ public SPARCLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new SPARCSpillMoveFactory(); + lir.setSpillMoveFactory(new SPARCSpillMoveFactory()); } @Override diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Mar 12 08:57:12 2014 +0100 @@ -661,8 +661,8 @@ protected CompilationResult compile(ResolvedJavaMethod method, final StructuredGraph graph) { CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - return compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), - getSpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + return compileGraph(graph, null, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, + getProfilingInfo(graph), getSpeculationLog(), getSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); } protected SpeculationLog getSpeculationLog() { diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Wed Mar 12 08:57:12 2014 +0100 @@ -62,8 +62,8 @@ final Method method = getMethod("testMethod"); final StructuredGraph graph = parse(method); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult cr = compileGraph(graph, null, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), + OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); if (sp instanceof Call) { @@ -85,8 +85,8 @@ assertTrue(graphLineSPs > 0); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); PhaseSuite graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerInfopointDefault()); - final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, - getProfilingInfo(graph), getSpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult cr = compileGraph(graph, null, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, + getProfilingInfo(graph), getSpeculationLog(), getSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); int lineSPs = 0; for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); diff -r f97c5ec83832 -r cf6092d510c6 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 Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Wed Mar 12 08:57:12 2014 +0100 @@ -120,7 +120,7 @@ } CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - LIRGenerator lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, cc); + LIRGenerator lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc); return new RegisterStats(lirGen.lir); } } diff -r f97c5ec83832 -r cf6092d510c6 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 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Mar 12 08:57:12 2014 +0100 @@ -131,15 +131,13 @@ * @param installedCodeOwner the method the compiled code will be * {@linkplain InstalledCode#getMethod() associated} with once installed. This * argument can be null. - * @param withScope specifies if a {@link DebugScope} with the name {@code "GraalCompiler"} - * should be used for the compilation * @return the result of the compilation */ - public static T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, + public static T compileGraph(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target, GraphCache cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, - SpeculationLog speculationLog, Suites suites, boolean withScope, T compilationResult, CompilationResultBuilderFactory factory) { + SpeculationLog speculationLog, Suites suites, T compilationResult, CompilationResultBuilderFactory factory) { assert !graph.isFrozen(); - try (Scope s0 = withScope ? Debug.scope("GraalCompiler", graph, providers.getCodeCache()) : null) { + try (Scope s0 = Debug.scope("GraalCompiler", graph, providers.getCodeCache())) { Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); SchedulePhase schedule = null; try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) { @@ -149,7 +147,7 @@ } try (TimerCloseable a = BackEnd.start()) { LIRGenerator lirGen = null; - lirGen = emitLIR(backend, target, schedule, graph, cc); + lirGen = emitLIR(backend, target, schedule, graph, stub, cc); try (Scope s = Debug.scope("CodeGen", lirGen)) { emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner, factory); } catch (Throwable e) { @@ -223,18 +221,18 @@ } - private static void emitBlock(LIRGenerator lirGen, Block b) { + private static void emitBlock(LIRGenerator lirGen, Block b, StructuredGraph graph, BlockMap> blockMap) { if (lirGen.lir.lir(b) == null) { for (Block pred : b.getPredecessors()) { if (!b.isLoopHeader() || !pred.isLoopEnd()) { - emitBlock(lirGen, pred); + emitBlock(lirGen, pred, graph, blockMap); } } - lirGen.doBlock(b); + lirGen.doBlock(b, graph, blockMap); } } - public static LIRGenerator emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, CallingConvention cc) { + public static LIRGenerator emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc) { Block[] blocks = schedule.getCFG().getBlocks(); Block startBlock = schedule.getCFG().getStartBlock(); assert startBlock != null; @@ -247,7 +245,7 @@ List codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock, nodeProbabilities); List linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock, nodeProbabilities); - lir = new LIR(schedule.getCFG(), schedule.getBlockToNodesMap(), linearScanOrder, codeEmittingOrder); + lir = new LIR(schedule.getCFG(), linearScanOrder, codeEmittingOrder); Debug.dump(lir, "After linear scan order"); } catch (Throwable e) { throw Debug.handle(e); @@ -257,11 +255,11 @@ } try (Scope ds = Debug.scope("BackEnd", lir)) { FrameMap frameMap = backend.newFrameMap(); - LIRGenerator lirGen = backend.newLIRGenerator(graph, frameMap, cc, lir); + LIRGenerator lirGen = backend.newLIRGenerator(graph, stub, frameMap, cc, lir); try (Scope s = Debug.scope("LIRGen", lirGen)) { for (Block b : lir.linearScanOrder()) { - emitBlock(lirGen, b); + emitBlock(lirGen, b, graph, schedule.getBlockToNodesMap()); } lirGen.beforeRegisterAllocation(); @@ -282,7 +280,7 @@ EdgeMoveOptimizer.optimize(lir); ControlFlowOptimizer.optimize(lir); if (lirGen.canEliminateRedundantMoves()) { - RedundantMoveElimination.optimize(lir, frameMap, lirGen.getGraph().method()); + RedundantMoveElimination.optimize(lir, frameMap); } NullCheckOptimizer.optimize(lir, target.implicitNullCheckLimit); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Mar 12 08:57:12 2014 +0100 @@ -168,7 +168,7 @@ this.registers = target.arch.getRegisters(); this.firstVariableNumber = registers.length; this.variables = new ArrayList<>(ir.numVariables() * 3 / 2); - this.blockData = new BlockMap<>(ir.cfg); + this.blockData = new BlockMap<>(ir.getControlFlowGraph()); } public int getFirstLirInstructionId(Block block) { @@ -335,7 +335,7 @@ } int numLoops() { - return ir.cfg.getLoops().length; + return ir.getControlFlowGraph().getLoops().length; } boolean isIntervalInLoop(int interval, int loop) { @@ -562,7 +562,7 @@ assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlot(toLocation) : "to operand must be a stack slot"; - insertionBuffer.append(j + 1, ir.spillMoveFactory.createMove(toLocation, fromLocation)); + insertionBuffer.append(j + 1, ir.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); } @@ -785,7 +785,7 @@ // this is checked by these assertions to be sure about it. // the entry block may have incoming // values in registers, which is ok. - if (isRegister(operand) && block != ir.cfg.getStartBlock()) { + if (isRegister(operand) && block != ir.getControlFlowGraph().getStartBlock()) { if (isProcessed(operand)) { assert liveKill.get(operandNumber(operand)) : "using fixed register that is not defined in this block"; } @@ -869,7 +869,7 @@ } // check that the liveIn set of the first block is empty - Block startBlock = ir.cfg.getStartBlock(); + Block startBlock = ir.getControlFlowGraph().getStartBlock(); if (blockData.get(startBlock).liveIn.cardinality() != 0) { if (DetailedAsserts.getValue()) { reportFailure(numBlocks); @@ -897,27 +897,11 @@ return null; } - private static StructuredGraph getGraphFromDebugContext() { - LIRGenerator gen = getLIRGeneratorFromDebugContext(); - if (gen != null) { - return gen.getGraph(); - } - return null; - } - - private static ResolvedJavaMethod getMethodFromDebugContext() { - StructuredGraph graph = getGraphFromDebugContext(); - if (graph != null) { - return graph.method(); - } - return null; - } - private void reportFailure(int numBlocks) { try (Scope s = Debug.forceLog()) { - Indent indent = Debug.logAndIndent("report failure, graph: %s", getGraphFromDebugContext()); + Indent indent = Debug.logAndIndent("report failure"); - BitSet startBlockLiveIn = blockData.get(ir.cfg.getStartBlock()).liveIn; + BitSet startBlockLiveIn = blockData.get(ir.getControlFlowGraph().getStartBlock()).liveIn; try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { Value operand = operandFor(operandNum); @@ -1873,7 +1857,7 @@ /* * This is the point to enable debug logging for the whole register allocation. */ - Indent indent = Debug.logAndIndent("LinearScan allocate %s", getMethodFromDebugContext()); + Indent indent = Debug.logAndIndent("LinearScan allocate"); try (Scope s = Debug.scope("LifetimeAnalysis")) { numberInstructions(); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Wed Mar 12 08:57:12 2014 +0100 @@ -202,7 +202,7 @@ AllocatableValue fromOpr = fromInterval.operand; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from %s to %s at %d", fromInterval, toInterval, insertIdx); } @@ -212,7 +212,7 @@ assert insertIdx != -1 : "must setup insert position first"; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx); } diff -r f97c5ec83832 -r cf6092d510c6 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 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -72,7 +72,6 @@ public final NodeMap nodeOperands; public final LIR lir; - protected final StructuredGraph graph; private final Providers providers; protected final CallingConvention cc; @@ -172,7 +171,6 @@ public abstract boolean canStoreConstant(Constant c, boolean isCompressed); public LIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { - this.graph = graph; this.providers = providers; this.frameMap = frameMap; this.cc = cc; @@ -220,10 +218,6 @@ return providers.getForeignCalls(); } - public StructuredGraph getGraph() { - return graph; - } - /** * Determines whether the code being generated makes at least one foreign call. */ @@ -347,7 +341,7 @@ } public LabelRef getLIRBlock(FixedNode b) { - Block result = lir.cfg.blockFor(b); + Block result = lir.getControlFlowGraph().blockFor(b); int suxIndex = currentBlock.getSuccessors().indexOf(result); assert suxIndex != -1 : "Block not in successor list of current block"; @@ -415,7 +409,7 @@ lir.lir(currentBlock).add(op); } - public void doBlock(Block block) { + public void doBlock(Block block, StructuredGraph graph, BlockMap> blockMap) { if (printIRWithLIR) { TTY.print(block.toString()); } @@ -432,14 +426,14 @@ TTY.println("BEGIN Generating LIR for block B" + block.getId()); } - if (block == lir.cfg.getStartBlock()) { + if (block == lir.getControlFlowGraph().getStartBlock()) { assert block.getPredecessorCount() == 0; - emitPrologue(); + emitPrologue(graph); } else { assert block.getPredecessorCount() > 0; } - List nodes = lir.nodesFor(block); + List nodes = blockMap.get(block); for (int i = 0; i < nodes.size(); i++) { Node instr = nodes.get(i); if (traceLevel >= 3) { @@ -528,7 +522,7 @@ } } - protected void emitPrologue() { + protected void emitPrologue(StructuredGraph graph) { CallingConvention incomingArguments = cc; Value[] params = new Value[incomingArguments.getArgumentCount()]; diff -r f97c5ec83832 -r cf6092d510c6 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 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Wed Mar 12 08:57:12 2014 +0100 @@ -65,7 +65,7 @@ public abstract FrameMap newFrameMap(); - public abstract LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir); + public abstract LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir); /** * Creates the assembler used to emit the machine code. diff -r f97c5ec83832 -r cf6092d510c6 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 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Mar 12 08:57:12 2014 +0100 @@ -72,8 +72,8 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { - return new AMD64HotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { + return new AMD64HotSpotLIRGenerator(graph, stub, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } /** diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -71,10 +71,13 @@ private final HotSpotVMConfig config; - protected AMD64HotSpotLIRGenerator(StructuredGraph graph, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { + private final Object stub; + + protected AMD64HotSpotLIRGenerator(StructuredGraph graph, Object stub, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); assert config.basicLockSize == 8; this.config = config; + this.stub = stub; } @Override @@ -154,7 +157,7 @@ } @Override - protected void emitPrologue() { + protected void emitPrologue(StructuredGraph graph) { CallingConvention incomingArguments = cc; @@ -205,7 +208,7 @@ @Override protected boolean needOnlyOopMaps() { // Stubs only need oop maps - return graph.start() instanceof StubStartNode; + return stub != null; } /** @@ -233,22 +236,18 @@ } Stub getStub() { - if (graph.start() instanceof StubStartNode) { - return ((StubStartNode) graph.start()).getStub(); - } - return null; + return (Stub) stub; } @Override public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) { - Stub stub = getStub(); boolean destroysRegisters = linkage.destroysRegisters(); AMD64SaveRegistersOp save = null; StackSlot[] savedRegisterLocations = null; if (destroysRegisters) { - if (stub != null) { - if (stub.preservesRegisters()) { + if (getStub() != null) { + if (getStub().preservesRegisters()) { Register[] savedRegisters = frameMap.registerConfig.getAllocatableRegisters(); savedRegisterLocations = new StackSlot[savedRegisters.length]; for (int i = 0; i < savedRegisters.length; i++) { @@ -275,8 +274,8 @@ } if (destroysRegisters) { - if (stub != null) { - if (stub.preservesRegisters()) { + if (getStub() != null) { + if (getStub().preservesRegisters()) { assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); calleeSaveInfo.put(currentRuntimeCallInfo, save); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Wed Mar 12 08:57:12 2014 +0100 @@ -132,8 +132,8 @@ graphBuilderSuite.appendPhase(new NonNullParametersPhase()); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Suites suites = providers.getSuites().getDefaultSuites(); - ExternalCompilationResult hsailCode = compileGraph(graph, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), null, - suites, true, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); + ExternalCompilationResult hsailCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), + null, suites, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); if (makeBinary) { if (!deviceInitialized) { @@ -188,7 +188,7 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { return new HSAILHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Wed Mar 12 08:57:12 2014 +0100 @@ -204,8 +204,8 @@ PhaseSuite graphBuilderSuite = providers.getSuites().getDefaultGraphBuilderSuite(); graphBuilderSuite.appendPhase(new NonNullParametersPhase()); Suites suites = providers.getSuites().getDefaultSuites(); - ExternalCompilationResult ptxCode = compileGraph(graph, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), null, - suites, true, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); + ExternalCompilationResult ptxCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), + null, suites, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); if (makeBinary) { try (Scope ds = Debug.scope("GeneratingKernelBinary")) { assert ptxCode.getTargetCode() != null; @@ -372,7 +372,7 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { return new PTXHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } @@ -392,7 +392,7 @@ asm.emitString(""); // Get the start block - Block startBlock = lir.cfg.getStartBlock(); + Block startBlock = lir.getControlFlowGraph().getStartBlock(); // Keep a list of ParameterOp instructions to delete from the // list of instructions in the block. ArrayList deleteOps = new ArrayList<>(); diff -r f97c5ec83832 -r cf6092d510c6 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 Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Wed Mar 12 08:57:12 2014 +0100 @@ -72,8 +72,8 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { - return new SPARCHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { + return new SPARCHotSpotLIRGenerator(graph, stub, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } /** diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed Mar 12 08:57:12 2014 +0100 @@ -51,10 +51,12 @@ public class SPARCHotSpotLIRGenerator extends SPARCLIRGenerator implements HotSpotLIRGenerator { private final HotSpotVMConfig config; + private final Object stub; - public SPARCHotSpotLIRGenerator(StructuredGraph graph, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { + public SPARCHotSpotLIRGenerator(StructuredGraph graph, Object stub, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); this.config = config; + this.stub = stub; } @Override @@ -84,23 +86,19 @@ @Override protected boolean needOnlyOopMaps() { // Stubs only need oop maps - return graph.start() instanceof StubStartNode; + return stub != null; } Stub getStub() { - if (graph.start() instanceof StubStartNode) { - return ((StubStartNode) graph.start()).getStub(); - } - return null; + return (Stub) stub; } @Override public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) { - Stub stub = getStub(); Variable result; if (linkage.canDeoptimize()) { - assert info != null || stub != null; + assert info != null || getStub() != null; HotSpotRegistersProvider registers = getProviders().getRegisters(); Register thread = registers.getThreadRegister(); Register stackPointer = registers.getStackPointerRegister(); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Wed Mar 12 08:57:12 2014 +0100 @@ -204,8 +204,8 @@ CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); // create suites everytime, as we modify options for the compiler final Suites suitesLocal = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites().createSuites(); - final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, true, new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult compResult = compileGraph(graph, null, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), + OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, new CompilationResult(), CompilationResultBuilderFactory.Default); addMethod(method, compResult); } diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Mar 12 08:57:12 2014 +0100 @@ -263,8 +263,8 @@ Suites suites = getSuites(providers); ProfilingInfo profilingInfo = getProfilingInfo(); OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo); - result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, - method.getSpeculationLog(), suites, true, new CompilationResult(), CompilationResultBuilderFactory.Default); + result = compileGraph(graph, null, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, + method.getSpeculationLog(), suites, new CompilationResult(), CompilationResultBuilderFactory.Default); result.setId(getId()); result.setEntryBCI(entryBCI); } catch (Throwable e) { diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Wed Mar 12 08:57:12 2014 +0100 @@ -157,8 +157,8 @@ Suites suites = providers.getSuites().createSuites(); PhaseSuite phaseSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy(); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, g.method(), false); - CompilationResult compResult = GraalCompiler.compileGraph(g, cc, g.method(), providers, backend, backend.getTarget(), null, phaseSuite, OptimisticOptimizations.ALL, - DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, true, new CompilationResult(), CompilationResultBuilderFactory.Default); + CompilationResult compResult = GraalCompiler.compileGraph(g, null, cc, g.method(), providers, backend, backend.getTarget(), null, phaseSuite, OptimisticOptimizations.ALL, + DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, new CompilationResult(), CompilationResultBuilderFactory.Default); InstalledCode installedCode; try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache(), g.method())) { installedCode = providers.getCodeCache().addMethod(g.method(), compResult, null); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Wed Mar 12 08:57:12 2014 +0100 @@ -186,7 +186,6 @@ boolean isObjectResult = linkage.getOutgoingCallingConvention().getReturn().getKind() == Kind.Object; StructuredGraph graph = new StructuredGraph(toString(), null); - graph.replaceFixed(graph.start(), graph.add(new StubStartNode(this))); GraphKit kit = new GraphKit(graph, providers); ParameterNode[] params = createParameters(kit, args); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Wed Mar 12 08:57:12 2014 +0100 @@ -145,9 +145,9 @@ CodeCacheProvider codeCache = providers.getCodeCache(); // The stub itself needs the incoming calling convention. CallingConvention incomingCc = linkage.getIncomingCallingConvention(); - final CompilationResult compResult = compileGraph(graph, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null, - providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites(), true, - new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult compResult = compileGraph(graph, Stub.this, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null, + providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites(), new CompilationResult(), + CompilationResultBuilderFactory.Default); assert destroyedRegisters != null; try (Scope s = Debug.scope("CodeInstall")) { diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java --- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Wed Mar 12 08:57:12 2014 +0100 @@ -49,7 +49,7 @@ new GraphBuilderPhase.Instance(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); PhaseSuite graphBuilderSuite = suitesProvider.getDefaultGraphBuilderSuite(); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); - compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites, true, + compileGraph(graph, null, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites, new CompilationResult(), CompilationResultBuilderFactory.Default); } } diff -r f97c5ec83832 -r cf6092d510c6 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 Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Wed Mar 12 08:57:12 2014 +0100 @@ -27,7 +27,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.lir.LIRInstruction.StateProcedure; import com.oracle.graal.lir.StandardOp.BlockEndOp; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; /** @@ -36,13 +35,7 @@ */ public class LIR { - public final ControlFlowGraph cfg; - - /** - * The nodes for the blocks. TODO: This should go away, we want all nodes connected with a - * next-pointer. - */ - private final BlockMap> blockToNodesMap; + private final ControlFlowGraph cfg; /** * The linear-scan ordered list of blocks. @@ -58,9 +51,9 @@ private int numVariables; - public SpillMoveFactory spillMoveFactory; + private SpillMoveFactory spillMoveFactory; - public final BlockMap> lirInstructions; + private final BlockMap> lirInstructions; public interface SpillMoveFactory { @@ -72,19 +65,15 @@ /** * Creates a new LIR instance for the specified compilation. */ - public LIR(ControlFlowGraph cfg, BlockMap> blockToNodesMap, List linearScanOrder, List codeEmittingOrder) { + public LIR(ControlFlowGraph cfg, List linearScanOrder, List codeEmittingOrder) { this.cfg = cfg; - this.blockToNodesMap = blockToNodesMap; this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; this.lirInstructions = new BlockMap<>(cfg); } - /** - * Gets the nodes in a given block. - */ - public List nodesFor(Block block) { - return blockToNodesMap.get(block); + public ControlFlowGraph getControlFlowGraph() { + return cfg; } /** @@ -101,6 +90,10 @@ return false; } + public SpillMoveFactory getSpillMoveFactory() { + return spillMoveFactory; + } + public List lir(Block block) { return lirInstructions.get(block); } @@ -214,4 +207,8 @@ } return true; } + + public void setSpillMoveFactory(SpillMoveFactory spillMoveFactory) { + this.spillMoveFactory = spillMoveFactory; + } } diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Wed Mar 12 08:57:12 2014 +0100 @@ -38,9 +38,9 @@ */ public final class RedundantMoveElimination { - public static void optimize(LIR lir, FrameMap frameMap, ResolvedJavaMethod method) { + public static void optimize(LIR lir, FrameMap frameMap) { RedundantMoveElimination redundantMoveElimination = new RedundantMoveElimination(); - redundantMoveElimination.doOptimize(lir, frameMap, method); + redundantMoveElimination.doOptimize(lir, frameMap); } /** @@ -100,9 +100,9 @@ /** * The main method doing the elimination of redundant moves. */ - private void doOptimize(LIR lir, FrameMap frameMap, ResolvedJavaMethod method) { + private void doOptimize(LIR lir, FrameMap frameMap) { - try (Indent indent = Debug.logAndIndent("eliminate redundant moves in %s", method)) { + try (Indent indent = Debug.logAndIndent("eliminate redundant moves")) { callerSaveRegs = frameMap.registerConfig.getCallerSaveRegisters(); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractBlock.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractBlock.java Wed Mar 12 08:57:12 2014 +0100 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes.cfg; + +import com.oracle.graal.nodes.*; + +public interface AbstractBlock { + + int getId(); + + AbstractBeginNode getBeginNode(); + + Loop getLoop(); + + int getLoopDepth(); + + boolean isLoopHeader(); + + boolean isLoopEnd(); + + boolean isExceptionEntry(); + + Iterable getPredecessors(); + + int getPredecessorCount(); + + Iterable getSuccessors(); + + int getSuccessorCount(); + + int getLinearScanNumber(); + + void setLinearScanNumber(int linearScanNumber); + + boolean isAligned(); + + void setAlign(boolean align); +} diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Wed Mar 12 08:57:12 2014 +0100 @@ -27,7 +27,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; -public final class Block { +public final class Block implements AbstractBlock { protected final AbstractBeginNode beginNode; diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/NodesToDoubles.java diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Wed Mar 12 08:57:12 2014 +0100 @@ -250,27 +250,20 @@ } } - if (lir != null) { - for (Node node : lir.nodesFor(block)) { - printNode(node, false); - } - } else { - Node cur = block.getBeginNode(); - while (true) { - printNode(cur, false); + Node cur = block.getBeginNode(); + while (true) { + printNode(cur, false); - if (cur == block.getEndNode()) { - for (Map.Entry entry : latestScheduling.entries()) { - if (entry.getValue() == block && !inFixedSchedule(entry.getKey()) && !printedNodes.isMarked(entry.getKey())) { - printNode(entry.getKey(), true); - } + if (cur == block.getEndNode()) { + for (Map.Entry entry : latestScheduling.entries()) { + if (entry.getValue() == block && !inFixedSchedule(entry.getKey()) && !printedNodes.isMarked(entry.getKey())) { + printNode(entry.getKey(), true); } - break; } - assert cur.successors().count() == 1; - cur = cur.successors().first(); + break; } - + assert cur.successors().count() == 1; + cur = cur.successors().first(); } out.enableIndentation(); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Wed Mar 12 08:57:12 2014 +0100 @@ -141,7 +141,7 @@ cfgPrinter.target = cfgPrinter.lirGenerator.target(); } if (cfgPrinter.lir != null) { - cfgPrinter.cfg = cfgPrinter.lir.cfg; + cfgPrinter.cfg = cfgPrinter.lir.getControlFlowGraph(); } CodeCacheProvider codeCache = Debug.contextLookup(CodeCacheProvider.class); diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Mar 12 08:57:12 2014 +0100 @@ -203,8 +203,8 @@ CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod); - return compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, - suites, true, new CompilationResult(), factory); + return compileGraph(graph, null, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, + suites, new CompilationResult(), factory); } private static Providers getGraalProviders() { diff -r f97c5ec83832 -r cf6092d510c6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Mar 12 00:00:05 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Mar 12 08:57:12 2014 +0100 @@ -203,8 +203,8 @@ CodeCacheProvider codeCache = providers.getCodeCache(); CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); CompilationResult compilationResult = new CompilationResult(name); - result = compileGraph(graph, cc, graph.method(), providers, backend, codeCache.getTarget(), null, createGraphBuilderSuite(), Optimizations, getProfilingInfo(graph), speculationLog, - suites, false, compilationResult, CompilationResultBuilderFactory.Default); + result = compileGraph(graph, null, cc, graph.method(), providers, backend, codeCache.getTarget(), null, createGraphBuilderSuite(), Optimizations, getProfilingInfo(graph), speculationLog, + suites, compilationResult, CompilationResultBuilderFactory.Default); } catch (Throwable e) { throw Debug.handle(e); }