summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-11-06 11:33:43 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2020-11-09 09:44:16 -0800
commit5582c5a2327d824e872f7f5bd22330094f189d66 (patch)
tree7c1dd030af9aa17bc082f31b3ee195e10286cf11 /vm_insnhelper.c
parenteb229994e5b53e201e776ea103970751d3b1725b (diff)
Remove iv table size check
iv tables cannot shrink. If the inline cache was ever set, then there must be an entry for the instance variable in the iv table. Just set the iv list on the object to be equal to the iv index table size, then set the iv.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3740
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index f8b2f707ca..d54a7e3b6d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1213,21 +1213,14 @@ vm_setivar(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic, const str
VALUE *ptr = ROBJECT_IVPTR(obj);
index = !is_attr ? ic->entry->index : vm_cc_attr_index(cc)-1;
- if (index < ROBJECT_NUMIV(obj)) {
- RB_OBJ_WRITE(obj, &ptr[index], val);
- RB_DEBUG_COUNTER_INC(ivar_set_ic_hit);
- return val; /* inline cache hit */
- } else {
- st_table * iv_idx_tbl = RCLASS_IV_INDEX_TBL(rb_class_real(klass));
- if (index < iv_idx_tbl->num_entries) {
- rb_init_iv_list(obj, ROBJECT_NUMIV(obj), iv_idx_tbl->num_entries, iv_idx_tbl);
- ptr = ROBJECT_IVPTR(obj);
- RB_OBJ_WRITE(obj, &ptr[index], val);
- RB_DEBUG_COUNTER_INC(ivar_set_ic_hit);
- return val; /* inline cache hit */
- }
+ if (index >= ROBJECT_NUMIV(obj)) {
+ st_table * iv_idx_tbl = ROBJECT_IV_INDEX_TBL(obj);
+ rb_init_iv_list(obj, ROBJECT_NUMIV(obj), (uint32_t)iv_idx_tbl->num_entries, iv_idx_tbl);
+ ptr = ROBJECT_IVPTR(obj);
}
- RB_DEBUG_COUNTER_INC(ivar_set_ic_miss_oorange);
+ RB_OBJ_WRITE(obj, &ptr[index], val);
+ RB_DEBUG_COUNTER_INC(ivar_set_ic_hit);
+ return val; /* inline cache hit */
}
else {
struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);