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
0
650
Opcodeを読んでいたら何故かphp-srcを読んでいた話
むらおか
December 21, 2024
Tweet
Share
Other Decks in Technology
See All in Technology
JAWS DAYS 2026 楽しく学ぼう!ストレージ 入門
yoshiki0705
2
170
OCHaCafe S11 #2 コンテナ時代の次の一手:Wasm 最前線
oracle4engineer
PRO
1
120
[JAWSDAYS2026][D8]その起票、愛が足りてますか?AWSサポートを味方につける、技術的「ラブレター」の書き方
hirosys_
3
170
Dr. Werner Vogelsの14年のキーノートから紐解くエンジニアリング組織への処方箋@JAWS DAYS 2026
p0n
1
130
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
4
1.2k
最強のAIエージェントを諦めたら品質が上がった話 / how quality improved after giving up on the strongest AI agent
kt2mikan
0
170
AIエージェント時代に備える AWS Organizations とアカウント設計
kossykinto
3
880
AWS DevOps Agent vs SRE俺 / AWS DevOps Agent vs me, the SRE
sms_tech
3
570
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
5
1.2k
マルチプレーンGPUネットワークを実現するシャッフルアーキテクチャの整理と考察
markunet
2
240
Lambda Web AdapterでLambdaをWEBフレームワーク利用する
sahou909
0
110
(Test) ai-meetup slide creation
oikon48
2
340
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
130
Joys of Absence: A Defence of Solitary Play
codingconduct
1
310
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
130
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Crafting Experiences
bethany
1
85
The Art of Programming - Codeland 2020
erikaheidi
57
14k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
140
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
140
How GitHub (no longer) Works
holman
316
140k
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/ 参考資料