Android to Include Ahead-Of-Time Compiler
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.
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.
The compile to native can be done in the cloud, before app download, based on the processor of the device.
York Xyander, Bodo Junglas Jul 31, 2015