From ac23fa09029a2db4045b03b377133f770cb25327 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 20 May 2025 15:34:47 -0400 Subject: [PATCH] Use rb_id_table_foreach_values for mark_cc_tbl We don't need the key, so we can improve performance by only iterating on the value. This will also fix the MMTk build because looking up the key in rb_id_table_foreach requires locking the VM, which is not supported in the MMTk worker threads. --- gc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index 322c8ca713..8cba7fbac8 100644 --- a/gc.c +++ b/gc.c @@ -2828,12 +2828,11 @@ struct mark_cc_entry_args { }; static enum rb_id_table_iterator_result -mark_cc_entry_i(ID id, VALUE ccs_ptr, void *data) +mark_cc_entry_i(VALUE ccs_ptr, void *data) { struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_ptr; VM_ASSERT(vm_ccs_p(ccs)); - VM_ASSERT(id == ccs->cme->called_id); if (METHOD_ENTRY_INVALIDATED(ccs->cme)) { rb_vm_ccs_free(ccs); @@ -2861,7 +2860,7 @@ mark_cc_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl, VALUE klass) args.objspace = objspace; args.klass = klass; - rb_id_table_foreach(tbl, mark_cc_entry_i, (void *)&args); + rb_id_table_foreach_values(tbl, mark_cc_entry_i, (void *)&args); } static enum rb_id_table_iterator_result