8209889: RedefineStress tests crash

Create CompileTaskWrapper before potential safepoint

Reviewed-by: mdoerr, dlong
This commit is contained in:
Coleen Phillimore 2018-10-05 09:15:52 -04:00
parent d872314ef3
commit 432605be5c

@ -1781,30 +1781,31 @@ void CompileBroker::compiler_thread_loop() {
return; // Stop this thread.
}
}
continue;
}
} else {
// Assign the task to the current thread. Mark this compilation
// thread as active for the profiler.
// CompileTaskWrapper also keeps the Method* from being deallocated if redefinition
// occurs after fetching the compile task off the queue.
CompileTaskWrapper ctw(task);
nmethodLocker result_handle; // (handle for the nmethod produced by this task)
task->set_code_handle(&result_handle);
methodHandle method(thread, task->method());
if (UseDynamicNumberOfCompilerThreads) {
possibly_add_compiler_threads();
}
// Never compile a method if breakpoints are present in it
if (method()->number_of_breakpoints() == 0) {
// Compile the method.
if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
invoke_compiler_on_method(task);
thread->start_idle_timer();
} else {
// After compilation is disabled, remove remaining methods from queue
method->clear_queued_for_compilation();
task->set_failure_reason("compilation is disabled");
}
}
// Assign the task to the current thread. Mark this compilation
// thread as active for the profiler.
CompileTaskWrapper ctw(task);
nmethodLocker result_handle; // (handle for the nmethod produced by this task)
task->set_code_handle(&result_handle);
methodHandle method(thread, task->method());
// Never compile a method if breakpoints are present in it
if (method()->number_of_breakpoints() == 0) {
// Compile the method.
if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
invoke_compiler_on_method(task);
thread->start_idle_timer();
} else {
// After compilation is disabled, remove remaining methods from queue
method->clear_queued_for_compilation();
task->set_failure_reason("compilation is disabled");
if (UseDynamicNumberOfCompilerThreads) {
possibly_add_compiler_threads();
}
}
}