Skip to content

Commit a0575cf

Browse files
committed
Store class in rb_class_cc_entries
We need the class to not invalidate unrelated callcaches. By moving to a VALUE object for the callcache table, we don't have access to the class to which it belongs anymore, so we can store it here.
1 parent 635bf6c commit a0575cf

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

vm_callinfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ struct rb_class_cc_entries {
563563
int capa;
564564
int len;
565565
const struct rb_callable_method_entry_struct *cme;
566+
const VALUE klass; // for checking which CCs should be invalidated
566567
struct rb_class_cc_entries_entry {
567568
unsigned int argc;
568569
unsigned int flag;

vm_insnhelper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,7 @@ vm_ccs_create(VALUE klass, VALUE cc_tbl, ID mid, const rb_callable_method_entry_
19901990
#endif
19911991
ccs->capa = 0;
19921992
ccs->len = 0;
1993+
*(VALUE *)&ccs->klass = klass;
19931994
ccs->cme = cme;
19941995
METHOD_ENTRY_CACHED_SET((rb_callable_method_entry_t *)cme);
19951996
ccs->entries = NULL;
@@ -2018,6 +2019,7 @@ vm_ccs_push(VALUE klass, struct rb_class_cc_entries *ccs, const struct rb_callin
20182019
}
20192020
}
20202021
VM_ASSERT(ccs->len < ccs->capa);
2022+
VM_ASSERT(ccs->klass == klass);
20212023

20222024
const int pos = ccs->len++;
20232025
ccs->entries[pos].argc = vm_ci_argc(ci);

vm_method.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ compact_cc_entry_i(VALUE ccs_ptr, void *data)
123123

124124
ccs->cme = (const struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)ccs->cme);
125125
VM_ASSERT(vm_ccs_p(ccs));
126+
*(VALUE *)&ccs->klass = rb_gc_location(ccs->klass);
126127

127128
for (int i=0; i<ccs->len; i++) {
128129
ccs->entries[i].cc = (const struct rb_callcache *)rb_gc_location((VALUE)ccs->entries[i].cc);

0 commit comments

Comments
 (0)