We present JOG, a framework that facilitates developing Java JIT peephole optimizations alongside JIT tests. JOG enables developers to write a pattern, in Java itself, that specifies desired code transformations by writing code before and after the optimization, as well as any necessary preconditions. Such patterns can be written in the same way that tests of the optimization are already written in OpenJDK. JOG translates each pattern into C/C++ code that can be integrated as a JIT optimization pass. JOG also generates Java tests for optimizations from patterns. Furthermore, JOG can automatically detect possible shadow relation between a pair of optimizations where the effect of the shadowed optimization is overridden by another. Our evaluation shows that JOG makes it easier to write readable JIT optimizations alongside tests without decreasing the effectiveness of JIT optimizations. We wrote 162 patterns, including 68 existing optimizations in OpenJDK, 92 new optimizations adapted from LLVM, and two new optimizations that we proposed. We opened eight pull requests (PRs) for OpenJDK, including six for new optimizations, one on removing shadowed optimizations, and one for newly generated JIT tests; seven PRs have already been integrated into the master branch of OpenJDK.
翻译:我们提出JOG框架,该框架能够促进Java JIT窥孔优化及其对应JIT测试的协同开发。JOG允许开发者用Java语言编写模式,通过定义优化前后的代码转换及必要前置条件来指定期望的代码转换规则。这些模式的编写方式与OpenJDK中已有的优化测试编写方式完全一致。JOG将每个模式自动翻译为可集成到JIT优化流程中的C/C++代码,同时根据模式自动生成相应的Java测试用例。此外,JOG能够自动检测优化对之间可能存在的遮盖关系,即被遮盖优化的效果被另一优化覆盖的情况。实验评估表明,JOG在不降低JIT优化效果的前提下,显著提升了可读性优化的编写便捷性。我们共编写了162个优化模式,包括OpenJDK中现有的68个优化、从LLVM适配的92个新优化以及我们提出的2个全新优化。针对OpenJDK,我们提交了8个拉取请求(PR),其中包含6项新优化、1项遮盖优化移除以及1项JIT测试生成;目前已有7个PR被合并到OpenJDK主分支。