VM Operation は, VMThread::execute() が呼び出されることで開始される (なお, 要求を出される VMThread 自身は, HotSpot の起動時に作成される (See: here for details)).
生成された VMThread は, VM Operation 要求が来るまで無限ループで待機している (より正確には, このループ内で VMOperationQueue_lock という Monitor に wait() して眠っている).
VMThread::execute() が呼び出されると, VMThread::vm_queue という VMOperationQueue に VM Operation 要求が追加される. さらに VMOperationQueue_lock に notify() が通知される. この notify() によって wait() していた VMThread が起床し, VMThread::vm_queue から VM Operation オブジェクトを取得し, VMThread::evaluate_operation() で VM Operation を実行する.
VMThread::run()
-> (1) VMThread の初期化を行う
-> Thread::initialize_thread_local_storage()
-> Thread::record_stack_base_and_size()
-> JNIHandleBlock::allocate_block()
-> Thread::set_active_handles()
-> os::set_native_priority()
(1) VMThread のメイン処理を実行
-> VMThread::loop()
(以下の処理を無限ループ)
-> (1) VM Operation 要求が来るまで待機する
-> VMOperationQueue::remove_next()
-> Monitor::wait()
(1) Safepoint 停止が必要であれば Safepoint 処理を開始させる
-> SafepointSynchronize::begin() (← 必要に応じて)
-> (See: here for details)
(1) 取得した VM Operation 要求を実行する
(なお safepoint が必要な VM Operation だった場合には,
safepoint 停止回数ができるだけ少なくなるように
VMThread::_vm_queue 内の他の safepoint を要求する VM Operation も全部実行する.)
-> VMThread::evaluate_operation()
-> VM_Operation::evaluate()
-> VM_Operation::doit() (← ここで実際の VM Operation 処理が行われる.
doit() は各サブクラスでオーバーライドされている)
(1) Safepoint 停止した場合には Safepoint を解除する
-> SafepointSynchronize::end() (← 必要に応じて)
-> (See: here for details)
(1) VM Operation 要求を出したスレッドが完了を待っているかもしれないため, 起床させておく
-> Monitor::notify_all()
(1) VMThread の終了処理を行う
-> SafepointSynchronize::begin()
-> CompileBroker::set_should_block()
-> VM_Exit::wait_for_threads_in_native_to_block()
VMThread::execute()
-> (VMThread自身から呼び出されたかどうかで, 以下の2通りのパスが存在)
* VMThread 以外から呼び出されたケース (nested VM Operation ではない場合)
-> VM_Operation::doit_prologue() (をサブクラスがオーバーライドしたもの)
-> _vm_queue に VM_Operation オブジェクトを追加
-> VMOperationQueue_lock に対して Monitor::notify() を呼び出す
-> (完了するまで待つように指定されている VM Operation の場合には)
VMOperationRequest_lock に対して Monitor::wait() して VM Operation の完了を待つ
-> (VMThread に delete されない種類の VM_Operation であれば)
VM_Operation::doit_epilogue() (をサブクラスがオーバーライドしたもの)
* VMThread から呼び出されたケース (nested VM Operation 等の場合)
-> SafepointSynchronize::begin() (← 必要に応じて)
-> (See: here for details)
-> VM_Operation::evaluate()
-> VM_Operation::doit() (← ここで実際の VM Operation 処理が行われる.
doit() は各サブクラスでオーバーライドされている)
-> SafepointSynchronize::end() (← 必要に応じて)
-> (See: here for details)
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
(#Under Construction)
See: here for details
(#Under Construction)
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.