Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
PHP で JVM を実装して、 HelloWorld を出力してみる
memory
PRO
February 09, 2020
Programming
2
3.4k
PHP で JVM を実装して、 HelloWorld を出力してみる
- PHPerKaigi 2020
- English Title:
Implement JVM with PHP and try to output Hello World
memory
PRO
February 09, 2020
Tweet
Share
More Decks by memory
See All by memory
PHP でガチの電卓を作る
memory1994
PRO
2
160
CTO から見た,なぜスタートアップ 初期のソフトウェア設計は壊れがちなのか
memory1994
PRO
86
34k
PHP メモリ管理術
memory1994
PRO
3
1.9k
PHP で NFC リーダーを実装する
memory1994
PRO
0
330
PHP でコードゴルフしよう!
memory1994
PRO
0
150
知育玩具サブスク「トイサブ!」におけるエンジニア組織立ち上げの事例
memory1994
PRO
2
790
株式会社トラーナにおける 心理的安全性が高い組織づくりの事例
memory1994
PRO
3
490
PHP ワンライナー物語
memory1994
PRO
2
240
Team building programs for Engineering Team at Torana, Inc
memory1994
PRO
2
420
Other Decks in Programming
See All in Programming
ペパカレで入社した私が感じた2つのギャップと向き合い方
kosuke_ito
0
320
Why Money Forward contributes to Ruby and RubyKaigi?
luccafort
0
130
Swift Concurrency in GoodNotes
inamiy
4
1.4k
2023年にクル(かもしれない)通信ミドルウェア技術(仮)
s_hosoai
0
220
ポケモンで学ぶiOS 16弾丸ツアー 🚅
giginet
PRO
1
620
Spring BootとKubernetesで実現する今どきのDevOps入門
xblood
0
400
Zynq MP SoC で楽しむエッジコンピューティング ~RTLプログラミングのススメ~
ryuz88
0
400
Rust、何もわからない...#6発表資料
ryu19
0
140
WordPress(再)入門 - 基礎知識・環境編
oleindesign
1
140
Remix + Cloudflare Pages + D1 で ポケモン SV のレンタルチームを検索できるアプリを作ってみた
kuroppe1819
4
1.4k
ECテックカンファレンス2023
kspace
1
380
xarray-Datatree: Hierarchical Data Structures for Multi-Model Science
tomnicholas
0
230
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
339
18k
Web Components: a chance to create the future
zenorocha
304
40k
Bash Introduction
62gerente
601
210k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
175
9.1k
Embracing the Ebb and Flow
colly
75
3.6k
A better future with KSS
kneath
230
16k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
657
120k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
Rebuilding a faster, lazier Slack
samanthasiow
69
7.6k
Designing on Purpose - Digital PM Summit 2013
jponch
108
5.9k
WebSockets: Embracing the real-time Web
robhawkes
58
6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
22
1.7k
Transcript
/ / PHPerKaigi PHP JVM HelloWorld © - BASE, Inc.
© - BASE, Inc. Who am I? (@m m r
) BASE 6 SDVX
© - BASE, Inc. Who am I?
None
© - BASE, Inc. PHPerKaigi Builderscon
© - BASE, Inc. php-java/php-java
OSS
None
© - BASE, Inc. JVM PHP
© - BASE, Inc. Hello World
JVM
JVM
© - BASE, Inc. JVM JVM Java Virtual Machine Java
JVM JRE JDK
JVM
<?php exec('java HelloWorld')
<?php exec('java HelloWorld')
© - BASE, Inc. JVM Java class class JVM
© - BASE, Inc. JVM JVM Java Virtual Machine Specification
Oracle
© - BASE, Inc. JVM
© - BASE, Inc. JVM Java class
© - BASE, Inc. JVM
© - BASE, Inc. JVM class
JVM
© - BASE, Inc. Perl PHP JavaScript / Builderscon YAPC::Kyoto
PHPerKaigi Qiita JVM
JVM
© - BASE, Inc. Rust Emacs Go Ruby rchaser gongoZ
DQNEO Daiki Miura JVM
JVM
JVM,
PHP
None
© - BASE, Inc. fopen / fread OK
None
© - BASE, Inc. 16 short, unsigned short, integer, unsigned
integer pack / unpack JVM
None
PHP
© - BASE, Inc. PHP int (- ^ ^ -
) bool string float, double array null etc...
Java
© - BASE, Inc. Java byte char short (- ^
^ - ) int (- ^ ^ - ) long (- ^ ^ - ) boolean float double
None
PHP Java
None
None
© - BASE, Inc. ( ) JVM invokevirtual iload /
istore
Hello World
Java Virtual Machine Specification
© - BASE, Inc. JVM Spec Java Virtual Machine Specification
JVM Spec JVM Spec Oracle JVM https://docs.oracle.com/javase/specs/ index.html
ClassFile Structure
© - BASE, Inc. ClassFile Structure
© - BASE, Inc. ClassFile Structure
© - BASE, Inc. JVM Spec u unsigned int u
unsigned short
Hello World
© - BASE, Inc. Constant Pool Method Info Code Attribute
Hello World
Method Info
© - BASE, Inc. Method Info
© - BASE, Inc. Method Info
Code Attribute
None
© - BASE, Inc. Code Attribute
© - BASE, Inc. Code Attribute
© - BASE, Inc. Code Attribute
© - BASE, Inc. Code Attribute
© - BASE, Inc. Code Attribute
© - BASE, Inc. Code Attribute
© - BASE, Inc. Code Attribute
None
© - BASE, Inc. JVM Spec code[code_length] JVM Spec
None
None
None
© - BASE, Inc. java.lang.System.out getstatic println invokevirtual
© - BASE, Inc. Constant Pool ldc return
4
None
getstatic
© - BASE, Inc. getstatic getstatic getstatic Constant Pool unsigned
short
© - BASE, Inc. getstatic getstatic <0xB > putstatic
© - BASE, Inc. getstatic
© - BASE, Inc. getstatic
© - BASE, Inc. getstatic
© - BASE, Inc. getstatic
© - BASE, Inc. getstatic
© - BASE, Inc. getstatic
© - BASE, Inc. getstatic
invokevirtual
© - BASE, Inc. invokevirtual invokevirtual Constant Pool
© - BASE, Inc. invokevirtual invokevirtual <0xB > invoke dynamic,
special, interface, static
© - BASE, Inc. invokevirtual invoke JVM invoke invokedynamic invokeinterface
© - BASE, Inc. invokevirtual
© - BASE, Inc. invokevirtual
© - BASE, Inc. invokevirtual
© - BASE, Inc. invokevirtual
© - BASE, Inc. invokevirtual
© - BASE, Inc. invokevirtual
© - BASE, Inc. invokevirtual void
ldc
© - BASE, Inc. ldc ldc Constant Pool UTF Integer,
short, byte Constant Pool unsigned byte
© - BASE, Inc. ldc ldc Long Double
© - BASE, Inc. ldc
© - BASE, Inc. ldc Constant Pool
© - BASE, Inc. ldc Constant Pool
© - BASE, Inc. ldc
return
© - BASE, Inc. return return void moniterenter return areturn,
ireturn, freturn, dreturn
Hello World
© - BASE, Inc. Hello World B NN MM NN
B NN MM B
© - BASE, Inc. Hello World B NN MM NN
B NN MM B getstatic
© - BASE, Inc. Hello World B NN MM NN
B NN MM B unsigned short
© - BASE, Inc. Hello World B NN MM NN
B NN MM B ldc
© - BASE, Inc. Hello World B NN MM NN
B NN MM B unsigned byte Hello World Constant Pool
© - BASE, Inc. Hello World B NN MM NN
B NN MM B invokevirtual
© - BASE, Inc. Hello World B NN MM NN
B NN MM B unsigned short Constant Pool
© - BASE, Inc. Hello World B NN MM NN
B NN MM B return
None
"java.lang.System"
© - BASE, Inc. "java.lang.System" Java java.lang.System PHP "java\lang\System" System
"out"
© - BASE, Inc. "java.lang.System" ;
"out"
© - BASE, Inc. "out" PHP JVM static
© - BASE, Inc. "out"
© - BASE, Inc. "out"
"println" "java.io.PrintStream"
© - BASE, Inc. "java.io.PrintStream"
Hello World
DEMO
THANK YOU FOR YOUR LISTENING