# HG changeset patch # User Doug Simon # Date 1382743629 -7200 # Node ID 63c378b7c1c3b6b37036f9ae26fe10b64da49413 # Parent 62fb4919edc9eaaa7d4f4bb5e29789c19dd8591c made Truffle compiler threads be named and have a debug configuration diff -r 62fb4919edc9 -r 63c378b7c1c3 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Fri Oct 25 23:50:05 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Sat Oct 26 01:27:09 2013 +0200 @@ -50,16 +50,16 @@ @Override public void run() { - GraalDebugConfig hotspotDebugConfig = null; + GraalDebugConfig debugConfig = null; if (Debug.isEnabled()) { PrintStream log = runtime().getVMToCompiler().log(); - DebugEnvironment.initialize(log); + debugConfig = DebugEnvironment.initialize(log); } try { super.run(); } finally { - if (hotspotDebugConfig != null) { - for (DebugDumpHandler dumpHandler : hotspotDebugConfig.dumpHandlers()) { + if (debugConfig != null) { + for (DebugDumpHandler dumpHandler : debugConfig.dumpHandlers()) { try { dumpHandler.close(); } catch (Throwable t) { diff -r 62fb4919edc9 -r 63c378b7c1c3 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Fri Oct 25 23:50:05 2013 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Sat Oct 26 01:27:09 2013 +0200 @@ -33,10 +33,10 @@ public class DebugEnvironment { - public static void initialize(PrintStream log) { + public static GraalDebugConfig initialize(PrintStream log) { if (!Debug.isEnabled()) { log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initialization.INITIALIZER_PROPERTY_NAME + "=true"); - return; + return null; } List dumpHandlers = new ArrayList<>(); dumpHandlers.add(new GraphPrinterDumpHandler()); @@ -49,7 +49,8 @@ if (DecompileAfterPhase.getValue() != null) { dumpHandlers.add(new DecompilerDebugDumpHandler()); } - GraalDebugConfig hotspotDebugConfig = new GraalDebugConfig(Log.getValue(), Meter.getValue(), Time.getValue(), Dump.getValue(), MethodFilter.getValue(), log, dumpHandlers); - Debug.setConfig(hotspotDebugConfig); + GraalDebugConfig debugConfig = new GraalDebugConfig(Log.getValue(), Meter.getValue(), Time.getValue(), Dump.getValue(), MethodFilter.getValue(), log, dumpHandlers); + Debug.setConfig(debugConfig); + return debugConfig; } } diff -r 62fb4919edc9 -r 63c378b7c1c3 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 Fri Oct 25 23:50:05 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Sat Oct 26 01:27:09 2013 +0200 @@ -81,7 +81,7 @@ this.skippedExceptionTypes = getSkippedExceptionTypes(providers.getMetaAccess()); // Create compilation queue. - compileQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); + compileQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), TruffleCompilerThread.FACTORY); final GraphBuilderConfiguration config = GraphBuilderConfiguration.getEagerDefault(); config.setSkippedExceptionTypes(skippedExceptionTypes); @@ -107,7 +107,7 @@ @Override public InstalledCode call() throws Exception { - Object[] debug = new Object[]{new DebugDumpScope("Truffle: " + compilable)}; + Object[] debug = new Object[]{new TruffleDebugJavaMethod(compilable)}; return Debug.scope("Truffle", debug, new Callable() { @Override diff -r 62fb4919edc9 -r 63c378b7c1c3 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerThread.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerThread.java Sat Oct 26 01:27:09 2013 +0200 @@ -0,0 +1,68 @@ +/* + * 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.graal.truffle; + +import java.util.concurrent.*; + +import com.oracle.graal.compiler.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.printer.*; + +public final class TruffleCompilerThread extends Thread { + + public static final ThreadFactory FACTORY = new ThreadFactory() { + + @Override + public Thread newThread(Runnable r) { + return new TruffleCompilerThread(r); + } + }; + + private TruffleCompilerThread(Runnable r) { + super(r); + this.setName("TruffleCompilerThread-" + this.getId()); + this.setPriority(MAX_PRIORITY); + this.setDaemon(true); + } + + @Override + public void run() { + GraalDebugConfig debugConfig = null; + if (Debug.isEnabled()) { + debugConfig = DebugEnvironment.initialize(System.out); + } + try { + super.run(); + } finally { + if (debugConfig != null) { + for (DebugDumpHandler dumpHandler : debugConfig.dumpHandlers()) { + try { + dumpHandler.close(); + } catch (Throwable t) { + + } + } + } + } + } +}