changeset 22090:91edea43c075

Messages should go to TTY and allow per instantiation control over caching
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 25 Jun 2015 14:24:07 -0700
parents 13a50cb905b7
children eed96001920d
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Jun 25 08:30:46 2015 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Jun 25 14:24:07 2015 -0700
@@ -28,7 +28,6 @@
 import static jdk.internal.jvmci.debug.Debug.*;
 import static jdk.internal.jvmci.meta.LocationIdentity.*;
 
-import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -163,8 +162,7 @@
         void notifyNewTemplate() {
             templateCount++;
             if (UseSnippetTemplateCache && templateCount == MaxTemplatesPerSnippet) {
-                PrintStream err = System.err;
-                err.printf("WARNING: Exceeded %d templates for snippet %s%n" + "         Adjust maximum with %s system property%n", MaxTemplatesPerSnippet, method.format("%h.%n(%p)"),
+                TTY.print("WARNING: Exceeded %d templates for snippet %s%n" + "         Adjust maximum with %s system property%n", MaxTemplatesPerSnippet, method.format("%h.%n(%p)"),
                                 MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME);
             }
         }
@@ -256,6 +254,7 @@
         protected final CacheKey cacheKey;
         protected final Object[] values;
         protected final Stamp[] constStamps;
+        protected boolean cacheable;
 
         protected int nextParamIdx;
 
@@ -264,6 +263,7 @@
             this.cacheKey = new CacheKey(info, guardsStage, loweringStage);
             this.values = new Object[info.getParameterCount()];
             this.constStamps = new Stamp[info.getParameterCount()];
+            this.cacheable = true;
         }
 
         public Arguments add(String name, Object value) {
@@ -297,6 +297,10 @@
             return this;
         }
 
+        public void setCacheable(boolean cacheable) {
+            this.cacheable = cacheable;
+        }
+
         private boolean check(String name, boolean constParam, boolean varargsParam) {
             assert nextParamIdx < info.getParameterCount() : "too many parameters: " + name + "  " + this;
             assert info.getParameterName(nextParamIdx) == null || info.getParameterName(nextParamIdx).equals(name) : "wrong parameter name: " + name + "  " + this;
@@ -530,12 +534,12 @@
          * Gets a template for a given key, creating it first if necessary.
          */
         protected SnippetTemplate template(final Arguments args) {
-            SnippetTemplate template = UseSnippetTemplateCache ? templates.get(args.cacheKey) : null;
+            SnippetTemplate template = UseSnippetTemplateCache && args.cacheable ? templates.get(args.cacheKey) : null;
             if (template == null) {
                 SnippetTemplates.increment();
                 try (DebugCloseable a = SnippetTemplateCreationTime.start(); Scope s = Debug.scope("SnippetSpecialization", args.info.method)) {
                     template = new SnippetTemplate(providers, snippetReflection, args);
-                    if (UseSnippetTemplateCache) {
+                    if (UseSnippetTemplateCache && args.cacheable) {
                         templates.put(args.cacheKey, template);
                     }
                 } catch (Throwable e) {