Skip to content

Commit d6e4c5f

Browse files
author
Doug Simon
committed
8357506: [JVMCI] Consolidate eager JVMCI initialization code
Reviewed-by: kvn, yzheng
1 parent 9d9e41f commit d6e4c5f

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

src/hotspot/share/jvmci/jvmci.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void* JVMCI::get_shared_library(char*& path, bool load) {
151151
return _shared_library_handle;
152152
}
153153

154-
void JVMCI::initialize_compiler(TRAPS) {
154+
void JVMCI::initialize_compiler_in_create_vm(TRAPS) {
155155
if (JVMCILibDumpJNIConfig) {
156156
JNIJVMCI::initialize_ids(nullptr);
157157
ShouldNotReachHere();
@@ -162,7 +162,12 @@ void JVMCI::initialize_compiler(TRAPS) {
162162
} else {
163163
runtime = JVMCI::java_runtime();
164164
}
165-
runtime->call_getCompiler(CHECK);
165+
166+
JVMCIENV_FROM_THREAD(THREAD);
167+
JVMCIENV->check_init(CHECK);
168+
JVMCIObject jvmciRuntime = runtime->get_HotSpotJVMCIRuntime(JVMCI_CHECK);
169+
runtime->initialize(JVMCI_CHECK);
170+
JVMCIENV->call_HotSpotJVMCIRuntime_getCompiler(jvmciRuntime, JVMCI_CHECK);
166171
}
167172

168173
void JVMCI::initialize_globals() {

src/hotspot/share/jvmci/jvmci.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ class JVMCI : public AllStatic {
191191

192192
static void initialize_globals();
193193

194-
// Called to force initialization of the JVMCI compiler
195-
// early in VM startup.
196-
static void initialize_compiler(TRAPS);
194+
// Initializes the JVMCI compiler during VM startup.
195+
static void initialize_compiler_in_create_vm(TRAPS);
197196

198197
// Ensures the boxing cache classes (e.g., java.lang.Integer.IntegerCache) are initialized.
199198
static void ensure_box_caches_initialized(TRAPS);

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,9 @@ void JVMCIEnv::check_init(TRAPS) {
251251
if (_init_error == JNI_OK) {
252252
return;
253253
}
254-
if (_init_error == JNI_ENOMEM) {
255-
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "JNI_ENOMEM creating or attaching to libjvmci");
256-
}
257254
stringStream st;
258255
st.print("Error creating or attaching to libjvmci (err: %d, description: %s)",
259-
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg);
256+
_init_error, _init_error_msg != nullptr ? _init_error_msg : (_init_error == JNI_ENOMEM ? "JNI_ENOMEM" : "none"));
260257
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), st.freeze());
261258
}
262259

src/hotspot/share/jvmci/jvmciRuntime.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,14 +743,6 @@ JVM_ENTRY_NO_ENV(jlong, JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jint
743743
JVM_END
744744

745745

746-
void JVMCIRuntime::call_getCompiler(TRAPS) {
747-
JVMCIENV_FROM_THREAD(THREAD);
748-
JVMCIENV->check_init(CHECK);
749-
JVMCIObject jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(JVMCI_CHECK);
750-
initialize(JVMCI_CHECK);
751-
JVMCIENV->call_HotSpotJVMCIRuntime_getCompiler(jvmciRuntime, JVMCI_CHECK);
752-
}
753-
754746
void JVMCINMethodData::initialize(int nmethod_mirror_index,
755747
int nmethod_entry_patch_offset,
756748
const char* nmethod_mirror_name,

src/hotspot/share/jvmci/jvmciRuntime.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,6 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
375375
// Explicitly initialize HotSpotJVMCIRuntime itself
376376
void initialize_HotSpotJVMCIRuntime(JVMCI_TRAPS);
377377

378-
void call_getCompiler(TRAPS);
379-
380378
// Shuts down this runtime by calling HotSpotJVMCIRuntime.shutdown().
381379
// If this is the last thread attached to this runtime, then
382380
// `_HotSpotJVMCIRuntime_instance` is set to null and `_init_state`

src/hotspot/share/runtime/threads.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
835835

836836
#if INCLUDE_JVMCI
837837
if (force_JVMCI_initialization) {
838-
JVMCI::initialize_compiler(CHECK_JNI_ERR);
838+
JVMCI::initialize_compiler_in_create_vm(CHECK_JNI_ERR);
839839
}
840840
#endif
841841

0 commit comments

Comments
 (0)