diff options
author | John Hawthorn <john@hawthorn.email> | 2020-01-18 18:18:00 -0800 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-02-13 00:14:55 +0900 |
commit | ed7b46b66be671165b6f38abd21d7638f4dfdcea (patch) | |
tree | 69dacc5327b52842c8999b7c4bc1f1d823519da4 /vm_insnhelper.c | |
parent | a91ce05046b1bddc60a3dafcea59a4366359dffa (diff) | |
download | ruby-ed7b46b66be671165b6f38abd21d7638f4dfdcea.tar.gz |
Use inline cache for super calls
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index d2b8a63676..9404b0d74a 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -3154,9 +3154,25 @@ vm_search_super_method(const rb_control_frame_t *reg_cfp, struct rb_call_data *c CC_SET_FASTPATH(cc, vm_call_method_missing, TRUE); } else { - /* TODO: use inline cache */ +#if OPT_INLINE_METHOD_CACHE + /* Unlike normal method search, we only consider the first class + * serial. Since we're testing defined_class rather than receiver, + * there's only one valid "warm" value. */ + if (LIKELY(RB_DEBUG_COUNTER_INC_UNLESS(mc_global_state_miss, + GET_GLOBAL_METHOD_STATE() == cc->method_state) && + cc->class_serial[0] == RCLASS_SERIAL(klass)) && + cc->me && ci->mid == cc->me->def->original_id) { + VM_ASSERT(cc->call != NULL); + RB_DEBUG_COUNTER_INC(mc_inline_hit); + return; + } +#endif + CC_SET_ME(cc, rb_callable_method_entry(klass, ci->mid)); CC_SET_FASTPATH(cc, vm_call_super_method, TRUE); + + cc->method_state = GET_GLOBAL_METHOD_STATE(); + cc->class_serial[0] = RCLASS_SERIAL(klass); } } |