src/hotspot/share/compiler/compileBroker.cpp
changeset 54015 cd701366fcf8
parent 53582 881c5fbeb849
child 54482 c914170817d4
equal deleted inserted replaced
54014:083d7a34bbfd 54015:cd701366fcf8
   256   if (task->is_blocking() && CompileBroker::compiler(task->comp_level())->is_jvmci()) {
   256   if (task->is_blocking() && CompileBroker::compiler(task->comp_level())->is_jvmci()) {
   257     task->set_jvmci_compiler_thread(thread);
   257     task->set_jvmci_compiler_thread(thread);
   258   }
   258   }
   259 #endif
   259 #endif
   260   CompileLog*     log  = thread->log();
   260   CompileLog*     log  = thread->log();
   261   if (log != NULL)  task->log_task_start(log);
   261   if (log != NULL && !task->is_unloaded())  task->log_task_start(log);
   262 }
   262 }
   263 
   263 
   264 CompileTaskWrapper::~CompileTaskWrapper() {
   264 CompileTaskWrapper::~CompileTaskWrapper() {
   265   CompilerThread* thread = CompilerThread::current();
   265   CompilerThread* thread = CompilerThread::current();
   266   CompileTask* task = thread->task();
   266   CompileTask* task = thread->task();
   267   CompileLog*  log  = thread->log();
   267   CompileLog*  log  = thread->log();
   268   if (log != NULL)  task->log_task_done(log);
   268   if (log != NULL && !task->is_unloaded())  task->log_task_done(log);
   269   thread->set_task(NULL);
   269   thread->set_task(NULL);
   270   task->set_code_handle(NULL);
   270   task->set_code_handle(NULL);
   271   thread->set_env(NULL);
   271   thread->set_env(NULL);
   272   if (task->is_blocking()) {
   272   if (task->is_blocking()) {
   273     bool free_task = false;
   273     bool free_task = false;
   442 
   442 
   443   CompileTask* task;
   443   CompileTask* task;
   444   {
   444   {
   445     NoSafepointVerifier nsv;
   445     NoSafepointVerifier nsv;
   446     task = CompilationPolicy::policy()->select_task(this);
   446     task = CompilationPolicy::policy()->select_task(this);
       
   447     if (task != NULL) {
       
   448       task = task->select_for_compilation();
       
   449     }
   447   }
   450   }
   448 
   451 
   449   if (task != NULL) {
   452   if (task != NULL) {
   450     // Save method pointers across unlock safepoint.  The task is removed from
   453     // Save method pointers across unlock safepoint.  The task is removed from
   451     // the compilation queue, which is walked during RedefineClasses.
   454     // the compilation queue, which is walked during RedefineClasses.
   453     save_hot_method = methodHandle(task->hot_method());
   456     save_hot_method = methodHandle(task->hot_method());
   454 
   457 
   455     remove(task);
   458     remove(task);
   456     purge_stale_tasks(); // may temporarily release MCQ lock
   459     purge_stale_tasks(); // may temporarily release MCQ lock
   457   }
   460   }
   458 
       
   459   return task;
   461   return task;
   460 }
   462 }
   461 
   463 
   462 // Clean & deallocate stale compile tasks.
   464 // Clean & deallocate stale compile tasks.
   463 // Temporarily releases MethodCompileQueue lock.
   465 // Temporarily releases MethodCompileQueue lock.
   481     }
   483     }
   482   }
   484   }
   483 }
   485 }
   484 
   486 
   485 void CompileQueue::remove(CompileTask* task) {
   487 void CompileQueue::remove(CompileTask* task) {
   486    assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
   488   assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
   487   if (task->prev() != NULL) {
   489   if (task->prev() != NULL) {
   488     task->prev()->set_next(task->next());
   490     task->prev()->set_next(task->next());
   489   } else {
   491   } else {
   490     // max is the first element
   492     // max is the first element
   491     assert(task == _first, "Sanity");
   493     assert(task == _first, "Sanity");
   532 void CompileBroker::print_compile_queues(outputStream* st) {
   534 void CompileBroker::print_compile_queues(outputStream* st) {
   533   st->print_cr("Current compiles: ");
   535   st->print_cr("Current compiles: ");
   534 
   536 
   535   char buf[2000];
   537   char buf[2000];
   536   int buflen = sizeof(buf);
   538   int buflen = sizeof(buf);
   537   Threads::print_threads_compiling(st, buf, buflen);
   539   Threads::print_threads_compiling(st, buf, buflen, /* short_form = */ true);
   538 
   540 
   539   st->cr();
   541   st->cr();
   540   if (_c1_compile_queue != NULL) {
   542   if (_c1_compile_queue != NULL) {
   541     _c1_compile_queue->print(st);
   543     _c1_compile_queue->print(st);
   542   }
   544   }