hotspot/src/share/vm/oops/methodOop.cpp
// Called when the method_holder is getting linked. Setup entrypoints so the method
// is ready to be called from interpreter, compiler, and vtables.
void methodOopDesc::link_method(methodHandle h_method, TRAPS) {
{- -------------------------------------------
(1) 既にリンク処理が終わっていれば, ここでリターン.
---------------------------------------- -}
// If the code cache is full, we may reenter this function for the
// leftover methods that weren't linked.
if (_i2i_entry != NULL) return;
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(_adapter == NULL, "init'd to NULL" );
assert( _code == NULL, "nothing compiled yet" );
{- -------------------------------------------
(1) Interpreter::entry_for_method() を呼んで
適切な method entry stub を取得し,
それをこのメソッドがインタープリタから呼び出される際の
エントリーポイント(_from_interpreted_entry, _i2i_entry)を設定する
(なお, native method の場合には, ... #TODO
)
---------------------------------------- -}
// Setup interpreter entrypoint
assert(this == h_method(), "wrong h_method()" );
address entry = Interpreter::entry_for_method(h_method);
assert(entry != NULL, "interpreter entry must be non-null");
// Sets both _i2i_entry and _from_interpreted_entry
set_interpreter_entry(entry);
if (is_native() && !is_method_handle_invoke()) {
set_native_function(
SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
!native_bind_event_is_interesting);
}
{- -------------------------------------------
(1) methodOopDesc::make_adapters() を呼んで,
このメソッドが JIT 生成コードから呼び出される際の
エントリーポイント(_from_compiled_entry)を設定する.
---------------------------------------- -}
// Setup compiler entrypoint. This is made eagerly, so we do not need
// special handling of vtables. An alternative is to make adapters more
// lazily by calling make_adapter() from from_compiled_entry() for the
// normal calls. For vtable calls life gets more complicated. When a
// call-site goes mega-morphic we need adapters in all methods which can be
// called from the vtable. We need adapters on such methods that get loaded
// later. Ditto for mega-morphic itable calls. If this proves to be a
// problem we'll make these lazily later.
(void) make_adapters(h_method, CHECK);
// ONLY USE the h_method now as make_adapter may have blocked
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.