Abstract
The Dalvik virtual machine is the main application platform running on Google's Android operating system for mobile devices and tablets. It is a Java Virtual Machine implementation that executes Java programs that have been translated to Google's DEX intermediate representation. This register-based virtual machine runs a basic trace-based Just-In-Time compiler to speed up the execution of programs that contain hot traces. Web browser JavaScript engines usually run a combination of both method and trace-based JIT types. Such JavaScript engines advocate to the power of a trace-based JIT compiler because of its ability to optimize frequently executed instructions, especially inside loops. Because a JIT is able to observer the runtime type of JavaScript variables, it can have different native versions of loops that work faster under the assumption that a variable is of a certain type. Android's Dalvik virtual machine runs dex instructions, which does not preserve variable types but uses operations that reveal what the operators' types are likely to be, uses a very simple trace-based JIT but does not implement any of the above optimizations. The method-based JIT compiler presented here delivers performance improvement comparable to that of an Ahead-Of-Time compiler based on the Low Level Virtual Machine framework. The method-based JIT was compared against Dalvik's own trace-based JIT using common benchmarks available in the Android Market. Results show that our method-based JIT is better than a basic trace-based, and that, by sharing profiling and compilation information among each other, a smart combination of both JIT techniques can achieve a great performance gain. Using a fine-tunes profiler that selects methods to be method-based JIT compiled in order to combine fast trace-based JIT compilation with highly optimized method-based JIT compilation when there is an opportunity to do so.