From 322548180d01ce99dcb8ecb3c36f2a9261554657 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Thu, 31 Aug 2023 15:35:56 +0100 Subject: [PATCH] Prevent rb_gc_mark_values from pinning objects This is an internal only function not exposed to the C extension API. It's only use so far is from rb_vm_mark, where it's used to mark the values in the vm->trap_list.cmd array. There shouldn't be any reason why these cannot move. This commit allows them to move by updating their references during the reference updating step of compaction. To do this we've introduced another internal function rb_gc_update_values as a partner to rb_gc_mark_values. This allows us to refactor rb_gc_mark_values to not pin --- gc.c | 8 +++++++- internal/gc.h | 1 + vm.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 59c507369e..d780bb0613 100644 --- a/gc.c +++ b/gc.c @@ -6348,7 +6348,7 @@ rb_gc_mark_values(long n, const VALUE *values) rb_objspace_t *objspace = &rb_objspace; for (i=0; ioverloaded_cme_table); + rb_gc_update_values(RUBY_NSIG, vm->trap_list.cmd); + if (vm->coverages) { vm->coverages = rb_gc_location(vm->coverages); vm->me2counter = rb_gc_location(vm->me2counter);