From 1bf0d3617172da9fe8b5e99796d8d85412c14f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Mon, 22 Jun 2020 11:07:26 +0900 Subject: vm_getivar: do not goto into a branch I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. --- vm_insnhelper.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 5c85d14967..294099b58f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1080,23 +1080,7 @@ vm_getivar(VALUE obj, ID id, IVC ic, const struct rb_callcache *cc, int is_attr) iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj); numiv = ROBJECT_NUMIV(obj); ivptr = ROBJECT_IVPTR(obj); - - fill: - if (iv_index_tbl) { - if (st_lookup(iv_index_tbl, id, &index)) { - if (!is_attr) { - ic->index = index; - ic->ic_serial = RCLASS_SERIAL(RBASIC(obj)->klass); - } - else { /* call_info */ - vm_cc_attr_index_set(cc, (int)index + 1); - } - - if (index < numiv) { - val = ivptr[index]; - } - } - } + goto fill; } else if (FL_TEST_RAW(obj, FL_EXIVAR)) { struct gen_ivtbl *ivtbl; @@ -1107,12 +1091,32 @@ vm_getivar(VALUE obj, ID id, IVC ic, const struct rb_callcache *cc, int is_attr) iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj)); goto fill; } + else { + goto ret; + } } else { // T_CLASS / T_MODULE goto general_path; } + fill: + if (iv_index_tbl) { + if (st_lookup(iv_index_tbl, id, &index)) { + if (!is_attr) { + ic->index = index; + ic->ic_serial = RCLASS_SERIAL(RBASIC(obj)->klass); + } + else { /* call_info */ + vm_cc_attr_index_set(cc, (int)index + 1); + } + + if (index < numiv) { + val = ivptr[index]; + } + } + } + ret: if (LIKELY(val != Qundef)) { return val; -- cgit v1.2.3