summaryrefslogtreecommitdiff
path: root/include/ruby/internal/intern
diff options
context:
space:
mode:
authorKunshan Wang <wks1986@gmail.com>2025-06-30 14:21:30 +0800
committerAlan Wu <XrXr@users.noreply.github.com>2025-07-14 16:21:55 -0400
commit51a3ea5adeb452e51c119a395acfd5c87cc63735 (patch)
tree99038ef6ffac631a942f848ae475adec82cc274e /include/ruby/internal/intern
parente288a86692694351278d0c3973881017b5b2e9c6 (diff)
YJIT: Set code mem permissions in bulk
Some GC modules, notably MMTk, support parallel GC, i.e. multiple GC threads work in parallel during a GC. Currently, when two GC threads scan two iseq objects simultaneously when YJIT is enabled, both threads will attempt to borrow `CodeBlock::mem_block`, which will result in panic. This commit makes one part of the change. We now set the YJIT code memory to writable in bulk before the reference-updating phase, and reset it to executable in bulk after the reference-updating phase. Previously, YJIT lazily sets memory pages writable while updating object references embedded in JIT-compiled machine code, and sets the memory back to executable by calling `mark_all_executable`. This approach is inherently unfriendly to parallel GC because (1) it borrows `CodeBlock::mem_block`, and (2) it sets the whole `CodeBlock` as executable which races with other GC threads that are updating other iseq objects. It also has performance overhead due to the frequent invocation of system calls. We now set the permission of all the code memory in bulk before and after the reference updating phase. Multiple GC threads can now perform raw memory writes in parallel. We should also see performance improvement during moving GC because of the reduced number of `mprotect` system calls.
Diffstat (limited to 'include/ruby/internal/intern')
0 files changed, 0 insertions, 0 deletions