In the code base, the reference implementation of the language, Ruby, has introduced a new JIT compiler called ZJIT. This JIT compiler is positioned as the next generation of Ruby Jit and will be included in the upcoming significant release of Ruby 3.5. It will be available as an option alongside the JIT compiler YJIT and may replace it in Ruby 3.6. ZJIT, like YJIT, is written in the language Rust and was developed by a team of developers from Shopify as part of the Ruby Program Extension Initiative aimed at enhancing the Rails framework and optimizing numerous methods.
Unlike YJIT, the ZJIT compiler does not bypass the YARV virtual machine with a low-level intermediate representation but rather converts bytecode into high-level SSA (Static Single Assignment). This allows for additional optimization phases and optimizations targeting large blocks of code rather than individual operations.
ZJIT performs compilation of whole methods at once, in contrast to YJIT, which could only manipulate the compilation of basic blocks. To profile, ZJIT uses a classic JIT architecture based on historical data on types gathered by the interpreter, as opposed to the base block technology employed by YJIT (LBBV – Lazy Basic Block Versioning).
The use of a high-level intermediate representation in ZJIT will address the extension issues encountered with YJIT, lay the groundwork for multi-level JIT compilation in the future, enable advanced optimizations such as more aggressive Inlin-expulsion, and facilitate JIT adaptation for various platforms. By reverting to traditional type profiling methods, the code will be less complex and more accessible to new contributors, as the use of LBBV in YJIT made the project challenging for external developers, limiting its development to Shopify employees only.