src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Sat May 4 16:23:08 2019
--- new/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Sat May 4 16:23:07 2019
*** 44,54 ****
--- 44,53 ----
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.TreeMap;
import java.util.function.Predicate;
import jdk.internal.misc.Unsafe;
import jdk.vm.ci.code.Architecture;
*** 178,189 ****
--- 177,188 ----
try (InitTimer t = timer("HotSpotJVMCIRuntime.<init>")) {
instance = result = new HotSpotJVMCIRuntime();
// Can only do eager initialization of the JVMCI compiler
// once the singleton instance is available.
! if (instance.config.getFlag("EagerJVMCI", Boolean.class)) {
! instance.getCompiler();
! if (result.config.getFlag("EagerJVMCI", Boolean.class)) {
! result.getCompiler();
}
}
// Ensures JVMCIRuntime::_HotSpotJVMCIRuntime_instance is
// initialized.
JVMCI.getRuntime();
*** 462,472 ****
--- 461,471 ----
compilerFactory.printProperties(vmLogStream);
System.exit(0);
}
if (Option.PrintConfig.getBoolean()) {
! printConfig(configStore, compilerToVm);
! configStore.printConfig();
}
}
HotSpotResolvedJavaType createClass(Class<?> javaClass) {
if (javaClass.isPrimitive()) {
*** 725,767 ****
--- 724,748 ----
for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
}
}
@SuppressFBWarnings(value = "DM_DEFAULT_ENCODING", justification = "no localization here please!")
private static void printConfigLine(CompilerToVM vm, String format, Object... args) {
String line = String.format(format, args);
byte[] lineBytes = line.getBytes();
vm.writeDebugOutput(lineBytes, 0, lineBytes.length);
vm.flushDebugOutput();
}
private static void printConfig(HotSpotVMConfigStore store, CompilerToVM vm) {
TreeMap<String, VMField> fields = new TreeMap<>(store.getFields());
for (VMField field : fields.values()) {
if (!field.isStatic()) {
printConfigLine(vm, "[vmconfig:instance field] %s %s {offset=%d[0x%x]}%n", field.type, field.name, field.offset, field.offset);
! } else {
! String value = field.value == null ? "null" : field.value instanceof Boolean ? field.value.toString() : String.format("%d[0x%x]", field.value, field.value);
printConfigLine(vm, "[vmconfig:static field] %s %s = %s {address=0x%x}%n", field.type, field.name, value, field.address);
}
}
TreeMap<String, VMFlag> flags = new TreeMap<>(store.getFlags());
for (VMFlag flag : flags.values()) {
printConfigLine(vm, "[vmconfig:flag] %s %s = %s%n", flag.type, flag.name, flag.value);
}
TreeMap<String, Long> addresses = new TreeMap<>(store.getAddresses());
for (Map.Entry<String, Long> e : addresses.entrySet()) {
printConfigLine(vm, "[vmconfig:address] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue());
}
TreeMap<String, Long> constants = new TreeMap<>(store.getConstants());
for (Map.Entry<String, Long> e : constants.entrySet()) {
printConfigLine(vm, "[vmconfig:constant] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue());
}
for (VMIntrinsicMethod e : store.getIntrinsics()) {
printConfigLine(vm, "[vmconfig:intrinsic] %d = %s.%s %s%n", e.id, e.declaringClass, e.name, e.descriptor);
}
+ /**
+ * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to HotSpot's
+ * log stream.
+ *
+ * @param flush specifies if the log stream should be flushed after writing
+ * @param canThrow specifies if an error in the {@code bytes}, {@code offset} or {@code length}
+ * arguments should result in an exception or a negative return value. If
+ * {@code false}, this call will not perform any heap allocation
+ * @return 0 on success, -1 if {@code bytes == null && !canThrow}, -2 if {@code !canThrow} and
+ * copying would cause access of data outside array bounds
+ * @throws NullPointerException if {@code bytes == null}
+ * @throws IndexOutOfBoundsException if copying would cause access of data outside array bounds
+ */
! public int writeDebugOutput(byte[] bytes, int offset, int length, boolean flush, boolean canThrow) {
! return compilerToVm.writeDebugOutput(bytes, offset, length, flush, canThrow);
}
/**
* Gets an output stream that writes to HotSpot's {@code tty} stream.
*/
*** 775,785 ****
--- 756,766 ----
} else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
! compilerToVm.writeDebugOutput(b, off, len, false, true);
}
@Override
public void write(int b) throws IOException {
write(new byte[]{(byte) b}, 0, 1);
*** 905,919 ****
--- 886,902 ----
*
* @return an array of 4 longs where the first value is the {@code JavaVM*} value representing
* the Java VM in the JVMCI shared library, and the remaining values are the first 3
* pointers in the Invocation API function table (i.e., {@code JNIInvokeInterface})
* @throws NullPointerException if {@code clazz == null}
! * @throws IllegalArgumentException if the current execution context is the JVMCI shared library
* or if {@code clazz} is {@link Class#isPrimitive()}
! * @throws UnsatisfiedLinkError if the JVMCI shared library is not available, a native method in
* {@code clazz} is already linked or the JVMCI shared library does not contain a
! * JNI-compatible symbol for a native method in {@code clazz}
! * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
+ * {@code -XX:-UseJVMCINativeLibrary})
! * @throws IllegalStateException if the current execution context is the JVMCI shared library
+ * @throws IllegalArgumentException if {@code clazz} is {@link Class#isPrimitive()}
! * @throws UnsatisfiedLinkError if there's a problem linking a native method in {@code clazz}
+ * (no matching JNI symbol or the native method is already linked to a different
+ * address)
*/
public long[] registerNativeMethods(Class<?> clazz) {
return compilerToVm.registerNativeMethods(clazz);
}
*** 933,942 ****
--- 916,927 ----
* library runtimes. In the receiving runtime, the value can be converted back to an object with
* {@link #unhand(Class, long)}.
*
* @param obj an object for which an equivalent instance in the peer runtime is requested
* @return a JNI global reference to the mirror of {@code obj} in the peer runtime
+ * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
+ * {@code -XX:-UseJVMCINativeLibrary})
* @throws IllegalArgumentException if {@code obj} is not of a translatable type
*
* @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references"
*/
public long translate(Object obj) {
*** 948,967 ****
--- 933,992 ----
* The global reference is deleted prior to returning. Any further use of {@code handle} is
* invalid.
*
* @param handle a JNI global reference to an object in the current runtime
* @return the object referred to by {@code handle}
! * @throws ClassCastException if the returned object cannot be case to {@code type}
! * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
+ * {@code -XX:-UseJVMCINativeLibrary})
+ * @throws ClassCastException if the returned object cannot be cast to {@code type}
*
* @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references"
*
*/
public <T> T unhand(Class<T> type, long handle) {
return type.cast(compilerToVm.unhand(handle));
}
/**
+ * Determines if the current thread is attached to the peer runtime.
+ *
+ * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
+ * {@code -XX:-UseJVMCINativeLibrary})
+ * @throws IllegalStateException if the peer runtime has not been initialized
+ */
+ public boolean isCurrentThreadAttached() {
+ return compilerToVm.isCurrentThreadAttached();
+ }
+
+ /**
+ * Ensures the current thread is attached to the peer runtime.
+ *
+ * @param asDaemon if the thread is not yet attached, should it be attached as a daemon
+ * @return {@code true} if this call attached the current thread, {@code false} if the current
+ * thread was already attached
+ * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
+ * {@code -XX:-UseJVMCINativeLibrary})
+ * @throws IllegalStateException if the peer runtime has not been initialized or there is an
+ * error while trying to attach the thread
+ */
+ public boolean attachCurrentThread(boolean asDaemon) {
+ return compilerToVm.attachCurrentThread(asDaemon);
+ }
+
+ /**
+ * Detaches the current thread from the peer runtime.
+ *
+ * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
+ * {@code -XX:-UseJVMCINativeLibrary})
+ * @throws IllegalStateException if the peer runtime has not been initialized or if the current
+ * thread is not attached or if there is an error while trying to detach the thread
+ */
+ public void detachCurrentThread() {
+ compilerToVm.detachCurrentThread();
+ }
+
+ /**
* Informs HotSpot that no method whose module is in {@code modules} is to be compiled
* with {@link #compileMethod}.
*
* @param modules the set of modules containing JVMCI compiler classes
*/
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File