Mercurial > hg > graal-compiler
changeset 12611:63c378b7c1c3
made Truffle compiler threads be named and have a debug configuration
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 26 Oct 2013 01:27:09 +0200 |
parents | 62fb4919edc9 |
children | 42a2c235652f |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerThread.java |
diffstat | 4 files changed, 79 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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) {
--- 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<DebugDumpHandler> 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; } }
--- 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<Runnable>()); + compileQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), 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<InstalledCode>() { @Override
--- /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) { + + } + } + } + } + } +}