# HG changeset patch # User Andreas Woess # Date 1385988365 -3600 # Node ID b96cc3b87e874cd42f0eb471938a3d7a525b5e18 # Parent bef512e4226226e6ac6e5d4e5bc136572b301037# Parent 66d793d064654c6ad3031d26cc5cd0a17a079ef5 Merge diff -r bef512e42262 -r b96cc3b87e87 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Mon Dec 02 12:45:18 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Mon Dec 02 13:46:05 2013 +0100 @@ -79,8 +79,9 @@ if (installedCode != null && installedCode.isValid()) { TruffleRuntime runtime = Truffle.getRuntime(); if (runtime instanceof GraalTruffleRuntime) { - OUT.printf("[truffle] reinstall OptimizedCallTarget.call code with frame prolog shortcut."); - OUT.println(); + if (TraceTruffleCompilation.getValue()) { + OUT.println("[truffle] reinstall OptimizedCallTarget.call code with frame prolog shortcut."); + } GraalTruffleRuntime.installOptimizedCallTargetCallMethod(); } } diff -r bef512e42262 -r b96cc3b87e87 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Mon Dec 02 12:45:18 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Mon Dec 02 13:46:05 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.*; @@ -88,12 +87,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()) { @@ -110,7 +108,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); diff -r bef512e42262 -r b96cc3b87e87 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Mon Dec 02 12:45:18 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Mon Dec 02 13:46:05 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(), factory); diff -r bef512e42262 -r b96cc3b87e87 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java Mon Dec 02 13:46:05 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 + } +} diff -r bef512e42262 -r b96cc3b87e87 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Mon Dec 02 12:45:18 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Mon Dec 02 13:46:05 2013 +0100 @@ -136,6 +136,10 @@ @Override public void virtualize(VirtualizerTool tool) { + if (!descriptor.isConstant()) { + return; + } + int frameSize = getFrameSize(); ResolvedJavaType frameType = stamp().javaType(tool.getMetaAccessProvider());