mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8258015: [JVMCI] JVMCI_lock shouldn't be held while initializing box classes
Reviewed-by: iveresov
This commit is contained in:
parent
b35401d6a7
commit
d163c6fe2e
4 changed files with 16 additions and 15 deletions
|
@ -37,7 +37,7 @@
|
||||||
JVMCIRuntime* JVMCI::_compiler_runtime = NULL;
|
JVMCIRuntime* JVMCI::_compiler_runtime = NULL;
|
||||||
JVMCIRuntime* JVMCI::_java_runtime = NULL;
|
JVMCIRuntime* JVMCI::_java_runtime = NULL;
|
||||||
volatile bool JVMCI::_is_initialized = false;
|
volatile bool JVMCI::_is_initialized = false;
|
||||||
volatile bool JVMCI::_box_caches_initialized = false;
|
bool JVMCI::_box_caches_initialized = false;
|
||||||
void* JVMCI::_shared_library_handle = NULL;
|
void* JVMCI::_shared_library_handle = NULL;
|
||||||
char* JVMCI::_shared_library_path = NULL;
|
char* JVMCI::_shared_library_path = NULL;
|
||||||
volatile bool JVMCI::_in_shutdown = false;
|
volatile bool JVMCI::_in_shutdown = false;
|
||||||
|
@ -130,12 +130,9 @@ void JVMCI::ensure_box_caches_initialized(TRAPS) {
|
||||||
if (_box_caches_initialized) {
|
if (_box_caches_initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MutexLocker locker(JVMCI_lock);
|
|
||||||
// Check again after locking
|
|
||||||
if (_box_caches_initialized) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// While multiple threads may reach here, that's fine
|
||||||
|
// since class initialization is synchronized.
|
||||||
Symbol* box_classes[] = {
|
Symbol* box_classes[] = {
|
||||||
java_lang_Boolean::symbol(),
|
java_lang_Boolean::symbol(),
|
||||||
java_lang_Byte_ByteCache::symbol(),
|
java_lang_Byte_ByteCache::symbol(),
|
||||||
|
|
|
@ -53,8 +53,8 @@ class JVMCI : public AllStatic {
|
||||||
// execution has completed successfully.
|
// execution has completed successfully.
|
||||||
static volatile bool _is_initialized;
|
static volatile bool _is_initialized;
|
||||||
|
|
||||||
// used to synchronize lazy initialization of boxing cache classes.
|
// True once boxing cache classes are guaranteed to be initialized.
|
||||||
static volatile bool _box_caches_initialized;
|
static bool _box_caches_initialized;
|
||||||
|
|
||||||
// Handle created when loading the JVMCI shared library with os::dll_load.
|
// Handle created when loading the JVMCI shared library with os::dll_load.
|
||||||
// Must hold JVMCI_lock when initializing.
|
// Must hold JVMCI_lock when initializing.
|
||||||
|
|
|
@ -945,6 +945,10 @@ JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (_has_auto_box) {
|
||||||
|
JavaThread* THREAD = JavaThread::current();
|
||||||
|
JVMCI::ensure_box_caches_initialized(CHECK_(JVMCI::ok));
|
||||||
|
}
|
||||||
return JVMCI::ok;
|
return JVMCI::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1022,7 +1026,6 @@ GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject de
|
||||||
}
|
}
|
||||||
GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(JVMCIENV->get_length(virtualObjects), JVMCIENV->get_length(virtualObjects), NULL);
|
GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(JVMCIENV->get_length(virtualObjects), JVMCIENV->get_length(virtualObjects), NULL);
|
||||||
// Create the unique ObjectValues
|
// Create the unique ObjectValues
|
||||||
bool has_auto_box = false;
|
|
||||||
for (int i = 0; i < JVMCIENV->get_length(virtualObjects); i++) {
|
for (int i = 0; i < JVMCIENV->get_length(virtualObjects); i++) {
|
||||||
// HandleMark hm(THREAD);
|
// HandleMark hm(THREAD);
|
||||||
JVMCIObject value = JVMCIENV->get_object_at(virtualObjects, i);
|
JVMCIObject value = JVMCIENV->get_object_at(virtualObjects, i);
|
||||||
|
@ -1030,7 +1033,7 @@ GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject de
|
||||||
JVMCIObject type = jvmci_env()->get_VirtualObject_type(value);
|
JVMCIObject type = jvmci_env()->get_VirtualObject_type(value);
|
||||||
bool is_auto_box = jvmci_env()->get_VirtualObject_isAutoBox(value);
|
bool is_auto_box = jvmci_env()->get_VirtualObject_isAutoBox(value);
|
||||||
if (is_auto_box) {
|
if (is_auto_box) {
|
||||||
has_auto_box = true;
|
_has_auto_box = true;
|
||||||
}
|
}
|
||||||
Klass* klass = jvmci_env()->asKlass(type);
|
Klass* klass = jvmci_env()->asKlass(type);
|
||||||
oop javaMirror = klass->java_mirror();
|
oop javaMirror = klass->java_mirror();
|
||||||
|
@ -1054,10 +1057,6 @@ GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject de
|
||||||
}
|
}
|
||||||
_debug_recorder->dump_object_pool(objects);
|
_debug_recorder->dump_object_pool(objects);
|
||||||
|
|
||||||
if (has_auto_box) {
|
|
||||||
JavaThread* THREAD = JavaThread::current();
|
|
||||||
JVMCI::ensure_box_caches_initialized(CHECK_NULL);
|
|
||||||
}
|
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ private:
|
||||||
Dependencies* _dependencies;
|
Dependencies* _dependencies;
|
||||||
ExceptionHandlerTable _exception_handler_table;
|
ExceptionHandlerTable _exception_handler_table;
|
||||||
ImplicitExceptionTable _implicit_exception_table;
|
ImplicitExceptionTable _implicit_exception_table;
|
||||||
|
bool _has_auto_box;
|
||||||
|
|
||||||
bool _immutable_pic_compilation; // Installer is called for Immutable PIC compilation.
|
bool _immutable_pic_compilation; // Installer is called for Immutable PIC compilation.
|
||||||
|
|
||||||
|
@ -230,7 +231,11 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CodeInstaller(JVMCIEnv* jvmci_env, bool immutable_pic_compilation) : _arena(mtJVMCI), _jvmci_env(jvmci_env), _immutable_pic_compilation(immutable_pic_compilation) {}
|
CodeInstaller(JVMCIEnv* jvmci_env, bool immutable_pic_compilation) :
|
||||||
|
_arena(mtJVMCI),
|
||||||
|
_jvmci_env(jvmci_env),
|
||||||
|
_has_auto_box(false),
|
||||||
|
_immutable_pic_compilation(immutable_pic_compilation) {}
|
||||||
|
|
||||||
#if INCLUDE_AOT
|
#if INCLUDE_AOT
|
||||||
JVMCI::CodeInstallResult gather_metadata(JVMCIObject target, JVMCIObject compiled_code, CodeMetadata& metadata, JVMCI_TRAPS);
|
JVMCI::CodeInstallResult gather_metadata(JVMCIObject target, JVMCIObject compiled_code, CodeMetadata& metadata, JVMCI_TRAPS);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue