Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android VM

Android VM

Delvik / ART

wagyu298

March 03, 2016
Tweet

More Decks by wagyu298

Other Decks in Programming

Transcript

  1. Hardware • Nexus 5X (Android) • Qualcomm® Snapdragon™ 808 ϓϩηοα

    1.8 GHz ϔΩαίΞ 64 Ϗοτ • 2GB LPDDR3 • ࠷৽͸ARM8ɺݹ͍σόΠε͸ARMҎ֎ʹ͸MIPS΍x86 CPUͷ΋ͷ΋͋Δ • ϚϧνCPUରԠʹVM͸༗ར • iPhone 6s • A9 • 2GB LPDDR4 • ಉ͘͡ARM8ɺݹ͍iPhone΋͢΂ͯARMޓ׵ • ୯ҰΞʔΩςΫνϟͳͷͰɺXcode͔Β࣮ߦՄೳόΠφϦΛग़ྗ͢Δ • 64bitରԠͷͨΊɺ32bitόΠφϦΛ64bitόΠφϦΛ࡞੒͢ΔΑ͏ʹͳͬͨ
  2. Android VM • Delvik: Android 4.4 • ART: Android 5.0

    or later • https://source.android.com/devices/tech/dalvik/ index.html
  3. Delvik • ϨδελϕʔεͷόʔνϟϧϚγϯʢJava VM͸ελοΫϕʔεʣ • ARM8͸31ݸͷ64bit൚༻Ϩδελͱ32ݸͷ128bitුಈখ਺఺Ϩδε λ͕࢖༻ՄೳͰARM7ͱൺ΂Delvikʹ༗ར • ௿ϝϞϦ؀ڥʹ࠷దԽ •

    ಈ࡞͢ΔόΠτίʔυ͸DexϑΥʔϚοτͰJavaόΠτίʔυͰ͸ͳ͍ ͨΊɺDelvik VM͸Java VMͰ͸ͳ͍ • Javaޓ׵ੑςετΛ௨ա͍ͯ͠ͳ͍ͷͰɺJava™Λ࢖༻Ͱ͖ͳ͍ • dxίϚϯυͰ.classϑΝΠϧΛ.dexϑΝΠϧʹม׵͢Δ • APKʹ͸ෳ਺ʢ௨ৗ1ͭʣͷ.dexϑΝΠϧؚ͕·ΕΔ • Android 2.1͔Β͸JIT΋αϙʔτ
  4. ART • AOT (Ahead-Of-Time) ίϯύΠϧ • ࣮ߦલʢΠϯετʔϧ࣌ʣʹ.dexϑΝΠϧΛELF dynamic objectʹม׵ •

    ࣮ߦ଎౓͕޲্͍ͯ͠Δ͕ɺAOTͷੑ্࣭ΞϓϦͷΠϯε τʔϧʹ͕͔͔࣌ؒΔΑ͏ʹͳΓ࣮ߦϑΝΠϧαΠζ΋େ ͖͘ͳ͍ͬͯΔ • dex2oatʢdexΛELFʹม׵͢ΔίϚϯυʣ͸LLVMͰ࣮૷ • JITίϯύΠϥ΋෇ଐ͍ͯ͠Δ͕ɺDelvikͷ࣮૷ͱҧ͍͋·Γ ࠷దԽ͞Ε͍ͯͳ͍
  5. 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
  6. 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