736 // the stable state, i.e., we do not want to evict methods from the
737 // code cache if it is unnecessary.
738 // We need a timed wait here, since compiler threads can exit if compilation
739 // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
740 // is not critical and we do not want idle compiler threads to wake up too often.
741 lock()->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
742 }
743 }
744
745 if (CompileBroker::is_compilation_disabled_forever()) {
746 return NULL;
747 }
748
749 CompileTask* task;
750 {
751 No_Safepoint_Verifier nsv;
752 task = CompilationPolicy::policy()->select_task(this);
753 }
754 if (task != NULL) {
755 remove(task);
756 purge_stale_tasks(); // may temporarily release MCQ lock
757 }
758 return task;
759 }
760
761 // Clean & deallocate stale compile tasks.
762 // Temporarily releases MethodCompileQueue lock.
763 void CompileQueue::purge_stale_tasks() {
764 assert(lock()->owned_by_self(), "must own lock");
765 if (_first_stale != NULL) {
766 // Stale tasks are purged when MCQ lock is released,
767 // but _first_stale updates are protected by MCQ lock.
768 // Once task processing starts and MCQ lock is released,
769 // other compiler threads can reuse _first_stale.
770 CompileTask* head = _first_stale;
771 _first_stale = NULL;
772 {
773 MutexUnlocker ul(lock());
774 for (CompileTask* task = head; task != NULL; ) {
775 CompileTask* next_task = task->next();
776 CompileTaskWrapper ctw(task); // Frees the task
777 task->set_failure_reason("stale task");
|
736 // the stable state, i.e., we do not want to evict methods from the
737 // code cache if it is unnecessary.
738 // We need a timed wait here, since compiler threads can exit if compilation
739 // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
740 // is not critical and we do not want idle compiler threads to wake up too often.
741 lock()->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
742 }
743 }
744
745 if (CompileBroker::is_compilation_disabled_forever()) {
746 return NULL;
747 }
748
749 CompileTask* task;
750 {
751 No_Safepoint_Verifier nsv;
752 task = CompilationPolicy::policy()->select_task(this);
753 }
754 if (task != NULL) {
755 remove(task);
756 }
757 purge_stale_tasks(); // may temporarily release MCQ lock
758 return task;
759 }
760
761 // Clean & deallocate stale compile tasks.
762 // Temporarily releases MethodCompileQueue lock.
763 void CompileQueue::purge_stale_tasks() {
764 assert(lock()->owned_by_self(), "must own lock");
765 if (_first_stale != NULL) {
766 // Stale tasks are purged when MCQ lock is released,
767 // but _first_stale updates are protected by MCQ lock.
768 // Once task processing starts and MCQ lock is released,
769 // other compiler threads can reuse _first_stale.
770 CompileTask* head = _first_stale;
771 _first_stale = NULL;
772 {
773 MutexUnlocker ul(lock());
774 for (CompileTask* task = head; task != NULL; ) {
775 CompileTask* next_task = task->next();
776 CompileTaskWrapper ctw(task); // Frees the task
777 task->set_failure_reason("stale task");
|