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
48
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
520
社内の3名登壇へ貢献した話 〜若手よ生意気になれ〜
yuhisatoxxx
0
700
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1.7k
Wakate.rb #1
yuhisatoxxx
0
32
ひとりぼっちの新卒エンジニアが社外の同期50人と繋った話
yuhisatoxxx
0
300
24th Dev オープニング
yuhisatoxxx
0
270
コミュニティビジョン ~繋がりとキャリア~
yuhisatoxxx
0
310
遅延評価勉強法で良質な学びを
yuhisatoxxx
3
1.3k
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
GraphQLとの向き合い方2022年版
quramy
50
15k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Bash Introduction
62gerente
615
210k
Navigating Weather and Climate Data
rabernat
0
170
The SEO identity crisis: Don't let AI make you average
varn
0
450
KATA
mclloyd
PRO
35
15k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
530
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
190
How to build a perfect <img>
jonoalderson
1
5.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.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