diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2023-06-01 14:55:36 -0700 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2023-06-01 14:55:36 -0700 |
commit | 10621f7cb9a0c70e568f89cce47a02e878af6778 (patch) | |
tree | cb8ce96582f7780a8093be1239689f768c74e6e5 /vm_insnhelper.c | |
parent | 2d2893f206b1ff012ac68bddbeb860ca737b765f (diff) | |
download | ruby-10621f7cb9a0c70e568f89cce47a02e878af6778.tar.gz |
Revert "Fix cvar caching when class is cloned"
This reverts commit 77d1b082470790c17c24a2f406b4fec5d522636b.
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 5ef1ad10de..9407a75981 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1491,7 +1491,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_index_t i } static VALUE -update_classvariable_cache(const rb_iseq_t *iseq, VALUE klass, ID id, const rb_cref_t * cref, ICVARC ic) +update_classvariable_cache(const rb_iseq_t *iseq, VALUE klass, ID id, ICVARC ic) { VALUE defined_class = 0; VALUE cvar_value = rb_cvar_find(klass, id, &defined_class); @@ -1511,13 +1511,9 @@ update_classvariable_cache(const rb_iseq_t *iseq, VALUE klass, ID id, const rb_c } struct rb_cvar_class_tbl_entry *ent = (void *)ent_data; - ent->global_cvar_state = GET_GLOBAL_CVAR_STATE(); - ent->cref = cref; - ic->entry = ent; - RUBY_ASSERT(BUILTIN_TYPE((VALUE)cref) == T_IMEMO && IMEMO_TYPE_P(cref, imemo_cref)); - RB_OBJ_WRITTEN(iseq, Qundef, ent->cref); + ic->entry = ent; RB_OBJ_WRITTEN(iseq, Qundef, ent->class_value); return cvar_value; @@ -1527,9 +1523,8 @@ static inline VALUE vm_getclassvariable(const rb_iseq_t *iseq, const rb_control_frame_t *reg_cfp, ID id, ICVARC ic) { const rb_cref_t *cref; - cref = vm_get_cref(GET_EP()); - if (ic->entry && ic->entry->global_cvar_state == GET_GLOBAL_CVAR_STATE() && ic->entry->cref == cref && LIKELY(rb_ractor_main_p())) { + if (ic->entry && ic->entry->global_cvar_state == GET_GLOBAL_CVAR_STATE() && LIKELY(rb_ractor_main_p())) { RB_DEBUG_COUNTER_INC(cvar_read_inline_hit); VALUE v = rb_ivar_lookup(ic->entry->class_value, id, Qundef); @@ -1538,9 +1533,10 @@ vm_getclassvariable(const rb_iseq_t *iseq, const rb_control_frame_t *reg_cfp, ID return v; } + cref = vm_get_cref(GET_EP()); VALUE klass = vm_get_cvar_base(cref, reg_cfp, 1); - return update_classvariable_cache(iseq, klass, id, cref, ic); + return update_classvariable_cache(iseq, klass, id, ic); } VALUE @@ -1553,20 +1549,20 @@ static inline void vm_setclassvariable(const rb_iseq_t *iseq, const rb_control_frame_t *reg_cfp, ID id, VALUE val, ICVARC ic) { const rb_cref_t *cref; - cref = vm_get_cref(GET_EP()); - if (ic->entry && ic->entry->global_cvar_state == GET_GLOBAL_CVAR_STATE() && ic->entry->cref == cref && LIKELY(rb_ractor_main_p())) { + if (ic->entry && ic->entry->global_cvar_state == GET_GLOBAL_CVAR_STATE()) { RB_DEBUG_COUNTER_INC(cvar_write_inline_hit); rb_class_ivar_set(ic->entry->class_value, id, val); return; } + cref = vm_get_cref(GET_EP()); VALUE klass = vm_get_cvar_base(cref, reg_cfp, 1); rb_cvar_set(klass, id, val); - update_classvariable_cache(iseq, klass, id, cref, ic); + update_classvariable_cache(iseq, klass, id, ic); } void |