Mercurial > hg > graal-jvmci-8
changeset 13207:9500ac5269ff
add truffle tree dump handler in order to make tree dumping respect the method filter.
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Sat, 30 Nov 2013 18:21:06 +0100 |
parents | c2deb575483c |
children | 66d793d06465 |
files | graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java |
diffstat | 3 files changed, 57 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Sat Nov 30 18:14:58 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Sat Nov 30 18:21:06 2013 +0100 @@ -22,7 +22,6 @@ */ package com.oracle.graal.truffle; -import static com.oracle.graal.compiler.GraalDebugConfig.*; import static com.oracle.graal.phases.GraalOptions.*; import static com.oracle.graal.truffle.TruffleCompilerOptions.*; @@ -89,12 +88,11 @@ } } - public StructuredGraph createGraph(final OptimizedCallTarget node, final Assumptions assumptions) { - if (Dump.getValue() != null && Dump.getValue().contains("Truffle")) { - RootNode root = node.getRootNode(); - if (root != null) { - new GraphPrintVisitor().beginGroup("TruffleGraph").beginGraph(node.toString()).visit(root).printToNetwork(); - } + public StructuredGraph createGraph(final OptimizedCallTarget callTarget, final Assumptions assumptions) { + try (Scope s = Debug.scope("TruffleTree")) { + Debug.dump(callTarget, "truffle tree"); + } catch (Throwable e) { + throw Debug.handle(e); } if (TraceTruffleCompilationDetails.getValue()) { @@ -111,7 +109,7 @@ // Replace thisNode with constant. LocalNode thisNode = graph.getLocal(0); - thisNode.replaceAndDelete(ConstantNode.forObject(node, providers.getMetaAccess(), graph)); + thisNode.replaceAndDelete(ConstantNode.forObject(callTarget, providers.getMetaAccess(), graph)); // Canonicalize / constant propagate. PhaseContext baseContext = new PhaseContext(providers, assumptions);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Sat Nov 30 18:14:58 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Sat Nov 30 18:21:06 2013 +0100 @@ -85,7 +85,13 @@ // Create compilation queue. CompilerThreadFactory factory = new CompilerThreadFactory("TruffleCompilerThread", new DebugConfigAccess() { public GraalDebugConfig getDebugConfig() { - return Debug.isEnabled() ? DebugEnvironment.initialize(TTY.out().out()) : null; + if (Debug.isEnabled()) { + GraalDebugConfig debugConfig = DebugEnvironment.initialize(TTY.out().out()); + debugConfig.dumpHandlers().add(new TruffleTreeDumpHandler()); + return debugConfig; + } else { + return null; + } } }); compileQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java Sat Nov 30 18:21:06 2013 +0100 @@ -0,0 +1,44 @@ +/* + * 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 com.oracle.graal.debug.*; +import com.oracle.truffle.api.impl.*; +import com.oracle.truffle.api.nodes.*; + +public class TruffleTreeDumpHandler implements DebugDumpHandler { + + @Override + public void dump(Object object, final String message) { + if (object instanceof DefaultCallTarget) { + DefaultCallTarget callTarget = (DefaultCallTarget) object; + if (callTarget.getRootNode() != null) { + new GraphPrintVisitor().beginGroup(callTarget.toString()).beginGraph(message).visit(callTarget.getRootNode()).printToNetwork(); + } + } + } + + public void close() { + // nothing to do + } +}