Skip to content
Permalink
Browse files
8254104: MethodCounters must exist before nmethod is installed
Reviewed-by: dnsimon, kvn
  • Loading branch information
Igor Veresov committed Oct 8, 2020
1 parent fd0cb98 commit 4e5ef303038d12ea872c221ef615c9ebc7ff7420
Showing 2 changed files with 21 additions and 5 deletions.
@@ -972,6 +972,18 @@ void ciEnv::register_method(ciMethod* target,
VM_ENTRY_MARK;
nmethod* nm = NULL;
{
methodHandle method(THREAD, target->get_Method());

// We require method counters to store some method state (max compilation levels) required by the compilation policy.
if (method->get_method_counters(THREAD) == NULL) {
record_failure("can't create method counters");
// All buffers in the CodeBuffer are allocated in the CodeCache.
// If the code buffer is created on each compile attempt
// as in C2, then it must be freed.
code_buffer->free_blob();
return;
}

// To prevent compile queue updates.
MutexLocker locker(THREAD, MethodCompileQueue_lock);

@@ -1011,9 +1023,6 @@ void ciEnv::register_method(ciMethod* target,
// Check for {class loads, evolution, breakpoints, ...} during compilation
validate_compile_task_dependencies(target);
}

methodHandle method(THREAD, target->get_Method());

#if INCLUDE_RTM_OPT
if (!failing() && (rtm_state != NoRTM) &&
(method()->method_data() != NULL) &&
@@ -1577,8 +1577,15 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
nmethod_mirror_index = -1;
}

JVMCI::CodeInstallResult result;
{
JVMCI::CodeInstallResult result(JVMCI::ok);

// We require method counters to store some method state (max compilation levels) required by the compilation policy.
if (method->get_method_counters(THREAD) == NULL) {
result = JVMCI::cache_full;
failure_detail = (char*) "can't create method counters";
}

if (result == JVMCI::ok) {
// To prevent compile queue updates.
MutexLocker locker(THREAD, MethodCompileQueue_lock);

1 comment on commit 4e5ef30

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 4e5ef30 Oct 8, 2020

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.