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
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
640
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
MCP with Cloudflare Workers
yusukebe
2
220
良いユニットテストを書こう
mototakatsu
4
1.7k
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
CSC305 Lecture 25
javiergs
PRO
0
130
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
7k
A Philosophy of Restraint
colly
203
16k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Building an army of robots
kneath
302
44k
For a Future-Friendly Web
brad_frost
175
9.4k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Agile that works and the tools we love
rasmusluckow
328
21k
What's in a price? How to price your products and services
michaelherold
243
12k
Why Our Code Smells
bkeepers
PRO
335
57k
A designer walks into a library…
pauljervisheath
204
24k
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