src/hotspot/share/runtime/tieredThresholdPolicy.cpp
changeset 54015 cd701366fcf8
parent 54009 13acb4339895
child 54647 c0d9bc9b4e1f
equal deleted inserted replaced
54014:083d7a34bbfd 54015:cd701366fcf8
   293   jlong t = os::javaTimeMillis();
   293   jlong t = os::javaTimeMillis();
   294   // Iterate through the queue and find a method with a maximum rate.
   294   // Iterate through the queue and find a method with a maximum rate.
   295   for (CompileTask* task = compile_queue->first(); task != NULL;) {
   295   for (CompileTask* task = compile_queue->first(); task != NULL;) {
   296     CompileTask* next_task = task->next();
   296     CompileTask* next_task = task->next();
   297     Method* method = task->method();
   297     Method* method = task->method();
       
   298     // If a method was unloaded or has been stale for some time, remove it from the queue.
       
   299     // Blocking tasks and tasks submitted from whitebox API don't become stale
       
   300     if (task->is_unloaded() || (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method))) {
       
   301       if (!task->is_unloaded()) {
       
   302         if (PrintTieredEvents) {
       
   303           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel) task->comp_level());
       
   304         }
       
   305         method->clear_queued_for_compilation();
       
   306       }
       
   307       compile_queue->remove_and_mark_stale(task);
       
   308       task = next_task;
       
   309       continue;
       
   310     }
   298     update_rate(t, method);
   311     update_rate(t, method);
   299     if (max_task == NULL) {
   312     if (max_task == NULL || compare_methods(method, max_method)) {
       
   313       // Select a method with the highest rate
   300       max_task = task;
   314       max_task = task;
   301       max_method = method;
   315       max_method = method;
   302     } else {
       
   303       // If a method has been stale for some time, remove it from the queue.
       
   304       // Blocking tasks and tasks submitted from whitebox API don't become stale
       
   305       if (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
       
   306         if (PrintTieredEvents) {
       
   307           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
       
   308         }
       
   309         compile_queue->remove_and_mark_stale(task);
       
   310         method->clear_queued_for_compilation();
       
   311         task = next_task;
       
   312         continue;
       
   313       }
       
   314 
       
   315       // Select a method with a higher rate
       
   316       if (compare_methods(method, max_method)) {
       
   317         max_task = task;
       
   318         max_method = method;
       
   319       }
       
   320     }
   316     }
   321 
   317 
   322     if (task->is_blocking()) {
   318     if (task->is_blocking()) {
   323       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
   319       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
   324         max_blocking_task = task;
   320         max_blocking_task = task;
   499       }
   495       }
   500     }
   496     }
   501   }
   497   }
   502 }
   498 }
   503 
   499 
   504 // Check if this method has been stale from a given number of milliseconds.
   500 // Check if this method has been stale for a given number of milliseconds.
   505 // See select_task().
   501 // See select_task().
   506 bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
   502 bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
   507   jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms();
   503   jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms();
   508   jlong delta_t = t - m->prev_time();
   504   jlong delta_t = t - m->prev_time();
   509   if (delta_t > timeout && delta_s > timeout) {
   505   if (delta_t > timeout && delta_s > timeout) {