Upgrade to Pro — share decks privately, control downloads, hide ads and more …

contributing-to-spinel

 contributing-to-spinel

RubyKaigi 2026 アフターイベント〜初参加LT・スポンサー4社のパネル〜
https://mybest.connpass.com/event/392055/

Avatar for yamasaki

yamasaki

May 13, 2026

More Decks by yamasaki

Other Decks in Programming

Transcript

  1. note inc. ⾃⼰紹介 Yamasaki sacckey • 2020/04 note⼊社 • サーバーサイドエンジニア

    ◦ 最近は物語投稿サイトTALESの実装 • 個⼈開発/ピアノ/⿇雀 2
  2. note inc. Spinel 4 • RubyのAOTコンパイラ • Ruby (.rb) →

    parse → type inference → C (.c) → native binary • Rubyプログラムの実⾏速度とポータビリティの向上
  3. note inc. さっそくSpinelを使ってみる % make deps % make % cat

    > hello.rb <<'RUBY' def fib(n) n < 2 ? n : fib(n - 1) + fib(n - 2) end puts fib(34) RUBY % ./spinel hello.rb % ./hello # prints 5702887 (instantly) 5
  4. note inc. Ruby Boy (https://github.com/sacckey/rubyboy) • Rubyで動くGame Boyのエミュレーター • ruby.wasmによってブラウザでも動く

    ◦ https://sacckey.github.io/rubyboy/ • 画⾯描画なしのベンチマークがある ◦ → Spinelでコンパイルしたい ◦ → コンパイル失敗 ◦ → 失敗箇所ごとにPR作成 6
  5. note inc. 貢献1: M::C.new対応 8 # コンパイルできるようになったコード module M class

    C def initialize puts "init" end end end M::C.new M::C のような名前空間つきクラスに対して .new できなかった ConstantPathNode がレシーバーになる ケースに対応
  6. note inc. 貢献2: インスタンス変数名とCキーワードの衝突回避 9 # コンパイルできるようになったコード class KeywordIvar def

    initialize @if = 40 @iv_if = 1 end def value @if + @iv_if + 1 end end puts KeywordIvar.new.value @if をCコードに変換すると、 Cの if と衝突してしまっていた 生成されるCのフィールド名に iv_ prefixを付 けた 例: @if → iv_if @iv_if → iv_iv_if
  7. note inc. その他の貢献 10 • nested ConstantPath reads • ConstantPath

    receiverへのclass method dispatch • polymorphic returnのbox • constructor initialize pathのGC save重複排除