changeset 10794:3fe325c3f31c

Truffle: add InlinedCallSite interface and an InlinableCallSite method to query the inlined call target
author Andreas Woess <andreas.woess@jku.at>
date Wed, 17 Jul 2013 14:14:52 +0200
parents 6e12e0ace0d5
children 6ac4cac7431f
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/InlinableCallSite.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/InlinedCallSite.java
diffstat 4 files changed, 41 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Wed Jul 17 13:53:11 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Wed Jul 17 14:14:52 2013 +0200
@@ -64,7 +64,6 @@
 
     // TruffleProfiling
     private int callCount;
-    private int inlinedCallSiteCount;
 
     // TraceTruffleCompilation
     long timeCompilationStarted;
@@ -176,11 +175,6 @@
     }
 
     @Override
-    public String toString() {
-        return "CallTarget " + rootNode;
-    }
-
-    @Override
     public void reportLoopCount(int count) {
         loopAndInvokeCounter -= count;
     }
@@ -224,7 +218,6 @@
                     if (TraceTruffleInlining.getValue()) {
                         printCallSiteInfo(policy, inlinableCallSite, "inlined");
                     }
-                    target.inlinedCallSiteCount++;
                     inlined = true;
                     break;
                 }
@@ -358,9 +351,8 @@
         int totalNotInlinedCallSiteCount = 0;
         int totalNodeCount = 0;
 
-        PrintStream out = TTY.out().out();
-        out.println();
-        out.printf("%-50s | %-10s | %s / %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count");
+        OUT.println();
+        OUT.printf("%-50s | %-10s | %s / %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count");
         for (OptimizedCallTarget callTarget : sortedCallTargets) {
             if (callTarget.callCount == 0) {
                 continue;
@@ -368,15 +360,16 @@
 
             int notInlinedCallSiteCount = InliningHelper.getInlinableCallSites(callTarget).size();
             int nodeCount = NodeUtil.countNodes(callTarget.rootNode);
+            int inlinedCallSiteCount = NodeUtil.countNodes(callTarget.rootNode, InlinedCallSite.class);
             String comment = callTarget.compiledMethod == null ? " int" : "";
-            out.printf("%-50s | %10s | %15s | %15s | %10s%s\n", callTarget.getRootNode(), callTarget.callCount, callTarget.inlinedCallSiteCount, notInlinedCallSiteCount, nodeCount, comment);
+            OUT.printf("%-50s | %10s | %15s | %15s | %10s%s\n", callTarget.getRootNode(), callTarget.callCount, inlinedCallSiteCount, notInlinedCallSiteCount, nodeCount, comment);
 
             totalCallCount += callTarget.callCount;
-            totalInlinedCallSiteCount += callTarget.inlinedCallSiteCount;
+            totalInlinedCallSiteCount += inlinedCallSiteCount;
             totalNotInlinedCallSiteCount += notInlinedCallSiteCount;
             totalNodeCount += nodeCount;
         }
-        out.printf("%-50s | %10s | %15s | %15s | %10s\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNotInlinedCallSiteCount, totalNodeCount);
+        OUT.printf("%-50s | %10s | %15s | %15s | %10s\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNotInlinedCallSiteCount, totalNodeCount);
     }
 
     private static void registerCallTarget(OptimizedCallTarget callTarget) {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Wed Jul 17 13:53:11 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Wed Jul 17 14:14:52 2013 +0200
@@ -39,7 +39,7 @@
 
     @Override
     public String toString() {
-        return "CallTarget " + rootNode;
+        return rootNode.toString();
     }
 
     @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/InlinableCallSite.java	Wed Jul 17 13:53:11 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/InlinableCallSite.java	Wed Jul 17 14:14:52 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.truffle.api.nodes;
 
+import com.oracle.truffle.api.*;
+
 public interface InlinableCallSite {
 
     int getCallCount();
@@ -30,6 +32,7 @@
 
     Node getInlineTree();
 
-    boolean inline(FrameFactory factory);
+    CallTarget getCallTarget();
 
+    boolean inline(FrameFactory factory);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/InlinedCallSite.java	Wed Jul 17 14:14:52 2013 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, 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.truffle.api.nodes;
+
+import com.oracle.truffle.api.*;
+
+public interface InlinedCallSite {
+
+    CallTarget getCallTarget();
+}