changeset 12596:3ee8ae69d676

Introduce TraceTruffleInliningTree option.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 22 Oct 2013 11:42:10 +0200
parents 36f39d0c9875
children ce8dd5fa8d54
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java
diffstat 2 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Thu Oct 17 17:26:18 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Tue Oct 22 11:42:10 2013 +0200
@@ -130,6 +130,10 @@
         config.setSkippedExceptionTypes(skippedExceptionTypes);
         runtime.evictDeoptedGraphs();
 
+        if (TraceTruffleInliningTree.getValue()) {
+            printInlineTree(compilable.getRootNode());
+        }
+
         long timeCompilationStarted = System.nanoTime();
         Assumptions assumptions = new Assumptions(true);
         try (TimerCloseable a = PartialEvaluationTime.start()) {
@@ -157,6 +161,37 @@
         return compiledMethod;
     }
 
+    private void printInlineTree(RootNode rootNode) {
+        OUT.println();
+        OUT.println("Inlining tree for: " + rootNode);
+        rootNode.accept(new InlineTreeVisitor());
+    }
+
+    private class InlineTreeVisitor implements NodeVisitor {
+
+        public boolean visit(Node node) {
+            if (node instanceof InlinedCallSite) {
+                InlinedCallSite inlinedCallSite = (InlinedCallSite) node;
+                int indent = this.indent(node);
+                for (int i = 0; i < indent; ++i) {
+                    OUT.print("   ");
+                }
+                OUT.println(inlinedCallSite.getCallTarget());
+            }
+            return true;
+        }
+
+        private int indent(Node n) {
+            if (n instanceof RootNode) {
+                return 0;
+            } else if (n instanceof InlinedCallSite) {
+                return indent(n.getParent()) + 1;
+            } else {
+                return indent(n.getParent());
+            }
+        }
+    }
+
     public InstalledCode compileMethodHelper(final StructuredGraph graph, final GraphBuilderConfiguration config, final Assumptions assumptions) {
         final PhasePlan plan = createPhasePlan(config);
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java	Thu Oct 17 17:26:18 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java	Tue Oct 22 11:42:10 2013 +0200
@@ -88,6 +88,8 @@
     @Option(help = "")
     public static final OptionValue<Boolean> TraceTruffleInlining = new OptionValue<>(true);
     @Option(help = "")
+    public static final OptionValue<Boolean> TraceTruffleInliningTree = new OptionValue<>(false);
+    @Option(help = "")
     public static final OptionValue<Boolean> TraceTruffleInliningDetails = new OptionValue<>(false);
     @Option(help = "")
     public static final OptionValue<Boolean> TruffleCallTargetProfiling = new StableOptionValue<>(false);