Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby YARV Challenge: Build Your Own Bytecode V...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
yuhi
April 22, 2026
28
1
Share
Ruby YARV Challenge: Build Your Own Bytecode VM in 7 Steps
RubyKaigi 2026 Lightning Talks
yuhi
April 22, 2026
More Decks by yuhi
See All by yuhi
APIリファレンスを 読み込むと楽しい
yuhisatoxxx
0
510
社内の3名登壇へ貢献した話 〜若手よ生意気になれ〜
yuhisatoxxx
0
690
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1.7k
Wakate.rb #1
yuhisatoxxx
0
31
ひとりぼっちの新卒エンジニアが社外の同期50人と繋った話
yuhisatoxxx
0
300
24th Dev オープニング
yuhisatoxxx
0
270
コミュニティビジョン ~繋がりとキャリア~
yuhisatoxxx
0
310
遅延評価勉強法で良質な学びを
yuhisatoxxx
3
1.3k
Featured
See All Featured
Abbi's Birthday
coloredviolet
2
6.8k
Accessibility Awareness
sabderemane
0
99
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
200
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
710
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
420
Color Theory Basics | Prateek | Gurzu
gurzu
0
290
Speed Design
sergeychernyshev
33
1.6k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Mind Mapping
helmedeiros
PRO
1
150
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
180
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
Transcript
Ruby YARV Challenge: Build Your Own Bytecode VM in 7
Steps yuhi(@yuhi_junior) RubyKaigi 2026 Lightning Talks 2026-04-22 #rubykaigiA
2 SmartBank, Inc. Software Engineer yuhi @yuhi_junior @Yuhi-Sato Self Introduction
Get Your Board43! @ HackSpace
• A browser-based workshop • Build simplified YARV bytecode and
compiler in Ruby • Tutorials + hints at every step What’s “Ruby YARV Challenge”?
None
Motivation • The problem ◦ Stack machines and bytecode are
unfamiliar concepts. ◦ YARV is written in C — hard to read for many Rubyists. • The solution ◦ Tutorials + hints guide you from zero — no prior VM knowledge needed. ◦ Reimplement YARV-like bytecode and compiler in Ruby — no C required
Where you implement the code bytecode (ISeq) AST Ruby code
VM Exec parser compiler
Where you implement the code Prism Ruby API bytecode (ISeq)
AST Ruby code VM Exec parser compiler
Where you implement the code yruby bytecode (ISeq) AST Ruby
code VM Exec parser compiler
Where you implement the code Workshop code bytecode (ISeq) AST
Ruby code VM Exec parser compiler
Goal Define and execute recursive Fibonacci on VM
7 steps to reach the goal 1. Literal values (putobject)
2. Addition (opt_plus) 3. Subtraction (opt_minus) 4. Local variables (getlocal, setlocal, dup) 5. Comparison (opt_lt) 6. Control flow (branchunless, jump) 7. Method definition and dispatch (definemethod, opt_send_without_block)
7 steps to reach the goal 1. Literal values (putobject)
2. Addition (opt_plus) 3. Subtraction (opt_minus) 4. Local variables (getlocal, setlocal, dup) 5. Comparison (opt_lt) 6. Control flow (branchunless, jump) 7. Method definition and dispatch (definemethod, opt_send_without_block)
Step 2: Addition • bytecode ◦ opt_plus • compile ◦
IntegerNode (Step 1) ◦ ArgumentsNode ◦ CallNode name: +
opt_plus opt_plus 1. pop two values 2. push the sum
1 2
opt_plus opt_plus 1. pop two values 2. push the sum
1 2
opt_plus opt_plus 1. pop two values 2. push the sum
1 2
opt_plus opt_plus 1. pop two values 2. push the sum
3
Compiler CallNode name: + IntegerNode value: 1 ArgumentsNode arguments: [2]
receiver arguments putobject 1 putobject 2 opt_plus AST bytecode
Demo: Step 2 URL: https://yuhi-sato.github.io/ruby-yarv-challenge
Let’s try! URL: https://yuhi-sato.github.io/ruby-yarv-challenge
None
Workshop UI
Workshop UI: Tutorial left pane
Workshop UI: Code center pane
Workshop UI: Results right pane
Step 2: Addition CallNode name: + IntegerNode value: 1 ArgumentsNode
arguments: [2] receiver arguments putobject 1 putobject 2 opt_plus AST bytecode
Step 2: Addition CallNode name: + IntegerNode value: 1 ArgumentsNode
arguments: [2] receiver arguments putobject 1 putobject 2 opt_plus AST bytecode
Step 2: Addition • bytecode ◦ opt_plus • compile ◦
IntegerNode (Step 1) ◦ ArgumentsNode ◦ CallNode name: +
Step 2: Addition CallNode name: + IntegerNode value: 1 ArgumentsNode
arguments: [2] receiver arguments putobject 1 putobject 2 opt_plus AST bytecode
Step 2: Addition • bytecode ◦ opt_plus • compile ◦
IntegerNode (Step 1) ◦ ArgumentsNode ◦ CallNode name: +
Step 2: Addition CallNode name: + IntegerNode value: 1 ArgumentsNode
arguments: [2] receiver arguments • compile_integer_node (Step 1) • compile_arguments_node • compile_binary_plus putobject 1 putobject 2 opt_plus
Step 2: Addition CallNode name: + IntegerNode value: 1 ArgumentsNode
arguments: [2] receiver arguments • compile_integer_node (Step 1) • compile_arguments_node • compile_binary_plus
Step 2: Addition • compile_integer_node (Step 1) • compile_arguments_node •
compile_binary_plus CallNode name: + IntegerNode value: 1 ArgumentsNode arguments: [2] receiver arguments
Step 2: Addition • compile_integer_node (Step 1) • compile_arguments_node •
compile_binary_plus CallNode name: + IntegerNode value: 1 ArgumentsNode arguments: [2] receiver arguments
Inspirations