5

Since the new ART runtime is compiling the apps AOT, I was wondering whether running an app still includes a virtual machine, or the code is executed directly on the system. I haven't been able to extract this information from articles around the web as some mention a virtual machine, where other talks about the apps being compiled to ELF files (to my knowledge, the binary format used by the Linux kernel suggesting that the apps are run natively).
Can anyone help me out on this?
BPou

5

Short story: yes, ART translates apps to code native to the actual phone's architecture and therefore apps execute natively without the need of a JIT compiler.

Long story: For reasons of compatibility, applications are still bundled in apks carrying the java code compiled into dex files. But instead of just optimizing the .dex code and executing it inside Dalvik VM (DVM), the code is compiled down to native code. This is done on the device using a tool called dex2oat, where oat files are embedded within the regular ELF file format.

The following figure depicts the difference between the usage of DVM and ART:

Diagram of the Android Run Time architecture, recreated from information published at A Closer Look at Android RunTime (ART) in Android L. (http://anandtech.com/show/8231/a-closer-look-at-android-runtime-art-in-android-l/) (Wikipedia: Diagram of the Android Run Time architecture, recreated from information published at A Closer Look at Android RunTime (ART) in Android L.)

The performance improvement comes from the fact that the DVM used JIT compilation each and every time an app is executed, while AOT compilation only happens at install time.

| improve this answer | |
  • 1
    But the compiled ELF file is not a standalone executable binary but a shared object. It's still loaded in memory along with other dependencies by the same app_process which starts zygote and forks VMs for system_server and all apps. – Irfan Latif Mar 5 at 17:15
  • 1
    Indeed, Android employs a large set of optimizations to speed up the start and runtime performance of apps, such as loading the actual app code oat file into a pre-warmed process that already loaded libraries and even a pre-filled heap with often used objects. – user3363866 Mar 5 at 17:19
  • Adding these lines to you answer would give a feel of more completeness :) – Irfan Latif Mar 5 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.