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.
Or read this on Hacker News