# HG changeset patch # User Tom Rodriguez # Date 1438039601 25200 # Node ID 7d48038267b473cefa4274a24357e68e87dc1200 # Parent 143099e04cfa8813c2f61a859197097dff2d9605 Eliminate jdk.internal.jvmci.debug diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/Util.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/Util.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/Util.java Mon Jul 27 16:26:41 2015 -0700 @@ -24,8 +24,9 @@ import java.util.*; +import com.oracle.graal.debug.*; + import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.debug.*; /** * The {@code Util} class contains a motley collection of utility methods used throughout the diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Jul 27 16:26:41 2015 -0700 @@ -64,8 +64,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.code.CallingConvention.Type; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Mon Jul 27 16:26:41 2015 -0700 @@ -24,8 +24,6 @@ import java.io.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import org.junit.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/InstructionPrinter.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/InstructionPrinter.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/InstructionPrinter.java Mon Jul 27 16:26:41 2015 -0700 @@ -23,8 +23,8 @@ package com.oracle.graal.compiler.gen; import static com.oracle.graal.compiler.gen.InstructionPrinter.InstructionLineColumn.*; -import jdk.internal.jvmci.debug.*; +import com.oracle.graal.debug.*; import com.oracle.graal.nodes.*; /** diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Mon Jul 27 16:26:41 2015 -0700 @@ -33,8 +33,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/LogStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/LogStream.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,477 @@ +/* + * Copyright (c) 2009, 2011, 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.debug; + +import java.io.*; + +/** + * A utility for printing compiler debug and informational output to an output stream. + * + * A {@link LogStream} instance maintains an internal buffer that is flushed to the underlying + * output stream every time one of the {@code println} methods is invoked, or a newline character ( + * {@code '\n'}) is written. + * + * All of the {@code print} and {@code println} methods return the {code LogStream} instance on + * which they were invoked. This allows chaining of these calls to mitigate use of String + * concatenation by the caller. + * + * A {@code LogStream} maintains a current {@linkplain #indentationLevel() indentation} level. Each + * line of output written to this stream has {@code n} spaces prefixed to it where {@code n} is the + * value that would be returned by {@link #indentationLevel()} when the first character of a new + * line is written. + * + * A {@code LogStream} maintains a current {@linkplain #position() position} for the current line + * being written. This position can be advanced to a specified position by + * {@linkplain #fillTo(int, char) filling} this stream with a given character. + */ +public class LogStream { + + /** + * Null output stream that simply swallows any output sent to it. + */ + public static final LogStream SINK = new LogStream(); + + private static final PrintStream SINK_PS = new PrintStream(new OutputStream() { + + @Override + public void write(int b) throws IOException { + } + }); + + private LogStream() { + this.ps = null; + this.lineBuffer = null; + } + + /** + * The output stream to which this log stream writes. + */ + private final PrintStream ps; + + private final StringBuilder lineBuffer; + private int indentationLevel; + private char indentation = ' '; + private boolean indentationDisabled; + + public final PrintStream out() { + if (ps == null) { + return SINK_PS; + } + return ps; + } + + /** + * The system dependent line separator. + */ + public static final String LINE_SEPARATOR = System.getProperty("line.separator"); + + /** + * Creates a new log stream. + * + * @param os the underlying output stream to which prints are sent + */ + public LogStream(OutputStream os) { + ps = os instanceof PrintStream ? (PrintStream) os : new PrintStream(os); + lineBuffer = new StringBuilder(100); + } + + /** + * Creates a new log stream that shares the same {@linkplain #ps output stream} as a given + * {@link LogStream}. + * + * @param log a LogStream whose output stream is shared with this one + */ + public LogStream(LogStream log) { + ps = log.ps; + lineBuffer = new StringBuilder(100); + } + + /** + * Prepends {@link #indentation} to the current output line until its write position is equal to + * the current {@linkplain #indentationLevel()} level. + */ + private void indent() { + if (ps != null) { + if (!indentationDisabled && indentationLevel != 0) { + while (lineBuffer.length() < indentationLevel) { + lineBuffer.append(indentation); + } + } + } + } + + private LogStream flushLine(boolean withNewline) { + if (ps != null) { + if (withNewline) { + lineBuffer.append(LINE_SEPARATOR); + } + ps.print(lineBuffer.toString()); + ps.flush(); + lineBuffer.setLength(0); + } + return this; + } + + /** + * Flushes the stream. This is done by terminating the current line if it is not at position 0 + * and then flushing the underlying output stream. + */ + public void flush() { + if (ps != null) { + if (lineBuffer.length() != 0) { + flushLine(false); + } + ps.flush(); + } + } + + /** + * Gets the current column position of this log stream. + * + * @return the current column position of this log stream + */ + public int position() { + return lineBuffer == null ? 0 : lineBuffer.length(); + + } + + /** + * Gets the current indentation level for this log stream. + * + * @return the current indentation level for this log stream. + */ + public int indentationLevel() { + return indentationLevel; + } + + /** + * Adjusts the current indentation level of this log stream. + * + * @param delta + */ + public void adjustIndentation(int delta) { + if (delta < 0) { + indentationLevel = Math.max(0, indentationLevel + delta); + } else { + indentationLevel += delta; + } + } + + /** + * Gets the current indentation character of this log stream. + */ + public char indentation() { + return indentation; + } + + public void disableIndentation() { + indentationDisabled = true; + } + + public void enableIndentation() { + indentationDisabled = false; + } + + /** + * Sets the character used for indentation. + */ + public void setIndentation(char c) { + indentation = c; + } + + /** + * Advances this stream's {@linkplain #position() position} to a given position by repeatedly + * appending a given character as necessary. + * + * @param position the position to which this stream's position will be advanced + * @param filler the character used to pad the stream + */ + public LogStream fillTo(int position, char filler) { + if (ps != null) { + indent(); + while (lineBuffer.length() < position) { + lineBuffer.append(filler); + } + } + return this; + } + + /** + * Writes a boolean value to this stream as {@code "true"} or {@code "false"}. + * + * @param b the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(boolean b) { + if (ps != null) { + indent(); + lineBuffer.append(b); + } + return this; + } + + /** + * Writes a boolean value to this stream followed by a {@linkplain #LINE_SEPARATOR line + * separator}. + * + * @param b the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(boolean b) { + if (ps != null) { + indent(); + lineBuffer.append(b); + return flushLine(true); + } + return this; + } + + /** + * Writes a character value to this stream. + * + * @param c the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(char c) { + if (ps != null) { + indent(); + lineBuffer.append(c); + if (c == '\n') { + if (lineBuffer.indexOf(LINE_SEPARATOR, lineBuffer.length() - LINE_SEPARATOR.length()) != -1) { + flushLine(false); + } + } + } + return this; + } + + /** + * Writes a character value to this stream followed by a {@linkplain #LINE_SEPARATOR line + * separator}. + * + * @param c the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(char c) { + if (ps != null) { + indent(); + lineBuffer.append(c); + flushLine(true); + } + return this; + } + + /** + * Prints an int value. + * + * @param i the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(int i) { + if (ps != null) { + indent(); + lineBuffer.append(i); + } + return this; + } + + /** + * Writes an int value to this stream followed by a {@linkplain #LINE_SEPARATOR line separator}. + * + * @param i the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(int i) { + if (ps != null) { + indent(); + lineBuffer.append(i); + return flushLine(true); + } + return this; + } + + /** + * Writes a float value to this stream. + * + * @param f the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(float f) { + if (ps != null) { + indent(); + lineBuffer.append(f); + } + return this; + } + + /** + * Writes a float value to this stream followed by a {@linkplain #LINE_SEPARATOR line separator} + * . + * + * @param f the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(float f) { + if (ps != null) { + indent(); + lineBuffer.append(f); + return flushLine(true); + } + return this; + } + + /** + * Writes a long value to this stream. + * + * @param l the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(long l) { + if (ps != null) { + indent(); + lineBuffer.append(l); + } + return this; + } + + /** + * Writes a long value to this stream followed by a {@linkplain #LINE_SEPARATOR line separator}. + * + * @param l the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(long l) { + if (ps != null) { + indent(); + lineBuffer.append(l); + return flushLine(true); + } + return this; + } + + /** + * Writes a double value to this stream. + * + * @param d the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(double d) { + if (ps != null) { + indent(); + lineBuffer.append(d); + } + return this; + } + + /** + * Writes a double value to this stream followed by a {@linkplain #LINE_SEPARATOR line + * separator}. + * + * @param d the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(double d) { + if (ps != null) { + indent(); + lineBuffer.append(d); + return flushLine(true); + } + return this; + } + + /** + * Writes a {@code String} value to this stream. This method ensures that the + * {@linkplain #position() position} of this stream is updated correctly with respect to any + * {@linkplain #LINE_SEPARATOR line separators} present in {@code s}. + * + * @param s the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream print(String s) { + if (ps != null) { + if (s == null) { + indent(); + lineBuffer.append(s); + return this; + } + + int index = 0; + int next = s.indexOf(LINE_SEPARATOR, index); + while (index < s.length()) { + indent(); + if (next > index) { + lineBuffer.append(s.substring(index, next)); + flushLine(true); + index = next + LINE_SEPARATOR.length(); + next = s.indexOf(LINE_SEPARATOR, index); + } else { + lineBuffer.append(s.substring(index)); + break; + } + } + } + return this; + } + + /** + * Writes a {@code String} value to this stream followed by a {@linkplain #LINE_SEPARATOR line + * separator}. + * + * @param s the value to be printed + * @return this {@link LogStream} instance + */ + public LogStream println(String s) { + if (ps != null) { + print(s); + flushLine(true); + } + return this; + } + + /** + * Writes a formatted string to this stream. + * + * @param format a format string as described in {@link String#format(String, Object...)} + * @param args the arguments to be formatted + * @return this {@link LogStream} instance + */ + public LogStream printf(String format, Object... args) { + if (ps != null) { + print(String.format(format, args)); + } + return this; + } + + /** + * Writes a {@linkplain #LINE_SEPARATOR line separator} to this stream. + * + * @return this {@code LogStream} instance + */ + public LogStream println() { + if (ps != null) { + indent(); + flushLine(true); + } + return this; + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/TTY.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/TTY.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2009, 2011, 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.debug; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +import jdk.internal.jvmci.service.*; + +/** + * A collection of static methods for printing debug and informational output to a global + * {@link LogStream}. The output can be (temporarily) suppressed per thread through use of a + * {@linkplain Filter filter}. + */ +public class TTY { + + /** + * Support for thread-local suppression of {@link TTY}. + */ + public static class Filter { + + private LogStream previous; + private final Thread thread = Thread.currentThread(); + + /** + * Creates an object that will suppress {@link TTY} for the current thread if the given + * filter does not match the given object. To revert the suppression state to how it was + * before this call, the {@link #remove()} method must be called on the suppression object. + * + * @param filter the pattern for matching. If {@code null}, then the match is successful. If + * it starts with "~", then a regular expression + * {@linkplain Pattern#matches(String, CharSequence) match} is performed where + * the regular expression is specified by {@code filter} without the "~" prefix. + * Otherwise, a simple {@linkplain String#contains(CharSequence) substring} match + * is performed where {@code filter} is the substring used. + * @param object an object whose {@linkplain Object#toString() string} value is matched + * against {@code filter} + */ + public Filter(String filter, Object object) { + boolean suppressed = false; + if (filter != null) { + String input = object.toString(); + if (filter.startsWith("~")) { + suppressed = !Pattern.matches(filter.substring(1), input); + } else { + suppressed = !input.contains(filter); + } + if (suppressed) { + previous = out(); + log.set(LogStream.SINK); + } + } + } + + /** + * Creates an object that will suppress {@link TTY} for the current thread. To revert the + * suppression state to how it was before this call, the {@link #remove()} method must be + * called on this filter object. + */ + public Filter() { + previous = out(); + log.set(LogStream.SINK); + } + + /** + * Reverts the suppression state of {@link TTY} to how it was before this object was + * constructed. + */ + public void remove() { + assert thread == Thread.currentThread(); + if (previous != null) { + log.set(previous); + } + } + } + + /** + * The {@link PrintStream} to which all non-suppressed output from {@link TTY} is written. + */ + public static final PrintStream out; + static { + TTYStreamProvider p = Services.loadSingle(TTYStreamProvider.class, false); + out = p == null ? System.out : p.getStream(); + } + + private static final ThreadLocal log = new ThreadLocal() { + + @Override + protected LogStream initialValue() { + return new LogStream(out); + } + }; + + public static boolean isSuppressed() { + return log.get() == LogStream.SINK; + } + + /** + * Gets the thread-local log stream to which the static methods of this class send their output. + * This will either be a global log stream or the global {@linkplain LogStream#SINK sink} + * depending on whether any suppression {@linkplain Filter filters} are in effect for the + * current thread. + */ + public static LogStream out() { + return log.get(); + } + + /** + * @see LogStream#print(String) + */ + public static void print(String s) { + out().print(s); + } + + /** + * @see LogStream#print(int) + */ + public static void print(int i) { + out().print(i); + } + + /** + * @see LogStream#print(long) + */ + public static void print(long i) { + out().print(i); + } + + /** + * @see LogStream#print(char) + */ + public static void print(char c) { + out().print(c); + } + + /** + * @see LogStream#print(boolean) + */ + public static void print(boolean b) { + out().print(b); + } + + /** + * @see LogStream#print(double) + */ + public static void print(double d) { + out().print(d); + } + + /** + * @see LogStream#print(float) + */ + public static void print(float f) { + out().print(f); + } + + /** + * @see LogStream#println(String) + */ + public static void println(String s) { + out().println(s); + } + + /** + * @see LogStream#println() + */ + public static void println() { + out().println(); + } + + /** + * @see LogStream#println(int) + */ + public static void println(int i) { + out().println(i); + } + + /** + * @see LogStream#println(long) + */ + public static void println(long l) { + out().println(l); + } + + /** + * @see LogStream#println(char) + */ + public static void println(char c) { + out().println(c); + } + + /** + * @see LogStream#println(boolean) + */ + public static void println(boolean b) { + out().println(b); + } + + /** + * @see LogStream#println(double) + */ + public static void println(double d) { + out().println(d); + } + + /** + * @see LogStream#println(float) + */ + public static void println(float f) { + out().println(f); + } + + public static void print(String format, Object... args) { + out().printf(format, args); + } + + public static void println(String format, Object... args) { + out().printf(format + "%n", args); + } + + public static void fillTo(int i) { + out().fillTo(i, ' '); + } + + public static void printFields(Class javaClass) { + final String className = javaClass.getSimpleName(); + TTY.println(className + " {"); + for (final Field field : javaClass.getFields()) { + printField(field, false); + } + TTY.println("}"); + } + + public static void printField(final Field field, boolean tabbed) { + final String fieldName = String.format("%35s", field.getName()); + try { + String prefix = tabbed ? "" : " " + fieldName + " = "; + String postfix = tabbed ? "\t" : "\n"; + if (field.getType() == int.class) { + TTY.print(prefix + field.getInt(null) + postfix); + } else if (field.getType() == boolean.class) { + TTY.print(prefix + field.getBoolean(null) + postfix); + } else if (field.getType() == float.class) { + TTY.print(prefix + field.getFloat(null) + postfix); + } else if (field.getType() == String.class) { + TTY.print(prefix + field.get(null) + postfix); + } else if (field.getType() == Map.class) { + Map m = (Map) field.get(null); + TTY.print(prefix + printMap(m) + postfix); + } else { + TTY.print(prefix + field.get(null) + postfix); + } + } catch (IllegalAccessException e) { + // do nothing. + } + } + + private static String printMap(Map m) { + StringBuilder sb = new StringBuilder(); + + List keys = new ArrayList<>(); + for (Object key : m.keySet()) { + keys.add((String) key); + } + Collections.sort(keys); + + for (String key : keys) { + sb.append(key); + sb.append("\t"); + sb.append(m.get(key)); + sb.append("\n"); + } + + return sb.toString(); + } + + public static void flush() { + out().flush(); + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/TTYStreamProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/TTYStreamProvider.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 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.debug; + +import java.io.*; + +/** + * Provides a {@link PrintStream} that writes to the underlying log stream of the VM. + */ +public interface TTYStreamProvider { + PrintStream getStream(); +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Jul 27 16:26:41 2015 -0700 @@ -26,8 +26,6 @@ import java.util.*; import java.util.concurrent.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; public final class DebugScope implements Debug.Scope { diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Mon Jul 27 16:26:41 2015 -0700 @@ -30,7 +30,6 @@ import java.util.*; import java.util.concurrent.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.hotspot.*; import com.oracle.graal.debug.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Jul 27 16:26:41 2015 -0700 @@ -33,7 +33,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.compiler.Compiler; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.hotspot.events.*; import jdk.internal.jvmci.hotspot.events.EventProvider.CompilationEvent; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Mon Jul 27 16:26:41 2015 -0700 @@ -35,7 +35,6 @@ import java.util.stream.*; import jdk.internal.jvmci.compiler.Compiler; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DebugValuesPrinter.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DebugValuesPrinter.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DebugValuesPrinter.java Mon Jul 27 16:26:41 2015 -0700 @@ -30,8 +30,8 @@ import java.util.stream.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; +import com.oracle.graal.debug.*; import com.oracle.graal.debug.internal.*; /** diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Jul 27 16:26:41 2015 -0700 @@ -23,9 +23,9 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.compiler.common.GraalOptions.*; +import static com.oracle.graal.debug.GraalDebugConfig.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*; import static jdk.internal.jvmci.common.UnsafeAccess.*; -import static com.oracle.graal.debug.GraalDebugConfig.*; import static jdk.internal.jvmci.hotspot.InitTimer.*; import java.lang.reflect.*; @@ -34,12 +34,7 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.code.stack.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - -import com.oracle.graal.debug.*; - import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.hotspot.logging.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; import jdk.internal.jvmci.runtime.*; @@ -49,8 +44,10 @@ import com.oracle.graal.api.replacements.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.debug.*; +import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.replacements.*; import com.oracle.graal.runtime.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Mon Jul 27 16:26:41 2015 -0700 @@ -22,12 +22,15 @@ */ package com.oracle.graal.hotspot; +import java.lang.reflect.*; +import java.util.*; + import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.service.*; import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.logging.*; @ServiceProvider(HotSpotVMEventListener.class) public class HotSpotGraalVMEventListener implements HotSpotVMEventListener { @@ -65,4 +68,36 @@ Debug.log("%s", codeCache.disassemble(installedCode)); } } + + @Override + public CompilerToVM completeInitialization(HotSpotJVMCIRuntime runtime, CompilerToVM compilerToVM) { + CompilerToVM toVM = compilerToVM; + if (CountingProxy.ENABLED) { + toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); + } + if (Logger.ENABLED) { + toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); + } + + if (Boolean.valueOf(System.getProperty("jvmci.printconfig"))) { + printConfig(runtime.getConfig()); + } + + return toVM; + } + + private static void printConfig(HotSpotVMConfig config) { + Field[] fields = config.getClass().getDeclaredFields(); + Map sortedFields = new TreeMap<>(); + for (Field f : fields) { + f.setAccessible(true); + sortedFields.put(f.getName(), f); + } + for (Field f : sortedFields.values()) { + try { + Logger.info(String.format("%9s %-40s = %s", f.getType().getSimpleName(), f.getName(), Logger.pretty(f.get(config)))); + } catch (Exception e) { + } + } + } } diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java Mon Jul 27 16:26:41 2015 -0700 @@ -29,11 +29,10 @@ import java.util.concurrent.atomic.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.options.*; +import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.nodes.debug.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2011, 2015, 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.hotspot.logging; + +import java.lang.reflect.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import com.oracle.graal.debug.*; + +/** + * A java.lang.reflect proxy that hierarchically logs all method invocations along with their + * parameters and return values. + */ +public class CountingProxy implements InvocationHandler { + + public static final boolean ENABLED = Boolean.valueOf(System.getProperty("jvmci.countcalls")); + + private T delegate; + + private ConcurrentHashMap calls = new ConcurrentHashMap<>(); + + public CountingProxy(T delegate) { + assert ENABLED; + TTY.println("Counting proxy for " + delegate.getClass().getSimpleName() + " created"); + this.delegate = delegate; + proxies.add(this); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + int argCount = args == null ? 0 : args.length; + if (method.getParameterTypes().length != argCount) { + throw new RuntimeException("wrong parameter count"); + } + final Object result; + if (!calls.containsKey(method)) { + calls.putIfAbsent(method, new AtomicLong(0)); + } + AtomicLong count = calls.get(method); + count.incrementAndGet(); + try { + if (args == null) { + result = method.invoke(delegate); + } else { + result = method.invoke(delegate, args); + } + } catch (InvocationTargetException e) { + throw e.getCause(); + } + return result; + } + + public static T getProxy(Class interf, T delegate) { + Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); + Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new CountingProxy<>(delegate)); + return interf.cast(obj); + } + + private static ArrayList> proxies = new ArrayList<>(); + + static { + if (ENABLED) { + Runtime.getRuntime().addShutdownHook(new Thread() { + + @Override + public void run() { + for (CountingProxy proxy : proxies) { + proxy.print(); + } + } + }); + } + } + + protected void print() { + long sum = 0; + for (Map.Entry entry : calls.entrySet()) { + Method method = entry.getKey(); + long count = entry.getValue().get(); + sum += count; + TTY.println(delegate.getClass().getSimpleName() + "." + method.getName() + ": " + count); + } + TTY.println(delegate.getClass().getSimpleName() + " calls: " + sum); + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/HotSpotTTYStreamProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/HotSpotTTYStreamProvider.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015, 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.hotspot.logging; + +import java.io.*; + +import com.oracle.graal.debug.*; + +import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; +import jdk.internal.jvmci.service.*; + +@ServiceProvider(TTYStreamProvider.class) +class HotSpotTTYStreamProvider implements TTYStreamProvider { + + public PrintStream getStream() { + return Options.LogFile.getStream(); + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2011, 2015, 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.hotspot.logging; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.debug.*; + +import jdk.internal.jvmci.hotspot.*; + +/** + * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls. + */ +public class Logger { + + public static final boolean ENABLED = Boolean.valueOf(System.getProperty("jvmci.debug")); + private static final int SPACING = 4; + private static final ThreadLocal loggerTL; + + private Deque openStack = new LinkedList<>(); + private boolean open = false; + private int level = 0; + + private static final PrintStream out; + + static { + if (ENABLED) { + loggerTL = new ThreadLocal() { + + @Override + protected Logger initialValue() { + return new Logger(); + } + }; + } else { + loggerTL = null; + } + + PrintStream ps = null; + String filename = System.getProperty("jvmci.info_file"); + if (filename != null && !"".equals(filename)) { + try { + ps = new PrintStream(new FileOutputStream(filename)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + ps = null; + } + } + out = ps; + if (out != null) { + out.println("start: " + new Date()); + } + } + + public static void info(String message) { + if (ENABLED) { + log(message); + } else { + TTY.println(message); + } + if (out != null) { + out.println(message); + out.flush(); + } + } + + public static void log(String message) { + if (ENABLED) { + Logger logger = loggerTL.get(); + for (String line : message.split("\n")) { + if (logger.open) { + TTY.println("..."); + logger.open = false; + } + TTY.print(space(logger.level)); + TTY.println(line); + } + } + } + + public static void startScope(String message) { + if (ENABLED) { + Logger logger = loggerTL.get(); + if (logger.open) { + TTY.println("..."); + logger.open = false; + } + TTY.print(space(logger.level)); + TTY.print(message); + logger.openStack.push(logger.open); + logger.open = true; + logger.level++; + } + } + + public static void endScope(String message) { + if (ENABLED) { + Logger logger = loggerTL.get(); + logger.level--; + if (logger.open) { + TTY.println(message); + } else { + TTY.println(space(logger.level) + "..." + message); + } + logger.open = logger.openStack.pop(); + } + } + + private static String[] spaces = new String[50]; + + private static String space(int count) { + assert count >= 0; + String result; + if (count >= spaces.length || spaces[count] == null) { + StringBuilder str = new StringBuilder(); + for (int i = 0; i < count * SPACING; i++) { + str.append(' '); + } + result = str.toString(); + if (count < spaces.length) { + spaces[count] = result; + } + } else { + result = spaces[count]; + } + return result; + } + + public static String pretty(Object value) { + if (value == null) { + return "null"; + } + + Class klass = value.getClass(); + if (value instanceof Void) { + return "void"; + } else if (value instanceof String) { + return "\"" + value + "\""; + } else if (value instanceof Method) { + return "method \"" + ((Method) value).getName() + "\""; + } else if (value instanceof Class) { + return "class \"" + ((Class) value).getSimpleName() + "\""; + } else if (value instanceof Integer) { + if ((Integer) value < 10) { + return value.toString(); + } + return value + " (0x" + Integer.toHexString((Integer) value) + ")"; + } else if (value instanceof Long) { + if ((Long) value < 10 && (Long) value > -10) { + return value + "l"; + } + return value + "l (0x" + Long.toHexString((Long) value) + "l)"; + } else if (klass.isArray()) { + StringBuilder str = new StringBuilder(); + int dimensions = 0; + while (klass.isArray()) { + dimensions++; + klass = klass.getComponentType(); + } + int length = Array.getLength(value); + str.append(klass.getSimpleName()).append('[').append(length).append(']'); + for (int i = 1; i < dimensions; i++) { + str.append("[]"); + } + str.append(" {"); + for (int i = 0; i < length; i++) { + str.append(pretty(Array.get(value, i))); + if (i < length - 1) { + str.append(", "); + } + } + str.append('}'); + return str.toString(); + } + + return value.toString(); + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/LoggingProxy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/LoggingProxy.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, 2015, 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.hotspot.logging; + +import java.lang.reflect.*; + +/** + * A java.lang.reflect proxy that hierarchically logs all method invocations along with their + * parameters and return values. + */ +public class LoggingProxy implements InvocationHandler { + + private T delegate; + + public LoggingProxy(T delegate) { + this.delegate = delegate; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + int argCount = args == null ? 0 : args.length; + if (method.getParameterTypes().length != argCount) { + throw new RuntimeException("wrong parameter count"); + } + StringBuilder str = new StringBuilder(); + str.append(method.getReturnType().getSimpleName() + " " + method.getDeclaringClass().getSimpleName() + "." + method.getName() + "("); + for (int i = 0; i < argCount; i++) { + str.append(i == 0 ? "" : ", "); + str.append(Logger.pretty(args[i])); + } + str.append(")"); + Logger.startScope(str.toString()); + final Object result; + try { + if (args == null) { + result = method.invoke(delegate); + } else { + result = method.invoke(delegate, args); + } + } catch (InvocationTargetException e) { + Logger.endScope(" = Exception " + e.getMessage()); + throw e.getCause(); + } + Logger.endScope(" = " + Logger.pretty(result)); + return result; + } + + /** + * The object returned by this method will implement all interfaces that are implemented by + * delegate. + */ + public static T getProxy(Class interf, T delegate) { + Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); + Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new LoggingProxy<>(delegate)); + return interf.cast(obj); + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/ProxyUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/ProxyUtil.java Mon Jul 27 16:26:41 2015 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011, 2015, 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.hotspot.logging; + +import java.util.*; + +public final class ProxyUtil { + + public static Class[] getAllInterfaces(Class clazz) { + HashSet> interfaces = new HashSet<>(); + getAllInterfaces(clazz, interfaces); + return interfaces.toArray(new Class[interfaces.size()]); + } + + private static void getAllInterfaces(Class clazz, HashSet> interfaces) { + for (Class iface : clazz.getInterfaces()) { + if (!interfaces.contains(iface)) { + interfaces.add(iface); + getAllInterfaces(iface, interfaces); + } + } + if (clazz.getSuperclass() != null) { + getAllInterfaces(clazz.getSuperclass(), interfaces); + } + } +} diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Mon Jul 27 16:26:41 2015 -0700 @@ -38,8 +38,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.compiler.Compiler; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Mon Jul 27 16:26:41 2015 -0700 @@ -29,11 +29,10 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.framemap.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/Interval.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/Interval.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/Interval.java Mon Jul 27 16:26:41 2015 -0700 @@ -30,11 +30,10 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.util.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; /** diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Mon Jul 27 16:26:41 2015 -0700 @@ -29,8 +29,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; @@ -39,6 +37,7 @@ import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.StandardOp.LabelOp; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Mon Jul 27 16:26:41 2015 -0700 @@ -31,8 +31,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Mon Jul 27 16:26:41 2015 -0700 @@ -28,8 +28,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import jdk.internal.jvmci.meta.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Mon Jul 27 16:26:41 2015 -0700 @@ -26,9 +26,9 @@ import java.util.*; import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.meta.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.util.*; /** diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraalDebugConfigCustomizer.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraalDebugConfigCustomizer.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraalDebugConfigCustomizer.java Mon Jul 27 16:26:41 2015 -0700 @@ -26,7 +26,6 @@ import com.oracle.graal.debug.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.service.*; import com.oracle.graal.graph.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Mon Jul 27 16:26:41 2015 -0700 @@ -35,7 +35,6 @@ import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.meta.*; import com.oracle.graal.graph.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Jul 27 16:26:41 2015 -0700 @@ -22,10 +22,10 @@ */ package com.oracle.graal.replacements; +import static com.oracle.graal.debug.Debug.*; import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; import static com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates.*; import static java.util.FormattableFlags.*; -import static com.oracle.graal.debug.Debug.*; import static jdk.internal.jvmci.meta.LocationIdentity.*; import java.lang.reflect.*; @@ -37,15 +37,12 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.Scope; - import jdk.internal.jvmci.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.Graph.Mark; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Mon Jul 27 16:26:41 2015 -0700 @@ -35,7 +35,6 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.code.CallingConvention.Type; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.service.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Mon Jul 27 16:26:41 2015 -0700 @@ -29,15 +29,12 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.code.stack.*; -import jdk.internal.jvmci.debug.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.Scope; - import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.service.*; import com.oracle.graal.api.runtime.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.nodes.*; import com.oracle.graal.truffle.debug.*; import com.oracle.graal.truffle.unsafe.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedAssumption.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedAssumption.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedAssumption.java Mon Jul 27 16:26:41 2015 -0700 @@ -29,8 +29,8 @@ import java.util.stream.*; import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.debug.*; +import com.oracle.graal.debug.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.impl.*; diff -r 143099e04cfa -r 7d48038267b4 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java Fri Jul 24 09:29:09 2015 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java Mon Jul 27 16:26:41 2015 -0700 @@ -27,8 +27,6 @@ import java.util.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; - import com.oracle.graal.debug.*; import jdk.internal.jvmci.meta.*; diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.debug/src/jdk/internal/jvmci/debug/LogStream.java --- a/jvmci/jdk.internal.jvmci.debug/src/jdk/internal/jvmci/debug/LogStream.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,477 +0,0 @@ -/* - * Copyright (c) 2009, 2011, 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 jdk.internal.jvmci.debug; - -import java.io.*; - -/** - * A utility for printing compiler debug and informational output to an output stream. - * - * A {@link LogStream} instance maintains an internal buffer that is flushed to the underlying - * output stream every time one of the {@code println} methods is invoked, or a newline character ( - * {@code '\n'}) is written. - * - * All of the {@code print} and {@code println} methods return the {code LogStream} instance on - * which they were invoked. This allows chaining of these calls to mitigate use of String - * concatenation by the caller. - * - * A {@code LogStream} maintains a current {@linkplain #indentationLevel() indentation} level. Each - * line of output written to this stream has {@code n} spaces prefixed to it where {@code n} is the - * value that would be returned by {@link #indentationLevel()} when the first character of a new - * line is written. - * - * A {@code LogStream} maintains a current {@linkplain #position() position} for the current line - * being written. This position can be advanced to a specified position by - * {@linkplain #fillTo(int, char) filling} this stream with a given character. - */ -public class LogStream { - - /** - * Null output stream that simply swallows any output sent to it. - */ - public static final LogStream SINK = new LogStream(); - - private static final PrintStream SINK_PS = new PrintStream(new OutputStream() { - - @Override - public void write(int b) throws IOException { - } - }); - - private LogStream() { - this.ps = null; - this.lineBuffer = null; - } - - /** - * The output stream to which this log stream writes. - */ - private final PrintStream ps; - - private final StringBuilder lineBuffer; - private int indentationLevel; - private char indentation = ' '; - private boolean indentationDisabled; - - public final PrintStream out() { - if (ps == null) { - return SINK_PS; - } - return ps; - } - - /** - * The system dependent line separator. - */ - public static final String LINE_SEPARATOR = System.getProperty("line.separator"); - - /** - * Creates a new log stream. - * - * @param os the underlying output stream to which prints are sent - */ - public LogStream(OutputStream os) { - ps = os instanceof PrintStream ? (PrintStream) os : new PrintStream(os); - lineBuffer = new StringBuilder(100); - } - - /** - * Creates a new log stream that shares the same {@linkplain #ps output stream} as a given - * {@link LogStream}. - * - * @param log a LogStream whose output stream is shared with this one - */ - public LogStream(LogStream log) { - ps = log.ps; - lineBuffer = new StringBuilder(100); - } - - /** - * Prepends {@link #indentation} to the current output line until its write position is equal to - * the current {@linkplain #indentationLevel()} level. - */ - private void indent() { - if (ps != null) { - if (!indentationDisabled && indentationLevel != 0) { - while (lineBuffer.length() < indentationLevel) { - lineBuffer.append(indentation); - } - } - } - } - - private LogStream flushLine(boolean withNewline) { - if (ps != null) { - if (withNewline) { - lineBuffer.append(LINE_SEPARATOR); - } - ps.print(lineBuffer.toString()); - ps.flush(); - lineBuffer.setLength(0); - } - return this; - } - - /** - * Flushes the stream. This is done by terminating the current line if it is not at position 0 - * and then flushing the underlying output stream. - */ - public void flush() { - if (ps != null) { - if (lineBuffer.length() != 0) { - flushLine(false); - } - ps.flush(); - } - } - - /** - * Gets the current column position of this log stream. - * - * @return the current column position of this log stream - */ - public int position() { - return lineBuffer == null ? 0 : lineBuffer.length(); - - } - - /** - * Gets the current indentation level for this log stream. - * - * @return the current indentation level for this log stream. - */ - public int indentationLevel() { - return indentationLevel; - } - - /** - * Adjusts the current indentation level of this log stream. - * - * @param delta - */ - public void adjustIndentation(int delta) { - if (delta < 0) { - indentationLevel = Math.max(0, indentationLevel + delta); - } else { - indentationLevel += delta; - } - } - - /** - * Gets the current indentation character of this log stream. - */ - public char indentation() { - return indentation; - } - - public void disableIndentation() { - indentationDisabled = true; - } - - public void enableIndentation() { - indentationDisabled = false; - } - - /** - * Sets the character used for indentation. - */ - public void setIndentation(char c) { - indentation = c; - } - - /** - * Advances this stream's {@linkplain #position() position} to a given position by repeatedly - * appending a given character as necessary. - * - * @param position the position to which this stream's position will be advanced - * @param filler the character used to pad the stream - */ - public LogStream fillTo(int position, char filler) { - if (ps != null) { - indent(); - while (lineBuffer.length() < position) { - lineBuffer.append(filler); - } - } - return this; - } - - /** - * Writes a boolean value to this stream as {@code "true"} or {@code "false"}. - * - * @param b the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(boolean b) { - if (ps != null) { - indent(); - lineBuffer.append(b); - } - return this; - } - - /** - * Writes a boolean value to this stream followed by a {@linkplain #LINE_SEPARATOR line - * separator}. - * - * @param b the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(boolean b) { - if (ps != null) { - indent(); - lineBuffer.append(b); - return flushLine(true); - } - return this; - } - - /** - * Writes a character value to this stream. - * - * @param c the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(char c) { - if (ps != null) { - indent(); - lineBuffer.append(c); - if (c == '\n') { - if (lineBuffer.indexOf(LINE_SEPARATOR, lineBuffer.length() - LINE_SEPARATOR.length()) != -1) { - flushLine(false); - } - } - } - return this; - } - - /** - * Writes a character value to this stream followed by a {@linkplain #LINE_SEPARATOR line - * separator}. - * - * @param c the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(char c) { - if (ps != null) { - indent(); - lineBuffer.append(c); - flushLine(true); - } - return this; - } - - /** - * Prints an int value. - * - * @param i the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(int i) { - if (ps != null) { - indent(); - lineBuffer.append(i); - } - return this; - } - - /** - * Writes an int value to this stream followed by a {@linkplain #LINE_SEPARATOR line separator}. - * - * @param i the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(int i) { - if (ps != null) { - indent(); - lineBuffer.append(i); - return flushLine(true); - } - return this; - } - - /** - * Writes a float value to this stream. - * - * @param f the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(float f) { - if (ps != null) { - indent(); - lineBuffer.append(f); - } - return this; - } - - /** - * Writes a float value to this stream followed by a {@linkplain #LINE_SEPARATOR line separator} - * . - * - * @param f the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(float f) { - if (ps != null) { - indent(); - lineBuffer.append(f); - return flushLine(true); - } - return this; - } - - /** - * Writes a long value to this stream. - * - * @param l the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(long l) { - if (ps != null) { - indent(); - lineBuffer.append(l); - } - return this; - } - - /** - * Writes a long value to this stream followed by a {@linkplain #LINE_SEPARATOR line separator}. - * - * @param l the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(long l) { - if (ps != null) { - indent(); - lineBuffer.append(l); - return flushLine(true); - } - return this; - } - - /** - * Writes a double value to this stream. - * - * @param d the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(double d) { - if (ps != null) { - indent(); - lineBuffer.append(d); - } - return this; - } - - /** - * Writes a double value to this stream followed by a {@linkplain #LINE_SEPARATOR line - * separator}. - * - * @param d the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(double d) { - if (ps != null) { - indent(); - lineBuffer.append(d); - return flushLine(true); - } - return this; - } - - /** - * Writes a {@code String} value to this stream. This method ensures that the - * {@linkplain #position() position} of this stream is updated correctly with respect to any - * {@linkplain #LINE_SEPARATOR line separators} present in {@code s}. - * - * @param s the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream print(String s) { - if (ps != null) { - if (s == null) { - indent(); - lineBuffer.append(s); - return this; - } - - int index = 0; - int next = s.indexOf(LINE_SEPARATOR, index); - while (index < s.length()) { - indent(); - if (next > index) { - lineBuffer.append(s.substring(index, next)); - flushLine(true); - index = next + LINE_SEPARATOR.length(); - next = s.indexOf(LINE_SEPARATOR, index); - } else { - lineBuffer.append(s.substring(index)); - break; - } - } - } - return this; - } - - /** - * Writes a {@code String} value to this stream followed by a {@linkplain #LINE_SEPARATOR line - * separator}. - * - * @param s the value to be printed - * @return this {@link LogStream} instance - */ - public LogStream println(String s) { - if (ps != null) { - print(s); - flushLine(true); - } - return this; - } - - /** - * Writes a formatted string to this stream. - * - * @param format a format string as described in {@link String#format(String, Object...)} - * @param args the arguments to be formatted - * @return this {@link LogStream} instance - */ - public LogStream printf(String format, Object... args) { - if (ps != null) { - print(String.format(format, args)); - } - return this; - } - - /** - * Writes a {@linkplain #LINE_SEPARATOR line separator} to this stream. - * - * @return this {@code LogStream} instance - */ - public LogStream println() { - if (ps != null) { - indent(); - flushLine(true); - } - return this; - } -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.debug/src/jdk/internal/jvmci/debug/TTY.java --- a/jvmci/jdk.internal.jvmci.debug/src/jdk/internal/jvmci/debug/TTY.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2009, 2011, 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 jdk.internal.jvmci.debug; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; -import java.util.regex.*; - -import jdk.internal.jvmci.service.*; - -/** - * A collection of static methods for printing debug and informational output to a global - * {@link LogStream}. The output can be (temporarily) suppressed per thread through use of a - * {@linkplain Filter filter}. - */ -public class TTY { - - /** - * Support for thread-local suppression of {@link TTY}. - */ - public static class Filter { - - private LogStream previous; - private final Thread thread = Thread.currentThread(); - - /** - * Creates an object that will suppress {@link TTY} for the current thread if the given - * filter does not match the given object. To revert the suppression state to how it was - * before this call, the {@link #remove()} method must be called on the suppression object. - * - * @param filter the pattern for matching. If {@code null}, then the match is successful. If - * it starts with "~", then a regular expression - * {@linkplain Pattern#matches(String, CharSequence) match} is performed where - * the regular expression is specified by {@code filter} without the "~" prefix. - * Otherwise, a simple {@linkplain String#contains(CharSequence) substring} match - * is performed where {@code filter} is the substring used. - * @param object an object whose {@linkplain Object#toString() string} value is matched - * against {@code filter} - */ - public Filter(String filter, Object object) { - boolean suppressed = false; - if (filter != null) { - String input = object.toString(); - if (filter.startsWith("~")) { - suppressed = !Pattern.matches(filter.substring(1), input); - } else { - suppressed = !input.contains(filter); - } - if (suppressed) { - previous = out(); - log.set(LogStream.SINK); - } - } - } - - /** - * Creates an object that will suppress {@link TTY} for the current thread. To revert the - * suppression state to how it was before this call, the {@link #remove()} method must be - * called on this filter object. - */ - public Filter() { - previous = out(); - log.set(LogStream.SINK); - } - - /** - * Reverts the suppression state of {@link TTY} to how it was before this object was - * constructed. - */ - public void remove() { - assert thread == Thread.currentThread(); - if (previous != null) { - log.set(previous); - } - } - } - - /** - * The {@link PrintStream} to which all non-suppressed output from {@link TTY} is written. - */ - public static final PrintStream out; - static { - TTYStreamProvider p = Services.loadSingle(TTYStreamProvider.class, false); - out = p == null ? System.out : p.getStream(); - } - - private static final ThreadLocal log = new ThreadLocal() { - - @Override - protected LogStream initialValue() { - return new LogStream(out); - } - }; - - public static boolean isSuppressed() { - return log.get() == LogStream.SINK; - } - - /** - * Gets the thread-local log stream to which the static methods of this class send their output. - * This will either be a global log stream or the global {@linkplain LogStream#SINK sink} - * depending on whether any suppression {@linkplain Filter filters} are in effect for the - * current thread. - */ - public static LogStream out() { - return log.get(); - } - - /** - * @see LogStream#print(String) - */ - public static void print(String s) { - out().print(s); - } - - /** - * @see LogStream#print(int) - */ - public static void print(int i) { - out().print(i); - } - - /** - * @see LogStream#print(long) - */ - public static void print(long i) { - out().print(i); - } - - /** - * @see LogStream#print(char) - */ - public static void print(char c) { - out().print(c); - } - - /** - * @see LogStream#print(boolean) - */ - public static void print(boolean b) { - out().print(b); - } - - /** - * @see LogStream#print(double) - */ - public static void print(double d) { - out().print(d); - } - - /** - * @see LogStream#print(float) - */ - public static void print(float f) { - out().print(f); - } - - /** - * @see LogStream#println(String) - */ - public static void println(String s) { - out().println(s); - } - - /** - * @see LogStream#println() - */ - public static void println() { - out().println(); - } - - /** - * @see LogStream#println(int) - */ - public static void println(int i) { - out().println(i); - } - - /** - * @see LogStream#println(long) - */ - public static void println(long l) { - out().println(l); - } - - /** - * @see LogStream#println(char) - */ - public static void println(char c) { - out().println(c); - } - - /** - * @see LogStream#println(boolean) - */ - public static void println(boolean b) { - out().println(b); - } - - /** - * @see LogStream#println(double) - */ - public static void println(double d) { - out().println(d); - } - - /** - * @see LogStream#println(float) - */ - public static void println(float f) { - out().println(f); - } - - public static void print(String format, Object... args) { - out().printf(format, args); - } - - public static void println(String format, Object... args) { - out().printf(format + "%n", args); - } - - public static void fillTo(int i) { - out().fillTo(i, ' '); - } - - public static void printFields(Class javaClass) { - final String className = javaClass.getSimpleName(); - TTY.println(className + " {"); - for (final Field field : javaClass.getFields()) { - printField(field, false); - } - TTY.println("}"); - } - - public static void printField(final Field field, boolean tabbed) { - final String fieldName = String.format("%35s", field.getName()); - try { - String prefix = tabbed ? "" : " " + fieldName + " = "; - String postfix = tabbed ? "\t" : "\n"; - if (field.getType() == int.class) { - TTY.print(prefix + field.getInt(null) + postfix); - } else if (field.getType() == boolean.class) { - TTY.print(prefix + field.getBoolean(null) + postfix); - } else if (field.getType() == float.class) { - TTY.print(prefix + field.getFloat(null) + postfix); - } else if (field.getType() == String.class) { - TTY.print(prefix + field.get(null) + postfix); - } else if (field.getType() == Map.class) { - Map m = (Map) field.get(null); - TTY.print(prefix + printMap(m) + postfix); - } else { - TTY.print(prefix + field.get(null) + postfix); - } - } catch (IllegalAccessException e) { - // do nothing. - } - } - - private static String printMap(Map m) { - StringBuilder sb = new StringBuilder(); - - List keys = new ArrayList<>(); - for (Object key : m.keySet()) { - keys.add((String) key); - } - Collections.sort(keys); - - for (String key : keys) { - sb.append(key); - sb.append("\t"); - sb.append(m.get(key)); - sb.append("\n"); - } - - return sb.toString(); - } - - public static void flush() { - out().flush(); - } -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.debug/src/jdk/internal/jvmci/debug/TTYStreamProvider.java --- a/jvmci/jdk.internal.jvmci.debug/src/jdk/internal/jvmci/debug/TTYStreamProvider.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2015, 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 jdk.internal.jvmci.debug; - -import java.io.*; - -/** - * Provides a {@link PrintStream} that writes to the underlying log stream of the VM. - */ -public interface TTYStreamProvider { - PrintStream getStream(); -} diff -r 143099e04cfa -r 7d48038267b4 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 Fri Jul 24 09:29:09 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Mon Jul 27 16:26:41 2015 -0700 @@ -25,12 +25,10 @@ import static jdk.internal.jvmci.common.UnsafeAccess.*; import static jdk.internal.jvmci.hotspot.InitTimer.*; -import java.lang.reflect.*; import java.util.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.hotspot.logging.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; import jdk.internal.jvmci.runtime.*; @@ -76,11 +74,8 @@ // to retrieve configuration details. CompilerToVM toVM = this.compilerToVm; - if (CountingProxy.ENABLED) { - toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); - } - if (Logger.ENABLED) { - toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); + for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + toVM = vmEventListener.completeInitialization(this, toVM); } this.compilerToVm = toVM; @@ -204,10 +199,6 @@ config = new HotSpotVMConfig(compilerToVm); } - if (Boolean.valueOf(System.getProperty("jvmci.printconfig"))) { - printConfig(config); - } - String hostArchitecture = config.getHostArchitectureName(); HotSpotJVMCIBackendFactory factory; @@ -237,21 +228,6 @@ return jvmciMirrors.get(javaClass); } - private static void printConfig(HotSpotVMConfig config) { - Field[] fields = config.getClass().getDeclaredFields(); - Map sortedFields = new TreeMap<>(); - for (Field f : fields) { - f.setAccessible(true); - sortedFields.put(f.getName(), f); - } - for (Field f : sortedFields.values()) { - try { - Logger.info(String.format("%9s %-40s = %s", f.getType().getSimpleName(), f.getName(), Logger.pretty(f.get(config)))); - } catch (Exception e) { - } - } - } - public HotSpotVMConfig getConfig() { return config; } diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIVMEventListener.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIVMEventListener.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015, 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 jdk.internal.jvmci.hotspot; - -import jdk.internal.jvmci.service.*; - -@ServiceProvider(HotSpotVMEventListener.class) -public class HotSpotJVMCIVMEventListener implements HotSpotVMEventListener { - -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Jul 24 09:29:09 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Mon Jul 27 16:26:41 2015 -0700 @@ -31,7 +31,6 @@ import java.util.*; import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.debug.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; @@ -418,8 +417,8 @@ if (metaspaceMethodData != 0) { methodData = new HotSpotMethodData(metaspaceMethodData); if (TraceMethodDataFilter != null && this.format("%H.%n").contains(TraceMethodDataFilter)) { - TTY.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); - TTY.println(methodData.toString()); + System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); + System.out.println(methodData.toString()); } } } diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotTTYStreamProvider.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotTTYStreamProvider.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, 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 jdk.internal.jvmci.hotspot; - -import java.io.*; - -import jdk.internal.jvmci.debug.*; -import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; -import jdk.internal.jvmci.service.*; - -@ServiceProvider(TTYStreamProvider.class) -class HotSpotTTYStreamProvider implements TTYStreamProvider { - - public PrintStream getStream() { - return Options.LogFile.getStream(); - } -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMEventListener.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMEventListener.java Fri Jul 24 09:29:09 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMEventListener.java Mon Jul 27 16:26:41 2015 -0700 @@ -60,4 +60,11 @@ */ default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompilationResult compResult) { } + + /** + * @param hotSpotJVMCIRuntime + */ + default CompilerToVM completeInitialization(HotSpotJVMCIRuntime hotSpotJVMCIRuntime, CompilerToVM compilerToVM) { + return compilerToVM; + } } diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/CountingProxy.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/CountingProxy.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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 jdk.internal.jvmci.hotspot.logging; - -import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import jdk.internal.jvmci.debug.*; - -/** - * A java.lang.reflect proxy that hierarchically logs all method invocations along with their - * parameters and return values. - */ -public class CountingProxy implements InvocationHandler { - - public static final boolean ENABLED = Boolean.valueOf(System.getProperty("jvmci.countcalls")); - - private T delegate; - - private ConcurrentHashMap calls = new ConcurrentHashMap<>(); - - public CountingProxy(T delegate) { - assert ENABLED; - TTY.println("Counting proxy for " + delegate.getClass().getSimpleName() + " created"); - this.delegate = delegate; - proxies.add(this); - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - int argCount = args == null ? 0 : args.length; - if (method.getParameterTypes().length != argCount) { - throw new RuntimeException("wrong parameter count"); - } - final Object result; - if (!calls.containsKey(method)) { - calls.putIfAbsent(method, new AtomicLong(0)); - } - AtomicLong count = calls.get(method); - count.incrementAndGet(); - try { - if (args == null) { - result = method.invoke(delegate); - } else { - result = method.invoke(delegate, args); - } - } catch (InvocationTargetException e) { - throw e.getCause(); - } - return result; - } - - public static T getProxy(Class interf, T delegate) { - Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); - Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new CountingProxy<>(delegate)); - return interf.cast(obj); - } - - private static ArrayList> proxies = new ArrayList<>(); - - static { - if (ENABLED) { - Runtime.getRuntime().addShutdownHook(new Thread() { - - @Override - public void run() { - for (CountingProxy proxy : proxies) { - proxy.print(); - } - } - }); - } - } - - protected void print() { - long sum = 0; - for (Map.Entry entry : calls.entrySet()) { - Method method = entry.getKey(); - long count = entry.getValue().get(); - sum += count; - TTY.println(delegate.getClass().getSimpleName() + "." + method.getName() + ": " + count); - } - TTY.println(delegate.getClass().getSimpleName() + " calls: " + sum); - } -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/Logger.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/Logger.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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 jdk.internal.jvmci.hotspot.logging; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import jdk.internal.jvmci.debug.*; -import jdk.internal.jvmci.hotspot.*; - -/** - * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls. - */ -public class Logger { - - public static final boolean ENABLED = Boolean.valueOf(System.getProperty("jvmci.debug")); - private static final int SPACING = 4; - private static final ThreadLocal loggerTL; - - private Deque openStack = new LinkedList<>(); - private boolean open = false; - private int level = 0; - - private static final PrintStream out; - - static { - if (ENABLED) { - loggerTL = new ThreadLocal() { - - @Override - protected Logger initialValue() { - return new Logger(); - } - }; - } else { - loggerTL = null; - } - - PrintStream ps = null; - String filename = System.getProperty("jvmci.info_file"); - if (filename != null && !"".equals(filename)) { - try { - ps = new PrintStream(new FileOutputStream(filename)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - ps = null; - } - } - out = ps; - if (out != null) { - out.println("start: " + new Date()); - } - } - - public static void info(String message) { - if (ENABLED) { - log(message); - } else { - TTY.println(message); - } - if (out != null) { - out.println(message); - out.flush(); - } - } - - public static void log(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - for (String line : message.split("\n")) { - if (logger.open) { - TTY.println("..."); - logger.open = false; - } - TTY.print(space(logger.level)); - TTY.println(line); - } - } - } - - public static void startScope(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - if (logger.open) { - TTY.println("..."); - logger.open = false; - } - TTY.print(space(logger.level)); - TTY.print(message); - logger.openStack.push(logger.open); - logger.open = true; - logger.level++; - } - } - - public static void endScope(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - logger.level--; - if (logger.open) { - TTY.println(message); - } else { - TTY.println(space(logger.level) + "..." + message); - } - logger.open = logger.openStack.pop(); - } - } - - private static String[] spaces = new String[50]; - - private static String space(int count) { - assert count >= 0; - String result; - if (count >= spaces.length || spaces[count] == null) { - StringBuilder str = new StringBuilder(); - for (int i = 0; i < count * SPACING; i++) { - str.append(' '); - } - result = str.toString(); - if (count < spaces.length) { - spaces[count] = result; - } - } else { - result = spaces[count]; - } - return result; - } - - public static String pretty(Object value) { - if (value == null) { - return "null"; - } - - Class klass = value.getClass(); - if (value instanceof Void) { - return "void"; - } else if (value instanceof String) { - return "\"" + value + "\""; - } else if (value instanceof Method) { - return "method \"" + ((Method) value).getName() + "\""; - } else if (value instanceof Class) { - return "class \"" + ((Class) value).getSimpleName() + "\""; - } else if (value instanceof Integer) { - if ((Integer) value < 10) { - return value.toString(); - } - return value + " (0x" + Integer.toHexString((Integer) value) + ")"; - } else if (value instanceof Long) { - if ((Long) value < 10 && (Long) value > -10) { - return value + "l"; - } - return value + "l (0x" + Long.toHexString((Long) value) + "l)"; - } else if (klass.isArray()) { - StringBuilder str = new StringBuilder(); - int dimensions = 0; - while (klass.isArray()) { - dimensions++; - klass = klass.getComponentType(); - } - int length = Array.getLength(value); - str.append(klass.getSimpleName()).append('[').append(length).append(']'); - for (int i = 1; i < dimensions; i++) { - str.append("[]"); - } - str.append(" {"); - for (int i = 0; i < length; i++) { - str.append(pretty(Array.get(value, i))); - if (i < length - 1) { - str.append(", "); - } - } - str.append('}'); - return str.toString(); - } - - return value.toString(); - } -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/LoggingProxy.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/LoggingProxy.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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 jdk.internal.jvmci.hotspot.logging; - -import java.lang.reflect.*; - -/** - * A java.lang.reflect proxy that hierarchically logs all method invocations along with their - * parameters and return values. - */ -public class LoggingProxy implements InvocationHandler { - - private T delegate; - - public LoggingProxy(T delegate) { - this.delegate = delegate; - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - int argCount = args == null ? 0 : args.length; - if (method.getParameterTypes().length != argCount) { - throw new RuntimeException("wrong parameter count"); - } - StringBuilder str = new StringBuilder(); - str.append(method.getReturnType().getSimpleName() + " " + method.getDeclaringClass().getSimpleName() + "." + method.getName() + "("); - for (int i = 0; i < argCount; i++) { - str.append(i == 0 ? "" : ", "); - str.append(Logger.pretty(args[i])); - } - str.append(")"); - Logger.startScope(str.toString()); - final Object result; - try { - if (args == null) { - result = method.invoke(delegate); - } else { - result = method.invoke(delegate, args); - } - } catch (InvocationTargetException e) { - Logger.endScope(" = Exception " + e.getMessage()); - throw e.getCause(); - } - Logger.endScope(" = " + Logger.pretty(result)); - return result; - } - - /** - * The object returned by this method will implement all interfaces that are implemented by - * delegate. - */ - public static T getProxy(Class interf, T delegate) { - Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); - Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new LoggingProxy<>(delegate)); - return interf.cast(obj); - } -} diff -r 143099e04cfa -r 7d48038267b4 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/ProxyUtil.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/logging/ProxyUtil.java Fri Jul 24 09:29:09 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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 jdk.internal.jvmci.hotspot.logging; - -import java.util.*; - -public final class ProxyUtil { - - public static Class[] getAllInterfaces(Class clazz) { - HashSet> interfaces = new HashSet<>(); - getAllInterfaces(clazz, interfaces); - return interfaces.toArray(new Class[interfaces.size()]); - } - - private static void getAllInterfaces(Class clazz, HashSet> interfaces) { - for (Class iface : clazz.getInterfaces()) { - if (!interfaces.contains(iface)) { - interfaces.add(iface); - getAllInterfaces(iface, interfaces); - } - } - if (clazz.getSuperclass() != null) { - getAllInterfaces(clazz.getSuperclass(), interfaces); - } - } -} diff -r 143099e04cfa -r 7d48038267b4 mx.graal/suite.py --- a/mx.graal/suite.py Fri Jul 24 09:29:09 2015 -0700 +++ b/mx.graal/suite.py Mon Jul 27 16:26:41 2015 -0700 @@ -197,30 +197,19 @@ "workingSets" : "API,JVMCI", }, - "jdk.internal.jvmci.debug" : { - "subDir" : "jvmci", - "sourceDirs" : ["src"], - "checkstyle" : "com.oracle.graal.graph", - "dependencies" : [ - "jdk.internal.jvmci.service", - ], - "annotationProcessors" : ["jdk.internal.jvmci.options.processor"], - "javaCompliance" : "1.8", - "workingSets" : "JVMCI,Debug", - }, "com.oracle.graal.debug" : { "subDir" : "graal", "sourceDirs" : ["src"], "checkstyle" : "com.oracle.graal.graph", "dependencies" : [ - "jdk.internal.jvmci.debug", + "jdk.internal.jvmci.service", "jdk.internal.jvmci.options", "jdk.internal.jvmci.code", ], "annotationProcessors" : ["jdk.internal.jvmci.options.processor"], "javaCompliance" : "1.8", - "workingSets" : "JVMCI,Debug", + "workingSets" : "Graal,Debug", }, "com.oracle.graal.debug.test" : { @@ -232,7 +221,7 @@ ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "JVMCI,Debug,Test", + "workingSets" : "Graal,Debug,Test", }, "jdk.internal.jvmci.options" : { @@ -308,8 +297,8 @@ "jdk.internal.jvmci.runtime", "jdk.internal.jvmci.common", "jdk.internal.jvmci.options", + "jdk.internal.jvmci.service", "jdk.internal.jvmci.runtime", - "jdk.internal.jvmci.debug", ], "annotationProcessors" : [ "jdk.internal.jvmci.hotspotvmconfig.processor", @@ -568,10 +557,8 @@ "subDir" : "graal", "sourceDirs" : ["src"], "dependencies" : [ - "com.oracle.graal.debug", "com.oracle.graal.nodeinfo", "com.oracle.graal.compiler.common", - "com.oracle.graal.debug", "com.oracle.graal.api.collections", "com.oracle.graal.api.runtime", ], @@ -665,7 +652,6 @@ "sourceDirs" : ["src"], "dependencies" : [ "com.oracle.graal.compiler.common", - "com.oracle.graal.debug", "com.oracle.graal.asm", ], "checkstyle" : "com.oracle.graal.graph", @@ -992,10 +978,8 @@ "subDir" : "graal", "sourceDirs" : ["src"], "dependencies" : [ - "jdk.internal.jvmci.debug", - "jdk.internal.jvmci.options", "jdk.internal.jvmci.common", - "jdk.internal.jvmci.code", + "com.oracle.graal.debug", ], "annotationProcessors" : ["jdk.internal.jvmci.options.processor"], "checkstyle" : "com.oracle.graal.graph",