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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-10-13 14:03:48 +00:00
Родитель 5f9f9013da
Коммит e4eb6e3342
1 изменённых файлов: 7 добавлений и 11 удалений

Просмотреть файл

@ -955,28 +955,24 @@ vm_search_const_defined_class(const VALUE cbase, ID id)
#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, IC ic, struct rb_call_cache *cc, int is_
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
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