hotspot/src/share/vm/prims/jni.cpp
JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result))
{- -------------------------------------------
(1) (デバッグ用の処理)
(See: JNIWrapper)
---------------------------------------- -}
JNIWrapper("PopLocalFrame");
{- -------------------------------------------
(1) (DTrace のフック点)
---------------------------------------- -}
DTRACE_PROBE2(hotspot_jni, PopLocalFrame__entry, env, result);
//%note jni_11
{- -------------------------------------------
(1) このスレッドの active_handles フィールドから現在の JNIHandleBlock を取得し,
さらにそこから pop_frame_link を辿ることで一つ前の JNIHandleBlock を取得する.
---------------------------------------- -}
Handle result_handle(thread, JNIHandles::resolve(result));
JNIHandleBlock* old_handles = thread->active_handles();
JNIHandleBlock* new_handles = old_handles->pop_frame_link();
{- -------------------------------------------
(1) もし一つ前の JNIHandleBlock が無かった場合には何もしない.
(こうすることで, 間違って対応する PushLocalFrame() が存在しない PopLocalFrame() が呼ばれた場合でも動作は継続できる.)
逆に一つ前の JNIHandleBlock が存在していれば,
スレッドの active_handles フィールドを一つ前の JNIHandleBlock に変更し,
今まで使っていた JNIHandleBlock は JNIHandleBlock::release_block() でフリーリストにつないでおく.
---------------------------------------- -}
if (new_handles != NULL) {
// As a sanity check we only release the handle blocks if the pop_frame_link is not NULL.
// This way code will still work if PopLocalFrame is called without a corresponding
// PushLocalFrame call. Note that we set the pop_frame_link to NULL explicitly, otherwise
// the release_block call will release the blocks.
thread->set_active_handles(new_handles);
old_handles->set_pop_frame_link(NULL); // clear link we won't release new_handles below
JNIHandleBlock::release_block(old_handles, thread); // may block
result = JNIHandles::make_local(thread, result_handle());
}
{- -------------------------------------------
(1) (DTrace のフック点)
---------------------------------------- -}
DTRACE_PROBE1(hotspot_jni, PopLocalFrame__return, result);
{- -------------------------------------------
(1) 結果をリターン.
---------------------------------------- -}
return result;
JNI_END
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.