skip to main content
10.1145/2093157.2093176acmotherconferencesArticle/Chapter ViewAbstractPublication PagespppjConference Proceedingsconference-collections
research-article

Trace-based compilation for the Java HotSpot virtual machine

Published: 24 August 2011 Publication History

Abstract

Traditional method-based just-in-time (JIT) compilation translates whole methods to optimized machine code. Trace-based compilation only generates machine code for frequently executed paths, so-called traces, that may span multiple methods.
In this paper, we present our implementation of a trace-based JIT compiler in which we modified the mature, method-based Java HotSpot client compiler. To simplify trace recording, we added a bytecode preprocessing step that detects and directly marks loops within the bytecodes. We duplicated the existing bytecode interpreter and instrumented it for trace recording. In our implementation, traces can be anchored both at loop headers and at method entries. When a trace anchor has been executed frequently enough, trace recording is started. After several times of trace recording, our modified JIT compiler merges the recorded traces into a structure suitable for compilation. During compilation, trace-specific optimizations are applied and guarded with runtime checks if necessary. The generated machine code is then invoked by the interpreter or by already compiled traces. If a method part must be executed that was not covered by traces and therefore not compiled, or if a runtime guard fails, execution falls back to the interpreter.
Benchmarks show an improved performance, less generated machine code and faster compilation compared to the method-based Java HotSpot client compiler. The peak performance of the SPECjvm2008 benchmarks is increased by 9% on average, while 29% less machine code is generated. Similarly, the performance of the SPECjbb2005 benchmark is increased by 13% and the DaCapo 9.12 Bach benchmarks show a peak performance increase of 5% on average.

References

