diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-07-30 16:51:59 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2025-08-01 10:42:04 +0200 |
| commit | 547f111b5b0d773af2a4268fe407fdacc7060109 (patch) | |
| tree | 23d9c77e2bdc54e29cf2cff352e8226c4776d20a /imemo.c | |
| parent | f2a7e48deadb9101d49c9b613abf5a83c9e1dd49 (diff) | |
Refactor `vm_lookup_cc` to allow lock-free lookups in `RClass.cc_tbl`
In multi-ractor mode, the `cc_tbl` mutations use the RCU pattern,
which allow lock-less reads.
Based on the assumption that invalidations and misses should be
increasingly rare as the process ages, locking on modification
isn't a big concern.
Diffstat (limited to 'imemo.c')
| -rw-r--r-- | imemo.c | 35 |
1 files changed, 0 insertions, 35 deletions
@@ -515,41 +515,6 @@ rb_free_const_table(struct rb_id_table *tbl) rb_id_table_free(tbl); } -// alive: if false, target pointers can be freed already. -static void -vm_ccs_free(struct rb_class_cc_entries *ccs, int alive, VALUE klass) -{ - if (ccs->entries) { - for (int i=0; i<ccs->len; i++) { - const struct rb_callcache *cc = ccs->entries[i].cc; - if (!alive) { - // ccs can be free'ed. - if (rb_gc_pointer_to_heap_p((VALUE)cc) && - !rb_objspace_garbage_object_p((VALUE)cc) && - IMEMO_TYPE_P(cc, imemo_callcache) && - cc->klass == klass) { - // OK. maybe target cc. - } - else { - continue; - } - } - - VM_ASSERT(!vm_cc_super_p(cc) && !vm_cc_refinement_p(cc)); - vm_cc_invalidate(cc); - } - ruby_xfree(ccs->entries); - } - ruby_xfree(ccs); -} - -void -rb_vm_ccs_free(struct rb_class_cc_entries *ccs) -{ - RB_DEBUG_COUNTER_INC(ccs_free); - vm_ccs_free(ccs, true, Qundef); -} - static inline void imemo_fields_free(struct rb_fields *fields) { |
