changeset 15090:07e7aae05983

Truffle: context sensitive inlining cleanup
author Christian Humer <christian.humer@gmail.com>
date Mon, 14 Apr 2014 18:25:23 +0200
parents 448338c9ce96
children 607e33885130
files graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallUtils.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java
diffstat 8 files changed, 300 insertions(+), 294 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java	Mon Apr 14 18:25:23 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.truffle.hotspot;
 
 import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
+import static com.oracle.graal.truffle.OptimizedCallTargetLog.*;
 
 import java.util.concurrent.*;
 
@@ -152,7 +153,6 @@
             return null;
         } else {
             performInlining();
-// cancelInlinedCallOptimization();
             logOptimizingQueued(this);
             this.installedCodeTask = compiler.compile(this);
             if (!TruffleBackgroundCompilation.getValue()) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java	Mon Apr 14 18:25:23 2014 +0200
@@ -119,7 +119,7 @@
         OptimizedCallTarget splitTarget = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(getCallTarget().getRootNode().split());
         splitTarget.setSplitSource(getCallTarget());
         if (heuristic) {
-            OptimizedCallTarget.logSplit(this, getCallTarget(), splitTarget);
+            OptimizedCallTargetLog.logSplit(this, getCallTarget(), splitTarget);
         }
         if (callCount >= 1) {
             getCallTarget().decrementKnownCallSites();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Mon Apr 14 18:25:23 2014 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.truffle;
 
+import static com.oracle.graal.truffle.OptimizedCallTargetLog.*;
 import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
 
 import java.io.*;
@@ -34,7 +35,6 @@
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.impl.*;
 import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
 
 /**
  * Call target that is optimized by Graal upon surpassing a specific invocation threshold.
@@ -117,11 +117,10 @@
         if (inliningPerformed) {
             return;
         }
-
         TruffleInliningHandler handler = new TruffleInliningHandler(new DefaultInliningPolicy());
         TruffleInliningResult result = handler.decideInlining(this, 0);
         performInlining(result);
-        logInliningDecision(result, 0);
+        logInliningDecision(result);
     }
 
     private void performInlining(TruffleInliningResult result) {
@@ -174,248 +173,4 @@
 
     }
 
-    private static void logInliningDecision(TruffleInliningResult result, int depth) {
-        if (!TraceTruffleInlining.getValue()) {
-            return;
-        }
-
-        logInliningStart(result.getCallTarget());
-        logInliningDecisionRecursive(result, depth);
-        logInliningDone(result.getCallTarget());
-    }
-
-    private static void logInliningDecisionRecursive(TruffleInliningResult result, int depth) {
-        List<OptimizedCallNode> callNodes = searchCallNodes(result.getCallTarget());
-        for (OptimizedCallNode callNode : callNodes) {
-            TruffleInliningProfile profile = result.getProfiles().get(callNode);
-            boolean inlined = result.isInlined(callNode);
-            String msg = inlined ? "inline success" : "inline failed";
-            logInlinedImpl(msg, profile, depth);
-            if (profile.getRecursiveResult() != null && inlined) {
-                logInliningDecisionRecursive(profile.getRecursiveResult(), depth + 1);
-            }
-        }
-    }
-
-    private static List<OptimizedCallNode> searchCallNodes(final OptimizedCallTarget target) {
-        final List<OptimizedCallNode> callNodes = new ArrayList<>();
-        target.getRootNode().accept(new NodeVisitor() {
-            public boolean visit(Node node) {
-                if (node instanceof OptimizedCallNode) {
-                    callNodes.add((OptimizedCallNode) node);
-                }
-                return true;
-            }
-        });
-        return callNodes;
-    }
-
-    private static void logInlinedImpl(String status, TruffleInliningProfile profile, int depth) {
-        Map<String, Object> properties = new LinkedHashMap<>();
-        addASTSizeProperty(profile.getCallNode().getCurrentCallTarget(), properties);
-        if (profile != null) {
-            properties.putAll(profile.getDebugProperties());
-        }
-        log((depth * 2), status, profile.getCallNode().getCurrentCallTarget().toString(), properties);
-    }
-
-    private static void logInliningStart(OptimizedCallTarget target) {
-        if (TraceTruffleInlining.getValue()) {
-            log(0, "inline start", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    private static void logInliningDone(OptimizedCallTarget target) {
-        if (TraceTruffleInlining.getValue()) {
-            log(0, "inline done", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    protected static void logOptimizingQueued(OptimizedCallTarget target) {
-        if (TraceTruffleCompilationDetails.getValue()) {
-            log(0, "opt queued", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    protected static void logOptimizingUnqueued(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
-        if (TraceTruffleCompilationDetails.getValue()) {
-            Map<String, Object> properties = new LinkedHashMap<>();
-            addReplaceProperties(properties, oldNode, newNode);
-            properties.put("Reason", reason);
-            log(0, "opt unqueued", target.toString(), properties);
-        }
-    }
-
-    private static void addReplaceProperties(Map<String, Object> properties, Node oldNode, Node newNode) {
-        if (oldNode != null && newNode != null) {
-            properties.put("OldClass", oldNode.getClass().getSimpleName());
-            properties.put("NewClass", newNode.getClass().getSimpleName());
-            properties.put("Node", newNode);
-        }
-    }
-
-    static void logOptimizingStart(OptimizedCallTarget target) {
-        if (TraceTruffleCompilationDetails.getValue()) {
-            log(0, "opt start", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    protected static void logOptimizedInvalidated(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
-        if (TraceTruffleCompilation.getValue()) {
-            Map<String, Object> properties = new LinkedHashMap<>();
-            addReplaceProperties(properties, oldNode, newNode);
-            properties.put("Reason", reason);
-            log(0, "opt invalidated", target.toString(), properties);
-        }
-    }
-
-    protected static void logOptimizingFailed(OptimizedCallTarget callSite, CharSequence reason) {
-        Map<String, Object> properties = new LinkedHashMap<>();
-        properties.put("Reason", reason);
-        log(0, "opt fail", callSite.toString(), properties);
-    }
-
-    static void logOptimizingDone(OptimizedCallTarget target, Map<String, Object> properties) {
-        if (TraceTruffleCompilationDetails.getValue() || TraceTruffleCompilation.getValue()) {
-            log(0, "opt done", target.toString(), properties);
-        }
-        if (TraceTruffleCompilationPolymorphism.getValue()) {
-
-            target.getRootNode().accept(new NodeVisitor() {
-                public boolean visit(Node node) {
-                    NodeCost kind = node.getCost();
-                    if (kind == NodeCost.POLYMORPHIC || kind == NodeCost.MEGAMORPHIC) {
-                        Map<String, Object> props = new LinkedHashMap<>();
-                        props.put("simpleName", node.getClass().getSimpleName());
-                        String msg = kind == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
-                        log(0, msg, node.toString(), props);
-                    }
-                    if (node instanceof CallNode) {
-                        CallNode callNode = (CallNode) node;
-                        if (callNode.isInliningForced()) {
-                            callNode.getCurrentRootNode().accept(this);
-                        }
-                    }
-                    return true;
-                }
-            });
-
-        }
-    }
-
-    private static int splitCount = 0;
-
-    static void logSplit(OptimizedCallNode callNode, OptimizedCallTarget target, OptimizedCallTarget newTarget) {
-        if (TraceTruffleSplitting.getValue()) {
-            Map<String, Object> properties = new LinkedHashMap<>();
-            addASTSizeProperty(target, properties);
-            properties.put("Split#", ++splitCount);
-            properties.put("Source", callNode.getEncapsulatingSourceSection());
-            log(0, "split", newTarget.toString(), properties);
-        }
-    }
-
-    static void addASTSizeProperty(OptimizedCallTarget target, Map<String, Object> properties) {
-        int polymorphicCount = OptimizedCallUtils.countNodes(target, new NodeCountFilter() {
-            public boolean isCounted(Node node) {
-                return node.getCost() == NodeCost.POLYMORPHIC;
-            }
-        }, true);
-
-        int megamorphicCount = OptimizedCallUtils.countNodes(target, new NodeCountFilter() {
-            public boolean isCounted(Node node) {
-                return node.getCost() == NodeCost.MEGAMORPHIC;
-            }
-        }, true);
-
-        String value = String.format("%4d (%d/%d)", OptimizedCallUtils.countNonTrivialNodes(target, true), polymorphicCount, megamorphicCount);
-        properties.put("ASTSize", value);
-    }
-
-    static void log(int indent, String msg, String details, Map<String, Object> properties) {
-        StringBuilder sb = new StringBuilder();
-        sb.append(String.format("[truffle] %-16s ", msg));
-        for (int i = 0; i < indent; i++) {
-            sb.append(' ');
-        }
-        sb.append(String.format("%-" + (60 - indent) + "s", details));
-        if (properties != null) {
-            for (String property : properties.keySet()) {
-                Object value = properties.get(property);
-                if (value == null) {
-                    continue;
-                }
-                sb.append('|');
-                sb.append(property);
-
-                StringBuilder propertyBuilder = new StringBuilder();
-                if (value instanceof Integer) {
-                    propertyBuilder.append(String.format("%6d", value));
-                } else if (value instanceof Double) {
-                    propertyBuilder.append(String.format("%8.2f", value));
-                } else {
-                    propertyBuilder.append(value);
-                }
-
-                int length = Math.max(1, 20 - property.length());
-                sb.append(String.format(" %" + length + "s ", propertyBuilder.toString()));
-            }
-        }
-        OUT.println(sb.toString());
-    }
-
-    private static void printProfiling() {
-        List<OptimizedCallTarget> sortedCallTargets = new ArrayList<>(OptimizedCallTarget.callTargets.keySet());
-        Collections.sort(sortedCallTargets, new Comparator<OptimizedCallTarget>() {
-
-            @Override
-            public int compare(OptimizedCallTarget o1, OptimizedCallTarget o2) {
-                return o2.callCount - o1.callCount;
-            }
-        });
-
-        int totalCallCount = 0;
-        int totalInlinedCallSiteCount = 0;
-        int totalNodeCount = 0;
-        int totalInvalidationCount = 0;
-
-        OUT.println();
-        OUT.printf("%-50s | %-10s | %s / %s | %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count", "Inv");
-        for (OptimizedCallTarget callTarget : sortedCallTargets) {
-            if (callTarget.callCount == 0) {
-                continue;
-            }
-
-            int nodeCount = OptimizedCallUtils.countNonTrivialNodes(callTarget, true);
-            String comment = callTarget.installedCode == null ? " int" : "";
-            comment += callTarget.compilationEnabled ? "" : " fail";
-            OUT.printf("%-50s | %10d | %15d | %10d | %3d%s\n", callTarget.getRootNode(), callTarget.callCount, nodeCount, nodeCount, callTarget.getCompilationProfile().getInvalidationCount(), comment);
-
-            totalCallCount += callTarget.callCount;
-            totalInlinedCallSiteCount += nodeCount;
-            totalNodeCount += nodeCount;
-            totalInvalidationCount += callTarget.getCompilationProfile().getInvalidationCount();
-        }
-        OUT.printf("%-50s | %10d | %15d | %10d | %3d\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNodeCount, totalInvalidationCount);
-    }
-
-    private static void registerCallTarget(OptimizedCallTarget callTarget) {
-        callTargets.put(callTarget, 0);
-    }
-
-    private static Map<OptimizedCallTarget, Integer> callTargets;
-    static {
-        if (TruffleCallTargetProfiling.getValue()) {
-            callTargets = new WeakHashMap<>();
-
-            Runtime.getRuntime().addShutdownHook(new Thread() {
-
-                @Override
-                public void run() {
-                    printProfiling();
-                }
-            });
-        }
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java	Mon Apr 14 18:25:23 2014 +0200
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2013, 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;
+
+import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
+
+import java.io.*;
+import java.util.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
+
+public final class OptimizedCallTargetLog {
+
+    protected static final PrintStream OUT = TTY.out().out();
+
+    private static Map<OptimizedCallTarget, Integer> callTargets;
+    static {
+        if (TruffleCallTargetProfiling.getValue()) {
+            callTargets = new WeakHashMap<>();
+
+            Runtime.getRuntime().addShutdownHook(new Thread() {
+
+                @Override
+                public void run() {
+                    printProfiling();
+                }
+            });
+        }
+    }
+
+    private OptimizedCallTargetLog() {
+    }
+
+    public static void logInliningDecision(TruffleInliningResult result) {
+        if (!TraceTruffleInlining.getValue()) {
+            return;
+        }
+
+        logInliningStart(result.getCallTarget());
+        logInliningDecisionRecursive(result, 0);
+        logInliningDone(result.getCallTarget());
+    }
+
+    private static void logInliningDecisionRecursive(TruffleInliningResult result, int depth) {
+        List<OptimizedCallNode> callNodes = searchCallNodes(result.getCallTarget());
+        for (OptimizedCallNode callNode : callNodes) {
+            TruffleInliningProfile profile = result.getProfiles().get(callNode);
+            boolean inlined = result.isInlined(callNode);
+            String msg = inlined ? "inline success" : "inline failed";
+            logInlinedImpl(msg, profile, depth);
+            if (profile.getRecursiveResult() != null && inlined) {
+                logInliningDecisionRecursive(profile.getRecursiveResult(), depth + 1);
+            }
+        }
+    }
+
+    private static List<OptimizedCallNode> searchCallNodes(final OptimizedCallTarget target) {
+        final List<OptimizedCallNode> callNodes = new ArrayList<>();
+        target.getRootNode().accept(new NodeVisitor() {
+            public boolean visit(Node node) {
+                if (node instanceof OptimizedCallNode) {
+                    callNodes.add((OptimizedCallNode) node);
+                }
+                return true;
+            }
+        });
+        return callNodes;
+    }
+
+    private static void logInlinedImpl(String status, TruffleInliningProfile profile, int depth) {
+        Map<String, Object> properties = new LinkedHashMap<>();
+        addASTSizeProperty(profile.getCallNode().getCurrentCallTarget(), properties);
+        if (profile != null) {
+            properties.putAll(profile.getDebugProperties());
+        }
+        log((depth * 2), status, profile.getCallNode().getCurrentCallTarget().toString(), properties);
+    }
+
+    private static void logInliningStart(OptimizedCallTarget target) {
+        if (TraceTruffleInlining.getValue()) {
+            log(0, "inline start", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    private static void logInliningDone(OptimizedCallTarget target) {
+        if (TraceTruffleInlining.getValue()) {
+            log(0, "inline done", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    public static void logOptimizingQueued(OptimizedCallTarget target) {
+        if (TraceTruffleCompilationDetails.getValue()) {
+            log(0, "opt queued", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    public static void logOptimizingUnqueued(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
+        if (TraceTruffleCompilationDetails.getValue()) {
+            Map<String, Object> properties = new LinkedHashMap<>();
+            addReplaceProperties(properties, oldNode, newNode);
+            properties.put("Reason", reason);
+            log(0, "opt unqueued", target.toString(), properties);
+        }
+    }
+
+    private static void addReplaceProperties(Map<String, Object> properties, Node oldNode, Node newNode) {
+        if (oldNode != null && newNode != null) {
+            properties.put("OldClass", oldNode.getClass().getSimpleName());
+            properties.put("NewClass", newNode.getClass().getSimpleName());
+            properties.put("Node", newNode);
+        }
+    }
+
+    static void logOptimizingStart(OptimizedCallTarget target) {
+        if (TraceTruffleCompilationDetails.getValue()) {
+            log(0, "opt start", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    public static void logOptimizedInvalidated(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
+        if (TraceTruffleCompilation.getValue()) {
+            Map<String, Object> properties = new LinkedHashMap<>();
+            addReplaceProperties(properties, oldNode, newNode);
+            properties.put("Reason", reason);
+            log(0, "opt invalidated", target.toString(), properties);
+        }
+    }
+
+    public static void logOptimizingFailed(OptimizedCallTarget callSite, CharSequence reason) {
+        Map<String, Object> properties = new LinkedHashMap<>();
+        properties.put("Reason", reason);
+        log(0, "opt fail", callSite.toString(), properties);
+    }
+
+    static void logOptimizingDone(OptimizedCallTarget target, Map<String, Object> properties) {
+        if (TraceTruffleCompilationDetails.getValue() || TraceTruffleCompilation.getValue()) {
+            log(0, "opt done", target.toString(), properties);
+        }
+        if (TraceTruffleCompilationPolymorphism.getValue()) {
+
+            target.getRootNode().accept(new NodeVisitor() {
+                public boolean visit(Node node) {
+                    NodeCost kind = node.getCost();
+                    if (kind == NodeCost.POLYMORPHIC || kind == NodeCost.MEGAMORPHIC) {
+                        Map<String, Object> props = new LinkedHashMap<>();
+                        props.put("simpleName", node.getClass().getSimpleName());
+                        String msg = kind == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
+                        log(0, msg, node.toString(), props);
+                    }
+                    if (node instanceof CallNode) {
+                        CallNode callNode = (CallNode) node;
+                        if (callNode.isInliningForced()) {
+                            callNode.getCurrentRootNode().accept(this);
+                        }
+                    }
+                    return true;
+                }
+            });
+
+        }
+    }
+
+    private static int splitCount = 0;
+
+    static void logSplit(OptimizedCallNode callNode, OptimizedCallTarget target, OptimizedCallTarget newTarget) {
+        if (TraceTruffleSplitting.getValue()) {
+            Map<String, Object> properties = new LinkedHashMap<>();
+            addASTSizeProperty(target, properties);
+            properties.put("Split#", ++splitCount);
+            properties.put("Source", callNode.getEncapsulatingSourceSection());
+            log(0, "split", newTarget.toString(), properties);
+        }
+    }
+
+    static void addASTSizeProperty(OptimizedCallTarget target, Map<String, Object> properties) {
+        int polymorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return node.getCost() == NodeCost.POLYMORPHIC;
+            }
+        }, true);
+
+        int megamorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return node.getCost() == NodeCost.MEGAMORPHIC;
+            }
+        }, true);
+
+        String value = String.format("%4d (%d/%d)", OptimizedCallUtils.countNonTrivialNodes(target, true), polymorphicCount, megamorphicCount);
+        properties.put("ASTSize", value);
+    }
+
+    static void log(int indent, String msg, String details, Map<String, Object> properties) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(String.format("[truffle] %-16s ", msg));
+        for (int i = 0; i < indent; i++) {
+            sb.append(' ');
+        }
+        sb.append(String.format("%-" + (60 - indent) + "s", details));
+        if (properties != null) {
+            for (String property : properties.keySet()) {
+                Object value = properties.get(property);
+                if (value == null) {
+                    continue;
+                }
+                sb.append('|');
+                sb.append(property);
+
+                StringBuilder propertyBuilder = new StringBuilder();
+                if (value instanceof Integer) {
+                    propertyBuilder.append(String.format("%6d", value));
+                } else if (value instanceof Double) {
+                    propertyBuilder.append(String.format("%8.2f", value));
+                } else {
+                    propertyBuilder.append(value);
+                }
+
+                int length = Math.max(1, 20 - property.length());
+                sb.append(String.format(" %" + length + "s ", propertyBuilder.toString()));
+            }
+        }
+        OUT.println(sb.toString());
+    }
+
+    private static void printProfiling() {
+        List<OptimizedCallTarget> sortedCallTargets = new ArrayList<>(callTargets.keySet());
+        Collections.sort(sortedCallTargets, new Comparator<OptimizedCallTarget>() {
+
+            @Override
+            public int compare(OptimizedCallTarget o1, OptimizedCallTarget o2) {
+                return o2.callCount - o1.callCount;
+            }
+        });
+
+        int totalCallCount = 0;
+        int totalInlinedCallSiteCount = 0;
+        int totalNodeCount = 0;
+        int totalInvalidationCount = 0;
+
+        OUT.println();
+        OUT.printf("%-50s | %-10s | %s / %s | %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count", "Inv");
+        for (OptimizedCallTarget callTarget : sortedCallTargets) {
+            if (callTarget.callCount == 0) {
+                continue;
+            }
+
+            int nodeCount = OptimizedCallUtils.countNonTrivialNodes(callTarget, true);
+            String comment = callTarget.installedCode == null ? " int" : "";
+            comment += callTarget.compilationEnabled ? "" : " fail";
+            OUT.printf("%-50s | %10d | %15d | %10d | %3d%s\n", callTarget.getRootNode(), callTarget.callCount, nodeCount, nodeCount, callTarget.getCompilationProfile().getInvalidationCount(), comment);
+
+            totalCallCount += callTarget.callCount;
+            totalInlinedCallSiteCount += nodeCount;
+            totalNodeCount += nodeCount;
+            totalInvalidationCount += callTarget.getCompilationProfile().getInvalidationCount();
+        }
+        OUT.printf("%-50s | %10d | %15d | %10d | %3d\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNodeCount, totalInvalidationCount);
+    }
+
+    public static void registerCallTarget(OptimizedCallTarget callTarget) {
+        callTargets.put(callTarget, 0);
+    }
+
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallUtils.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallUtils.java	Mon Apr 14 18:25:23 2014 +0200
@@ -27,14 +27,8 @@
 
 class OptimizedCallUtils {
 
-    public static int countNodes(OptimizedCallTarget target, NodeCountFilter filter, boolean inlined) {
-        NodeCountVisitorImpl nodeCount = new NodeCountVisitorImpl(filter, inlined);
-        target.getRootNode().accept(nodeCount);
-        return nodeCount.nodeCount;
-    }
-
     public static int countCalls(OptimizedCallTarget target) {
-        return countNodes(target, new NodeCountFilter() {
+        return NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
             public boolean isCounted(Node node) {
                 return node instanceof CallNode;
             }
@@ -42,7 +36,7 @@
     }
 
     public static int countCallsInlined(OptimizedCallTarget target) {
-        return countNodes(target, new NodeCountFilter() {
+        return NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
             public boolean isCounted(Node node) {
                 return (node instanceof OptimizedCallNode) && ((OptimizedCallNode) node).isInlined();
             }
@@ -50,7 +44,7 @@
     }
 
     public static int countNonTrivialNodes(final OptimizedCallTarget target, final boolean inlined) {
-        return countNodes(target, new NodeCountFilter() {
+        return NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
             public boolean isCounted(Node node) {
                 NodeCost cost = node.getCost();
                 if (cost != null && cost != NodeCost.NONE && cost != NodeCost.UNINITIALIZED) {
@@ -60,33 +54,4 @@
             }
         }, inlined);
     }
-
-    private static final class NodeCountVisitorImpl implements NodeVisitor {
-
-        private final NodeCountFilter filter;
-        private int nodeCount;
-        private boolean followInlined;
-
-        private NodeCountVisitorImpl(NodeCountFilter filter, boolean followInlined) {
-            this.filter = filter;
-            this.followInlined = followInlined;
-        }
-
-        public boolean visit(Node node) {
-            if (filter == null || filter.isCounted(node)) {
-                nodeCount++;
-            }
-            if (followInlined) {
-                if (node instanceof OptimizedCallNode) {
-                    OptimizedCallNode ocn = (OptimizedCallNode) node;
-                    if (ocn.isInlined()) {
-                        ocn.getCurrentRootNode().accept(this);
-                    }
-                }
-            }
-            return true;
-        }
-
-    }
-
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Mon Apr 14 18:25:23 2014 +0200
@@ -136,7 +136,7 @@
         final StructuredGraph graph;
 
         if (TraceTruffleCompilation.getValue()) {
-            OptimizedCallTarget.logOptimizingStart(compilable);
+            OptimizedCallTargetLog.logOptimizingStart(compilable);
         }
 
         long timeCompilationStarted = System.nanoTime();
@@ -169,7 +169,7 @@
             int inlinedCalls = OptimizedCallUtils.countCallsInlined(compilable);
             int dispatchedCalls = calls - inlinedCalls;
             Map<String, Object> properties = new LinkedHashMap<>();
-            OptimizedCallTarget.addASTSizeProperty(compilable, properties);
+            OptimizedCallTargetLog.addASTSizeProperty(compilable, properties);
             properties.put("Time", String.format("%5.0f(%4.0f+%-4.0f)ms", //
                             (timeCompilationFinished - timeCompilationStarted) / 1e6, //
                             (timePartialEvaluationFinished - timeCompilationStarted) / 1e6, //
@@ -179,7 +179,7 @@
             properties.put("CodeSize", code != null ? code.length : 0);
             properties.put("Source", formatSourceSection(compilable.getRootNode().getSourceSection()));
 
-            OptimizedCallTarget.logOptimizingDone(compilable, properties);
+            OptimizedCallTargetLog.logOptimizingDone(compilable, properties);
         }
         return compiledMethod;
     }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java	Mon Apr 14 18:25:23 2014 +0200
@@ -88,6 +88,7 @@
     /**
      * Enforces the runtime system to inline the {@link CallTarget} at this call site. If the
      * runtime system does not support inlining or it is already inlined this method has no effect.
+     * The runtime system may decide to not inline calls which were forced to inline.
      */
     public abstract void forceInlining();
 
@@ -95,8 +96,8 @@
      * Returns true if the runtime system has decided to inline this call-site. If the
      * {@link CallNode} was forced to inline then this does not necessarily mean that the
      * {@link CallNode} is really going to be inlined. This depends on whether or not the runtime
-     * system supports inlining or not. The runtime system may also decide to ignore calls to
-     * {@link #forceInlining()}.
+     * system supports inlining. The runtime system may also decide to not inline calls which were
+     * forced to inline.
      */
     public abstract boolean isInlined();
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Mon Apr 14 18:25:23 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Mon Apr 14 18:25:23 2014 +0200
@@ -638,7 +638,7 @@
 
             if (visitInlinedCallNodes && node instanceof CallNode) {
                 CallNode call = (CallNode) node;
-                if (call.isInliningForced()) {
+                if (call.isInlined()) {
                     Node target = ((RootCallTarget) call.getCurrentCallTarget()).getRootNode();
                     if (target != null) {
                         target.accept(this);
@@ -763,7 +763,7 @@
     /**
      * Prints a human readable form of a {@link Node} AST to the given {@link PrintStream}. This
      * print method does not check for cycles in the node structure.
-     * 
+     *
      * @param out the stream to print to.
      * @param node the root node to write
      */