Some Assembly Required
summary
Builds a pure Ruby JIT called TenderJIT that actually emits x86 machine bytes with an assembler library fisk, writes them into executable memory and calls them, and patches Ruby internals using fiddle and odinflex to install a jit_func. Shows a working pipeline that turns YARV instruction sequences into machine code, records a benchmark (interpreted ~10s vs jitted ~4s) and demos setting a jit to return 42, proving the approach works end to end.
AI-written summary · about
chapters (15)
- 0:00Start
- 6:04Fibonacci Benchmark
- 8:40Generate Machine Code
- 9:39ERB Template
- 11:41Stack Machine
- 14:20Register Machine
- 15:29x86 Instructions
- 20:29Access Instruction From Ruby
- 20:56Mini YARV
- 22:52Integrate Virtual Stack
- 24:03Execution Example
- 24:46Refactor To a Method
- 26:45Update Virtual Stack
- 29:17CFP: Control Frame Pointer One per stack frame
- 29:45ISeq: Instruction Sequence One per "executable code"
related talks
20mBYOJ: Build your own JIT with Ruby
32mExperiments in sharing Java VM technology with CRuby
37mKeynote: YJIT's Three Languages: the Fun of Code that Writes Code
57mRuby: 2020
20mEvaluating YJIT’s Performance in a Production Context: A Pragmatic Approach
36mCompiling Ruby
29mRuby Internals: A Guide For Rails Developers
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
