summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-12-21 14:06:02 +0900
committerKoichi Sasada <ko1@atdot.net>2021-12-21 15:21:30 +0900
commitad450c9fe51c51626dd07f6e766f47d839cae3ba (patch)
treef61545a929b263b3df661cd02b8affca12f12637 /vm.c
parent3c7e95966d6b9efd201170eb59b0e4a3c4eb6134 (diff)
make `overloaded_cme_table` truly weak key map
`overloaded_cme_table` keeps cme -> monly_cme pairs to manage corresponding `monly_cme` for `cme`. The lifetime of the `monly_cme` should be longer than `monly_cme`, but the previous patch losts the reference to the living `monly_cme`. Now `overloaded_cme_table` values are always root (keys are only weak reference), it means `monly_cme` does not freed until corresponding `cme` is invalidated. To make managing easy, move `overloaded_cme_table` to `rb_vm_t`.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5316
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index 0d423cd979..287fe2547d 100644
--- a/vm.c
+++ b/vm.c
@@ -2540,6 +2540,8 @@ rb_vm_update_references(void *ptr)
vm->top_self = rb_gc_location(vm->top_self);
vm->orig_progname = rb_gc_location(vm->orig_progname);
+ rb_gc_update_tbl_refs(vm->overloaded_cme_table);
+
if (vm->coverages) {
vm->coverages = rb_gc_location(vm->coverages);
vm->me2counter = rb_gc_location(vm->me2counter);
@@ -2637,9 +2639,10 @@ rb_vm_mark(void *ptr)
rb_mark_tbl(vm->loading_table);
}
- rb_gc_mark_values(RUBY_NSIG, vm->trap_list.cmd);
+ rb_gc_mark_values(RUBY_NSIG, vm->trap_list.cmd);
rb_id_table_foreach_values(vm->negative_cme_table, vm_mark_negative_cme, NULL);
+ rb_mark_tbl_no_pin(vm->overloaded_cme_table);
for (i=0; i<VM_GLOBAL_CC_CACHE_TABLE_SIZE; i++) {
const struct rb_callcache *cc = vm->global_cc_cache_table[i];
@@ -3801,6 +3804,7 @@ Init_BareVM(void)
vm->objspace = rb_objspace_alloc();
ruby_current_vm_ptr = vm;
vm->negative_cme_table = rb_id_table_create(16);
+ vm->overloaded_cme_table = st_init_numtable();
Init_native_thread(th);
th->vm = vm;