diff options
| author | Kunshan Wang <wks1986@gmail.com> | 2025-07-10 16:55:53 +0800 |
|---|---|---|
| committer | Alan Wu <XrXr@users.noreply.github.com> | 2025-07-14 16:21:55 -0400 |
| commit | 3a47f4eacf3cd755df9db554a0b5e40789611602 (patch) | |
| tree | 67b1213d000827254ee1366d1e4ece377f3df032 /include/ruby/internal/intern/select | |
| parent | 51a3ea5adeb452e51c119a395acfd5c87cc63735 (diff) | |
YJIT: Move RefCell one level down
This is the second part of making YJIT work with parallel GC.
During GC, `rb_yjit_iseq_mark` and `rb_yjit_iseq_update_references` need
to resolve offsets in `Block::gc_obj_offsets` into absolute addresses
before reading or updating the fields. This needs the base address
stored in `VirtualMemory::region_start` which was previously behind a
`RefCell`. When multiple GC threads scan multiple iseq simultaneously
(which is possible for some GC modules such as MMTk), it will panic
because the `RefCell` is already borrowed.
We notice that some fields of `VirtualMemory`, such as `region_start`,
are never modified once `VirtualMemory` is constructed. We change the
type of the field `CodeBlock::mem_block` from `Rc<RefCell<T>>` to
`Rc<T>`, and push the `RefCell` into `VirtualMemory`. We extract
mutable fields of `VirtualMemory` into a dedicated struct
`VirtualMemoryMut`, and store them in a field `VirtualMemory::mutable`
which is a `RefCell<VirtualMemoryMut>`. After this change, methods that
access immutable fields in `VirtualMemory`, particularly `base_ptr()`
which reads `region_start`, will no longer need to borrow any `RefCell`.
Methods that access mutable fields will need to borrow
`VirtualMemory::mutable`, but the number of borrowing operations becomes
strictly fewer than before because borrowing operations previously done
in callers (such as `CodeBlock::write_mem`) are moved into methods of
`VirtualMemory` (such as `VirtualMemory::write_bytes`).
Diffstat (limited to 'include/ruby/internal/intern/select')
0 files changed, 0 insertions, 0 deletions
