ZJIT has been merged into Ruby
a year ago
- #Ruby
- #Programming
- #JIT Compilation
- ZJIT, a new just-in-time (JIT) compiler for Ruby, has been merged into the reference Ruby implementation, YARV.
- ZJIT differs from YJIT by using a high-level SSA-based intermediate representation (HIR), compiling entire methods at once, and leveraging historical type information from the profiled interpreter.
- The ZJIT compiler pipeline includes transforming YARV bytecode into HIR, optimizing HIR, lowering to a low-level IR (LIR), and finally emitting machine code.
- ZJIT introduces optimizations like type specialization with GuardType instructions and efficient arithmetic operations like FixnumAdd.
- Future plans for ZJIT include implementing side-exits for better interpreter integration, running the Ruby test suite, and benchmarking performance against YJIT.
- Ruby 3.5 will ship with both YJIT and ZJIT, with ongoing development to bring ZJIT to feature and performance parity with YJIT.