changeset 15997:2b79ddf41d2f

[inliner] trickle up, thus making more visible, graph copying
author Miguel Garcia <miguel.m.garcia@oracle.com>
date Mon, 02 Jun 2014 17:20:11 +0200
parents a27eceb10d33
children 9b9d0017168c
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Mon Jun 02 17:05:34 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Mon Jun 02 17:20:11 2014 +0200
@@ -42,7 +42,9 @@
     private final StructuredGraph graph;
 
     public InlineableGraph(final ResolvedJavaMethod method, final Invoke invoke, final HighTierContext context, CanonicalizerPhase canonicalizer) {
-        this.graph = buildGraph(method, context, canonicalizer);
+        StructuredGraph original = buildGraph(method, context, canonicalizer);
+        // TODO copying the graph is only necessary if it is modified or if it contains any invokes
+        this.graph = original.copy();
         specializeGraphToArguments(invoke, context, canonicalizer);
     }
 
@@ -61,14 +63,17 @@
         return null;
     }
 
+    /**
+     * This method looks up in a cache the graph for the argument, if not found bytecode is parsed.
+     * The graph thus obtained is returned, ie the caller is responsible for cloning before
+     * modification.
+     */
     private static StructuredGraph buildGraph(final ResolvedJavaMethod method, final HighTierContext context, CanonicalizerPhase canonicalizer) {
-        StructuredGraph newGraph = getOriginalGraph(method, context);
-        if (newGraph == null) {
-            newGraph = parseBytecodes(method, context, canonicalizer);
+        StructuredGraph result = getOriginalGraph(method, context);
+        if (result == null) {
+            result = parseBytecodes(method, context, canonicalizer);
         }
-        // TODO (chaeubl): copying the graph is only necessary if it is modified or if it contains
-        // any invokes
-        return newGraph.copy();
+        return result;
     }
 
     /**