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
PHP で JVM を実装して、 HelloWorld を出力してみる
Search
memory
PRO
February 09, 2020
Programming
2
4.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
事業観点から見る技術的負債の返済
memory1994
PRO
4
870
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
180
PHP でアセンブリっぽく書く技術
memory1994
PRO
1
110
How to implement a RubyVM with PHP?
memory1994
PRO
3
2.4k
二郎系ラーメンのコールで学ぶ AST 解析
memory1994
PRO
8
2.5k
RubyVM を PHP で実装する 〜Hello World を出力するまで〜
memory1994
PRO
1
750
令和最新版 PHP メモリ管理術
memory1994
PRO
6
4k
技術的負債が生まれる背景を理解して,アーリーからレイター向けの根本的なアプローチを考える
memory1994
PRO
23
9k
激辛のすゝめ
memory1994
PRO
1
560
Other Decks in Programming
See All in Programming
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
MCP with Cloudflare Workers
yusukebe
2
220
Jakarta EE meets AI
ivargrimstad
0
230
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
良いユニットテストを書こう
mototakatsu
4
1.6k
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
350
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
たのしいparse.y
ydah
3
120
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Why Our Code Smells
bkeepers
PRO
335
57k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Optimising Largest Contentful Paint
csswizardry
33
3k
Bash Introduction
62gerente
608
210k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
How STYLIGHT went responsive
nonsquared
95
5.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
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