ZJIT, the new JIT compiler for Ruby, has landed a global register allocator replacing the local one inherited from YJIT. The post explains register allocation fundamentals including lifetimes/live ranges, interference graphs, and the linear scan algorithm based on Christian Wimmer's paper. It contrasts local vs. global allocation: the old local allocator only tracked lifetimes within a single basic block, requiring values to be spilled at block boundaries, while the new global allocator spans entire functions. This enables keeping values in registers across block boundaries, simplifies optimization passes that manipulate basic blocks, and is a prerequisite for method inlining now actively in progress. The post also previews future work on lifetime holes to enable more aggressive register reuse.

12m read timeFrom railsatscale.com
Post cover image
Table of contents
What is a register allocator?How does it work?Where we are now
2.8K Impressions