Trace-based compilation for the Java HotSpot virtual machine

Trace-based compilation for the Java HotSpot virtual machine
复制标题

Java HotSpot 虚拟机的基于跟踪的编译

DOI:
--
复制
发表时间:
2011
期刊:
Principles and Practice of Programming in Java
影响因子:
--
通讯作者:
H. Mössenböck
H. Mössenböck
中科院分区:
--
文献类型:
--
作者:
Christian Häubl;H. Mössenböck

文献摘要

被引文献

相似文献

传统的基于方法的即时 (JIT) 编译将整个方法转换为优化的机器代码。基于跟踪的编译仅为频繁执行的路径(即所谓的跟踪)生成机器代码,这些路径可能跨越多个方法。 在本文中,我们介绍了基于跟踪的 JIT 编译器的实现,其中我们修改了成熟的、基于方法的 Java HotSpot 客户端编译器。为了简化跟踪记录,我们添加了字节码预处理步骤,用于检测并直接标记字节码内的循环。我们复制了现有的字节码解释器并对其进行了跟踪记录。在我们的实现中,跟踪可以锚定在循环头和方法入口处。当跟踪锚点执行得足够频繁时,就开始跟踪记录。经过多次跟踪记录后,我们修改后的 JIT 编译器将记录的跟踪合并为适合编译的结构。在编译期间,如有必要,将应用特定于跟踪的优化并通过运行时检查进行保护。然后,解释器或已编译的跟踪调用生成的机器代码。如果必须执行未被跟踪覆盖并因此未编译的方法部分,或者如果运行时防护失败,则执行将回退到解释器。 基准测试显示,与基于方法的 Java HotSpot 客户端编译器相比,性能有所提高,生成的机器代码更少,编译速度更快。 SPECjvm2008 基准测试的峰值性能平均提高了 9%,同时生成的机器代码减少了 29%。同样,SPECjbb2005 基准测试的性能提高了 13%,DaCapo 9.12 Bach 基准测试的峰值性能平均提高了 5%。
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.