Mercurial > hg > truffle
changeset 5328:e4e02131c58b
log file (i.e. -G:LogFile=log.txt option) now used for TTY output as well
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 30 Apr 2012 20:28:49 +0200 |
parents | 28577a53d3a7 |
children | 7ceb3f3671b9 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java graal/com.oracle.max.criutils/src/com/oracle/max/criutils/TTY.java |
diffstat | 5 files changed, 37 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Mon Apr 30 20:26:47 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Mon Apr 30 20:28:49 2012 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.hotspot; +import java.io.*; import java.util.concurrent.*; import com.oracle.graal.compiler.*; @@ -57,7 +58,8 @@ public void run() { if (GraalOptions.Debug) { Debug.enable(); - HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter, GraalOptions.LogFile); + PrintStream log = CompilerImpl.getInstance().getVMToCompiler().log(); + HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter, log); Debug.setConfig(hotspotDebugConfig); } super.run();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java Mon Apr 30 20:26:47 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java Mon Apr 30 20:28:49 2012 +0200 @@ -43,10 +43,7 @@ private final List<DebugDumpHandler> dumpHandlers = new ArrayList<>(); private final PrintStream output; - private static final PrintStream cachedOut = System.out; - - - public HotSpotDebugConfig(String logFilter, String meterFilter, String timerFilter, String dumpFilter, String methodFilter, String logFile) { + public HotSpotDebugConfig(String logFilter, String meterFilter, String timerFilter, String dumpFilter, String methodFilter, PrintStream output) { this.logFilter = DebugFilter.parse(logFilter); this.meterFilter = DebugFilter.parse(meterFilter); this.timerFilter = DebugFilter.parse(timerFilter); @@ -72,15 +69,7 @@ dumpHandlers.add(new IdealGraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort)); } dumpHandlers.add(new CFGPrinterObserver()); - if (logFile == null || logFile.isEmpty()) { - output = cachedOut; - } else { - try { - output = new PrintStream(logFile); - } catch (FileNotFoundException e) { - throw new RuntimeException("couldn't create log file: " + logFile, e); - } - } + this.output = output; } public boolean isLogEnabled() { @@ -163,10 +152,12 @@ Debug.log(String.format("Exception occured in scope: %s", Debug.currentScope())); for (Object o : Debug.context()) { Debug.log("Context obj %s", o); - if (o instanceof Graph && GraalOptions.DumpOnError) { - Graph graph = (Graph) o; - Debug.log("Found graph in context: ", graph); - Debug.dump(o, "Exception graph"); + if (o instanceof Graph) { + if (GraalOptions.DumpOnError) { + Debug.dump(o, "Exception graph"); + } else { + Debug.log("Use -G:+DumpOnError to enable dumping of graphs on this error"); + } } } return null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java Mon Apr 30 20:26:47 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java Mon Apr 30 20:28:49 2012 +0200 @@ -23,6 +23,8 @@ package com.oracle.graal.hotspot.bridge; +import java.io.*; + import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.phases.*; import com.oracle.graal.hotspot.ri.*; @@ -42,6 +44,8 @@ void bootstrap() throws Throwable; + PrintStream log(); + RiMethod createRiMethodUnresolved(String name, String signature, RiType holder); RiSignature createRiSignature(String signature);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Apr 30 20:26:47 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Apr 30 20:28:49 2012 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.bridge; +import java.io.*; import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; @@ -67,6 +68,8 @@ private ThreadPoolExecutor slowCompileQueue; private AtomicInteger compileTaskIds = new AtomicInteger(); + private PrintStream log = System.out; + public VMToCompilerImpl(Compiler compiler) { this.compiler = compiler; @@ -82,8 +85,16 @@ } public void startCompiler() throws Throwable { - // Make sure TTY is initialized here such that the correct System.out is used for TTY. - TTY.initialize(); + if (GraalOptions.LogFile != null) { + try { + final boolean enableAutoflush = true; + log = new PrintStream(new FileOutputStream(GraalOptions.LogFile), enableAutoflush); + } catch (FileNotFoundException e) { + throw new RuntimeException("couldn't open log file: " + GraalOptions.LogFile, e); + } + } + + TTY.initialize(log); if (GraalOptions.Log == null && GraalOptions.Meter == null && GraalOptions.Time == null && GraalOptions.Dump == null) { if (GraalOptions.MethodFilter != null) { @@ -93,7 +104,7 @@ if (GraalOptions.Debug) { Debug.enable(); - HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter, GraalOptions.LogFile); + HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter, log); Debug.setConfig(hotspotDebugConfig); } // Install intrinsics. @@ -473,4 +484,9 @@ } return phasePlan; } + + @Override + public PrintStream log() { + return log; + } }
--- a/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/TTY.java Mon Apr 30 20:26:47 2012 +0200 +++ b/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/TTY.java Mon Apr 30 20:28:49 2012 +0200 @@ -89,12 +89,10 @@ } } - public static final String MAX_TTY_LOG_FILE_PROPERTY = "max.tty.file"; - public static PrintStream cachedOut; - public static void initialize() { - cachedOut = System.out; + public static void initialize(PrintStream ps) { + cachedOut = ps; } private static LogStream createLog() { @@ -102,16 +100,7 @@ // In case initialize() was not called. cachedOut = System.out; } - PrintStream newOut = cachedOut; - String value = System.getProperty(MAX_TTY_LOG_FILE_PROPERTY); - if (value != null) { - try { - newOut = new PrintStream(new FileOutputStream(value)); - } catch (FileNotFoundException e) { - System.err.println("Could not open log file " + value + ": " + e); - } - } - return new LogStream(newOut); + return new LogStream(cachedOut); } private static final ThreadLocal<LogStream> out = new ThreadLocal<LogStream>() {