changeset 12707:3b2b8a71d10d

added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false) added metrics for size (i.e., node count) of prepared snippets graphs and snippet templates
author Doug Simon <doug.simon@oracle.com>
date Thu, 07 Nov 2013 18:36:33 +0100
parents bb5fa27daa20
children 882a0aadfed6
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Nov 07 18:34:42 2013 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Nov 07 18:36:33 2013 +0100
@@ -335,6 +335,10 @@
 
     private static final DebugTimer SnippetCreationAndSpecialization = Debug.timer("SnippetCreationAndSpecialization");
     private static final DebugMetric SnippetSpecializations = Debug.metric("SnippetSpecializations");
+    private static final DebugMetric SnippetSpecializationsNodeCount = Debug.metric("SnippetSpecializationsNodeCount");
+    private static final DebugMetric SnippetGraphsNodeCount = Debug.metric("SnippetGraphsNodeCount");
+
+    private static final boolean UseSnippetTemplateCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetTemplateCache", "true"));
 
     /**
      * Base class for snippet classes. It provides a cache for {@link SnippetTemplate}s.
@@ -348,7 +352,11 @@
         protected AbstractTemplates(Providers providers, TargetDescription target) {
             this.providers = providers;
             this.target = target;
-            this.templates = new ConcurrentHashMap<>();
+            if (UseSnippetTemplateCache) {
+                this.templates = new ConcurrentHashMap<>();
+            } else {
+                this.templates = null;
+            }
         }
 
         /**
@@ -372,7 +380,7 @@
          * Gets a template for a given key, creating it first if necessary.
          */
         protected SnippetTemplate template(final Arguments args) {
-            SnippetTemplate template = templates.get(args.cacheKey);
+            SnippetTemplate template = UseSnippetTemplateCache ? templates.get(args.cacheKey) : null;
             if (template == null) {
                 SnippetSpecializations.increment();
                 try (TimerCloseable a = SnippetCreationAndSpecialization.start()) {
@@ -383,7 +391,9 @@
                             return new SnippetTemplate(providers, args);
                         }
                     });
-                    templates.put(args.cacheKey, template);
+                    if (UseSnippetTemplateCache) {
+                        templates.put(args.cacheKey, template);
+                    }
                 }
             }
             return template;
@@ -410,6 +420,7 @@
      */
     protected SnippetTemplate(final Providers providers, Arguments args) {
         StructuredGraph snippetGraph = providers.getReplacements().getSnippet(args.info.method);
+        SnippetGraphsNodeCount.add(snippetGraph.getNodeCount());
 
         ResolvedJavaMethod method = snippetGraph.method();
         Signature signature = method.getSignature();
@@ -596,6 +607,8 @@
         this.deoptNodes = curDeoptNodes;
         this.stampNodes = curStampNodes;
         this.returnNode = retNode;
+
+        SnippetSpecializationsNodeCount.add(nodes.size());
     }
 
     private static boolean checkAllVarargPlaceholdersAreDeleted(int parameterCount, VarargsPlaceholderNode[] placeholders) {