changeset 15598:98dbd88812c6

[inlining] refactor, GraphInfo constructor can populate the callsite list
author Miguel Garcia <miguel.m.garcia@oracle.com>
date Mon, 12 May 2014 19:52:06 +0200
parents a027048a2e5f
children f0254bab4c6b c73df62cbaee
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java
diffstat 1 files changed, 21 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- 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<Invoke>(), 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<Invoke> 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<Invoke> invokes) {
-            int count = 0;
-            Iterator<Invoke> iterator = invokes.iterator();
-            while (iterator.hasNext()) {
-                iterator.next();
-                count++;
-            }
-            return count;
-        }
     }
 
     private static class MethodInvocation {
@@ -709,13 +697,19 @@
         private final ToDoubleFunction<FixedNode> probabilities;
         private final ComputeInliningRelevance computeInliningRelevance;
 
-        public GraphInfo(StructuredGraph graph, LinkedList<Invoke> 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<Invoke> 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<Invoke> invokes) {
+            int count = 0;
+            Iterator<Invoke> iterator = invokes.iterator();
+            while (iterator.hasNext()) {
+                iterator.next();
+                count++;
+            }
+            return count;
+        }
+
         /**
          * Gets the method associated with the {@linkplain #graph() graph} represented by this
          * object.