# HG changeset patch # User Doug Simon # Date 1443534937 -7200 # Node ID b6b46b741102e33d6c7cf04266b69dc95b18a632 # Parent 545590b1ab83c00b653ec3143ff876a0c42306c4 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private diff -r 545590b1ab83 -r b6b46b741102 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Tue Sep 29 14:43:37 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Tue Sep 29 15:55:37 2015 +0200 @@ -566,7 +566,7 @@ * Writes {@code length} bytes from {@code buf} starting at offset {@code offset} to the * HotSpot's log stream. No range checking is performed. */ - public void writeDebugOutput(byte[] bytes, int offset, int length) { + void writeDebugOutput(byte[] bytes, int offset, int length) { writeDebugOutputImpl(bytes, offset, length); } @@ -575,7 +575,7 @@ /** * Flush HotSpot's log stream. */ - public void flushDebugOutput() { + void flushDebugOutput() { flushDebugOutputImpl(); } diff -r 545590b1ab83 -r b6b46b741102 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Tue Sep 29 14:43:37 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Tue Sep 29 15:55:37 2015 +0200 @@ -24,6 +24,8 @@ import static jdk.internal.jvmci.inittimer.InitTimer.timer; +import java.io.IOException; +import java.io.OutputStream; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -338,4 +340,31 @@ } return value.toString(); } + + public OutputStream getLogStream() { + return new OutputStream() { + + @Override + public void write(byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + compilerToVm.writeDebugOutput(b, off, len); + } + + @Override + public void write(int b) throws IOException { + write(new byte[]{(byte) b}, 0, 1); + } + + @Override + public void flush() throws IOException { + compilerToVm.flushDebugOutput(); + } + }; + } } diff -r 545590b1ab83 -r b6b46b741102 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntimeProvider.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntimeProvider.java Tue Sep 29 14:43:37 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntimeProvider.java Tue Sep 29 15:55:37 2015 +0200 @@ -22,6 +22,8 @@ */ package jdk.internal.jvmci.hotspot; +import java.io.OutputStream; + import jdk.internal.jvmci.common.JVMCIError; import jdk.internal.jvmci.compiler.Compiler; import jdk.internal.jvmci.meta.JVMCIMetaAccessContext; @@ -45,6 +47,11 @@ Compiler getCompiler(); /** + * Gets an output stream that writes to the HotSpot's {@code tty} stream. + */ + OutputStream getLogStream(); + + /** * Converts a name to a Java type. This method attempts to resolve {@code name} to a * {@link ResolvedJavaType}. *