[1]
V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: A Transparent Dynamic Optimization System. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 1--12. ACM Press, 2000.
[2]
M. Bebenita, F. Brandner, M. Fahndrich, F. Logozzo, W. Schulte, N. Tillmann, and H. Venter. SPUR: A Trace-Based JIT Compiler for CIL. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, pages 708--725. ACM Press, 2010.
[3]
M. Bebenita, M. Chang, G. Wagner, A. Gal, C. Wimmer, and M. Franz. Trace-Based Compilation in Execution Environments without Interpreters. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 59--68. ACM Press, 2010.
[4]
S. M. Blackburn, R. Garner, C. Hoffman, A. M. Khan, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, A. Phansalkar, D. Stefanović, T. VanDrunen, D. von Dincklage, and B. Wiedermann. The DaCapo benchmarks: Java benchmarking development and analysis. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 169--190. ACM Press, 2006.
[5]
C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the Meta-Level: PyPy's Tracing JIT Compiler. In Proceedings of the Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 18--25. ACM Press, 2009.
[6]
B. J. Bradel and T. S. Abdelrahman. The Use of Traces for Inlining in Java Programs. In Proceedings of the International Workshop on Languages and Compilers for Parallel Computing, pages 179--193, 2004.
[7]
M. Chang, E. Smith, R. Reitmaier, M. Bebenita, A. Gal, C. Wimmer, B. Eich, and M. Franz. Tracing for Web 3.0: Trace Compilation for the Next Generation Web Applications. In Proceedings of the ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, pages 71--80. ACM Press, 2009.
[8]
R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently Computing Static Single Assignment Form and the Control Dependence Graph. ACM Transactions on Programming Languages and Systems, 13(4):451--490, 1991.
[9]
E. Duesterwald and V. Bala. Software Profiling for Hot Path Prediction: Less is More. SIGPLAN Notices, 35:202--211, 2000.
[10]
A. Gal and M. Franz. Incremental Dynamic Code Generation with Trace Trees. Technical report, Donald Bren School of Information and Computer Science, University of California, Irvine, USA, 2006.
[11]
A. Gal, C. W. Probst, and M. Franz. HotpathVM: An Effective JIT Compiler for Resource-constrained Devices. In Proceedings of the International Conference on Virtual Execution Environments, pages 144--153. ACM Press, 2006.
[12]
A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. R. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E. W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. Trace-based Just-in-Time Type Specialization for Dynamic Languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 465--478. ACM Press, 2009.
[13]
R. Griesemer. Generation of Virtual Machine Code at Startup. In OOPSLA Workshop on Simplicity, Performance, and Portability in Virtual Machine Design. Sun Microsystems, Inc., 1999.
[14]
H. Hayashizaki, P. Wu, H. Inoue, M. J. Serrano, and T. Nakatani. Improving the Performance of Trace-based Systems by False Loop Filtering. In Proceedings of the International Conference on Architectural Support for Programming Languages and Operating Systems, pages 405--418. ACM Press, 2011.
[15]
K. Hazelwood and D. Grove. Adaptive Online Context-Sensitive In-lining. In Proceedings of the International Symposium on Code Generation and Optimization, pages 253--264. IEEE Computer Society, 2003.
[16]
D. Hiniker, K. Hazelwood, and M. D. Smith. Improving Region Selection in Dynamic Optimization Systems. In Proceedings of the IEEE/ACM International Symposium on Microarchitecture, pages 141--154. IEEE Computer Society, 2005.
[17]
U. Hölzle, C. Chambers, and D. Ungar. Debugging Optimized Code with Dynamic Deoptimization, 1992.
[18]
H. Inoue, H. Hayashizaki, P. Wu, and T. Nakatani. A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler. In Proceedings of the International Symposium on Code Generation and Optimization, pages 246--256. IEEE Computer Society, 2011.
[19]
T. Kotzmann, C. Wimmer, H. Mössenböck, T. Rodriguez, K. Russell, and D. Cox. Design of the Java HotSpot Client Compiler for Java 6. ACM Transactions on Architecture and Code Optimization, 5(1):7, 2008.
[20]
T. Lindholm and F. Yellin. The Java#8482; Virtual Machine Specification. Addison-Wesley, 2nd edition, 1999.
[21]
Java Platform, Standard Edition 7 Source Snapshot Releases. Oracle Corporation, 2011. http://download.java.net/jdk7/.
[22]
M. Paleczny, C. Vick, and C. Click. The Java HotSpot Server Compiler. In Proceedings of the Java Virtual Machine Research and Technology Symposium, pages 1--12. USENIX, 2001.
[23]
The SPECjbb2005 Benchmark. Standard Performance Evaluation Corporation, 2005. http://www.spec.org/jbb2005/.
[24]
The SPECjvm2008 Benchmarks. Standard Performance Evaluation Corporation, 2008. http://www.spec.org/jvm2008/.
[25]
T. Suganuma, T. Yasue, and T. Nakatani. A Region-Based Compilation Technique for a Java Just-In-Time Compiler. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 312--323. ACM Press, 2003.
[26]
T. Suganuma, T. Yasue, and T. Nakatani. A Region-Based Compilation Technique for Dynamic Compilers. ACM Transactions on Programming Languages and Systems, 28:134--174, 2006.
[27]
J. Whaley. Partial Method Compilation using Dynamic Profile Information. SIGPLAN Notices, 36:166--179, 2001.
[28]
C. Wimmer and H. Mössenböck. Optimized Interval Splitting in a Linear Scan Register Allocator. In Proceedings of the ACM/USENIX International Conference on Virtual Execution Environments, pages 132--141. ACM Press, 2005.
[29]
C. Wimmer, M. S. Cintra, M. Bebenita, M. Chang, A. Gal, and M. Franz. Phase Detection using Trace Compilation. In Proceedings of the International Conference on Principles and Practice of Programming in Java, pages 172--181. ACM Press, 2009.

Cited By

View all
  • (2024)Dias: Dynamic Rewriting of Pandas CodeProceedings of the ACM on Management of Data10.1145/36393132:1(1-27)Online publication date: 26-Mar-2024
  • (2023)Enabling eBPF on Embedded Systems Through Decoupled VerificationProceedings of the 1st Workshop on eBPF and Kernel Extensions10.1145/3609021.3609299(63-69)Online publication date: 10-Sep-2023
  • (2022)Just-In-Time Compilation on ARM—A Closer Look at Call-Site Code ConsistencyACM Transactions on Architecture and Code Optimization10.1145/354656819:4(1-23)Online publication date: 16-Sep-2022
  • Show More Cited By

Index Terms

  1. Trace-based compilation for the Java HotSpot virtual machine

    Recommendations

    Comments