Skip to content
Permalink
Browse files
8258015: [JVMCI] JVMCI_lock shouldn't be held while initializing box …
…classes

Reviewed-by: iveresov
  • Loading branch information
Doug Simon committed Dec 10, 2020
1 parent b35401d commit d163c6fe2ec235a175b62ec821477d33b14841fe
@@ -37,7 +37,7 @@
JVMCIRuntime* JVMCI::_compiler_runtime = NULL;
JVMCIRuntime* JVMCI::_java_runtime = NULL;
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;
char* JVMCI::_shared_library_path = NULL;
volatile bool JVMCI::_in_shutdown = false;
@@ -130,12 +130,9 @@ void JVMCI::ensure_box_caches_initialized(TRAPS) {
if (_box_caches_initialized) {
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[] = {
java_lang_Boolean::symbol(),
java_lang_Byte_ByteCache::symbol(),
@@ -53,8 +53,8 @@ class JVMCI : public AllStatic {
// execution has completed successfully.
static volatile bool _is_initialized;

// used to synchronize lazy initialization of boxing cache classes.
static volatile bool _box_caches_initialized;
// True once boxing cache classes are guaranteed to be initialized.
static bool _box_caches_initialized;

// Handle created when loading the JVMCI shared library with os::dll_load.
// Must hold JVMCI_lock when initializing.
@@ -945,6 +945,10 @@ JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bo
}
}
#endif
if (_has_auto_box) {
JavaThread* THREAD = JavaThread::current();
JVMCI::ensure_box_caches_initialized(CHECK_(JVMCI::ok));
}
return JVMCI::ok;
}

@@ -1022,15 +1026,14 @@ GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject de
}
GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(JVMCIENV->get_length(virtualObjects), JVMCIENV->get_length(virtualObjects), NULL);
// Create the unique ObjectValues
bool has_auto_box = false;
for (int i = 0; i < JVMCIENV->get_length(virtualObjects); i++) {
// HandleMark hm(THREAD);
JVMCIObject value = JVMCIENV->get_object_at(virtualObjects, i);
int id = jvmci_env()->get_VirtualObject_id(value);
JVMCIObject type = jvmci_env()->get_VirtualObject_type(value);
bool is_auto_box = jvmci_env()->get_VirtualObject_isAutoBox(value);
if (is_auto_box) {
has_auto_box = true;
_has_auto_box = true;
}
Klass* klass = jvmci_env()->asKlass(type);
oop javaMirror = klass->java_mirror();
@@ -1054,10 +1057,6 @@ GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject de
}
_debug_recorder->dump_object_pool(objects);

if (has_auto_box) {
JavaThread* THREAD = JavaThread::current();
JVMCI::ensure_box_caches_initialized(CHECK_NULL);
}
return objects;
}

@@ -200,6 +200,7 @@ class CodeInstaller : public StackObj {
Dependencies* _dependencies;
ExceptionHandlerTable _exception_handler_table;
ImplicitExceptionTable _implicit_exception_table;
bool _has_auto_box;

bool _immutable_pic_compilation; // Installer is called for Immutable PIC compilation.

@@ -230,7 +231,11 @@ class CodeInstaller : public StackObj {

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
JVMCI::CodeInstallResult gather_metadata(JVMCIObject target, JVMCIObject compiled_code, CodeMetadata& metadata, JVMCI_TRAPS);

1 comment on commit d163c6f

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on d163c6f Dec 10, 2020

Please sign in to comment.