How to implement a RubyVM with PHP?
summary
A Ruby VM written in PHP reads YARV binaries from disk, read binary YARV headers with fread/fseek/unpack, parses global-object and iseq offsets, implements readSmallValue and loadObject, and executes a tiny subset of bytecodes. The implementation handles only four opcodes for Hello World—putself putstring opt_send_without_block leave—while noting >50 metadata fields exist, ~100 opcodes are commonly used (≈200 total, +6 in 3.3). Repo is on GitHub and the demo runs Hello World and FizzBuzz.
AI-written summary · about
chapters (6)
- 0:00Introduction and motivation
- 5:24What is RubyVM and YARV
- 12:25Reading Ruby core code
- 20:21Processing instruction sequences
- 27:40Implementing bytecode execution
- 33:44Demo of RubyVM in PHP
related talks
30mGarnet.js: Implementing the YARV Virtual Machine
36mCompiling Ruby
38mRubyX: Compiling Ruby and it's effect on the community
32mExperiments in sharing Java VM technology with CRuby
29mA Rails Developer’s Guide To The Ruby VM
50mImplementing Virtual Machines in Ruby (and C)
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
40mCompiling Ruby
