How Ruby Executes JIT Code: The Hidden Mechanics Behind the Magic | Rails at Scale
12-Sep-2025 63
Ever since YJIT’s introduction, I’ve felt simultaneously close to and distant from Ruby’s JIT compiler. I know how to enable it in my Ruby programs. I know it makes my Ruby programs run faster by compiling some of them into machine code. But my understanding around YJIT, or JIT compilers in Ruby in general, seems to end here.
A few months ago, my colleague Max Bernstein wrote ZJIT has been merged into Ruby to explain how ZJIT compiles Ruby’s bytecode to HIR, LIR, and then to native code. It sheds some light on how JIT compilers can compile our program, which is why I started to contribute to ZJIT in July. But I still had many questions unanswered before digging into the source code and asking the JIT experts around me (Max, Kokubun, and Alan).
So I want to use this post to answer some questions/mental gaps you might also have about JIT compilers for Ruby:
.
How Ruby Executes JIT Code: The Hidden Mechanics Behind the Magic | Rails at Scale #ruby #rubydeveloper #rubyonrails #Executes #Code: #Hidden #Mechanics #Behind #Magic #Rails #Scale #code: https://rubyonrails.ba/link/how-ruby-executes-jit-code-the-hidden-mechanics-behind-the-magic-rails-at-scale