# HG changeset patch # User Doug Simon # Date 1463079451 -7200 # Node ID 1d4ce2d19e52197449ebf81b7a1e70e3b25f713c # Parent b3a816d3b844ebb12bfd56a876ece4a995f69d35 clean up and minimize JVMCI (JDK-8156835) diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.aarch64/src/jdk/vm/ci/aarch64/AArch64Kind.java --- a/jvmci/jdk.vm.ci.aarch64/src/jdk/vm/ci/aarch64/AArch64Kind.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.aarch64/src/jdk/vm/ci/aarch64/AArch64Kind.java Thu May 12 20:57:31 2016 +0200 @@ -45,12 +45,7 @@ V128_DWORD(16, DWORD), V128_QWORD(16, QWORD), V128_SINGLE(16, SINGLE), - V128_DOUBLE(16, DOUBLE), - - MASK8(1), - MASK16(2), - MASK32(4), - MASK64(8); + V128_DOUBLE(16, DOUBLE); private final int size; private final int vectorLength; @@ -121,18 +116,6 @@ } } - public boolean isMask() { - switch (this) { - case MASK8: - case MASK16: - case MASK32: - case MASK64: - return true; - default: - return false; - } - } - public char getTypeChar() { switch (this) { case BYTE: @@ -159,11 +142,6 @@ case V128_SINGLE: case V128_DOUBLE: return 'v'; - case MASK8: - case MASK16: - case MASK32: - case MASK64: - return 'k'; default: return '-'; } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/BytecodeFrame.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/BytecodeFrame.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/BytecodeFrame.java Thu May 12 20:57:31 2016 +0200 @@ -98,6 +98,11 @@ */ public final boolean rethrowException; + /** + * Specifies if this objects represents a frame state in the middle of executing a call. If + * true, the arguments to the call have been popped from the stack and the return value (for a + * non-void call) has not yet been pushed. + */ public final boolean duringCall; /** diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java Thu May 12 20:57:31 2016 +0200 @@ -23,7 +23,9 @@ package jdk.vm.ci.code; /** - * The output from compiling a method. + * Marker type for an object containing the output of a compiler in a form suitable for installing + * into a managed code heap. Since the details of such are code are specific to each runtime, this + * interface does not specify any methods. */ public interface CompiledCode { } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ReferenceMap.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ReferenceMap.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ReferenceMap.java Thu May 12 20:57:31 2016 +0200 @@ -22,5 +22,10 @@ */ package jdk.vm.ci.code; +/** + * Marker type for an object containing information about where the object references are in machine + * state (e.g., registers or stack locations). This is typically associated with an execution point + * in compiled code. + */ public abstract class ReferenceMap { } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Register.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Register.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Register.java Thu May 12 20:57:31 2016 +0200 @@ -47,7 +47,7 @@ /** * The identifier for this register that is unique across all the registers in a - * {@link Architecture}. A valid register has {@code number > 0}. + * {@link Architecture}. A valid register has {@code number >= 0}. */ public final int number; @@ -166,38 +166,6 @@ return number >= 0; } - /** - * Gets the maximum register {@linkplain #number number} in a given set of registers. - * - * @param registers the set of registers to process - * @return the maximum register number for any register in {@code registers} - */ - public static int maxRegisterNumber(Register[] registers) { - int max = Integer.MIN_VALUE; - for (Register r : registers) { - if (r.number > max) { - max = r.number; - } - } - return max; - } - - /** - * Gets the maximum register {@linkplain #encoding encoding} in a given set of registers. - * - * @param registers the set of registers to process - * @return the maximum register encoding for any register in {@code registers} - */ - public static int maxRegisterEncoding(Register[] registers) { - int max = Integer.MIN_VALUE; - for (Register r : registers) { - if (r.encoding > max) { - max = r.encoding; - } - } - return max; - } - @Override public String toString() { return name; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/RegisterConfig.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/RegisterConfig.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/RegisterConfig.java Thu May 12 20:57:31 2016 +0200 @@ -106,14 +106,6 @@ RegisterAttributes[] getAttributesMap(); /** - * Gets the register corresponding to a runtime-defined role. - * - * @param id the identifier of a runtime-defined register role - * @return the register playing the role specified by {@code id} - */ - Register getRegisterForRole(int id); - - /** * Determines if all {@link #getAllocatableRegisters() allocatable} registers are * {@link #getCallerSaveRegisters() caller saved}. */ diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/SourceStackTrace.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/SourceStackTrace.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015, 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.vm.ci.code; - -/** - * Class representing a exception with a stack trace of the currently processed position in the - * compiled Java program instead of the stack trace of the compiler. The exception of the compiler - * is saved as the cause of this exception. - */ -public abstract class SourceStackTrace extends BailoutException { - private static final long serialVersionUID = 2144811793442316776L; - - public static SourceStackTrace create(Throwable cause, String format, StackTraceElement[] elements) { - return new SourceStackTrace(cause, format) { - - private static final long serialVersionUID = 6279381376051787907L; - - @Override - public synchronized Throwable fillInStackTrace() { - assert elements != null; - setStackTrace(elements); - return this; - } - }; - } - - private SourceStackTrace(Throwable cause, String format) { - super(cause, format); - } -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ValueUtil.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ValueUtil.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ValueUtil.java Thu May 12 20:57:31 2016 +0200 @@ -22,9 +22,6 @@ */ package jdk.vm.ci.code; -import java.util.ArrayList; -import java.util.List; - import jdk.vm.ci.meta.AllocatableValue; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaValue; @@ -111,73 +108,4 @@ return asRegister(value); } } - - public static boolean sameRegister(Value v1, Value v2) { - return isRegister(v1) && isRegister(v2) && asRegister(v1).equals(asRegister(v2)); - } - - public static boolean sameRegister(Value v1, Value v2, Value v3) { - return sameRegister(v1, v2) && sameRegister(v1, v3); - } - - /** - * Checks if all the provided values are different physical registers. The parameters can be - * either {@link Register registers}, {@link Value values} or arrays of them. All values that - * are not {@link RegisterValue registers} are ignored. - */ - public static boolean differentRegisters(Object... values) { - List registers = collectRegisters(values, new ArrayList()); - for (int i = 1; i < registers.size(); i++) { - Register r1 = registers.get(i); - for (int j = 0; j < i; j++) { - Register r2 = registers.get(j); - if (r1.equals(r2)) { - return false; - } - } - } - return true; - } - - private static List collectRegisters(Object[] values, List registers) { - for (Object o : values) { - if (o instanceof Register) { - registers.add((Register) o); - } else if (o instanceof Value) { - if (isRegister((Value) o)) { - registers.add(asRegister((Value) o)); - } - } else if (o instanceof Object[]) { - collectRegisters((Object[]) o, registers); - } else { - throw new IllegalArgumentException("Not a Register or Value: " + o); - } - } - return registers; - } - - /** - * Subtract sets of registers (x - y). - * - * @param x a set of register to subtract from. - * @param y a set of registers to subtract. - * @return resulting set of registers (x - y). - */ - public static Value[] subtractRegisters(Value[] x, Value[] y) { - ArrayList result = new ArrayList<>(x.length); - for (Value i : x) { - boolean append = true; - for (Value j : y) { - if (ValueUtil.sameRegister(i, j)) { - append = false; - break; - } - } - if (append) { - result.add(i); - } - } - Value[] resultArray = new Value[result.size()]; - return result.toArray(resultArray); - } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ConstantReference.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ConstantReference.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ConstantReference.java Thu May 12 20:57:31 2016 +0200 @@ -26,6 +26,10 @@ import jdk.vm.ci.meta.VMConstant; +/** + * Represents an embedded {@link VMConstant} in the code or data section that needs to be + * {@link DataPatch patched} by the VM (e.g. an embedded pointer to a Java object). + */ public final class ConstantReference extends Reference { private final VMConstant constant; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataPatch.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataPatch.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataPatch.java Thu May 12 20:57:31 2016 +0200 @@ -24,12 +24,12 @@ import java.util.Objects; -import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.VMConstant; /** * Represents a code site that references some data. The associated data can be either a * {@link DataSectionReference reference} to the data section, or it may be an inlined - * {@link JavaConstant} that needs to be patched. + * {@link VMConstant} that needs to be patched. */ public final class DataPatch extends Site { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataSectionReference.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataSectionReference.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataSectionReference.java Thu May 12 20:57:31 2016 +0200 @@ -22,6 +22,10 @@ */ package jdk.vm.ci.code.site; +/** + * Represents a pointer to some location in the data section that should be {@link DataPatch + * patched} into the code. + */ public final class DataSectionReference extends Reference { private boolean initialized; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Mark.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Mark.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Mark.java Thu May 12 20:57:31 2016 +0200 @@ -25,13 +25,23 @@ import java.util.Objects; /** - * Represents a mark in the machine code that can be used by the runtime for its own purposes. A - * mark can reference other marks. + * Associates arbitrary information with a position in machine code. For example, HotSpot specific + * code in a compiler backend may use this to denote the position of a safepoint, exception handler + * entry point, verified entry point etc. */ public final class Mark extends Site { + /** + * An object denoting extra semantic information about the machine code position of this mark. + */ public final Object id; + /** + * Creates a mark that associates {@code id} with the machine code position {@code pcOffset}. + * + * @param pcOffset + * @param id + */ public Mark(int pcOffset, Object id) { super(pcOffset); this.id = id; @@ -40,7 +50,7 @@ @Override public String toString() { if (id == null) { - return String.format("%d[]", pcOffset); + return String.format("%d[]", pcOffset); } else if (id instanceof Integer) { return String.format("%d[]", pcOffset, Integer.toHexString((Integer) id)); } else { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/stack/InspectedFrame.java --- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/stack/InspectedFrame.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/stack/InspectedFrame.java Thu May 12 20:57:31 2016 +0200 @@ -24,16 +24,19 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; +/** + * Access to the object variables in a stack frame. + */ public interface InspectedFrame { /** - * Returns the value of the local at the given index. Currently only works for object values. - * This value is a copy iff {@link #isVirtual(int)} is true. + * Returns the value of the object local at {@code index}. This value is a copy iff + * {@link #isVirtual(int)} is true. */ Object getLocal(int index); /** - * Returns whether the local at the given index is a virtual object, and therefore the object + * Returns whether the local at {@code index} is a virtual object, and therefore the object * returned by {@link #getLocal(int)} is a copy. */ boolean isVirtual(int index); diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/InitTimer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/InitTimer.java Thu May 12 20:57:31 2016 +0200 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, 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.vm.ci.common; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * A facility for timing a step in the runtime initialization sequence. This is independent from all + * other JVMCI code so as to not perturb the initialization sequence. It is enabled by setting the + * {@code "jvmci.inittimer"} system property to {@code "true"}. + */ +public final class InitTimer implements AutoCloseable { + final String name; + final long start; + + private InitTimer(String name) { + int n = nesting.getAndIncrement(); + if (n == 0) { + initializingThread = Thread.currentThread(); + System.out.println("INITIALIZING THREAD: " + initializingThread); + } else { + assert Thread.currentThread() == initializingThread : Thread.currentThread() + " != " + initializingThread; + } + this.name = name; + this.start = System.currentTimeMillis(); + System.out.println("START: " + SPACES.substring(0, n * 2) + name); + } + + @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field") + public void close() { + final long end = System.currentTimeMillis(); + int n = nesting.decrementAndGet(); + System.out.println(" DONE: " + SPACES.substring(0, n * 2) + name + " [" + (end - start) + " ms]"); + if (n == 0) { + initializingThread = null; + } + } + + public static InitTimer timer(String name) { + return ENABLED ? new InitTimer(name) : null; + } + + public static InitTimer timer(String name, Object suffix) { + return ENABLED ? new InitTimer(name + suffix) : null; + } + + /** + * Specifies if initialization timing is enabled. + */ + private static final boolean ENABLED = Boolean.getBoolean("jvmci.InitTimer"); + + public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null; + public static final String SPACES = " "; + + /** + * Used to assert the invariant that all related initialization happens on the same thread. + */ + public static Thread initializingThread; +} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/JVMCIError.java --- a/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/JVMCIError.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/JVMCIError.java Thu May 12 20:57:31 2016 +0200 @@ -31,7 +31,6 @@ public class JVMCIError extends Error { private static final long serialVersionUID = 531632331813456233L; - private final ArrayList context = new ArrayList<>(); public static RuntimeException unimplemented() { throw new JVMCIError("unimplemented"); @@ -101,27 +100,6 @@ super(cause); } - /** - * This constructor creates a {@link JVMCIError} and adds all the - * {@linkplain #addContext(String) context} of another {@link JVMCIError}. - * - * @param e the original {@link JVMCIError} - */ - public JVMCIError(JVMCIError e) { - super(e); - context.addAll(e.context); - } - - @Override - public String toString() { - StringBuilder str = new StringBuilder(); - str.append(super.toString()); - for (String s : context) { - str.append("\n\tat ").append(s); - } - return str.toString(); - } - private static String format(String msg, Object... args) { if (args != null) { // expand Iterable parameters into a list representation @@ -137,13 +115,4 @@ } return String.format(Locale.ENGLISH, msg, args); } - - public JVMCIError addContext(String newContext) { - this.context.add(newContext); - return this; - } - - public JVMCIError addContext(String name, Object obj) { - return addContext(format("%s: %s", name, obj)); - } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/SuppressFBWarnings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/SuppressFBWarnings.java Thu May 12 20:57:31 2016 +0200 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 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.vm.ci.common; + +/** + * Used to suppress FindBugs warnings. + */ +@interface SuppressFBWarnings { + /** + * The set of FindBugs + * warnings that are to be + * suppressed in annotated element. The value can be a bug category, kind or pattern. + */ + String[] value(); + + /** + * Reason why the warning is suppressed. + */ + String justification(); +} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java --- a/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.common; - -import sun.misc.Unsafe; - -/** - * Utilities for operating on raw memory with {@link Unsafe}. - */ -public class UnsafeUtil { - - /** - * Copies the contents of a {@link String} to a native memory buffer as a {@code '\0'} - * terminated C string. The native memory buffer is allocated via - * {@link Unsafe#allocateMemory(long)}. The caller is responsible for releasing the buffer when - * it is no longer needed via {@link Unsafe#freeMemory(long)}. - * - * @return the native memory pointer of the C string created from {@code s} - */ - public static long createCString(Unsafe unsafe, String s) { - return writeCString(unsafe, s, unsafe.allocateMemory(s.length() + 1)); - } - - /** - * Reads a {@code '\0'} terminated C string from native memory and converts it to a - * {@link String}. - * - * @return a Java string - */ - public static String readCString(Unsafe unsafe, long address) { - if (address == 0) { - return null; - } - StringBuilder sb = new StringBuilder(); - for (int i = 0;; i++) { - char c = (char) unsafe.getByte(address + i); - if (c == 0) { - break; - } - sb.append(c); - } - return sb.toString(); - } - - /** - * Writes the contents of a {@link String} to a native memory buffer as a {@code '\0'} - * terminated C string. The caller is responsible for ensuring the buffer is at least - * {@code s.length() + 1} bytes long. The caller is also responsible for releasing the buffer - * when it is no longer. - * - * @return the value of {@code buf} - */ - public static long writeCString(Unsafe unsafe, String s, long buf) { - int size = s.length(); - for (int i = 0; i < size; i++) { - unsafe.putByte(buf + i, (byte) s.charAt(i)); - } - unsafe.putByte(buf + size, (byte) '\0'); - return buf; - } -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Thu May 12 20:57:31 2016 +0200 @@ -22,7 +22,7 @@ */ package jdk.vm.ci.hotspot.aarch64; -import static jdk.vm.ci.inittimer.InitTimer.timer; +import static jdk.vm.ci.common.InitTimer.timer; import java.util.EnumSet; @@ -31,6 +31,7 @@ import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; @@ -38,7 +39,6 @@ import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; import jdk.vm.ci.hotspot.HotSpotStackIntrospection; import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.runtime.JVMCIBackend; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java --- a/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Thu May 12 20:57:31 2016 +0200 @@ -195,11 +195,6 @@ } @Override - public Register getRegisterForRole(int index) { - throw new UnsupportedOperationException(); - } - - @Override public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; if (type == HotSpotCallingConventionType.NativeCall) { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Thu May 12 20:57:31 2016 +0200 @@ -22,7 +22,7 @@ */ package jdk.vm.ci.hotspot.amd64; -import static jdk.vm.ci.inittimer.InitTimer.timer; +import static jdk.vm.ci.common.InitTimer.timer; import java.util.EnumSet; @@ -31,6 +31,7 @@ import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; @@ -38,7 +39,6 @@ import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; import jdk.vm.ci.hotspot.HotSpotStackIntrospection; import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.runtime.JVMCIBackend; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu May 12 20:57:31 2016 +0200 @@ -192,11 +192,6 @@ } @Override - public Register getRegisterForRole(int index) { - throw new UnsupportedOperationException(); - } - - @Override public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; if (type == HotSpotCallingConventionType.NativeCall) { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java --- a/jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java Thu May 12 20:57:31 2016 +0200 @@ -104,8 +104,8 @@ @com.oracle.jrockit.jfr.EventDefinition(name = "Compilation", path = "vm/compiler/compilation") public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { - /* - * FIXME method should be a Method* but we can't express that in Java. + /** + * Should be a {@code Method*} but we can't express that in Java. */ @com.oracle.jrockit.jfr.ValueDefinition(name = "Java Method") public String method; @com.oracle.jrockit.jfr.ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Thu May 12 20:57:31 2016 +0200 @@ -22,7 +22,7 @@ */ package jdk.vm.ci.hotspot.sparc; -import static jdk.vm.ci.inittimer.InitTimer.timer; +import static jdk.vm.ci.common.InitTimer.timer; import java.util.EnumSet; @@ -30,6 +30,7 @@ import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; @@ -37,7 +38,6 @@ import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; import jdk.vm.ci.hotspot.HotSpotStackIntrospection; import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.runtime.JVMCIBackend; import jdk.vm.ci.sparc.SPARC; import jdk.vm.ci.sparc.SPARC.CPUFeature; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Thu May 12 20:57:31 2016 +0200 @@ -198,11 +198,6 @@ } @Override - public Register getRegisterForRole(int index) { - throw new UnsupportedOperationException(); - } - - @Override public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; if (type == HotSpotCallingConventionType.JavaCall || type == HotSpotCallingConventionType.NativeCall) { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Thu May 12 20:57:31 2016 +0200 @@ -23,8 +23,8 @@ package jdk.vm.ci.hotspot; +import static jdk.vm.ci.common.InitTimer.timer; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.inittimer.InitTimer.timer; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -33,9 +33,9 @@ import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.code.InvalidInstalledCodeException; import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; -import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; @@ -79,7 +79,7 @@ native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method); /** - * Gets the number of entries in {@code method}'s exception handler table or 0 if it has not + * Gets the number of entries in {@code method}'s exception handler table or 0 if it has no * exception handler table. */ native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method); @@ -435,7 +435,7 @@ native Object readUncompressedOop(long address); /** - * Determines if {@code method} should not be inlined or compiled. + * Specifies that {@code method} should not be inlined or compiled. */ native void doNotInlineOrCompile(HotSpotResolvedJavaMethodImpl method); @@ -487,10 +487,10 @@ native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip); /** - * Materializes all virtual objects within {@code stackFrame} updates its locals. + * Materializes all virtual objects within {@code stackFrame} and updates its locals. * * @param invalidate if {@code true}, the compiled method for the stack frame will be - * invalidated. + * invalidated */ native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); @@ -507,7 +507,6 @@ /** * Determines if debug info should also be emitted at non-safepoint locations. */ - native boolean shouldDebugNonSafepoints(); /** diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java Thu May 12 20:57:31 2016 +0200 @@ -25,7 +25,6 @@ import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.site.DataPatch; import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.inittimer.SuppressFBWarnings; import jdk.vm.ci.meta.Assumptions.Assumption; import jdk.vm.ci.meta.ResolvedJavaMethod; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java Thu May 12 20:57:31 2016 +0200 @@ -42,7 +42,7 @@ /** * Implementation of {@link ConstantPool} for HotSpot. */ -final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { +final class HotSpotConstantPool implements ConstantPool, MetaspaceWrapperObject { /** * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Thu May 12 20:57:31 2016 +0200 @@ -37,7 +37,7 @@ /** * HotSpot implementation of {@link ConstantReflectionProvider}. */ -public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { +public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider { protected final HotSpotJVMCIRuntimeProvider runtime; protected final HotSpotMethodHandleAccessProvider methodHandleAccess; @@ -131,7 +131,7 @@ @Override public JavaConstant boxPrimitive(JavaConstant source) { - if (!source.getJavaKind().isPrimitive() || !isBoxCached(source)) { + if (source == null || !source.getJavaKind().isPrimitive() || !isBoxCached(source)) { return null; } return HotSpotObjectConstantImpl.forObject(source.asBoxedPrimitive()); @@ -139,7 +139,7 @@ @Override public JavaConstant unboxPrimitive(JavaConstant source) { - if (!source.getJavaKind().isObject()) { + if (source == null || !source.getJavaKind().isObject()) { return null; } if (source.isNull()) { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java Thu May 12 20:57:31 2016 +0200 @@ -23,8 +23,8 @@ package jdk.vm.ci.hotspot; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.inittimer.SuppressFBWarnings; import sun.misc.Unsafe; /** diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext.java Thu May 12 20:57:31 2016 +0200 @@ -30,7 +30,6 @@ import java.util.Map; import java.util.WeakHashMap; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaType; @@ -47,7 +46,7 @@ * longer used. * */ -public class HotSpotJVMCIMetaAccessContext implements JVMCIMetaAccessContext { +public class HotSpotJVMCIMetaAccessContext { /** * The set of currently live contexts used for tracking of live metadata. Examined from the VM @@ -149,7 +148,11 @@ private final Map, WeakReference> typeMap = new WeakHashMap<>(); - @Override + /** + * Gets the JVMCI mirror for a {@link Class} object. + * + * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} + */ public synchronized ResolvedJavaType fromClass(Class javaClass) { WeakReference typeRef = typeMap.get(javaClass); ResolvedJavaType type = typeRef != null ? typeRef.get() : null; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu May 12 20:57:31 2016 +0200 @@ -22,7 +22,7 @@ */ package jdk.vm.ci.hotspot; -import static jdk.vm.ci.inittimer.InitTimer.timer; +import static jdk.vm.ci.common.InitTimer.timer; import java.io.IOException; import java.io.OutputStream; @@ -41,12 +41,10 @@ import jdk.vm.ci.code.CompilationRequestResult; import jdk.vm.ci.code.CompiledCode; import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory; import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; -import jdk.vm.ci.inittimer.InitTimer; -import jdk.vm.ci.inittimer.SuppressFBWarnings; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaType; @@ -57,8 +55,6 @@ import jdk.vm.ci.services.Services; import sun.misc.VM; -//JaCoCo Exclude - /** * HotSpot implementation of a JVMCI runtime. * @@ -69,7 +65,7 @@ * {@link #runtime()}. This allows the initialization to funnel back through * {@link JVMCI#initialize()} without deadlocking. */ -public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider, HotSpotProxified { +public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider { @SuppressWarnings("try") static class DelayedInit { @@ -95,7 +91,8 @@ */ public enum Option { Compiler(String.class, null, "Selects the system compiler."), - // Note: The following one is not used (see InitTimer.ENABLED). + // Note: The following one is not used (see InitTimer.ENABLED). It is added here + // so that -Djvmci.PrintFlags=true shows the option. InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."), PrintConfig(boolean.class, false, "Prints all HotSpotVMConfig fields."), PrintFlags(boolean.class, false, "Prints all JVMCI flags and exits."), @@ -207,7 +204,7 @@ private final JVMCICompilerFactory compilerFactory; private final HotSpotJVMCICompilerFactory hsCompilerFactory; private volatile JVMCICompiler compiler; - protected final JVMCIMetaAccessContext metaAccessContext; + protected final HotSpotJVMCIMetaAccessContext metaAccessContext; /** * Stores the result of {@link HotSpotJVMCICompilerFactory#getCompilationLevelAdjustment} so @@ -245,18 +242,7 @@ } vmEventListeners = Services.load(HotSpotVMEventListener.class); - - JVMCIMetaAccessContext context = null; - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - context = vmEventListener.createMetaAccessContext(this); - if (context != null) { - break; - } - } - if (context == null) { - context = new HotSpotJVMCIMetaAccessContext(); - } - metaAccessContext = context; + metaAccessContext = new HotSpotJVMCIMetaAccessContext(); boolean printFlags = Option.PrintFlags.getBoolean(); boolean showFlags = Option.ShowFlags.getBoolean(); @@ -302,10 +288,6 @@ return compilerToVm; } - public JVMCIMetaAccessContext getMetaAccessContext() { - return metaAccessContext; - } - public JVMCICompiler getCompiler() { if (compiler == null) { synchronized (this) { diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java Thu May 12 20:57:31 2016 +0200 @@ -25,15 +25,12 @@ import java.io.OutputStream; import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.runtime.JVMCIRuntime; import sun.misc.Unsafe; -//JaCoCo Exclude - /** * Configuration information for the HotSpot JVMCI runtime. */ @@ -70,8 +67,6 @@ */ ResolvedJavaType fromClass(Class clazz); - JVMCIMetaAccessContext getMetaAccessContext(); - /** * The offset from the origin of an array to the first element. * diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java Thu May 12 20:57:31 2016 +0200 @@ -33,7 +33,7 @@ /** * HotSpot implementation of {@link MemoryAccessProvider}. */ -class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified { +class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider { protected final HotSpotJVMCIRuntimeProvider runtime; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Thu May 12 20:57:31 2016 +0200 @@ -52,7 +52,7 @@ /** * HotSpot implementation of {@link MetaAccessProvider}. */ -public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { +public class HotSpotMetaAccessProvider implements MetaAccessProvider { protected final HotSpotJVMCIRuntimeProvider runtime; @@ -308,7 +308,6 @@ return 0; } else { if (lookupJavaType.isArray()) { - // TODO(tw): Add compressed pointer support. int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); ResolvedJavaType elementType = lookupJavaType.getComponentType(); JavaKind elementKind = elementType.getJavaKind(); diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java Thu May 12 20:57:31 2016 +0200 @@ -27,7 +27,7 @@ import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.VMConstant; -final class HotSpotMetaspaceConstantImpl implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified { +final class HotSpotMetaspaceConstantImpl implements HotSpotMetaspaceConstant, VMConstant { static HotSpotMetaspaceConstantImpl forMetaspaceObject(MetaspaceWrapperObject metaspaceObject, boolean compressed) { return new HotSpotMetaspaceConstantImpl(metaspaceObject, compressed); diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java Thu May 12 20:57:31 2016 +0200 @@ -33,7 +33,7 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified { +public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider { private final ConstantReflectionProvider constantReflection; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java Thu May 12 20:57:31 2016 +0200 @@ -28,7 +28,6 @@ import java.lang.invoke.ConstantCallSite; import java.lang.invoke.MethodHandle; -import jdk.vm.ci.inittimer.SuppressFBWarnings; import jdk.vm.ci.meta.Assumptions; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.JavaConstant; @@ -39,7 +38,7 @@ * Represents a constant non-{@code null} object reference, within the compiler and across the * compiler/runtime interface. */ -final class HotSpotObjectConstantImpl implements HotSpotObjectConstant, HotSpotProxified { +final class HotSpotObjectConstantImpl implements HotSpotObjectConstant { static JavaConstant forObject(Object object) { return forObject(object, false); diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java Thu May 12 20:57:31 2016 +0200 @@ -28,7 +28,7 @@ import jdk.vm.ci.meta.ProfilingInfo; import jdk.vm.ci.meta.TriState; -public final class HotSpotProfilingInfo implements ProfilingInfo, HotSpotProxified { +public final class HotSpotProfilingInfo implements ProfilingInfo { private final HotSpotMethodData methodData; private final HotSpotResolvedJavaMethod method; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProxified.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProxified.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014, 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.vm.ci.hotspot; - -/** - * Marker interface for classes whose values are proxied during replay compilation capture. - */ -public interface HotSpotProxified { -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotReferenceMap.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotReferenceMap.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotReferenceMap.java Thu May 12 20:57:31 2016 +0200 @@ -53,7 +53,7 @@ } if (obj instanceof HotSpotReferenceMap) { HotSpotReferenceMap that = (HotSpotReferenceMap) obj; - if (Arrays.equals(objects, that.objects)) { + if (sizeInBytes == that.sizeInBytes && maxRegisterSize == that.maxRegisterSize && Arrays.equals(objects, that.objects) && Arrays.equals(derivedBase, that.derivedBase)) { return true; } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java Thu May 12 20:57:31 2016 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Thu May 12 20:57:31 2016 +0200 @@ -27,8 +27,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Field; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ModifiersProvider; import jdk.vm.ci.meta.ResolvedJavaType; @@ -36,7 +34,7 @@ /** * Represents a field in a HotSpot type. */ -class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified { +class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField { private final HotSpotResolvedObjectTypeImpl holder; private final String name; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java Thu May 12 20:57:31 2016 +0200 @@ -56,6 +56,11 @@ */ boolean isDontInline(); + /** + * Returns true if this method has a {@code ReservedStackAccess} annotation. + * + * @return true if ReservedStackAccess annotation present, false otherwise + */ boolean hasReservedStackAccess(); /** diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Thu May 12 20:57:31 2016 +0200 @@ -46,11 +46,8 @@ import jdk.vm.ci.meta.JavaMethod; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.LineNumberTable; -import jdk.vm.ci.meta.LineNumberTableImpl; import jdk.vm.ci.meta.Local; -import jdk.vm.ci.meta.LocalImpl; import jdk.vm.ci.meta.LocalVariableTable; -import jdk.vm.ci.meta.LocalVariableTableImpl; import jdk.vm.ci.meta.ModifiersProvider; import jdk.vm.ci.meta.ProfilingInfo; import jdk.vm.ci.meta.ResolvedJavaMethod; @@ -62,7 +59,7 @@ /** * Implementation of {@link JavaMethod} for resolved HotSpot methods. */ -final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, HotSpotProxified, MetaspaceWrapperObject { +final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, MetaspaceWrapperObject { /** * Reference to metaspace Method object. @@ -170,6 +167,7 @@ * @return flags of this method */ private int getFlags() { + // Important: Size of field changed, JDK8 has u1 and JDK9 u2 return UNSAFE.getByte(metaspaceMethod + config().methodFlagsOffset); } @@ -572,7 +570,7 @@ line[i] = (int) values[i * 2 + 1]; } - return new LineNumberTableImpl(line, bci); + return new LineNumberTable(line, bci); } @Override @@ -597,13 +595,13 @@ String localName = getConstantPool().lookupUtf8(nameCpIndex); String localType = getConstantPool().lookupUtf8(typeCpIndex); - locals[i] = new LocalImpl(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot); + locals[i] = new Local(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot); // Go to the next LocalVariableTableElement localVariableTableElement += config.localVariableTableElementSize; } - return new LocalVariableTableImpl(locals); + return new LocalVariableTable(locals); } /** diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Thu May 12 20:57:31 2016 +0200 @@ -56,7 +56,7 @@ /** * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. */ -final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified, MetaspaceWrapperObject { +final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, MetaspaceWrapperObject { /** * The Java class this type represents. diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Thu May 12 20:57:31 2016 +0200 @@ -40,7 +40,7 @@ /** * Implementation of {@link JavaType} for primitive HotSpot types. */ -public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified { +public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType { private final JavaKind kind; @@ -55,7 +55,7 @@ * @param kind the Kind to create the mirror for */ public HotSpotResolvedPrimitiveType(JavaKind kind) { - super(String.valueOf(Character.toUpperCase(kind.getTypeChar()))); + super(String.valueOf(kind.getTypeChar())); this.kind = kind; assert mirror().isPrimitive() : mirror() + " not a primitive type"; } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Thu May 12 20:57:31 2016 +0200 @@ -22,7 +22,6 @@ */ package jdk.vm.ci.hotspot; -import static jdk.vm.ci.common.UnsafeUtil.readCString; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; @@ -37,8 +36,7 @@ import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; import jdk.vm.ci.hotspotvmconfig.HotSpotVMValue; - -//JaCoCo Exclude +import sun.misc.Unsafe; /** * Used to access native configuration details. @@ -116,6 +114,27 @@ } /** + * Reads a {@code '\0'} terminated C string from native memory and converts it to a + * {@link String}. + * + * @return a Java string + */ + static String readCString(Unsafe unsafe, long address) { + if (address == 0) { + return null; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0;; i++) { + char c = (char) unsafe.getByte(address + i); + if (c == 0) { + break; + } + sb.append(c); + } + return sb.toString(); + } + + /** * Check that the initialization produces the same result as the values captured through * vmStructs. */ diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/SuppressFBWarnings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/SuppressFBWarnings.java Thu May 12 20:57:31 2016 +0200 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 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.vm.ci.hotspot; + +/** + * Used to suppress FindBugs warnings. + */ +@interface SuppressFBWarnings { + /** + * The set of FindBugs + * warnings that are to be + * suppressed in annotated element. The value can be a bug category, kind or pattern. + */ + String[] value(); + + /** + * Reason why the warning is suppressed. + */ + String justification(); +} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java Thu May 12 20:57:31 2016 +0200 @@ -25,14 +25,10 @@ import jdk.vm.ci.code.CompiledCode; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.services.JVMCIPermission; /** - * Service-provider class for responding to VM events and for creating - * {@link JVMCIMetaAccessContext}s. + * Service-provider class for responding to VM events. */ public abstract class HotSpotVMEventListener { @@ -79,16 +75,4 @@ */ public void notifyBootstrapFinished() { } - - /** - * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded - * metadata. It a custom one isn't created then the default implementation will be a single - * context with globally shared instances of {@link ResolvedJavaType} that are never released. - * - * @param runtime the runtime instance that will use the returned context - * @return a custom context or null - */ - public JVMCIMetaAccessContext createMetaAccessContext(HotSpotJVMCIRuntime runtime) { - return null; - } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/InitTimer.java --- a/jvmci/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/InitTimer.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014, 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.vm.ci.inittimer; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * A facility for timing a step in the runtime initialization sequence. This is independent from all - * other JVMCI code so as to not perturb the initialization sequence. It is enabled by setting the - * {@code "jvmci.inittimer"} system property to {@code "true"}. - */ -public final class InitTimer implements AutoCloseable { - final String name; - final long start; - - private InitTimer(String name) { - int n = nesting.getAndIncrement(); - if (n == 0) { - initializingThread = Thread.currentThread(); - System.out.println("INITIALIZING THREAD: " + initializingThread); - } else { - assert Thread.currentThread() == initializingThread : Thread.currentThread() + " != " + initializingThread; - } - this.name = name; - this.start = System.currentTimeMillis(); - System.out.println("START: " + SPACES.substring(0, n * 2) + name); - } - - @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field") - public void close() { - final long end = System.currentTimeMillis(); - int n = nesting.decrementAndGet(); - System.out.println(" DONE: " + SPACES.substring(0, n * 2) + name + " [" + (end - start) + " ms]"); - if (n == 0) { - initializingThread = null; - } - } - - public static InitTimer timer(String name) { - return ENABLED ? new InitTimer(name) : null; - } - - public static InitTimer timer(String name, Object suffix) { - return ENABLED ? new InitTimer(name + suffix) : null; - } - - /** - * Specifies if initialization timing is enabled. - */ - private static final boolean ENABLED = Boolean.getBoolean("jvmci.InitTimer"); - - public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null; - public static final String SPACES = " "; - - /** - * Used to assert the invariant that all related initialization happens on the same thread. - */ - public static Thread initializingThread; -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/SuppressFBWarnings.java --- a/jvmci/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/SuppressFBWarnings.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014, 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.vm.ci.inittimer; - -/** - * Used to suppress FindBugs warnings. - */ -public @interface SuppressFBWarnings { - /** - * The set of FindBugs - * warnings that are to be - * suppressed in annotated element. The value can be a bug category, kind or pattern. - */ - String[] value(); - - /** - * Reason why the warning is suppressed. - */ - String justification(); -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JVMCIMetaAccessContext.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JVMCIMetaAccessContext.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2015, 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.vm.ci.meta; - -/** - * A context in which the results looking up the {@link ResolvedJavaType} for a {@link Class} are - * cached. - */ -public interface JVMCIMetaAccessContext { - - /** - * Gets the JVMCI mirror for a {@link Class} object. - * - * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} - */ - - ResolvedJavaType fromClass(Class clazz); -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaConstant.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaConstant.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaConstant.java Thu May 12 20:57:31 2016 +0200 @@ -357,106 +357,4 @@ throw new IllegalArgumentException(kind.toString()); } } - - /** - * Returns the zero value for a given numeric kind. - */ - static JavaConstant zero(JavaKind kind) { - switch (kind) { - case Boolean: - return FALSE; - case Byte: - return forByte((byte) 0); - case Char: - return forChar((char) 0); - case Double: - return DOUBLE_0; - case Float: - return FLOAT_0; - case Int: - return INT_0; - case Long: - return LONG_0; - case Short: - return forShort((short) 0); - default: - throw new IllegalArgumentException(kind.toString()); - } - } - - /** - * Returns the one value for a given numeric kind. - */ - static JavaConstant one(JavaKind kind) { - switch (kind) { - case Boolean: - return TRUE; - case Byte: - return forByte((byte) 1); - case Char: - return forChar((char) 1); - case Double: - return DOUBLE_1; - case Float: - return FLOAT_1; - case Int: - return INT_1; - case Long: - return LONG_1; - case Short: - return forShort((short) 1); - default: - throw new IllegalArgumentException(kind.toString()); - } - } - - /** - * Adds two numeric constants. - */ - static JavaConstant add(JavaConstant x, JavaConstant y) { - assert x.getJavaKind() == y.getJavaKind(); - switch (x.getJavaKind()) { - case Byte: - return forByte((byte) (x.asInt() + y.asInt())); - case Char: - return forChar((char) (x.asInt() + y.asInt())); - case Double: - return forDouble(x.asDouble() + y.asDouble()); - case Float: - return forFloat(x.asFloat() + y.asFloat()); - case Int: - return forInt(x.asInt() + y.asInt()); - case Long: - return forLong(x.asLong() + y.asLong()); - case Short: - return forShort((short) (x.asInt() + y.asInt())); - default: - throw new IllegalArgumentException(x.getJavaKind().toString()); - } - } - - /** - * Multiplies two numeric constants. - */ - static PrimitiveConstant mul(JavaConstant x, JavaConstant y) { - assert x.getJavaKind() == y.getJavaKind(); - switch (x.getJavaKind()) { - case Byte: - return forByte((byte) (x.asInt() * y.asInt())); - case Char: - return forChar((char) (x.asInt() * y.asInt())); - case Double: - return forDouble(x.asDouble() * y.asDouble()); - case Float: - return forFloat(x.asFloat() * y.asFloat()); - case Int: - return forInt(x.asInt() * y.asInt()); - case Long: - return forLong(x.asLong() * y.asLong()); - case Short: - return forShort((short) (x.asInt() * y.asInt())); - default: - throw new IllegalArgumentException(x.getJavaKind().toString()); - } - } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaKind.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaKind.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaKind.java Thu May 12 20:57:31 2016 +0200 @@ -33,34 +33,34 @@ */ public enum JavaKind { /** The primitive boolean kind, represented as an int on the stack. */ - Boolean('z', "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class), + Boolean('Z', "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class), /** The primitive byte kind, represented as an int on the stack. */ - Byte('b', "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class), + Byte('B', "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class), /** The primitive short kind, represented as an int on the stack. */ - Short('s', "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class), + Short('S', "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class), /** The primitive char kind, represented as an int on the stack. */ - Char('c', "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class), + Char('C', "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class), /** The primitive int kind, represented as an int on the stack. */ - Int('i', "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class), + Int('I', "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class), /** The primitive float kind. */ - Float('f', "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class), + Float('F', "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class), /** The primitive long kind. */ - Long('j', "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class), + Long('J', "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class), /** The primitive double kind. */ - Double('d', "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class), + Double('D', "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class), /** The Object kind, also used for arrays. */ - Object('a', "Object", 1, false, null, null), + Object('A', "Object", 1, false, null, null), - /** The void float kind. */ - Void('v', "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class), + /** The void kind. */ + Void('V', "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class), /** The non-type. */ Illegal('-', "illegal", 0, false, null, null); @@ -98,7 +98,11 @@ } /** - * Returns the name of the kind as a single character. + * Returns the name of the kind as a single upper case character. For the void and primitive + * kinds, this is the FieldType term in + * + * table 4.3-A of the JVM Specification. For {@link #Object}, the character {@code 'A'} is + * returned and for {@link #Illegal}, {@code '-'} is returned. */ public char getTypeChar() { return typeChar; @@ -204,7 +208,7 @@ /** * Returns the kind from the character describing a primitive or void. * - * @param ch the character + * @param ch the character for a void or primitive kind as returned by {@link #getTypeChar()} * @return the kind */ public static JavaKind fromPrimitiveOrVoidTypeChar(char ch) { @@ -369,9 +373,9 @@ } /** - * The minimum value that can be represented as a value of this kind. + * Gets the minimum value that can be represented as a value of this kind. * - * @return the minimum value + * @return the minimum value represented as a {@code long} */ public long getMinValue() { switch (this) { @@ -387,15 +391,19 @@ return java.lang.Integer.MIN_VALUE; case Long: return java.lang.Long.MIN_VALUE; + case Float: + return java.lang.Float.floatToRawIntBits(java.lang.Float.MIN_VALUE); + case Double: + return java.lang.Double.doubleToRawLongBits(java.lang.Double.MIN_VALUE); default: throw new IllegalArgumentException("illegal call to minValue on " + this); } } /** - * The maximum value that can be represented as a value of this kind. + * Gets the maximum value that can be represented as a value of this kind. * - * @return the maximum value + * @return the maximum value represented as a {@code long} */ public long getMaxValue() { switch (this) { @@ -411,6 +419,10 @@ return java.lang.Integer.MAX_VALUE; case Long: return java.lang.Long.MAX_VALUE; + case Float: + return java.lang.Float.floatToRawIntBits(java.lang.Float.MAX_VALUE); + case Double: + return java.lang.Double.doubleToRawLongBits(java.lang.Double.MAX_VALUE); default: throw new IllegalArgumentException("illegal call to maxValue on " + this); } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaType.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaType.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaType.java Thu May 12 20:57:31 2016 +0200 @@ -62,6 +62,15 @@ } /** + * Checks whether this type is an array class. + * + * @return {@code true} if this type is an array class + */ + default boolean isArray() { + return getComponentType() != null; + } + + /** * For array types, gets the type of the components, or {@code null} if this is not an array * type. This method is analogous to {@link Class#getComponentType()}. */ diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java Thu May 12 20:57:31 2016 +0200 @@ -22,11 +22,30 @@ */ package jdk.vm.ci.meta; -public interface LineNumberTable { +public class LineNumberTable { + + private final int[] lineNumbers; + private final int[] bci; - int[] getLineNumberEntries(); + public LineNumberTable(int[] lineNumbers, int[] bci) { + this.lineNumbers = lineNumbers; + this.bci = bci; + } + + public int[] getLineNumberEntries() { + return lineNumbers; + } - int[] getBciEntries(); + public int[] getBciEntries() { + return bci; + } - int getLineNumber(int bci); + public int getLineNumber(int atBci) { + for (int i = 0; i < this.bci.length - 1; i++) { + if (this.bci[i] <= atBci && atBci < this.bci[i + 1]) { + return lineNumbers[i]; + } + } + return lineNumbers[lineNumbers.length - 1]; + } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTableImpl.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTableImpl.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 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.vm.ci.meta; - -public class LineNumberTableImpl implements LineNumberTable { - - private final int[] lineNumbers; - private final int[] bci; - - public LineNumberTableImpl(int[] lineNumbers, int[] bci) { - this.lineNumbers = lineNumbers; - this.bci = bci; - } - - @Override - public int[] getLineNumberEntries() { - return lineNumbers; - } - - @Override - public int[] getBciEntries() { - return bci; - } - - @Override - public int getLineNumber(@SuppressWarnings("hiding") int bci) { - for (int i = 0; i < this.bci.length - 1; i++) { - if (this.bci[i] <= bci && bci < this.bci[i + 1]) { - return lineNumbers[i]; - } - } - return lineNumbers[lineNumbers.length - 1]; - } -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Local.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Local.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Local.java Thu May 12 20:57:31 2016 +0200 @@ -22,15 +22,58 @@ */ package jdk.vm.ci.meta; -public interface Local { +public class Local { + + private final String name; + private final int startBci; + private final int endBci; + private final int slot; + private final JavaType type; - int getStartBCI(); + public Local(String name, JavaType type, int startBci, int endBci, int slot) { + this.name = name; + this.startBci = startBci; + this.endBci = endBci; + this.slot = slot; + this.type = type; + } - int getEndBCI(); + public int getStartBCI() { + return startBci; + } + + public int getEndBCI() { + return endBci; + } + + public String getName() { + return name; + } - int getSlot(); + public JavaType getType() { + return type; + } + + public int getSlot() { + return slot; + } - String getName(); + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Local)) { + return false; + } + Local that = (Local) obj; + return this.name.equals(that.name) && this.startBci == that.startBci && this.endBci == that.endBci && this.slot == that.slot && this.type.equals(that.type); + } - JavaType getType(); + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public String toString() { + return "LocalImpl"; + } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalImpl.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalImpl.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 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.vm.ci.meta; - -public class LocalImpl implements Local { - - private final String name; - private final int startBci; - private final int endBci; - private final int slot; - private final JavaType type; - - public LocalImpl(String name, JavaType type, int startBci, int endBci, int slot) { - this.name = name; - this.startBci = startBci; - this.endBci = endBci; - this.slot = slot; - this.type = type; - } - - @Override - public int getStartBCI() { - return startBci; - } - - @Override - public int getEndBCI() { - return endBci; - } - - @Override - public String getName() { - return name; - } - - @Override - public JavaType getType() { - return type; - } - - @Override - public int getSlot() { - return slot; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof LocalImpl)) { - return false; - } - LocalImpl that = (LocalImpl) obj; - return this.name.equals(that.name) && this.startBci == that.startBci && this.endBci == that.endBci && this.slot == that.slot && this.type.equals(that.type); - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public String toString() { - return "LocalImpl"; - } -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalVariableTable.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalVariableTable.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalVariableTable.java Thu May 12 20:57:31 2016 +0200 @@ -22,11 +22,42 @@ */ package jdk.vm.ci.meta; -public interface LocalVariableTable { +import java.util.ArrayList; +import java.util.List; + +public class LocalVariableTable { - Local[] getLocals(); + private final Local[] locals; + + public LocalVariableTable(Local[] locals) { + this.locals = locals; + } - Local[] getLocalsAt(int bci); + public Local getLocal(int slot, int bci) { + Local result = null; + for (Local local : locals) { + if (local.getSlot() == slot && local.getStartBCI() <= bci && local.getEndBCI() >= bci) { + if (result == null) { + result = local; + } else { + throw new IllegalStateException("Locals overlap!"); + } + } + } + return result; + } - Local getLocal(int slot, int bci); + public Local[] getLocals() { + return locals; + } + + public Local[] getLocalsAt(int bci) { + List result = new ArrayList<>(); + for (Local l : locals) { + if (l.getStartBCI() <= bci && bci <= l.getEndBCI()) { + result.add(l); + } + } + return result.toArray(new Local[result.size()]); + } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalVariableTableImpl.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LocalVariableTableImpl.java Thu May 12 11:06:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 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.vm.ci.meta; - -import java.util.ArrayList; -import java.util.List; - -public class LocalVariableTableImpl implements LocalVariableTable { - - private final Local[] locals; - - public LocalVariableTableImpl(Local[] locals) { - this.locals = locals; - } - - @Override - public Local getLocal(int slot, int bci) { - Local result = null; - for (Local local : locals) { - if (local.getSlot() == slot && local.getStartBCI() <= bci && local.getEndBCI() >= bci) { - if (result == null) { - result = local; - } else { - throw new IllegalStateException("Locals overlap!"); - } - } - } - return result; - } - - @Override - public Local[] getLocals() { - return locals; - } - - @Override - public Local[] getLocalsAt(int bci) { - List result = new ArrayList<>(); - for (Local l : locals) { - if (l.getStartBCI() <= bci && bci <= l.getEndBCI()) { - result.add(l); - } - } - return result.toArray(new Local[result.size()]); - } - -} diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java Thu May 12 20:57:31 2016 +0200 @@ -35,8 +35,8 @@ * @param displacement the displacement within the object in bytes * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the * value cannot be read. - * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void} or - * not {@linkplain JavaKind#isPrimitive() primitive} kind + * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void}, not + * {@link JavaKind#Object} or not {@linkplain JavaKind#isPrimitive() primitive} kind */ JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant base, long displacement) throws IllegalArgumentException; diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java Thu May 12 20:57:31 2016 +0200 @@ -22,132 +22,14 @@ */ package jdk.vm.ci.meta; -import java.io.PrintStream; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; /** * Miscellaneous collection of utility methods used by {@code jdk.vm.ci.meta} and its clients. */ public class MetaUtil { - private static class ClassInfo { - public long totalSize; - public long instanceCount; - - @Override - public String toString() { - return "totalSize=" + totalSize + ", instanceCount=" + instanceCount; - } - } - - /** - * Returns the number of bytes occupied by this constant value or constant object and - * recursively all values reachable from this value. - * - * @param constant the constant whose bytes should be measured - * @param printTopN print total size and instance count of the top n classes is desired - * @return the number of bytes occupied by this constant - */ - public static long getMemorySizeRecursive(MetaAccessProvider access, ConstantReflectionProvider constantReflection, JavaConstant constant, PrintStream out, int printTopN) { - Set marked = new HashSet<>(); - Deque stack = new ArrayDeque<>(); - if (constant.getJavaKind() == JavaKind.Object && constant.isNonNull()) { - marked.add(constant); - } - final HashMap histogram = new HashMap<>(); - stack.push(constant); - long sum = 0; - while (!stack.isEmpty()) { - JavaConstant c = stack.pop(); - long memorySize = access.getMemorySize(constant); - sum += memorySize; - if (c.getJavaKind() == JavaKind.Object && c.isNonNull()) { - ResolvedJavaType clazz = access.lookupJavaType(c); - if (!histogram.containsKey(clazz)) { - histogram.put(clazz, new ClassInfo()); - } - ClassInfo info = histogram.get(clazz); - info.instanceCount++; - info.totalSize += memorySize; - ResolvedJavaType type = access.lookupJavaType(c); - if (type.isArray()) { - if (!type.getComponentType().isPrimitive()) { - int length = constantReflection.readArrayLength(c); - for (int i = 0; i < length; i++) { - JavaConstant value = constantReflection.readArrayElement(c, i); - pushConstant(marked, stack, value); - } - } - } else { - ResolvedJavaField[] instanceFields = type.getInstanceFields(true); - for (ResolvedJavaField f : instanceFields) { - if (f.getJavaKind() == JavaKind.Object) { - JavaConstant value = constantReflection.readFieldValue(f, c); - pushConstant(marked, stack, value); - } - } - } - } - } - ArrayList clazzes = new ArrayList<>(); - clazzes.addAll(histogram.keySet()); - Collections.sort(clazzes, new Comparator() { - - @Override - public int compare(ResolvedJavaType o1, ResolvedJavaType o2) { - long l1 = histogram.get(o1).totalSize; - long l2 = histogram.get(o2).totalSize; - if (l1 > l2) { - return -1; - } else if (l1 == l2) { - return 0; - } else { - return 1; - } - } - }); - - int z = 0; - for (ResolvedJavaType c : clazzes) { - if (z > printTopN) { - break; - } - out.println("Class " + c + ", " + histogram.get(c)); - ++z; - } - - return sum; - } - - private static void pushConstant(Set marked, Deque stack, JavaConstant value) { - if (value.isNonNull()) { - if (!marked.contains(value)) { - marked.add(value); - stack.push(value); - } - } - } - - /** - * Calls {@link JavaType#resolve(ResolvedJavaType)} on an array of types. - */ - public static ResolvedJavaType[] resolveJavaTypes(JavaType[] types, ResolvedJavaType accessingClass) { - ResolvedJavaType[] result = new ResolvedJavaType[types.length]; - for (int i = 0; i < result.length; i++) { - result[i] = types[i].resolve(accessingClass); - } - return result; - } - /** * Extends the functionality of {@link Class#getSimpleName()} to include a non-empty string for * anonymous and local classes. @@ -184,7 +66,17 @@ return name.substring(index + 1); } - static String internalNameToJava(String name, boolean qualified, boolean classForNameCompatible) { + /** + * Converts a type name in internal form to an external form. + * + * @param name the internal name to convert + * @param qualified whether the returned name should be qualified with the package name + * @param classForNameCompatible specifies if the returned name for array types should be in + * {@link Class#forName(String)} format (e.g., {@code "[Ljava.lang.Object;"}, + * {@code "[[I"}) or in Java source code format (e.g., {@code "java.lang.Object[]"}, + * {@code "int[][]"} ). + */ + public static String internalNameToJava(String name, boolean qualified, boolean classForNameCompatible) { switch (name.charAt(0)) { case 'L': { String result = name.substring(1, name.length() - 1).replace('/', '.'); @@ -207,19 +99,6 @@ } /** - * Turns an class name in internal format into a resolved Java type. - */ - public static ResolvedJavaType classForName(String internal, MetaAccessProvider metaAccess, ClassLoader cl) { - JavaKind k = JavaKind.fromTypeString(internal); - try { - String n = internalNameToJava(internal, true, true); - return metaAccess.lookupJavaType(k.isPrimitive() ? k.toJavaClass() : Class.forName(n, true, cl)); - } catch (ClassNotFoundException cnfe) { - throw new IllegalArgumentException("could not instantiate class described by " + internal, cnfe); - } - } - - /** * Convenient shortcut for calling * {@link #appendLocation(StringBuilder, ResolvedJavaMethod, int)} without having to supply a * {@link StringBuilder} instance and convert the result to a string. @@ -337,21 +216,6 @@ } /** - * Prepends the String {@code indentation} to every line in String {@code lines}, including a - * possibly non-empty line following the final newline. - */ - public static String indent(String lines, String indentation) { - if (lines.length() == 0) { - return lines; - } - final String newLine = "\n"; - if (lines.endsWith(newLine)) { - return indentation + (lines.substring(0, lines.length() - 1)).replace(newLine, newLine + indentation) + newLine; - } - return indentation + lines.replace(newLine, newLine + indentation); - } - - /** * Gets a string representation of an object based soley on its class and its * {@linkplain System#identityHashCode(Object) identity hash code}. This avoids and calls to * virtual methods on the object such as {@link Object#hashCode()}. diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/PlatformKind.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/PlatformKind.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/PlatformKind.java Thu May 12 20:57:31 2016 +0200 @@ -42,7 +42,7 @@ @Override public int hashCode() { - return e.ordinal() ^ e.name().hashCode(); + return e.ordinal(); } @Override diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Thu May 12 20:57:31 2016 +0200 @@ -62,13 +62,6 @@ boolean isInstanceClass(); /** - * Checks whether this type is an array class. - * - * @return {@code true} if this type is an array class - */ - boolean isArray(); - - /** * Checks whether this type is primitive. * * @return {@code true} if this type is primitive diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/VMConstant.java --- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/VMConstant.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/VMConstant.java Thu May 12 20:57:31 2016 +0200 @@ -22,5 +22,8 @@ */ package jdk.vm.ci.meta; +/** + * Represents a constant that needs to be patched at runtime by the VM. + */ public interface VMConstant extends Constant { } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java --- a/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java Thu May 12 20:57:31 2016 +0200 @@ -29,12 +29,11 @@ package jdk.vm.ci.runtime.test; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; - import org.junit.Assert; import org.junit.Test; +import jdk.vm.ci.meta.JavaConstant; + public class ConstantTest extends FieldUniverse { @Test @@ -47,30 +46,4 @@ public void testNullIsNull() { Assert.assertTrue(JavaConstant.NULL_POINTER.isNull()); } - - @Test - public void testOne() { - for (JavaKind kind : JavaKind.values()) { - if (kind.isNumericInteger() || kind.isNumericFloat()) { - Assert.assertTrue(JavaConstant.one(kind).getJavaKind() == kind); - } - } - Assert.assertEquals(1, JavaConstant.one(JavaKind.Int).asInt()); - Assert.assertEquals(1L, JavaConstant.one(JavaKind.Long).asLong()); - Assert.assertEquals(1, JavaConstant.one(JavaKind.Byte).asInt()); - Assert.assertEquals(1, JavaConstant.one(JavaKind.Short).asInt()); - Assert.assertEquals(1, JavaConstant.one(JavaKind.Char).asInt()); - Assert.assertTrue(1F == JavaConstant.one(JavaKind.Float).asFloat()); - Assert.assertTrue(1D == JavaConstant.one(JavaKind.Double).asDouble()); - } - - @Test(expected = IllegalArgumentException.class) - public void testIllegalOne() { - JavaConstant.one(JavaKind.Illegal); - } - - @Test(expected = IllegalArgumentException.class) - public void testVoidOne() { - JavaConstant.one(JavaKind.Void); - } } diff -r b3a816d3b844 -r 1d4ce2d19e52 jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java --- a/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java Thu May 12 11:06:49 2016 +0200 +++ b/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java Thu May 12 20:57:31 2016 +0200 @@ -57,8 +57,6 @@ import jdk.vm.ci.runtime.JVMCI; import sun.misc.Unsafe; -//JaCoCo Exclude - /** * Context for type related tests. */ diff -r b3a816d3b844 -r 1d4ce2d19e52 make/jvmci.make --- a/make/jvmci.make Thu May 12 11:06:49 2016 +0200 +++ b/make/jvmci.make Thu May 12 20:57:31 2016 +0200 @@ -100,7 +100,6 @@ EXPORTED_FILES += $(JVMCI_SERVICES_JAR) -JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.inittimer/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.meta/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.code/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.runtime/src -type f 2> /dev/null) diff -r b3a816d3b844 -r 1d4ce2d19e52 mx.jvmci/suite.py --- a/mx.jvmci/suite.py Thu May 12 11:06:49 2016 +0200 +++ b/mx.jvmci/suite.py Thu May 12 20:57:31 2016 +0200 @@ -120,14 +120,6 @@ "workingSets" : "API,JVMCI", }, - "jdk.vm.ci.inittimer" : { - "subDir" : "jvmci", - "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.services", - "javaCompliance" : "1.8", - "workingSets" : "JVMCI", - }, - # ------------- JVMCI:HotSpot ------------- "jdk.vm.ci.aarch64" : { @@ -163,7 +155,6 @@ "dependencies" : [ "jdk.vm.ci.hotspotvmconfig", "jdk.vm.ci.common", - "jdk.vm.ci.inittimer", "jdk.vm.ci.runtime", ], "annotationProcessors" : [ @@ -317,7 +308,6 @@ "JVMCI_API" : { "subDir" : "jvmci", "dependencies" : [ - "jdk.vm.ci.inittimer", "jdk.vm.ci.runtime", "jdk.vm.ci.common", "jdk.vm.ci.aarch64", diff -r b3a816d3b844 -r 1d4ce2d19e52 src/share/vm/jvmci/jvmciRuntime.cpp --- a/src/share/vm/jvmci/jvmciRuntime.cpp Thu May 12 11:06:49 2016 +0200 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Thu May 12 20:57:31 2016 +0200 @@ -54,15 +54,15 @@ BasicType JVMCIRuntime::kindToBasicType(jchar ch, TRAPS) { switch(ch) { - case 'z': return T_BOOLEAN; - case 'b': return T_BYTE; - case 's': return T_SHORT; - case 'c': return T_CHAR; - case 'i': return T_INT; - case 'f': return T_FLOAT; - case 'j': return T_LONG; - case 'd': return T_DOUBLE; - case 'a': return T_OBJECT; + case 'Z': return T_BOOLEAN; + case 'B': return T_BYTE; + case 'S': return T_SHORT; + case 'C': return T_CHAR; + case 'I': return T_INT; + case 'F': return T_FLOAT; + case 'J': return T_LONG; + case 'D': return T_DOUBLE; + case 'A': return T_OBJECT; case '-': return T_ILLEGAL; default: JVMCI_ERROR_(T_ILLEGAL, "unexpected Kind: %c", ch); @@ -558,14 +558,14 @@ } uu; uu.l = value; switch (typeChar) { - case 'z': tty->print(value == 0 ? "false" : "true"); break; - case 'b': tty->print("%d", (jbyte) value); break; - case 'c': tty->print("%c", (jchar) value); break; - case 's': tty->print("%d", (jshort) value); break; - case 'i': tty->print("%d", (jint) value); break; - case 'f': tty->print("%f", uu.f); break; - case 'j': tty->print(JLONG_FORMAT, value); break; - case 'd': tty->print("%lf", uu.d); break; + case 'Z': tty->print(value == 0 ? "false" : "true"); break; + case 'B': tty->print("%d", (jbyte) value); break; + case 'C': tty->print("%c", (jchar) value); break; + case 'S': tty->print("%d", (jshort) value); break; + case 'I': tty->print("%d", (jint) value); break; + case 'F': tty->print("%f", uu.f); break; + case 'J': tty->print(JLONG_FORMAT, value); break; + case 'D': tty->print("%lf", uu.d); break; default: assert(false, "unknown typeChar"); break; } if (newline) {