Skip to content

Commit 3e21b7f

Browse files
committed
Invalidate CC when they're not garbage
This is less than ideal but we need this to invalidate callcaches when callcache entries for a method ID are removed from a class’s cc_table.
1 parent a55cc8b commit 3e21b7f

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

imemo.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -537,22 +537,19 @@ rb_free_const_table(struct rb_id_table *tbl)
537537

538538
// alive: if false, target pointers can be freed already.
539539
static void
540-
vm_ccs_free(struct rb_class_cc_entries *ccs, int alive, VALUE klass)
540+
vm_ccs_free(struct rb_class_cc_entries *ccs)
541541
{
542542
if (ccs->entries) {
543543
for (int i=0; i<ccs->len; i++) {
544544
const struct rb_callcache *cc = ccs->entries[i].cc;
545-
if (!alive) {
546-
// ccs can be free'ed.
547-
if (rb_gc_pointer_to_heap_p((VALUE)cc) &&
548-
!rb_objspace_garbage_object_p((VALUE)cc) &&
549-
IMEMO_TYPE_P(cc, imemo_callcache) &&
550-
cc->klass == klass) {
551-
// OK. maybe target cc.
552-
}
553-
else {
554-
continue;
555-
}
545+
if (rb_gc_pointer_to_heap_p((VALUE)cc) &&
546+
!rb_objspace_garbage_object_p((VALUE)cc) &&
547+
IMEMO_TYPE_P(cc, imemo_callcache)) {
548+
// OK. maybe target cc.
549+
}
550+
else {
551+
/* rb_bug("Freeing garbage cc"); */
552+
continue;
556553
}
557554

558555
VM_ASSERT(!vm_cc_super_p(cc) && !vm_cc_refinement_p(cc));
@@ -567,7 +564,7 @@ void
567564
rb_vm_ccs_free(struct rb_class_cc_entries *ccs)
568565
{
569566
RB_DEBUG_COUNTER_INC(ccs_free);
570-
vm_ccs_free(ccs, true, Qundef);
567+
vm_ccs_free(ccs);
571568
}
572569

573570
static inline void

0 commit comments

Comments
 (0)