503 Views
May 14, 26
スライド概要
@Omotesando.rb #121
MEDLEY × mov RubyKaigi事後勉強会との共同開催
Professional Ruby and Rails programmer in Tokyo.
自分の仮想機械を作る @Omotesando.rb #121 MEDLEY × mov RubyKaigi事後勉強会との共同開催
もとつねの日常 @daily_mototsune Ruby on Railsを中心に扱っているフリーランスエンジニア ドメインモデリングからAWSでの運用、スクラム運営やチームビルディ ングなどなど楽しくやらせてもらってます 普段はOmotesando.rbやGinza.rbによくいます 🍷♨✈🏎
RubyKaigi楽しかったですね
お気に入りのセッションは なんでしたか?
私はVM話が好物でした
and more!
mruby in the 8-bit world: mruby VM for Zilog Z80 「Build your own VM」
は?
作るかー
そもそもVMとは - Virtual Machine(仮想機械) ユーザーが書いたコードを元にバイトコードが生成され、VMがバイトコードを 読んで実行する Rubyでは1.9からYARVというスタックVMが採用されている それ以前はtree-walking interpreter
バイトコードを見てみる
1
2 1
3 2 1
2 1 .*( 3 )
6 1
6 1
1 .+( 6 )
7
なんかいけそうな気がしてきた
RubyVM::INSTRUCTION_NAMES ["nop", "getlocal", "setlocal", "getblockparam", "setblockparam", "getblockparamproxy", "getspecial", "setspecial", "getinstancevariable", "setinstancevariable", "getclassvariable", "setclassvariable", "opt_getconstant_path", "getconstant", "setconstant", "getglobal", "setglobal", "putnil", "putself", "putobject", "putspecialobject", "putstring", "putchilledstring", "concatstrings", "anytostring", "toregexp", "intern", "newarray", "pushtoarraykwsplat", "duparray", "duphash", "expandarray", "concatarray", "concattoarray", "pushtoarray", "splatarray", "splatkw", "newhash", "newrange", "pop", "dup", "dupn", "swap", "opt_reverse", "topn", "setn", "adjuststack", "defined", "definedivar", "checkmatch", "checkkeyword", "checktype", "defineclass", "definemethod", "definesmethod", "send", "sendforward", "opt_send_without_block", "opt_new", "objtostring", "opt_ary_freeze", "opt_hash_freeze", "opt_str_freeze", "opt_nil_p", "opt_str_uminus", "opt_duparray_send", "opt_newarray_send", "invokesuper", "invokesuperforward", "invokeblock", "leave", "throw", "jump", "branchif", "branchunless", "branchnil", "once", "opt_case_dispatch", "opt_plus", "opt_minus", "opt_mult", "opt_div", "opt_mod", "opt_eq", "opt_neq", "opt_lt", "opt_le", "opt_gt", "opt_ge", "opt_ltlt", "opt_and", "opt_or", "opt_aref",
なんかいけなさそうな 気がしてきた
RubyVM::INSTRUCTION_NAMES ["nop", "getlocal", "setlocal", "getblockparam", "setblockparam", "getblockparamproxy", "getspecial", "setspecial", "getinstancevariable", "setinstancevariable", "getclassvariable", "setclassvariable", "opt_getconstant_path", "getconstant", "setconstant", "getglobal", "setglobal", "putnil", "putself", "putobject", "putspecialobject", "putstring", "putchilledstring", "concatstrings", "anytostring", "toregexp", "intern", "newarray", "pushtoarraykwsplat", "duparray", "duphash", "expandarray", "concatarray", "concattoarray", "pushtoarray", "splatarray", "splatkw", "newhash", "newrange", "pop", "dup", "dupn", "swap", "opt_reverse", "topn", "setn", "adjuststack", "defined", "definedivar", "checkmatch", "checkkeyword", "checktype", "defineclass", "definemethod", "definesmethod", "send", "sendforward", "opt_send_without_block", "opt_new", "objtostring", "opt_ary_freeze", "opt_hash_freeze", "opt_str_freeze", "opt_nil_p", "opt_str_uminus", "opt_duparray_send", "opt_newarray_send", "invokesuper", "invokesuperforward", "invokeblock", "leave", "throw", "jump", "branchif", "branchunless", "branchnil", "once", "opt_case_dispatch", "opt_plus", "opt_minus", "opt_mult", "opt_div", "opt_mod", "opt_eq", "opt_neq", "opt_lt", "opt_le", "opt_gt", "opt_ge", "opt_ltlt", "opt_and", "opt_or", "opt_aref",
とりあえず小さな一歩を
「Build your own VM」
https://blog.youchan-apps.net/2026-04-17