Get the latest tech news

How Ruby executes JIT code


Where does JIT-compiled code live? How does Ruby switch between bytecode and native execution? Why does TracePoint slow everything down? This post answers the JIT questions most Ruby developers have but rarely see explained.

Ever since YJIT’s introduction, I’ve felt simultaneously close to and distant from Ruby’s JIT compiler. Because Ruby doesn’t know what opt_plus would be called with beforehand, the underlying C function vm_opt_plus needs to handle various classes (like String, Array, Float, Integer, etc.) Therefore, when ZJIT and YJIT compilers detect TracePoint’s activation, they immediately throw away the optimized code to force Ruby to interpret YARV instructions instead.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of magic

magic

Photo of ruby

ruby

Photo of jit code

jit code

Related news:

News photo

Rivian CEO: There's No 'Magic' Behind China's Low-Cost EVs

News photo

"It's a classic title for the genre" Final Fantasy Tactics: The Ivalice Chronicles directors talk difficulty tweaks, new features, and preserving a seminal title's magic

News photo

Show HN: AfriTales – Discover the Magic of African Storytelling