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
420
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
540
社内の3名登壇へ貢献した話 〜若手よ生意気になれ〜
yuhisatoxxx
0
710
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1.7k
Wakate.rb #1
yuhisatoxxx
0
36
ひとりぼっちの新卒エンジニアが社外の同期50人と繋った話
yuhisatoxxx
0
310
24th Dev オープニング
yuhisatoxxx
0
270
コミュニティビジョン ~繋がりとキャリア~
yuhisatoxxx
0
310
遅延評価勉強法で良質な学びを
yuhisatoxxx
3
1.3k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
76
5.1k
How GitHub (no longer) Works
holman
316
150k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
180
Embracing the Ebb and Flow
colly
88
5k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
690
Everyday Curiosity
cassininazir
0
200
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
320
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
260
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
280
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
210
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