# HG changeset patch # User Miguel Garcia # Date 1400234352 -7200 # Node ID c5ff0e1e53cf7932293ad39a3eea8e5d98028810 # Parent bd9be86ce6344b2a40809ee986ee23347866f5fc [inlining] fixing input as instance final rather than passing it over and over diff -r bd9be86ce634 -r c5ff0e1e53cf graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Fri May 16 14:01:20 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Fri May 16 11:59:12 2014 +0200 @@ -140,11 +140,11 @@ */ @Override protected void run(final StructuredGraph graph, final HighTierContext context) { - final InliningData data = new InliningData(graph, context.getAssumptions(), maxMethodPerInlining, canonicalizer, inliningPolicy); + final InliningData data = new InliningData(graph, context, maxMethodPerInlining, canonicalizer, inliningPolicy); ToDoubleFunction probabilities = new FixedNodeProbabilityCache(); while (data.hasUnprocessedGraphs()) { - boolean wasInlined = data.moveForward(context, probabilities); + boolean wasInlined = data.moveForward(probabilities); if (wasInlined) { inliningCount++; } diff -r bd9be86ce634 -r c5ff0e1e53cf graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Fri May 16 14:01:20 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Fri May 16 11:59:12 2014 +0200 @@ -61,28 +61,30 @@ /** * Call hierarchy from outer most call (i.e., compilation unit) to inner most callee. */ - private final ArrayDeque graphQueue; - private final ArrayDeque invocationQueue; + private final ArrayDeque graphQueue = new ArrayDeque<>(); + private final ArrayDeque invocationQueue = new ArrayDeque<>(); + + private final HighTierContext context; private final int maxMethodPerInlining; private final CanonicalizerPhase canonicalizer; private final InliningPolicy inliningPolicy; private int maxGraphs; - public InliningData(StructuredGraph rootGraph, Assumptions rootAssumptions, int maxMethodPerInlining, CanonicalizerPhase canonicalizer, InliningPolicy inliningPolicy) { + public InliningData(StructuredGraph rootGraph, HighTierContext context, int maxMethodPerInlining, CanonicalizerPhase canonicalizer, InliningPolicy inliningPolicy) { assert rootGraph != null; - this.graphQueue = new ArrayDeque<>(); - this.invocationQueue = new ArrayDeque<>(); + this.context = context; this.maxMethodPerInlining = maxMethodPerInlining; this.canonicalizer = canonicalizer; this.inliningPolicy = inliningPolicy; this.maxGraphs = 1; + Assumptions rootAssumptions = context.getAssumptions(); invocationQueue.push(new MethodInvocation(null, rootAssumptions, 1.0, 1.0)); pushGraph(rootGraph, 1.0, 1.0); } - private void doInline(CallsiteHolder callerCallsiteHolder, MethodInvocation calleeInfo, Assumptions callerAssumptions, HighTierContext context) { + private void doInline(CallsiteHolder callerCallsiteHolder, MethodInvocation calleeInfo, Assumptions callerAssumptions) { StructuredGraph callerGraph = callerCallsiteHolder.graph(); Graph.Mark markBeforeInlining = callerGraph.getMark(); InlineInfo callee = calleeInfo.callee(); @@ -122,14 +124,13 @@ /** * @return true iff inlining was actually performed */ - private boolean tryToInline(ToDoubleFunction probabilities, CallsiteHolder callerCallsiteHolder, MethodInvocation calleeInfo, MethodInvocation parentInvocation, int inliningDepth, - HighTierContext context) { + private boolean tryToInline(ToDoubleFunction probabilities, CallsiteHolder callerCallsiteHolder, MethodInvocation calleeInfo, MethodInvocation parentInvocation, int inliningDepth) { InlineInfo callee = calleeInfo.callee(); Assumptions callerAssumptions = parentInvocation.assumptions(); metricInliningConsidered.increment(); if (inliningPolicy.isWorthInlining(probabilities, context.getReplacements(), callee, inliningDepth, calleeInfo.probability(), calleeInfo.relevance(), true)) { - doInline(callerCallsiteHolder, calleeInfo, callerAssumptions, context); + doInline(callerCallsiteHolder, calleeInfo, callerAssumptions); return true; } @@ -143,7 +144,7 @@ /** * Process the next invoke and enqueue all its graphs for processing. */ - void processNextInvoke(HighTierContext context) { + void processNextInvoke() { CallsiteHolder callsiteHolder = currentGraph(); Invoke invoke = callsiteHolder.popInvoke(); MethodInvocation callerInvocation = currentInvocation(); @@ -287,7 +288,7 @@ /** * @return true iff inlining was actually performed */ - public boolean moveForward(HighTierContext context, ToDoubleFunction probabilities) { + public boolean moveForward(ToDoubleFunction probabilities) { final MethodInvocation currentInvocation = currentInvocation(); @@ -303,7 +304,7 @@ final boolean delve = currentGraph().hasRemainingInvokes() && inliningPolicy.continueInlining(currentGraph().graph()); if (delve) { - processNextInvoke(context); + processNextInvoke(); return false; } @@ -319,7 +320,7 @@ popInvocation(); final MethodInvocation parentInvoke = currentInvocation(); try (Debug.Scope s = Debug.scope("Inlining", inliningContext())) { - return tryToInline(probabilities, currentGraph(), currentInvocation, parentInvoke, inliningDepth() + 1, context); + return tryToInline(probabilities, currentGraph(), currentInvocation, parentInvoke, inliningDepth() + 1); } catch (Throwable e) { throw Debug.handle(e); }