Implementing Virtual Machines in Ruby (and C)
summary
Shows a concrete VM design and several runnable implementations: a simple opcode set (push add print exit) with a dispatch loop, a Ruby version that compiles opcodes to direct calls, and a tiny C interpreter that compiles dispatch tables. Demonstrates a working loop counting 13 down to 0, sandboxing by blacklisting methods, and experiments with indirect/direct threading and JITting machine code. Uses 20 lines of C for the core demo, uses Fiddle/FFI and malloc and claims a theoretical 100-fold speedup for threaded dispatch.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 0:56Machine Philosophy
- 2:53Emulation
- 5:11What is a VM
- 7:16What is a computer
- 13:00C
- 15:51Program Interpretation
- 17:22Optimize Dispatch
- 20:10Blacklist
- 22:53Interpreter
- 25:10Dispatch Loop
- 30:10Dispatch Compilation
- 33:15Virtual Machine V1
- 40:05Register Machines
- 43:35Ruby assembler
- 46:45Books
related talks
24mOne machine please, make it Turing
32mExperiments in sharing Java VM technology with CRuby
40mImplementation Details of Ruby 2.0 VM
38mRubyX: Compiling Ruby and it's effect on the community
29mA Rails Developer’s Guide To The Ruby VM
45mFuture of RubyVM
41mCoding like it’s 1977: Ruby on the Apple ][
39mInside Ruby's VM: The TMI Edition.
