changeset 12706:bb5fa27daa20

added ability to disable snippet graph preparation cache (-Dgraal.useSnippetGraphCache=false)
author Doug Simon <doug.simon@oracle.com>
date Thu, 07 Nov 2013 18:34:42 +0100
parents 001b8429afc3
children 3b2b8a71d10d
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Nov 07 18:33:01 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Nov 07 18:34:42 2013 +0100
@@ -79,14 +79,21 @@
         this.snippetTemplateCache = new HashMap<>();
     }
 
+    private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true"));
+
     public StructuredGraph getSnippet(ResolvedJavaMethod method) {
         assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName();
         assert !Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers()) : "Snippet must not be abstract or native";
 
-        StructuredGraph graph = graphs.get(method);
+        StructuredGraph graph = UseSnippetGraphCache ? graphs.get(method) : null;
         if (graph == null) {
-            graphs.putIfAbsent(method, makeGraph(method, null, inliningPolicy(method), method.getAnnotation(Snippet.class).removeAllFrameStates()));
+            StructuredGraph newGraph = makeGraph(method, null, inliningPolicy(method), method.getAnnotation(Snippet.class).removeAllFrameStates());
+            if (UseSnippetGraphCache) {
+                return newGraph;
+            }
+            graphs.putIfAbsent(method, newGraph);
             graph = graphs.get(method);
+
         }
         return graph;
     }