# HG changeset patch # User Miguel Garcia # Date 1399917126 -7200 # Node ID 98dbd88812c6ad91d4682f609e9ea3e4ac9c9962 # Parent a027048a2e5ffefdef9cb9036aba3a8bb49e98e1 [inlining] refactor, GraphInfo constructor can populate the callsite list diff -r a027048a2e5f -r 98dbd88812c6 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 Mon May 12 19:25:59 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Mon May 12 19:52:06 2014 +0200 @@ -483,7 +483,7 @@ */ static class InliningData { - private static final GraphInfo DummyGraphInfo = new GraphInfo(null, new LinkedList(), 1.0, 1.0); + private static final GraphInfo DummyGraphInfo = new GraphInfo(null, 1.0, 1.0); /** * Call hierarchy from outer most call (i.e., compilation unit) to inner most callee. @@ -508,9 +508,7 @@ public void pushGraph(StructuredGraph graph, double probability, double relevance) { assert !contains(graph); - LinkedList invokes = new InliningIterator(graph).apply(); - assert invokes.size() == count(graph.getInvokes()); - graphQueue.push(new GraphInfo(graph, invokes, probability, relevance)); + graphQueue.push(new GraphInfo(graph, probability, relevance)); assert graphQueue.size() <= maxGraphs; } @@ -618,16 +616,6 @@ } return false; } - - private static int count(Iterable invokes) { - int count = 0; - Iterator iterator = invokes.iterator(); - while (iterator.hasNext()) { - iterator.next(); - count++; - } - return count; - } } private static class MethodInvocation { @@ -709,13 +697,19 @@ private final ToDoubleFunction probabilities; private final ComputeInliningRelevance computeInliningRelevance; - public GraphInfo(StructuredGraph graph, LinkedList invokes, double probability, double relevance) { + public GraphInfo(StructuredGraph graph, double probability, double relevance) { this.graph = graph; - this.remainingInvokes = invokes; + if (graph == null) { + this.remainingInvokes = new LinkedList<>(); + } else { + LinkedList invokes = new InliningIterator(graph).apply(); + assert invokes.size() == count(graph.getInvokes()); + this.remainingInvokes = invokes; + } this.probability = probability; this.relevance = relevance; - if (graph != null && (graph.hasNode(InvokeNode.class) || graph.hasNode(InvokeWithExceptionNode.class))) { + if (graph != null && !remainingInvokes.isEmpty()) { probabilities = new FixedNodeProbabilityCache(); computeInliningRelevance = new ComputeInliningRelevance(graph, probabilities); computeProbabilities(); @@ -725,6 +719,16 @@ } } + private static int count(Iterable invokes) { + int count = 0; + Iterator iterator = invokes.iterator(); + while (iterator.hasNext()) { + iterator.next(); + count++; + } + return count; + } + /** * Gets the method associated with the {@linkplain #graph() graph} represented by this * object.