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
450
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
560
社内の3名登壇へ貢献した話 〜若手よ生意気になれ〜
yuhisatoxxx
0
740
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1.8k
Wakate.rb #1
yuhisatoxxx
0
40
ひとりぼっちの新卒エンジニアが社外の同期50人と繋った話
yuhisatoxxx
0
320
24th Dev オープニング
yuhisatoxxx
0
280
コミュニティビジョン ~繋がりとキャリア~
yuhisatoxxx
0
310
遅延評価勉強法で良質な学びを
yuhisatoxxx
3
1.3k
Featured
See All Featured
Visualization
eitanlees
152
17k
The Language of Interfaces
destraynor
162
27k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
How to Talk to Developers About Accessibility
jct
2
220
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
190
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
ラッコキーワード サービス紹介資料
rakko
1
3.5M
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
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