Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
220
速習iPhone Duo対応
yuukiw00w
1
670
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
140
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
210
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
360
wkhtmltopdfの次どうするか問題2026
willnet
2
1.5k
スマート反転とウェブアクセシビリティ
camiha
0
210
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
220
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
350
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.5k
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
120
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
180
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
550
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
From π to Pie charts
rasagy
1
370
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
700
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Rails Girls Zürich Keynote
gr2m
96
14k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Discover your Explorer Soul
emna__ayadi
2
1.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Odyssey Design
rkendrick25
PRO
2
810
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でぽちぽちしたり再起動したりいろいろつらい想いをする ▪ リカバリモードで起動とか ▪ だいたい失敗するので何度も再挑戦する ▪ つらい、不毛、非生産的な作業の連続