changeset 22813:fb1fcdf468af

Truffle: differentiate between performance warning and info
author Andreas Woess <andreas.woess@oracle.com>
date Wed, 14 Oct 2015 17:47:30 +0200
parents 995235213b99
children 42c3911e6993
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/TracePerformanceWarningsListener.java
diffstat 4 files changed, 19 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Oct 14 17:27:06 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Oct 14 17:47:30 2015 +0200
@@ -50,7 +50,6 @@
 import com.oracle.graal.truffle.debug.TraceCompilationListener;
 import com.oracle.graal.truffle.debug.TraceCompilationPolymorphismListener;
 import com.oracle.graal.truffle.debug.TraceInliningListener;
-import com.oracle.graal.truffle.debug.TracePerformanceWarningsListener;
 import com.oracle.graal.truffle.debug.TraceSplittingListener;
 import com.oracle.truffle.api.Assumption;
 import com.oracle.truffle.api.CallTarget;
@@ -113,7 +112,6 @@
         TraceCompilationListener.install(this);
         TraceCompilationPolymorphismListener.install(this);
         TraceCompilationCallTreeListener.install(this);
-        TracePerformanceWarningsListener.install(this);
         TraceInliningListener.install(this);
         TraceSplittingListener.install(this);
         PrintCallTargetProfiling.install(this);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Oct 14 17:27:06 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Oct 14 17:47:30 2015 +0200
@@ -82,8 +82,8 @@
 import com.oracle.graal.replacements.InlineDuringParsingPlugin;
 import com.oracle.graal.replacements.PEGraphDecoder;
 import com.oracle.graal.replacements.ReplacementsImpl;
+import com.oracle.graal.truffle.debug.AbstractDebugCompilationListener;
 import com.oracle.graal.truffle.debug.HistogramInlineInvokePlugin;
-import com.oracle.graal.truffle.debug.TracePerformanceWarningsListener;
 import com.oracle.graal.truffle.nodes.AssumptionValidAssumption;
 import com.oracle.graal.truffle.nodes.asserts.NeverPartOfCompilationNode;
 import com.oracle.graal.truffle.nodes.frame.MaterializeFrameNode;
@@ -477,7 +477,7 @@
                 continue; // native methods cannot be inlined
             }
             if (call.targetMethod().getAnnotation(TruffleBoundary.class) == null && call.targetMethod().getAnnotation(TruffleCallBoundary.class) == null) {
-                TracePerformanceWarningsListener.logPerformanceWarning(target, String.format("not inlined %s call to %s (%s)", call.invokeKind(), call.targetMethod(), call), null);
+                logPerformanceWarning(target, String.format("not inlined %s call to %s (%s)", call.invokeKind(), call.targetMethod(), call), null);
                 warnings.add(call);
             }
         }
@@ -492,7 +492,7 @@
             }
         }
         for (Map.Entry<String, ArrayList<ValueNode>> entry : groupedByType.entrySet()) {
-            TracePerformanceWarningsListener.logPerformanceWarning(target, String.format("non-leaf type checkcast: %s", entry.getKey()), Collections.singletonMap("Nodes", entry.getValue()));
+            logPerformanceInfo(target, String.format("non-leaf type checkcast: %s", entry.getKey()), Collections.singletonMap("Nodes", entry.getValue()));
         }
 
         groupedByType = new HashMap<>();
@@ -504,7 +504,7 @@
             }
         }
         for (Map.Entry<String, ArrayList<ValueNode>> entry : groupedByType.entrySet()) {
-            TracePerformanceWarningsListener.logPerformanceWarning(target, String.format("non-leaf type instanceof: %s", entry.getKey()), Collections.singletonMap("Nodes", entry.getValue()));
+            logPerformanceInfo(target, String.format("non-leaf type instanceof: %s", entry.getKey()), Collections.singletonMap("Nodes", entry.getValue()));
         }
 
         if (Debug.isEnabled() && !warnings.isEmpty()) {
@@ -552,7 +552,7 @@
             if (TruffleCompilerOptions.TraceTrufflePerformanceWarnings.getValue()) {
                 Map<String, Object> properties = new LinkedHashMap<>();
                 properties.put("callNode", callNode);
-                TracePerformanceWarningsListener.logPerformanceWarning(target, "A direct call within the Truffle AST is not reachable anymore. Call node could not be inlined.", properties);
+                logPerformanceWarning(target, "A direct call within the Truffle AST is not reachable anymore. Call node could not be inlined.", properties);
             }
         }
 
@@ -561,10 +561,22 @@
                 Map<String, Object> properties = new LinkedHashMap<>();
                 properties.put("originalTarget", decision.getTarget());
                 properties.put("callNode", callNode);
-                TracePerformanceWarningsListener.logPerformanceWarning(target, String.format("CallTarget changed during compilation. Call node could not be inlined."), properties);
+                logPerformanceWarning(target, "CallTarget changed during compilation. Call node could not be inlined.", properties);
             }
             return null;
         }
         return decision;
     }
+
+    private static void logPerformanceWarning(OptimizedCallTarget target, String details, Map<String, Object> properties) {
+        logPerformanceWarning(target, "perf warn", details, properties);
+    }
+
+    private static void logPerformanceInfo(OptimizedCallTarget target, String details, Map<String, Object> properties) {
+        logPerformanceWarning(target, "perf info", details, properties);
+    }
+
+    private static void logPerformanceWarning(OptimizedCallTarget target, String msg, String details, Map<String, Object> properties) {
+        AbstractDebugCompilationListener.log(target, 0, msg, String.format("%-60s|%s", target, details), properties);
+    }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java	Wed Oct 14 17:27:06 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java	Wed Oct 14 17:47:30 2015 +0200
@@ -192,7 +192,7 @@
                     return String.format("(%s)", e.getFileName());
                 }
             } else {
-                return String.format("(Unknown Source)");
+                return "(Unknown Source)";
             }
         }
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/TracePerformanceWarningsListener.java	Wed Oct 14 17:27:06 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.truffle.debug;
-
-import static com.oracle.graal.truffle.TruffleCompilerOptions.TraceTrufflePerformanceWarnings;
-
-import java.util.Map;
-
-import com.oracle.graal.truffle.GraalTruffleRuntime;
-import com.oracle.graal.truffle.OptimizedCallTarget;
-
-public final class TracePerformanceWarningsListener extends AbstractDebugCompilationListener {
-
-    private TracePerformanceWarningsListener() {
-    }
-
-    public static void install(GraalTruffleRuntime runtime) {
-        if (isEnabled()) {
-            runtime.addCompilationListener(new TracePerformanceWarningsListener());
-        }
-    }
-
-    public static boolean isEnabled() {
-        return TraceTrufflePerformanceWarnings.getValue();
-    }
-
-    public static void logPerformanceWarning(OptimizedCallTarget target, String details, Map<String, Object> properties) {
-        log(target, 0, "perf warn", String.format("%-60s|%s", target, details), properties);
-    }
-
-}