hotspot/src/share/vm/compiler/compileBroker.cpp
// ------------------------------------------------------------------
// CompileQueue::get
//
// Get the next CompileTask from a CompileQueue
CompileTask* CompileQueue::get() {
{- -------------------------------------------
(1) 不要になった JIT 生成コード(nmethod)の回収作業を少しだけ行っておく. (See: [here](no1904IaU.html) for details)
---------------------------------------- -}
NMethodSweeper::possibly_sweep();
{- -------------------------------------------
(1) キューに CopmileTask が届くまで Monitor::wait() で待機.
---------------------------------------- -}
MutexLocker locker(lock());
// Wait for an available CompileTask.
while (_first == NULL) {
// There is no work to be done right now. Wait.
if (UseCodeCacheFlushing && (!CompileBroker::should_compile_new_jobs() || CodeCache::needs_flushing())) {
// During the emergency sweeping periods, wake up and sweep occasionally
bool timedout = lock()->wait(!Mutex::_no_safepoint_check_flag, NmethodSweepCheckInterval*1000);
if (timedout) {
MutexUnlocker ul(lock());
// When otherwise not busy, run nmethod sweeping
NMethodSweeper::possibly_sweep();
}
} else {
// During normal operation no need to wake up on timer
lock()->wait();
}
}
{- -------------------------------------------
(1) CompilationPolicy::select_task() (を各サブクラスがオーバーライドしたもの) を呼んで,
キューから最適な CompileTask を取り出す.
(取り出した CompileTask は, CompileQueue::remove() でキューからは削除しておく)
---------------------------------------- -}
CompileTask* task = CompilationPolicy::policy()->select_task(this);
remove(task);
{- -------------------------------------------
(1) 結果をリターン
---------------------------------------- -}
return task;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.