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
Opcodeを読んでいたら何故かphp-srcを読んでいた話
Search
むらおか
December 21, 2024
Technology
720
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Opcodeを読んでいたら何故かphp-srcを読んでいた話
むらおか
December 21, 2024
Other Decks in Technology
See All in Technology
Jetpack Compose で挑む新聞紙面UI ─ 複合ジェスチャー・ポリゴン記事領域・適応的ページ構成という3つの壁/droidkaigi2026
nikkei_engineer_recruiting
0
150
[RSJ26] Flow as Flow: Modeling Robot Velocity Fields as Probability Velocity Fields
keio_smilab
PRO
0
180
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
1
390
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
77k
いま好きなこと 最初はそんなに好きじゃなかった #tamagawadev
nishiuma
1
220
Claude Codeで開発以外の業務も爆速化しよう!
minorun365
PRO
12
9.5k
DINO-EdgeQuery:Edge-First Polygon Decoding for Building Footprint Extraction from Satellite Imagery
lehupa
0
130
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
160
Master Dataグループ紹介資料
sansan33
PRO
1
4.9k
Sony-DroidKaigi2026
sony
1
290
Azure App Service / Container Apps の組み込み認証
kuniteru
0
150
Point Cloud as a Foreign Language for Multi-modal Large Language Model
takmin
0
360
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
510
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
500
Agile that works and the tools we love
rasmusluckow
331
22k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Google's AI Overviews - The New Search
badams
0
1.6k
We Are The Robots
honzajavorek
0
330
Practical Orchestrator
shlominoach
191
12k
Embracing the Ebb and Flow
colly
88
5.2k
Mobile First: as difficult as doing things right
swwweet
225
10k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Transcript
Opcodeを読んでいたら 何故かphp-srcを読んでいた話 むらおか @muraSHOTARO PHP Conference Japan 2024
intの型キャストとintval関数 • (int) “1234” と intval(“1234”) • 文字列を整数にする
intの型キャストとintval関数 • (int) “1234” と intval(“1234”) • 文字列を整数にする なにが違う?
php-srcを読んでみよう!
C言語わからない。。。
php-srcの前にOpcodeを読むと良いらしい • OpcodeはPHPファイルを解析して生成される中間コード • PHP実行時に内容を出力することができる
Opcodeを読んでみよう!
intval (int)
intval (int)
関数の呼び出しの場合 • INIT_FCALL • DO_ICALL
• いくつかの関数がOpcodeのコンパイル時に最適化されるようになった ◦ intvalもそのうちの1つ (>=7.1.0) • Opcodeのコンパイルは zend_compile_* 関数で行われる ◦
https://wiki.php.net/rfc/abstract_syntax_tree#compiler_implementation AST導入とOpcodeの最適化
• いくつかの関数がOpcodeのコンパイル時に最適化されるようになった ◦ intvalもそのうちの1つ (>=7.1.0) • Opcodeのコンパイルは zend_compile_* 関数で行われる ◦
https://wiki.php.net/rfc/abstract_syntax_tree#compiler_implementation AST導入とOpcodeの最適化 zend_compile_* を探そう!
php-srcを読んでみよう!
zend_compile.c を読む • zend_try_compile_special_func ◦ intvalは特別な関数 https://github.com/php/php-src/blob/php-7.1.0/Zend/zend_compile.c#L3664
zend_compile.c を読む • zend_compile_func_cast ◦ ZEND_CASTにコンパイルされる https://github.com/php/php-src/blob/php-7.1.0/Zend/zend_compile.c#L3395
intval (int) Opcodeが 最適化されてる
• Opcodeリーディングはphp-srcを読む糸口になる • C言語を読むのに抵抗がある人でもOpcodeなら読みやすいかも? まとめ
• Opcodeリーディングはphp-srcを読む糸口になる • C言語を読むのに抵抗がある人でもOpcodeなら読みやすいかも? まとめ Opcodeから始めよう!
ありがとうございました!
https://wiki.php.net/rfc/abstract_syntax_tree https://qiita.com/tadsan/items/d11229761504c8a1ca81 https://speakerdeck.com/yasuaki640/phpnoopcodewo-du-ndemiyou https://hakre.wordpress.com/2010/05/13/php-casting-vs-intval/ 参考資料