ruby-changes:52849
From: k0kubun <ko1@a...>
Date: Sat, 13 Oct 2018 23:03:53 +0900 (JST)
Subject: [ruby-changes:52849] k0kubun:r65061 (trunk): vm_insnhelper.c: finish reverting r63333
k0kubun 2018-10-13 23:03:48 +0900 (Sat, 13 Oct 2018) New Revision: 65061 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65061 Log: vm_insnhelper.c: finish reverting r63333 That optimization is already reverted and we're not retrying the optimization soon. Let me simplify the code of vm_getivar. Modified files: trunk/vm_insnhelper.c Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 65060) +++ vm_insnhelper.c (revision 65061) @@ -955,28 +955,24 @@ vm_search_const_defined_class(const VALU https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L955 #endif /* `index` argument is used in MJIT to inline index value of call cache */ -ALWAYS_INLINE(static VALUE vm_getivar(VALUE, ID, IC, struct rb_call_cache *, st_index_t, int)); +ALWAYS_INLINE(static VALUE vm_getivar(VALUE, ID, IC, struct rb_call_cache *, int)); static inline VALUE -vm_getivar(VALUE obj, ID id, IC ic, struct rb_call_cache *cc, st_index_t index, int is_attr) +vm_getivar(VALUE obj, ID id, IC ic, struct rb_call_cache *cc, int is_attr) { #if USE_IC_FOR_IVAR if (LIKELY(RB_TYPE_P(obj, T_OBJECT))) { VALUE val = Qundef; - if (LIKELY(index > 0 || is_attr ? + if (LIKELY(is_attr ? RB_DEBUG_COUNTER_INC_UNLESS(ivar_get_ic_miss_unset, cc->aux.index > 0) : RB_DEBUG_COUNTER_INC_UNLESS(ivar_get_ic_miss_serial, ic->ic_serial == RCLASS_SERIAL(RBASIC(obj)->klass)))) { - if (index == 0) { - index = !is_attr ? ic->ic_value.index : (cc->aux.index - 1); - } - else { - index--; /* MJIT passes `cc->aux.index` as `index`. This will be `cc->aux.index - 1` */ - } + st_index_t index = !is_attr ? ic->ic_value.index : (cc->aux.index - 1); if (LIKELY(index < ROBJECT_NUMIV(obj))) { val = ROBJECT_IVPTR(obj)[index]; } } else { + st_data_t index; struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj); if (iv_index_tbl) { @@ -1064,7 +1060,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1060 static inline VALUE vm_getinstancevariable(VALUE obj, ID id, IC ic) { - return vm_getivar(obj, id, ic, NULL, 0, FALSE); + return vm_getivar(obj, id, ic, NULL, FALSE); } static inline void @@ -1948,7 +1944,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1944 vm_call_ivar(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc) { cfp->sp -= 1; - return vm_getivar(calling->recv, cc->me->def->body.attr.id, NULL, cc, 0, TRUE); + return vm_getivar(calling->recv, cc->me->def->body.attr.id, NULL, cc, TRUE); } static VALUE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/