diff --git a/src/hotspot/share/jvmci/jvmci.cpp b/src/hotspot/share/jvmci/jvmci.cpp index 15973f4549f33..b59c7fa34448a 100644 --- a/src/hotspot/share/jvmci/jvmci.cpp +++ b/src/hotspot/share/jvmci/jvmci.cpp @@ -151,7 +151,7 @@ void* JVMCI::get_shared_library(char*& path, bool load) { return _shared_library_handle; } -void JVMCI::initialize_compiler(TRAPS) { +void JVMCI::initialize_compiler_in_create_vm(TRAPS) { if (JVMCILibDumpJNIConfig) { JNIJVMCI::initialize_ids(nullptr); ShouldNotReachHere(); @@ -162,7 +162,12 @@ void JVMCI::initialize_compiler(TRAPS) { } else { runtime = JVMCI::java_runtime(); } - runtime->call_getCompiler(CHECK); + + JVMCIENV_FROM_THREAD(THREAD); + JVMCIENV->check_init(CHECK); + JVMCIObject jvmciRuntime = runtime->get_HotSpotJVMCIRuntime(JVMCI_CHECK); + runtime->initialize(JVMCI_CHECK); + JVMCIENV->call_HotSpotJVMCIRuntime_getCompiler(jvmciRuntime, JVMCI_CHECK); } void JVMCI::initialize_globals() { diff --git a/src/hotspot/share/jvmci/jvmci.hpp b/src/hotspot/share/jvmci/jvmci.hpp index 7eaea597936a0..196007fc7dd94 100644 --- a/src/hotspot/share/jvmci/jvmci.hpp +++ b/src/hotspot/share/jvmci/jvmci.hpp @@ -191,9 +191,8 @@ class JVMCI : public AllStatic { static void initialize_globals(); - // Called to force initialization of the JVMCI compiler - // early in VM startup. - static void initialize_compiler(TRAPS); + // Initializes the JVMCI compiler during VM startup. + static void initialize_compiler_in_create_vm(TRAPS); // Ensures the boxing cache classes (e.g., java.lang.Integer.IntegerCache) are initialized. static void ensure_box_caches_initialized(TRAPS); diff --git a/src/hotspot/share/jvmci/jvmciEnv.cpp b/src/hotspot/share/jvmci/jvmciEnv.cpp index 5a0efef0bd32b..b847455225664 100644 --- a/src/hotspot/share/jvmci/jvmciEnv.cpp +++ b/src/hotspot/share/jvmci/jvmciEnv.cpp @@ -251,12 +251,9 @@ void JVMCIEnv::check_init(TRAPS) { if (_init_error == JNI_OK) { return; } - if (_init_error == JNI_ENOMEM) { - THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "JNI_ENOMEM creating or attaching to libjvmci"); - } stringStream st; st.print("Error creating or attaching to libjvmci (err: %d, description: %s)", - _init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg); + _init_error, _init_error_msg != nullptr ? _init_error_msg : (_init_error == JNI_ENOMEM ? "JNI_ENOMEM" : "none")); THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), st.freeze()); } diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index f02ef57de3486..15fb0d6ed3a9c 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -743,14 +743,6 @@ JVM_ENTRY_NO_ENV(jlong, JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jint JVM_END -void JVMCIRuntime::call_getCompiler(TRAPS) { - JVMCIENV_FROM_THREAD(THREAD); - JVMCIENV->check_init(CHECK); - JVMCIObject jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(JVMCI_CHECK); - initialize(JVMCI_CHECK); - JVMCIENV->call_HotSpotJVMCIRuntime_getCompiler(jvmciRuntime, JVMCI_CHECK); -} - void JVMCINMethodData::initialize(int nmethod_mirror_index, int nmethod_entry_patch_offset, const char* nmethod_mirror_name, diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp index c35813eb16ffc..aa4685c5818fb 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp @@ -375,8 +375,6 @@ class JVMCIRuntime: public CHeapObj { // Explicitly initialize HotSpotJVMCIRuntime itself void initialize_HotSpotJVMCIRuntime(JVMCI_TRAPS); - void call_getCompiler(TRAPS); - // Shuts down this runtime by calling HotSpotJVMCIRuntime.shutdown(). // If this is the last thread attached to this runtime, then // `_HotSpotJVMCIRuntime_instance` is set to null and `_init_state` diff --git a/src/hotspot/share/runtime/threads.cpp b/src/hotspot/share/runtime/threads.cpp index 47c030fdb729e..aac827246d208 100644 --- a/src/hotspot/share/runtime/threads.cpp +++ b/src/hotspot/share/runtime/threads.cpp @@ -835,7 +835,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { #if INCLUDE_JVMCI if (force_JVMCI_initialization) { - JVMCI::initialize_compiler(CHECK_JNI_ERR); + JVMCI::initialize_compiler_in_create_vm(CHECK_JNI_ERR); } #endif