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
See all the way through ruby -e 'p 1'
Search
ujihisa
September 27, 2018
Programming
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
See all the way through ruby -e 'p 1'
at meguro.rb #19
https://megurorb.connpass.com/event/100401/
ujihisa
September 27, 2018
More Decks by ujihisa
See All by ujihisa
13 Vim plugins I use every day
ujihisa
0
610
"雑" / Almost Microservices
ujihisa
4
6.2k
Modes / VimConf 2018
ujihisa
4
4.4k
.vimconf.swp 2018
ujihisa
0
710
:|┃ / tokyu rubykaigi 12
ujihisa
0
210
Vim / vim-railsdm-2018-07
ujihisa
1
820
Other Decks in Programming
See All in Programming
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
530
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
550
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
730
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
160
「人を評価する AI」の設計と実装
ryoyanara
0
260
Press start. Python's next generation.
willingc
PRO
3
250
信頼性の目標を誰も求めてない
shubox
0
230
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.3k
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
830
バグを直したら useEffect が消えた
colorful12
3
770
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
430
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
180
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
220
The Mindset for Success: Future Career Progression
greggifford
PRO
0
480
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
450
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
240
A better future with KSS
kneath
240
18k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Optimizing for Happiness
mojombo
378
71k
Making Projects Easy
brettharned
120
6.7k
Transcript
ruby -e 'p 1'を ぜんぶ見る meguro.rb 2018-09-27 ujihisa
はじめてのCRubyのソースコードの読み方 • 興味あるXの実装から ◦ メソッド ◦ parser ◦ GC •
mainから実行順 ◦ 静的 ◦ 動的 • ソースコードのファイル名アルファベット順に全部
はじめてのCRubyのソースコードの読み方 • 興味あるXの実装から ◦ メソッド ←僕は長らくこれで読んでた ◦ parser ←めっちゃ楽しい (そしてつらい) ◦
GC ←挫折 (nariさんの本読んで完全に理解 ) • mainから実行順 ◦ 静的 ←事例けっこうあるぽい? ◦ 動的 ←本発表 • ソースコードのファイル名アルファベット順に全部
-e command Specifies script from command-line while telling Ruby not
to search the rest of the arguments for a script file name.
Demo with GDB Linux • RUBY_CFLAGS="-ggdb3" RUBY_OPTFLAGS='-O0' rbenv install -k
2.6.0-dev • gdb `rbenv which ruby` -q --tui • :execute 'Termdebug' trim(system('rbenv which ruby')) • start -e 'p 123' • call rb_p(ばりゅー) • おまけ ◦ mrkn/vim-cruby ◦ ctags -R Mac • 後述
(gvimとtermdebug.vimによるデモ)
用語集 • iseq ◦ instruction sequence ◦ (みんなが日常的に会話に出すやつ) • ec
◦ current execution context (vm_eval.c) • cfp ◦ Control Frame Pointer (doc/yarvarch.ja) ◦ pcとspとselfを持つ • pc ◦ Program Counter (doc/yarvarch.ja) • sp ◦ Stack Pointer • ep ◦ Environment Pointer
VALUE逆引き表 include/ruby/ruby.h enum ruby_value_type { RUBY_T_NONE = 0x00, RUBY_T_OBJECT =
0x01, RUBY_T_CLASS = 0x02, RUBY_T_MODULE = 0x03, RUBY_T_FLOAT = 0x04, RUBY_T_STRING = 0x05, RUBY_T_REGEXP = 0x06, RUBY_T_ARRAY = 0x07, RUBY_T_HASH = 0x08, RUBY_T_STRUCT = 0x09, RUBY_T_BIGNUM = 0x0a, RUBY_T_FILE = 0x0b, RUBY_T_DATA = 0x0c, RUBY_T_MATCH = 0x0d, RUBY_T_COMPLEX = 0x0e, RUBY_T_RATIONAL = 0x0f, RUBY_T_NIL = 0x11, RUBY_T_TRUE = 0x12, RUBY_T_FALSE = 0x13, RUBY_T_SYMBOL = 0x14, RUBY_T_FIXNUM = 0x15, RUBY_T_UNDEF = 0x16, RUBY_T_IMEMO = 0x1a, /*!< @see imemo_type */ RUBY_T_NODE = 0x1b, RUBY_T_ICLASS = 0x1c, RUBY_T_ZOMBIE = 0x1d,
今回説明を省いた点 • insns.def ◦ insns.def - YARV instruction definitions ◦
YARV命令の実装 (putselfとかそういうやつ) ◦ CだけどCに見えないと噂 • vm.inc ◦ コンパイル時にinsns.defからRubyで生成される
ujihisa • @ujm • Quipper社 2018-09-01から ◦ Rails • Fablic社
2017-01-01から ◦ Rails • Hootsuite社 2010から ◦ 非Ruby • 今月オススメの魚 ◦ 秋刀魚 • 最近の活動 ◦ VimConf 2018 の主催 ◦ https://vimconf.org/2018
おまけ: macOS High Sierraでgdbを使う方法 おすすめ • Gentoo Linuxなど、便利なLinux distributionを入れ、そこで行う 遅いけど結構おすすめ
• VirtualboxとかDockerとかそれ系でなんかのLinuxを使えるようにし、それで行う 一応あり • 古いMac OSXで上書きインストール
おまけ: macOS High Sierraでgdbを使う方法 絶対におすすめしない最悪の方法 • macOS High Sierraでgdbを使う •
17ステップぐらいある ◦ gdbのダウングレード、バージョン固定 ◦ https://gist.github.com/danisfermi/17d6c0078a2fd4c6ee818c954d2de13c ▪ GUIでぽちぽちしたり再起動したりいろいろつらい想いをする ▪ リカバリモードで起動とか ▪ だいたい失敗するので何度も再挑戦する ▪ つらい、不毛、非生産的な作業の連続