diff options
author | Peter Zhu <[email protected]> | 2023-01-18 11:37:45 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-01-19 11:23:35 -0500 |
commit | 9af84c95d7349ec609789c2be9acb3aaa020bfeb (patch) | |
tree | 853d66f114c0432c1620c63d65de361f07cdcb79 /iseq.c | |
parent | 41bf2354e30fc585a61528560c291fd8ee77d107 (diff) |
Combine code paths for marking cc
This commit avoids a separate code path for marking and moving the
callcache of the iseq.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7140
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -310,14 +310,26 @@ rb_iseq_mark_and_update(rb_iseq_t *iseq, bool reference_updating) if (cds[i].ci) rb_gc_mark_and_move_ptr(&cds[i].ci); - if (cds[i].cc && (reference_updating || vm_cc_markable(cds[i].cc))) { - VM_ASSERT(reference_updating || (cds[i].cc->flags & VM_CALLCACHE_ON_STACK) == 0); - - if (reference_updating || !vm_cc_invalidated_p(cds[i].cc)) { - rb_gc_mark_and_move_ptr(&cds[i].cc); + const struct rb_callcache *cc = cds[i].cc; + if (cc) { + if (reference_updating) { + cc = (const struct rb_callcache *)rb_gc_location((VALUE)cc); } - else { - cds[i].cc = rb_vm_empty_cc(); + + if (vm_cc_markable(cc)) { + VM_ASSERT((cc->flags & VM_CALLCACHE_ON_STACK) == 0); + + const struct rb_callable_method_entry_struct *cme = vm_cc_cme(cc); + if (reference_updating) { + cme = (const struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)cme); + } + + if (cc->klass && !METHOD_ENTRY_INVALIDATED(cme)) { + rb_gc_mark_and_move_ptr(&cds[i].cc); + } + else { + cds[i].cc = rb_vm_empty_cc(); + } } } } |