hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
void TemplateTable::monitorexit() {
{- -------------------------------------------
(1) (assert) (See: TemplateTable::transition())
---------------------------------------- -}
transition(atos, vtos);
{- -------------------------------------------
(1) コード生成:
「もしロック確保対象のオブジェクトが null であれば, NullPointerException」
(See: [here](no30592Qc.html) for details)
---------------------------------------- -}
// check for NULL object
__ null_check(rax);
{- -------------------------------------------
(1) コード生成:
「スタックフレーム中の BasicObjectLock 領域から対応する BasicObjectLock を探す.
(見つからなければ InterpreterRuntime::throw_illegal_monitor_state_exception() を呼んで
IllegalMonitorStateException を出す)」
---------------------------------------- -}
const Address monitor_block_top(
rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
rbp, frame::interpreter_frame_initial_sp_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
Label found;
// find matching slot
{
Label entry, loop;
__ movptr(c_rarg1, monitor_block_top); // points to current entry,
// starting with top-most entry
__ lea(c_rarg2, monitor_block_bot); // points to word before bottom
// of monitor block
__ jmpb(entry);
{- -------------------------------------------
(1.1) (ここからが, 対応する BasicObjectLock を探すループ)
---------------------------------------- -}
__ bind(loop);
// check if current entry is for same object
__ cmpptr(rax, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()));
// if same object then stop searching
__ jcc(Assembler::equal, found);
// otherwise advance to next entry
__ addptr(c_rarg1, entry_size);
__ bind(entry);
// check if bottom reached
__ cmpptr(c_rarg1, c_rarg2);
// if not at bottom then check this entry
__ jcc(Assembler::notEqual, loop);
{- -------------------------------------------
(1.1) (ここまでが探索のループ)
---------------------------------------- -}
}
{- -------------------------------------------
(1.1) (見つからなければ InterpreterRuntime::throw_illegal_monitor_state_exception())
---------------------------------------- -}
// error handling. Unlocking was not block-structured
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
InterpreterRuntime::throw_illegal_monitor_state_exception));
__ should_not_reach_here();
{- -------------------------------------------
(1) コード生成:
「InterpreterMacroAssembler::unlock_object() が生成するコードで, 対象のオブジェクトにアンロック処理を行う」
(なお, oopmap と合致するように unlock_object() 中だけ stack 上にも置いておくらしい <= ?? #TODO)
---------------------------------------- -}
// call run-time routine
// rsi: points to monitor entry
__ bind(found);
__ push_ptr(rax); // make sure object is on stack (contract with oopMaps)
__ unlock_object(c_rarg1);
__ pop_ptr(rax); // discard object
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.