changeset 21885:c869a5c3da16

made access to CompilerToVM from PrintStreamOption lazy to resolve initialization issue
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 20:36:45 +0200
parents 525c4df9428b
children b1234c06ea49
files jvmci/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/DebugScope.java jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotTTYStreamProvider.java jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/PrintStreamOption.java
diffstat 3 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/DebugScope.java	Tue Jun 09 12:04:47 2015 -0700
+++ b/jvmci/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/DebugScope.java	Tue Jun 09 20:36:45 2015 +0200
@@ -144,8 +144,6 @@
             logScopeName = true;
         }
 
-        // Be pragmatic: provide a default log stream to prevent a crash if the stream is not
-        // set while logging
         this.output = TTY.out;
         assert context != null;
     }
--- a/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotTTYStreamProvider.java	Tue Jun 09 12:04:47 2015 -0700
+++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotTTYStreamProvider.java	Tue Jun 09 20:36:45 2015 +0200
@@ -32,7 +32,6 @@
 class HotSpotTTYStreamProvider implements TTYStreamProvider {
 
     public PrintStream getStream() {
-        CompilerToVM compilerToVm = HotSpotJVMCIRuntime.runtime().getCompilerToVM();
-        return Options.LogFile.getStream(compilerToVm);
+        return Options.LogFile.getStream();
     }
 }
--- a/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/PrintStreamOption.java	Tue Jun 09 12:04:47 2015 -0700
+++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/PrintStreamOption.java	Tue Jun 09 20:36:45 2015 +0200
@@ -40,7 +40,7 @@
      * The print stream to which output will be written.
      *
      * Declared {@code volatile} to enable safe use of double-checked locking in
-     * {@link #getStream(CompilerToVM)} and {@link #setValue(Object)}.
+     * {@link #getStream()} and {@link #setValue(Object)}.
      */
     private volatile PrintStream ps;
 
@@ -72,7 +72,7 @@
      * Gets the print stream configured by this option. If no file is configured, the print stream
      * will output to {@link CompilerToVM#writeDebugOutput(byte[], int, int)}.
      */
-    public PrintStream getStream(final CompilerToVM compilerToVM) {
+    public PrintStream getStream() {
         if (ps == null) {
             if (getValue() != null) {
                 synchronized (this) {
@@ -94,6 +94,15 @@
                 }
             } else {
                 OutputStream ttyOut = new OutputStream() {
+                    CompilerToVM vm;
+
+                    private CompilerToVM vm() {
+                        if (vm == null) {
+                            vm = HotSpotJVMCIRuntime.runtime().getCompilerToVM();
+                        }
+                        return vm;
+                    }
+
                     @Override
                     public void write(byte[] b, int off, int len) throws IOException {
                         if (b == null) {
@@ -103,7 +112,7 @@
                         } else if (len == 0) {
                             return;
                         }
-                        compilerToVM.writeDebugOutput(b, off, len);
+                        vm().writeDebugOutput(b, off, len);
                     }
 
                     @Override
@@ -113,7 +122,7 @@
 
                     @Override
                     public void flush() throws IOException {
-                        compilerToVM.flushDebugOutput();
+                        vm().flushDebugOutput();
                     }
                 };
                 ps = new PrintStream(ttyOut);