Swift: a register-based JIT compiler for embedded JVMs

Code quality and compilation speed are two challenges to JIT compilers, while selective compilation is commonly used to trade-off these two issues. Meanwhile, with more and more Java applications running in mobile devices, selective compilation meets many problems. Since these applications always have flat execution profile and short live time, a lightweight JIT technique without losing code quality is extremely needed. However, the overhead of compiling stack-based Java bytecode to heterogeneous register-based machine code is significant in embedded devices. This paper presents a fast and effective JIT technique for mobile devices, building on a register-based Java bytecode format which is more similar to the underlying machine architecture. Through a comprehensive study on the characteristics of Java applications, we observe that virtual registers used by more than 90% Java methods can be directly fulfilled by 11 physical registers. Based on this observation, this paper proposes Swift, a novel JIT compiler on register-based bytecode, which generates native code for RISC machines. After mapping virtual registers to physical registers, the code is generated efficiently by looking up a translation table. And the code quality is guaranteed by the static compiler which is used to generate register-based bytecode. Besides, we design two lightweight optimizations and an efficient code unloader to make Swift more suitable for embedded environment. As the prevalence of Android, a prototype of Swift is implemented upon DEX bytecode which is the official distribution format of Android applications. Swift is evaluated with three benchmarks (SPECjvm98, EmbeddedCaffeineMark3 and JemBench2) on two different ARM SOCs: S3C6410 (armv6) and OMAP3530 (armv7). The results show that Swift achieves a speedup of 3.13 over the best-performing interpreter on the selected benchmarks. Compared with the state-of-the-art JIT compiler in Android, JITC-Droid, Swift achieves a speedup of 1.42.

[1]  Michael Franz,et al.  Trace-based compilation in execution environments without interpreters , 2010, PPPJ.

[2]  Peter U. Schulthess,et al.  Reply to the case against stack-oriented instruction sets , 1977, CARN.

[3]  Michael Franz,et al.  Optimization of dynamic languages using hierarchical layering of virtual machines , 2009, DLS '09.

[4]  Erik R. Altman,et al.  LaTTe: a Java VM just-in-time compiler with fast and efficient register allocation , 1999, 1999 International Conference on Parallel Architectures and Compilation Techniques (Cat. No.PR00425).

[5]  Toshio Nakatani,et al.  A trace-based Java JIT compiler retrofitted from a method-based compiler , 2011, International Symposium on Code Generation and Optimization (CGO 2011).

[6]  David Gregg,et al.  The Structure and Performance of Efficient Interpreters , 2003, J. Instr. Level Parallelism.

[7]  Chandra Krintz,et al.  Profile-driven code unloading for resource-constrained JVMs , 2004, PPPJ.

[8]  GoslingJames Java intermediate bytecodes , 1995 .

[9]  Cliff Click,et al.  The java hotspot TM server compiler , 2001 .

[10]  Alec Wolman,et al.  The structure and performance of interpreters , 1996, ASPLOS VII.

[11]  Chandra Krintz,et al.  Using annotations to reduce dynamic optimization time , 2001, PLDI '01.

[12]  Saman Amarasinghe,et al.  Dynamic native optimization of interpreters , 2003, IVME '03.

[13]  David Gregg,et al.  Optimizing indirect branch prediction accuracy in virtual machine interpreters , 2003, PLDI '03.

[14]  Michael Franz,et al.  HotpathVM: an effective JIT compiler for resource-constrained devices , 2006, VEE '06.

[15]  Brian T. Lewis,et al.  The Open Runtime Platform: a flexible high‐performance managed runtime environment , 2005, Concurr. Pract. Exp..

[16]  David Gregg,et al.  The case for virtual register machines , 2003, IVME '03.

[17]  Cliff Click,et al.  The Java HotSpot Server Compiler , 2001, Java Virtual Machine Research and Technology Symposium.

[18]  Brian T. Lewis,et al.  The Open Runtime Platform: a flexible high-performance managed runtime environment: Research Articles , 2005 .

[19]  Martin Schoeberl,et al.  The embedded Java benchmark suite JemBench , 2010, JTRES '10.

[20]  Wei-Kuan Shih,et al.  A method-based ahead-of-time compiler for Android applications , 2011, 2011 Proceedings of the 14th International Conference on Compilers, Architectures and Synthesis for Embedded Systems (CASES).

[21]  Toshiaki Yasue,et al.  Overview of the IBM Java Just-in-Time Compiler , 2000, IBM Syst. J..

[22]  Jens Palsberg,et al.  The essence of compiling with traces , 2011, POPL '11.

[23]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[24]  Robert Wahbe,et al.  Efficient and language-independent mobile programs , 1996, PLDI '96.

[25]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[26]  David Gregg,et al.  Virtual machine showdown: stack versus registers , 2005, VEE '05.

[27]  Soo-Mook Moon,et al.  Hybrid Java compilation and optimization for digital TV software platform , 2010, CGO '10.

[28]  James Gosling,et al.  Java Intermediate Bytecode , 1995, Intermediate Representations Workshop.

[29]  Andreas Krall,et al.  Efficient JavaVM just-in-time compilation , 1998, Proceedings. 1998 International Conference on Parallel Architectures and Compilation Techniques (Cat. No.98EX192).

[30]  Nikolai Tillmann,et al.  SPUR: a trace-based JIT compiler for CIL , 2010, OOPSLA.

[31]  Glenford J. Myers,et al.  The case against stack-oriented instruction sets , 1977, CARN.

[32]  Alexander V. Veidenbaum,et al.  A simplified java bytecode compilation system for resource-constrained embedded processors , 2007, CASES '07.

[33]  Chandra Krintz,et al.  Adaptive code unloading for resource-constrained JVMs , 2004, LCTES '04.