Project

General

Profile

« Previous | Next » 

Revision 51a3ea5a

Added by wks (Kunshan Wang) 6 days ago

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.