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
Android VM
Search
wagyu298
March 03, 2016
Programming
0
630
Android VM
Delvik / ART
wagyu298
March 03, 2016
Tweet
Share
More Decks by wagyu298
See All by wagyu298
Swagger Codegen
wagyu298
1
2.6k
HTTP/2 Mobile
wagyu298
0
930
Option Type
wagyu298
0
1.1k
process.nextTick differences between node-v0.8 and node-v0.11
wagyu298
1
1.7k
Other Decks in Programming
See All in Programming
良いユニットテストを書こう
mototakatsu
11
3.5k
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
570
DMMオンラインサロンアプリのSwift化
hayatan
0
160
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
360
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
240
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
560
テストコード書いてみませんか?
onopon
2
320
functionalなアプローチで動的要素を排除する
ryopeko
1
190
선언형 UI에서의 상태관리
l2hyunwoo
0
270
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1k
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
4
1.1k
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
5
200
The World Runs on Bad Software
bkeepers
PRO
66
11k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Gamification - CAS2011
davidbonilla
80
5.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Become a Pro
speakerdeck
PRO
26
5.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Unsuck your backbone
ammeep
669
57k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Designing for humans not robots
tammielis
250
25k
Transcript
Android VM @wagyu298
Android VM ≠ Java VM
Android VM Delvik: Android 4.4 ART: Android 5.0 or later
Hardware • Nexus 5X (Android) • Qualcomm® Snapdragon™ 808 ϓϩηοα
1.8 GHz ϔΩαίΞ 64 Ϗοτ • 2GB LPDDR3 • ࠷৽ARM8ɺݹ͍σόΠεARMҎ֎ʹMIPSx86 CPUͷͷ͋Δ • ϚϧνCPUରԠʹVM༗ར • iPhone 6s • A9 • 2GB LPDDR4 • ಉ͘͡ARM8ɺݹ͍iPhoneͯ͢ARMޓ • ୯ҰΞʔΩςΫνϟͳͷͰɺXcode͔Β࣮ߦՄೳόΠφϦΛग़ྗ͢Δ • 64bitରԠͷͨΊɺ32bitόΠφϦΛ64bitόΠφϦΛ࡞͢ΔΑ͏ʹͳͬͨ
Android VM • Delvik: Android 4.4 • ART: Android 5.0
or later • https://source.android.com/devices/tech/dalvik/ index.html
Android VM https://ja.wikipedia.org/wiki/Android_Runtime
Delvik • ϨδελϕʔεͷόʔνϟϧϚγϯʢJava VMελοΫϕʔεʣ • ARM831ݸͷ64bit൚༻Ϩδελͱ32ݸͷ128bitුಈখϨδε λ͕༻ՄೳͰARM7ͱൺDelvikʹ༗ར • ϝϞϦڥʹ࠷దԽ •
ಈ࡞͢ΔόΠτίʔυDexϑΥʔϚοτͰJavaόΠτίʔυͰͳ͍ ͨΊɺDelvik VMJava VMͰͳ͍ • JavaޓੑςετΛ௨ա͍ͯ͠ͳ͍ͷͰɺJava™Λ༻Ͱ͖ͳ͍ • dxίϚϯυͰ.classϑΝΠϧΛ.dexϑΝΠϧʹม͢Δ • APKʹෳʢ௨ৗ1ͭʣͷ.dexϑΝΠϧؚ͕·ΕΔ • Android 2.1͔ΒJITαϙʔτ
Dex Specs • https://source.android.com/devices/tech/dalvik/dex- format.html
ART • AOT (Ahead-Of-Time) ίϯύΠϧ • ࣮ߦલʢΠϯετʔϧ࣌ʣʹ.dexϑΝΠϧΛELF dynamic objectʹม •
࣮ߦ্͕͍ͯ͠Δ͕ɺAOTͷੑ্࣭ΞϓϦͷΠϯε τʔϧʹ͕͔͔࣌ؒΔΑ͏ʹͳΓ࣮ߦϑΝΠϧαΠζେ ͖͘ͳ͍ͬͯΔ • dex2oatʢdexΛELFʹม͢ΔίϚϯυʣLLVMͰ࣮ • JITίϯύΠϥଐ͍ͯ͠Δ͕ɺDelvikͷ࣮ͱҧ͍͋·Γ ࠷దԽ͞Ε͍ͯͳ͍
Zygote • AndroidΞϓϦͷىಈϓϩηε • AndroidࣗମLinuxϚγϯͰ͋ΓɺσόΠεىಈ࣌/ init͔Β࢝·ΔҰ࿈ͷىಈϓϩηε͕ී௨ʹ࣮ߦ͞Εɺ/ init.rcεΫϦϓτ͔Βىಈ͞ΕΔίϚϯυapp_process ͷ͜ͱ • https://android.googlesource.com/platform/system/
core/+/master/rootdir/init.zygote64_32.rc
Zygote • zygoteϓϩηεΞϓϦىಈʹඞཁͳͯ͢ͷϥΠϒ ϥϦ͕dynamic link͞Ε͓ͯΓɺࢠϓϩηεΛforkͯ͠ ʢexecͤͣʹʣΞϓϦΛىಈ͢Δ • app_processzygoteϞʔυͰىಈ͞ΕΔͱ com.android.internal.os.ZygoteInitΛ࣮ߦ͢Δ •
https://android.googlesource.com/platform/ frameworks/base/+/master/cmds/app_process/ app_main.cpp
Zygote • ZygoteInit͋ʔͩ͜ʔͩͨ͋͠ͱ • https://android.googlesource.com/platform/frameworks/ base/+/master/core/java/com/android/internal/os/ ZygoteInit.java • app_processͷAppRuntimeΫϥεΛܦ༝͠AndroidRuntime͔ ΒActivityThreadΫϥεͷmainؔΛݺͼग़͢ɻ
• https://android.googlesource.com/platform/frameworks/ base/+/master/core/jni/AndroidRuntime.cpp • https://android.googlesource.com/platform/frameworks/ base/+/master/core/java/android/app/ActivityThread.java
References • http://d.hatena.ne.jp/embedded/20131104/p1 • http://blog.kmckk.com/archives/3551546.html • http://blog.kmckk.com/archives/4164432.html • http://elinux.org/Android_Zygote_Startup •
http://crimsonwoods.hatenablog.com/entry/ 2014/11/10/013025 • http://blog.hermit4.info/2011/01/zygote.html • http://dsas.blog.klab.org/archives/52003951.html