29
30 import java.io.IOException;
31 import java.io.OutputStream;
32 import java.io.PrintStream;
33 import java.io.Serializable;
34
35 import java.lang.invoke.CallSite;
36 import java.lang.invoke.ConstantCallSite;
37 import java.lang.invoke.MethodHandle;
38 import java.lang.module.ModuleDescriptor.Requires;
39 import java.lang.ref.WeakReference;
40
41 import java.util.ArrayList;
42 import java.util.Collections;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.Objects;
48 import java.util.ServiceLoader;
49 import java.util.TreeMap;
50 import java.util.function.Predicate;
51
52 import jdk.internal.misc.Unsafe;
53
54 import jdk.vm.ci.code.Architecture;
55 import jdk.vm.ci.code.CompilationRequestResult;
56 import jdk.vm.ci.code.CompiledCode;
57 import jdk.vm.ci.code.InstalledCode;
58 import jdk.vm.ci.common.InitTimer;
59 import jdk.vm.ci.common.JVMCIError;
60 import jdk.vm.ci.common.NativeImageReinitialize;
61 import jdk.vm.ci.meta.JavaKind;
62 import jdk.vm.ci.meta.JavaType;
63 import jdk.vm.ci.meta.ResolvedJavaType;
64 import jdk.vm.ci.meta.UnresolvedJavaType;
65 import jdk.vm.ci.runtime.JVMCI;
66 import jdk.vm.ci.runtime.JVMCIBackend;
67 import jdk.vm.ci.runtime.JVMCICompiler;
68 import jdk.vm.ci.runtime.JVMCICompilerFactory;
69 import jdk.vm.ci.runtime.JVMCIRuntime;
163
164 /**
165 * Gets the singleton {@link HotSpotJVMCIRuntime} object.
166 */
167 @VMEntryPoint
168 @SuppressWarnings("try")
169 public static HotSpotJVMCIRuntime runtime() {
170 HotSpotJVMCIRuntime result = instance;
171 if (result == null) {
172 // Synchronize on JVMCI.class to avoid deadlock
173 // between the two JVMCI initialization paths:
174 // HotSpotJVMCIRuntime.runtime() and JVMCI.getRuntime().
175 synchronized (JVMCI.class) {
176 result = instance;
177 if (result == null) {
178 try (InitTimer t = timer("HotSpotJVMCIRuntime.<init>")) {
179 instance = result = new HotSpotJVMCIRuntime();
180
181 // Can only do eager initialization of the JVMCI compiler
182 // once the singleton instance is available.
183 if (instance.config.getFlag("EagerJVMCI", Boolean.class)) {
184 instance.getCompiler();
185 }
186 }
187 // Ensures JVMCIRuntime::_HotSpotJVMCIRuntime_instance is
188 // initialized.
189 JVMCI.getRuntime();
190 }
191 }
192 }
193 return result;
194 }
195
196 @VMEntryPoint
197 static Throwable decodeThrowable(String encodedThrowable) throws Throwable {
198 return TranslatedException.decodeThrowable(encodedThrowable);
199 }
200
201 @VMEntryPoint
202 static String encodeThrowable(Throwable throwable) throws Throwable {
203 return TranslatedException.encodeThrowable(throwable);
204 }
447 if (hsCompilerFactory.getCompilationLevelAdjustment() != None) {
448 String name = HotSpotJVMCICompilerFactory.class.getName();
449 String msg = String.format("%s.getCompilationLevelAdjustment() is no longer supported. " +
450 "Use %s.excludeFromJVMCICompilation() instead.", name, name);
451 throw new UnsupportedOperationException(msg);
452 }
453 } else {
454 hsCompilerFactory = null;
455 }
456
457 if (config.getFlag("JVMCIPrintProperties", Boolean.class)) {
458 if (vmLogStream == null) {
459 vmLogStream = new PrintStream(getLogStream());
460 }
461 Option.printProperties(vmLogStream);
462 compilerFactory.printProperties(vmLogStream);
463 System.exit(0);
464 }
465
466 if (Option.PrintConfig.getBoolean()) {
467 printConfig(configStore, compilerToVm);
468 }
469 }
470
471 HotSpotResolvedJavaType createClass(Class<?> javaClass) {
472 if (javaClass.isPrimitive()) {
473 return HotSpotResolvedPrimitiveType.forKind(JavaKind.fromJavaClass(javaClass));
474 }
475 if (IS_IN_NATIVE_IMAGE) {
476 try {
477 return compilerToVm.lookupType(javaClass.getName().replace('.', '/'), null, true);
478 } catch (ClassNotFoundException e) {
479 throw new JVMCIError(e);
480 }
481 }
482 return compilerToVm.lookupClass(javaClass);
483 }
484
485 private HotSpotResolvedJavaType fromClass0(Class<?> javaClass) {
486 if (resolvedJavaType == null) {
487 synchronized (this) {
710 @VMEntryPoint
711 private void bootstrapFinished() throws Exception {
712 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
713 vmEventListener.notifyBootstrapFinished();
714 }
715 }
716
717 /**
718 * Notify on successful install into the CodeCache.
719 *
720 * @param hotSpotCodeCacheProvider
721 * @param installedCode
722 * @param compiledCode
723 */
724 void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
725 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
726 vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
727 }
728 }
729
730 @SuppressFBWarnings(value = "DM_DEFAULT_ENCODING", justification = "no localization here please!")
731 private static void printConfigLine(CompilerToVM vm, String format, Object... args) {
732 String line = String.format(format, args);
733 byte[] lineBytes = line.getBytes();
734 vm.writeDebugOutput(lineBytes, 0, lineBytes.length);
735 vm.flushDebugOutput();
736 }
737
738 private static void printConfig(HotSpotVMConfigStore store, CompilerToVM vm) {
739 TreeMap<String, VMField> fields = new TreeMap<>(store.getFields());
740 for (VMField field : fields.values()) {
741 if (!field.isStatic()) {
742 printConfigLine(vm, "[vmconfig:instance field] %s %s {offset=%d[0x%x]}%n", field.type, field.name, field.offset, field.offset);
743 } else {
744 String value = field.value == null ? "null" : field.value instanceof Boolean ? field.value.toString() : String.format("%d[0x%x]", field.value, field.value);
745 printConfigLine(vm, "[vmconfig:static field] %s %s = %s {address=0x%x}%n", field.type, field.name, value, field.address);
746 }
747 }
748 TreeMap<String, VMFlag> flags = new TreeMap<>(store.getFlags());
749 for (VMFlag flag : flags.values()) {
750 printConfigLine(vm, "[vmconfig:flag] %s %s = %s%n", flag.type, flag.name, flag.value);
751 }
752 TreeMap<String, Long> addresses = new TreeMap<>(store.getAddresses());
753 for (Map.Entry<String, Long> e : addresses.entrySet()) {
754 printConfigLine(vm, "[vmconfig:address] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue());
755 }
756 TreeMap<String, Long> constants = new TreeMap<>(store.getConstants());
757 for (Map.Entry<String, Long> e : constants.entrySet()) {
758 printConfigLine(vm, "[vmconfig:constant] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue());
759 }
760 for (VMIntrinsicMethod e : store.getIntrinsics()) {
761 printConfigLine(vm, "[vmconfig:intrinsic] %d = %s.%s %s%n", e.id, e.declaringClass, e.name, e.descriptor);
762 }
763 }
764
765 /**
766 * Gets an output stream that writes to HotSpot's {@code tty} stream.
767 */
768 public OutputStream getLogStream() {
769 return new OutputStream() {
770
771 @Override
772 public void write(byte[] b, int off, int len) throws IOException {
773 if (b == null) {
774 throw new NullPointerException();
775 } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) {
776 throw new IndexOutOfBoundsException();
777 } else if (len == 0) {
778 return;
779 }
780 compilerToVm.writeDebugOutput(b, off, len);
781 }
782
783 @Override
784 public void write(int b) throws IOException {
785 write(new byte[]{(byte) b}, 0, 1);
786 }
787
788 @Override
789 public void flush() throws IOException {
790 compilerToVm.flushDebugOutput();
791 }
792 };
793 }
794
795 /**
796 * Collects the current values of all JVMCI benchmark counters, summed up over all threads.
797 */
798 public long[] collectCounters() {
799 return compilerToVm.collectCounters();
800 }
890 * }
891 * </pre>
892 *
893 * The implementation of the native {@code JCompile.compile0} method would be in the JVMCI
894 * shared library that contains the bulk of the JVMCI compiler. The {@code JCompile.compile0}
895 * implementation will be exported as the following JNI-compatible symbol:
896 *
897 * <pre>
898 * Java_com_jcompile_JCompile_compile0
899 * </pre>
900 *
901 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#resolving_native_method_names"
902 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#creating_the_vm"
903 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#invocation_api_functions"
904 *
905 *
906 * @return an array of 4 longs where the first value is the {@code JavaVM*} value representing
907 * the Java VM in the JVMCI shared library, and the remaining values are the first 3
908 * pointers in the Invocation API function table (i.e., {@code JNIInvokeInterface})
909 * @throws NullPointerException if {@code clazz == null}
910 * @throws IllegalArgumentException if the current execution context is the JVMCI shared library
911 * or if {@code clazz} is {@link Class#isPrimitive()}
912 * @throws UnsatisfiedLinkError if the JVMCI shared library is not available, a native method in
913 * {@code clazz} is already linked or the JVMCI shared library does not contain a
914 * JNI-compatible symbol for a native method in {@code clazz}
915 */
916 public long[] registerNativeMethods(Class<?> clazz) {
917 return compilerToVm.registerNativeMethods(clazz);
918 }
919
920 /**
921 * Creates or retrieves an object in the peer runtime that mirrors {@code obj}. The types whose
922 * objects can be translated are:
923 * <ul>
924 * <li>{@link HotSpotResolvedJavaMethodImpl},</li>
925 * <li>{@link HotSpotResolvedObjectTypeImpl},</li>
926 * <li>{@link HotSpotResolvedPrimitiveType},</li>
927 * <li>{@link IndirectHotSpotObjectConstantImpl},</li>
928 * <li>{@link DirectHotSpotObjectConstantImpl} and</li>
929 * <li>{@link HotSpotNmethod}</li>
930 * </ul>
931 *
932 * This mechanism can be used to pass and return values between the HotSpot and JVMCI shared
933 * library runtimes. In the receiving runtime, the value can be converted back to an object with
934 * {@link #unhand(Class, long)}.
935 *
936 * @param obj an object for which an equivalent instance in the peer runtime is requested
937 * @return a JNI global reference to the mirror of {@code obj} in the peer runtime
938 * @throws IllegalArgumentException if {@code obj} is not of a translatable type
939 *
940 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references"
941 */
942 public long translate(Object obj) {
943 return compilerToVm.translate(obj);
944 }
945
946 /**
947 * Dereferences and returns the object referred to by the JNI global reference {@code handle}.
948 * The global reference is deleted prior to returning. Any further use of {@code handle} is
949 * invalid.
950 *
951 * @param handle a JNI global reference to an object in the current runtime
952 * @return the object referred to by {@code handle}
953 * @throws ClassCastException if the returned object cannot be case to {@code type}
954 *
955 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references"
956 *
957 */
958 public <T> T unhand(Class<T> type, long handle) {
959 return type.cast(compilerToVm.unhand(handle));
960 }
961
962 /**
963 * Informs HotSpot that no method whose module is in {@code modules} is to be compiled
964 * with {@link #compileMethod}.
965 *
966 * @param modules the set of modules containing JVMCI compiler classes
967 */
968 public void excludeFromJVMCICompilation(Module...modules) {
969 this.excludeFromJVMCICompilation = modules.clone();
970 }
971 }
|
29
30 import java.io.IOException;
31 import java.io.OutputStream;
32 import java.io.PrintStream;
33 import java.io.Serializable;
34
35 import java.lang.invoke.CallSite;
36 import java.lang.invoke.ConstantCallSite;
37 import java.lang.invoke.MethodHandle;
38 import java.lang.module.ModuleDescriptor.Requires;
39 import java.lang.ref.WeakReference;
40
41 import java.util.ArrayList;
42 import java.util.Collections;
43 import java.util.HashMap;
44 import java.util.HashSet;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.Objects;
48 import java.util.ServiceLoader;
49 import java.util.function.Predicate;
50
51 import jdk.internal.misc.Unsafe;
52
53 import jdk.vm.ci.code.Architecture;
54 import jdk.vm.ci.code.CompilationRequestResult;
55 import jdk.vm.ci.code.CompiledCode;
56 import jdk.vm.ci.code.InstalledCode;
57 import jdk.vm.ci.common.InitTimer;
58 import jdk.vm.ci.common.JVMCIError;
59 import jdk.vm.ci.common.NativeImageReinitialize;
60 import jdk.vm.ci.meta.JavaKind;
61 import jdk.vm.ci.meta.JavaType;
62 import jdk.vm.ci.meta.ResolvedJavaType;
63 import jdk.vm.ci.meta.UnresolvedJavaType;
64 import jdk.vm.ci.runtime.JVMCI;
65 import jdk.vm.ci.runtime.JVMCIBackend;
66 import jdk.vm.ci.runtime.JVMCICompiler;
67 import jdk.vm.ci.runtime.JVMCICompilerFactory;
68 import jdk.vm.ci.runtime.JVMCIRuntime;
162
163 /**
164 * Gets the singleton {@link HotSpotJVMCIRuntime} object.
165 */
166 @VMEntryPoint
167 @SuppressWarnings("try")
168 public static HotSpotJVMCIRuntime runtime() {
169 HotSpotJVMCIRuntime result = instance;
170 if (result == null) {
171 // Synchronize on JVMCI.class to avoid deadlock
172 // between the two JVMCI initialization paths:
173 // HotSpotJVMCIRuntime.runtime() and JVMCI.getRuntime().
174 synchronized (JVMCI.class) {
175 result = instance;
176 if (result == null) {
177 try (InitTimer t = timer("HotSpotJVMCIRuntime.<init>")) {
178 instance = result = new HotSpotJVMCIRuntime();
179
180 // Can only do eager initialization of the JVMCI compiler
181 // once the singleton instance is available.
182 if (result.config.getFlag("EagerJVMCI", Boolean.class)) {
183 result.getCompiler();
184 }
185 }
186 // Ensures JVMCIRuntime::_HotSpotJVMCIRuntime_instance is
187 // initialized.
188 JVMCI.getRuntime();
189 }
190 }
191 }
192 return result;
193 }
194
195 @VMEntryPoint
196 static Throwable decodeThrowable(String encodedThrowable) throws Throwable {
197 return TranslatedException.decodeThrowable(encodedThrowable);
198 }
199
200 @VMEntryPoint
201 static String encodeThrowable(Throwable throwable) throws Throwable {
202 return TranslatedException.encodeThrowable(throwable);
203 }
446 if (hsCompilerFactory.getCompilationLevelAdjustment() != None) {
447 String name = HotSpotJVMCICompilerFactory.class.getName();
448 String msg = String.format("%s.getCompilationLevelAdjustment() is no longer supported. " +
449 "Use %s.excludeFromJVMCICompilation() instead.", name, name);
450 throw new UnsupportedOperationException(msg);
451 }
452 } else {
453 hsCompilerFactory = null;
454 }
455
456 if (config.getFlag("JVMCIPrintProperties", Boolean.class)) {
457 if (vmLogStream == null) {
458 vmLogStream = new PrintStream(getLogStream());
459 }
460 Option.printProperties(vmLogStream);
461 compilerFactory.printProperties(vmLogStream);
462 System.exit(0);
463 }
464
465 if (Option.PrintConfig.getBoolean()) {
466 configStore.printConfig();
467 }
468 }
469
470 HotSpotResolvedJavaType createClass(Class<?> javaClass) {
471 if (javaClass.isPrimitive()) {
472 return HotSpotResolvedPrimitiveType.forKind(JavaKind.fromJavaClass(javaClass));
473 }
474 if (IS_IN_NATIVE_IMAGE) {
475 try {
476 return compilerToVm.lookupType(javaClass.getName().replace('.', '/'), null, true);
477 } catch (ClassNotFoundException e) {
478 throw new JVMCIError(e);
479 }
480 }
481 return compilerToVm.lookupClass(javaClass);
482 }
483
484 private HotSpotResolvedJavaType fromClass0(Class<?> javaClass) {
485 if (resolvedJavaType == null) {
486 synchronized (this) {
709 @VMEntryPoint
710 private void bootstrapFinished() throws Exception {
711 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
712 vmEventListener.notifyBootstrapFinished();
713 }
714 }
715
716 /**
717 * Notify on successful install into the CodeCache.
718 *
719 * @param hotSpotCodeCacheProvider
720 * @param installedCode
721 * @param compiledCode
722 */
723 void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
724 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
725 vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
726 }
727 }
728
729 /**
730 * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to HotSpot's
731 * log stream.
732 *
733 * @param flush specifies if the log stream should be flushed after writing
734 * @param canThrow specifies if an error in the {@code bytes}, {@code offset} or {@code length}
735 * arguments should result in an exception or a negative return value. If
736 * {@code false}, this call will not perform any heap allocation
737 * @return 0 on success, -1 if {@code bytes == null && !canThrow}, -2 if {@code !canThrow} and
738 * copying would cause access of data outside array bounds
739 * @throws NullPointerException if {@code bytes == null}
740 * @throws IndexOutOfBoundsException if copying would cause access of data outside array bounds
741 */
742 public int writeDebugOutput(byte[] bytes, int offset, int length, boolean flush, boolean canThrow) {
743 return compilerToVm.writeDebugOutput(bytes, offset, length, flush, canThrow);
744 }
745
746 /**
747 * Gets an output stream that writes to HotSpot's {@code tty} stream.
748 */
749 public OutputStream getLogStream() {
750 return new OutputStream() {
751
752 @Override
753 public void write(byte[] b, int off, int len) throws IOException {
754 if (b == null) {
755 throw new NullPointerException();
756 } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) {
757 throw new IndexOutOfBoundsException();
758 } else if (len == 0) {
759 return;
760 }
761 compilerToVm.writeDebugOutput(b, off, len, false, true);
762 }
763
764 @Override
765 public void write(int b) throws IOException {
766 write(new byte[]{(byte) b}, 0, 1);
767 }
768
769 @Override
770 public void flush() throws IOException {
771 compilerToVm.flushDebugOutput();
772 }
773 };
774 }
775
776 /**
777 * Collects the current values of all JVMCI benchmark counters, summed up over all threads.
778 */
779 public long[] collectCounters() {
780 return compilerToVm.collectCounters();
781 }
871 * }
872 * </pre>
873 *
874 * The implementation of the native {@code JCompile.compile0} method would be in the JVMCI
875 * shared library that contains the bulk of the JVMCI compiler. The {@code JCompile.compile0}
876 * implementation will be exported as the following JNI-compatible symbol:
877 *
878 * <pre>
879 * Java_com_jcompile_JCompile_compile0
880 * </pre>
881 *
882 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#resolving_native_method_names"
883 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#creating_the_vm"
884 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#invocation_api_functions"
885 *
886 *
887 * @return an array of 4 longs where the first value is the {@code JavaVM*} value representing
888 * the Java VM in the JVMCI shared library, and the remaining values are the first 3
889 * pointers in the Invocation API function table (i.e., {@code JNIInvokeInterface})
890 * @throws NullPointerException if {@code clazz == null}
891 * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
892 * {@code -XX:-UseJVMCINativeLibrary})
893 * @throws IllegalStateException if the current execution context is the JVMCI shared library
894 * @throws IllegalArgumentException if {@code clazz} is {@link Class#isPrimitive()}
895 * @throws UnsatisfiedLinkError if there's a problem linking a native method in {@code clazz}
896 * (no matching JNI symbol or the native method is already linked to a different
897 * address)
898 */
899 public long[] registerNativeMethods(Class<?> clazz) {
900 return compilerToVm.registerNativeMethods(clazz);
901 }
902
903 /**
904 * Creates or retrieves an object in the peer runtime that mirrors {@code obj}. The types whose
905 * objects can be translated are:
906 * <ul>
907 * <li>{@link HotSpotResolvedJavaMethodImpl},</li>
908 * <li>{@link HotSpotResolvedObjectTypeImpl},</li>
909 * <li>{@link HotSpotResolvedPrimitiveType},</li>
910 * <li>{@link IndirectHotSpotObjectConstantImpl},</li>
911 * <li>{@link DirectHotSpotObjectConstantImpl} and</li>
912 * <li>{@link HotSpotNmethod}</li>
913 * </ul>
914 *
915 * This mechanism can be used to pass and return values between the HotSpot and JVMCI shared
916 * library runtimes. In the receiving runtime, the value can be converted back to an object with
917 * {@link #unhand(Class, long)}.
918 *
919 * @param obj an object for which an equivalent instance in the peer runtime is requested
920 * @return a JNI global reference to the mirror of {@code obj} in the peer runtime
921 * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
922 * {@code -XX:-UseJVMCINativeLibrary})
923 * @throws IllegalArgumentException if {@code obj} is not of a translatable type
924 *
925 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references"
926 */
927 public long translate(Object obj) {
928 return compilerToVm.translate(obj);
929 }
930
931 /**
932 * Dereferences and returns the object referred to by the JNI global reference {@code handle}.
933 * The global reference is deleted prior to returning. Any further use of {@code handle} is
934 * invalid.
935 *
936 * @param handle a JNI global reference to an object in the current runtime
937 * @return the object referred to by {@code handle}
938 * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
939 * {@code -XX:-UseJVMCINativeLibrary})
940 * @throws ClassCastException if the returned object cannot be cast to {@code type}
941 *
942 * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references"
943 *
944 */
945 public <T> T unhand(Class<T> type, long handle) {
946 return type.cast(compilerToVm.unhand(handle));
947 }
948
949 /**
950 * Determines if the current thread is attached to the peer runtime.
951 *
952 * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
953 * {@code -XX:-UseJVMCINativeLibrary})
954 * @throws IllegalStateException if the peer runtime has not been initialized
955 */
956 public boolean isCurrentThreadAttached() {
957 return compilerToVm.isCurrentThreadAttached();
958 }
959
960 /**
961 * Ensures the current thread is attached to the peer runtime.
962 *
963 * @param asDaemon if the thread is not yet attached, should it be attached as a daemon
964 * @return {@code true} if this call attached the current thread, {@code false} if the current
965 * thread was already attached
966 * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
967 * {@code -XX:-UseJVMCINativeLibrary})
968 * @throws IllegalStateException if the peer runtime has not been initialized or there is an
969 * error while trying to attach the thread
970 */
971 public boolean attachCurrentThread(boolean asDaemon) {
972 return compilerToVm.attachCurrentThread(asDaemon);
973 }
974
975 /**
976 * Detaches the current thread from the peer runtime.
977 *
978 * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e.
979 * {@code -XX:-UseJVMCINativeLibrary})
980 * @throws IllegalStateException if the peer runtime has not been initialized or if the current
981 * thread is not attached or if there is an error while trying to detach the thread
982 */
983 public void detachCurrentThread() {
984 compilerToVm.detachCurrentThread();
985 }
986
987 /**
988 * Informs HotSpot that no method whose module is in {@code modules} is to be compiled
989 * with {@link #compileMethod}.
990 *
991 * @param modules the set of modules containing JVMCI compiler classes
992 */
993 public void excludeFromJVMCICompilation(Module...modules) {
994 this.excludeFromJVMCICompilation = modules.clone();
995 }
996 }
|