8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"

Use weak handles for compile tasks to allow unloading of referenced methods.

Reviewed-by: kvn, coleenp, eosterlund
This commit is contained in:
Tobias Hartmann 2019-03-07 08:38:16 +01:00
parent e28fea2d7c
commit ac17b61a59
9 changed files with 195 additions and 56 deletions

View file

@ -295,28 +295,24 @@ CompileTask* TieredThresholdPolicy::select_task(CompileQueue* compile_queue) {
for (CompileTask* task = compile_queue->first(); task != NULL;) {
CompileTask* next_task = task->next();
Method* method = task->method();
// If a method was unloaded or has been stale for some time, remove it from the queue.
// Blocking tasks and tasks submitted from whitebox API don't become stale
if (task->is_unloaded() || (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method))) {
if (!task->is_unloaded()) {
if (PrintTieredEvents) {
print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel) task->comp_level());
}
method->clear_queued_for_compilation();
}
compile_queue->remove_and_mark_stale(task);
task = next_task;
continue;
}
update_rate(t, method);
if (max_task == NULL) {
if (max_task == NULL || compare_methods(method, max_method)) {
// Select a method with the highest rate
max_task = task;
max_method = method;
} else {
// If a method has been stale for some time, remove it from the queue.
// Blocking tasks and tasks submitted from whitebox API don't become stale
if (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
if (PrintTieredEvents) {
print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
}
compile_queue->remove_and_mark_stale(task);
method->clear_queued_for_compilation();
task = next_task;
continue;
}
// Select a method with a higher rate
if (compare_methods(method, max_method)) {
max_task = task;
max_method = method;
}
}
if (task->is_blocking()) {
@ -501,7 +497,7 @@ void TieredThresholdPolicy::update_rate(jlong t, Method* m) {
}
}
// Check if this method has been stale from a given number of milliseconds.
// Check if this method has been stale for a given number of milliseconds.
// See select_task().
bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms();