Skip to content

Commit

Permalink
8289071: Compute allocation sizes of stubs and nmethods outside of lo…
Browse files Browse the repository at this point in the history
…ck protection

Reviewed-by: thartmann, phh
  • Loading branch information
Yi-Fan Tsai authored and Paul Hohensee committed Jun 28, 2022
1 parent d4eeeb8 commit 88fe19c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/hotspot/share/code/codeBlob.cpp
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
25 changes: 13 additions & 12 deletions src/hotspot/share/code/nmethod.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

1 comment on commit 88fe19c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.