ruby/yjit
Kunshan Wang 3a47f4eacf 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`).
2025-07-14 16:21:55 -04:00
..
bindgen ZJIT: Mark profiled objects when marking ISEQ (#13784) 2025-07-09 16:03:23 -07:00
src YJIT: Move RefCell one level down 2025-07-14 16:21:55 -04:00
.gitignore
Cargo.lock Bump capstone from 0.12.0 to 0.13.0 in /yjit 2025-02-05 11:37:34 +09:00
Cargo.toml YJIT: ZJIT: Allow both JITs in the same build 2025-05-15 00:39:03 +09:00
not_gmake.mk Define ZJIT libs for non-gmake 2025-04-18 21:52:55 +09:00
yjit.mk YJIT: ZJIT: Allow both JITs in the same build 2025-05-15 00:39:03 +09:00