BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Android to Include Ahead-Of-Time Compiler

Android to Include Ahead-Of-Time Compiler

This item in japanese

Lire ce contenu en français

Bookmarks

Google has replaced the just-in-time (JIT) compiler in Android with an ahead-of-time (AOT) compiler that translates bytecode to native machine code during installation.

Google announced the next version of the Android operating system at Google I/O 2014. Code named “L release,” in the most significant change to the system architecture a new runtime simply called the Android RunTime (ART) with an AOT compiler replaces the Dalvik virtual machine and its JIT compiler.

AOT and JIT compilation strategies have different advantages and drawbacks in different situations. Google’s implementation of ART adjusts JIT’s space for speed trade-off while keeping the hardware flexibility benefits of JIT compilation. This strategy is optimized for Android’s collection of hardware platforms. Other mobile platforms make different choices depending on their hardware and software environments:

  • iOS depends primarily on static compilation where the initial build process generates optimized native code on the developer’s machine before an application is uploaded.
  • Windows Phone uses a cloud compilation strategy where the store generates machine dependent code before an application is installed onto the phone.

These strategies are optimized for Apple’s tightly controlled hardware ecosystem and Microsoft’s very heterogeneous execution environment respectively.

In the new Android runtime the OS compiles bytecode to native machine code on the device at installation and stores the native code for later execution. The native code representation is larger both in permanent storage and in RAM on the device. Unlike with Dalvik and traditional JIT compilers, on the other hand, the compilation process does not need to be repeated on every application execution.

ART does retain one of the key benefits of JIT compilation: OS knows exactly what the hardware specifications are when installing an application on a phone, tablet or other device and it is able to produce native machine code. It knows that the hardware will not change and so is able to optimize the generated code to match the processor. This is in contrast to static compilers which must often produce code which is not optimized for a particular processor or produce multiple versions of code for different processors.

Google is claiming up to 200% performance improvements overall for ART over Dalvik, partially because the AOT compiler has an overview of all the code while the JIT compiler only performs local optimizations. Writing for AnandTech Andre Frumusanu points out that “Overhead such as exception checks in code are largely removed, and method and interface calls are vastly sped up.” In addition

Because ART compiles an ELF executable, the kernel is now able to handle page handling of code pages - this results in possibly much better memory management, and less memory usage too.

There is a developer preview now with final release expected this fall so the final overall improvement as well as any trade-offs remain to be seen. This does not seem to be a fundamental advance in compilation, Google is not setting a new agenda but neither are they following; they are continuing to look for the optimal compilation strategy for Android’s particular collection of hardware as capabilities change.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Common

    by Kerem Kusmezer,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    We have aot since the beginning of time in .Net using NGEN and Google is finally decided to switch to aot great news.

  • Re: Common

    by Anatolii Maslov,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    In fact, the java world had the AOT compiler before the .net even existed.
    The article tells about the compilation strategy for Android platform.

    And if you look at how the code for Windows Phone is compiled, I'll be surprised, because there is no NGEN there, the optimized version of JIT strategy is used.

  • Re: Common

    by Faisal Waris,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    The direction of .Net is ".Net Native", see:

    blogs.msdn.com/b/dotnet/archive/2014/04/02/anno...

    The compile to native can be done in the cloud, before app download, based on the processor of the device.

  • What does 200% performance improvement mean

    by Puc Cup,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    If something is twice as fast, we say 100% speed improvement. Does this 200% mean it is 3 times faster or has someone made the common mistake of changing twice as fast to 200%?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT