A study of devirtualization techniques for a Java Just-In-Time compiler

Many devirtualization techniques have been proposed to reduce the runtime overhead of dynamic method calls for various object-oriented languages, however, most of them are less effective or cannot be applied for Java in a straightforward manner. This is partly because Java is a statically-typed language and thus transforming a dynamic call to a static one does not make a tangible performance gain (owing to the low overhead of accessing the method table) unless it is inlined, and partly because the dynamic class loading feature of Java prohibits the whole program analysis and optimizations from being applied.We propose a new technique called direct devirtualization with the code patching mechanism. For a given dynamic call site, our compiler first determines whether the call can be devirtualized, by analyzing the current class hierarchy. When the call is devirtualizable and the target method is suitably sized, the compiler generates the inlined code of the method, together with the backup code of making the dynamic call. Only the inlined code is actually executed until our assumption about the devirtualization becomes invalidated, at which time the compiler performs code patching to make the backup code executed subsequently. Since the new technique prevents some code motions across the merge point between the inlined code and the backup code, we have furthermore implemented recently-known analysis techniques, such as type analysis and preexistence analysis, which allow the backup code to be completely eliminated. We made various experiments using 16 real programs to understand the effectiveness and characteristics of the devirtualization techniques in our Java Just-In-Time (JIT) compiler. In summary, we reduced the number of dynamic calls by ranging from 8.9% to 97.3% (the average of 40.2%), and we improved the execution performance by ranging from -1% to 133% (with the geometric mean of 16%).

[1]  Craig Chambers,et al.  Debugging optimized code with dynamic deoptimization , 1992, PLDI '92.

[2]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[3]  Dirk Grunwald,et al.  Reducing indirect function call overhead in C++ programs , 1994, POPL '94.

[4]  David Grove,et al.  Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis , 1995, ECOOP.

[5]  David Grove,et al.  Profile-guided receiver class prediction , 1995, OOPSLA.

[6]  Laurie J. Hendren,et al.  Practical virtual method call resolution for Java , 2000, OOPSLA '00.

[7]  Craig Chambers,et al.  Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches , 1991, ECOOP.

[8]  David Detlefs,et al.  Inlining of Virtual Methods , 1999, ECOOP.

[9]  Craig Chambers,et al.  Iterative type analysis and extended message splitting; optimizing dynamically-typed object-oriented programs , 1990, PLDI '90.

[10]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[11]  Jong-Deok Choi,et al.  Dynamic linking on a shared-memory multiprocessor , 1999, 1999 International Conference on Parallel Architectures and Compilation Techniques (Cat. No.PR00425).

[12]  Bernhard Steffen,et al.  Lazy code motion , 1992, PLDI '92.

[13]  Urs Hölzle,et al.  Eliminating Virtual Function Calls in C++ Programs , 1996, ECOOP.

[14]  David F. Bacon,et al.  Fast static analysis of C++ virtual function calls , 1996, OOPSLA '96.

[15]  Toshiaki Yasue,et al.  Design, implementation, and evaluation of optimizations in a just-in-time compiler , 1999, JAVA '99.

[16]  Jong-Deok Choi,et al.  Escape analysis for Java , 1999, OOPSLA '99.

[17]  Toshio Nakatani,et al.  Effective null pointer check elimination utilizing hardware trap , 2000, SIGP.

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

[19]  Fred C. Chow Minimizing register usage penalty at procedure calls , 1988, PLDI '88.

[20]  Urs Hölzle,et al.  Adaptive optimization for self: reconciling high performance with exploratory programming , 1994 .

[21]  Mary F. Fernández,et al.  Simple and effective link-time optimization of Modula-3 programs , 1995, PLDI '95.

[22]  Urs Hölzle,et al.  Type feedback vs. concrete type inference: a comparison of optimization techniques for object-oriented languages , 1995, OOPSLA.

[23]  Jens Palsberg,et al.  Scalable propagation-based call graph construction algorithms , 2000, OOPSLA '00.

[24]  Laurie J. Hendren,et al.  Efficient Inference of Static Types for Java Bytecode , 2000, SAS.

[25]  David F. Bacon,et al.  Fast and effective optimization of statically typed object-oriented languages , 1997 .

[26]  Jens Palsberg,et al.  Object-oriented type inference , 1991, OOPSLA '91.

[27]  P. Carini ReportFlow-Sensitive Type Analysis for C + + , 1995 .

[28]  Martin C. Rinard,et al.  Compositional pointer and escape analysis for Java programs , 1999, OOPSLA '99.

[29]  James M. Stichnoth,et al.  Practicing JUDO: Java under dynamic optimizations , 2000, PLDI '00.

[30]  Erik R. Altman,et al.  Reducing virtual call overheads in a Java VM just-in-time compiler , 2000, CARN.