8289071: Compute allocation sizes of stubs and nmethods outside of lock protection

Reviewed-by: thartmann, phh
This commit is contained in:
Yi-Fan Tsai 2022-06-28 15:16:21 +00:00 committed by Paul Hohensee
parent d4eeeb82cb
commit 88fe19c5b2
2 changed files with 18 additions and 17 deletions

View File

@ -409,10 +409,10 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
bool caller_must_gc_arguments)
{
RuntimeStub* stub = NULL;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub));
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub));
stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
}
@ -468,10 +468,10 @@ DeoptimizationBlob* DeoptimizationBlob::create(
int frame_size)
{
DeoptimizationBlob* blob = NULL;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(DeoptimizationBlob));
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
unsigned int size = CodeBlob::allocation_size(cb, sizeof(DeoptimizationBlob));
blob = new (size) DeoptimizationBlob(cb,
size,
oop_maps,
@ -507,10 +507,10 @@ UncommonTrapBlob* UncommonTrapBlob::create(
int frame_size)
{
UncommonTrapBlob* blob = NULL;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(UncommonTrapBlob));
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
unsigned int size = CodeBlob::allocation_size(cb, sizeof(UncommonTrapBlob));
blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size);
}
@ -543,10 +543,10 @@ ExceptionBlob* ExceptionBlob::create(
int frame_size)
{
ExceptionBlob* blob = NULL;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(ExceptionBlob));
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
unsigned int size = CodeBlob::allocation_size(cb, sizeof(ExceptionBlob));
blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size);
}
@ -578,10 +578,10 @@ SafepointBlob* SafepointBlob::create(
int frame_size)
{
SafepointBlob* blob = NULL;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(SafepointBlob));
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
unsigned int size = CodeBlob::allocation_size(cb, sizeof(SafepointBlob));
blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size);
}

View File

@ -470,9 +470,9 @@ nmethod* nmethod::new_native_nmethod(const methodHandle& method,
code_buffer->finalize_oop_references(method);
// create nmethod
nmethod* nm = NULL;
int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod));
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod));
CodeOffsets offsets;
offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
@ -525,21 +525,22 @@ nmethod* nmethod::new_nmethod(const methodHandle& method,
code_buffer->finalize_oop_references(method);
// create nmethod
nmethod* nm = NULL;
{ MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
#if INCLUDE_JVMCI
int jvmci_data_size = !compiler->is_jvmci() ? 0 : JVMCINMethodData::compute_size(nmethod_mirror_name);
int jvmci_data_size = !compiler->is_jvmci() ? 0 : JVMCINMethodData::compute_size(nmethod_mirror_name);
#endif
int nmethod_size =
CodeBlob::allocation_size(code_buffer, sizeof(nmethod))
+ adjust_pcs_size(debug_info->pcs_size())
+ align_up((int)dependencies->size_in_bytes(), oopSize)
+ align_up(handler_table->size_in_bytes() , oopSize)
+ align_up(nul_chk_table->size_in_bytes() , oopSize)
int nmethod_size =
CodeBlob::allocation_size(code_buffer, sizeof(nmethod))
+ adjust_pcs_size(debug_info->pcs_size())
+ align_up((int)dependencies->size_in_bytes(), oopSize)
+ align_up(handler_table->size_in_bytes() , oopSize)
+ align_up(nul_chk_table->size_in_bytes() , oopSize)
#if INCLUDE_JVMCI
+ align_up(speculations_len , oopSize)
+ align_up(jvmci_data_size , oopSize)
+ align_up(speculations_len , oopSize)
+ align_up(jvmci_data_size , oopSize)
#endif
+ align_up(debug_info->data_size() , oopSize);
+ align_up(debug_info->data_size() , oopSize);
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
nm = new (nmethod_size, comp_level)
nmethod(method(), compiler->type(), nmethod_size, compile_id, entry_bci, offsets,