arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.11469cs.PL
收藏

Deegen:一种面向动态语言的具备 JIT 能力的虚拟机生成器

Deegen: A JIT-Capable VM Generator for Dynamic Languages

Haoran Xu, Fredrik Kjolstad

AI总结:

Deegen 是一个元编译器,能够以接近编写简单解释器的成本自动生成高性能 JIT 虚拟机;基于它实现的 LuaJIT Remake 在解释器和基线 JIT 性能上显著超越 PUC Lua 并接近 LuaJIT。

摘要:

为动态语言构建高性能且具备 JIT 能力的虚拟机,传统上需要耗费大量的时间、资金和专业知识。我们提出了 Deegen,这是一种元编译器,允许用户以接近编写简单解释器的工程成本,为自己的语言生成高性能且具备 JIT 能力的虚拟机。Deegen 接收以 C++ 函数形式实现的字节码执行语义,并自动生成一个两层虚拟机执行引擎,其中包括一个最先进的解释器、一个最先进的基线 JIT,以及将它们连接成一个自适应系统的层级切换逻辑。我们是首个展示 JIT 编译器自动生成的工作,也是首个展示自动生成超越现有最先进水平的解释器的工作。我们的性能来源于 Deegen 支持的一长串优化,包括字节码特化与 quickening、寄存器固定、标签寄存器优化、调用内联缓存、泛型内联缓存、JIT 多态内联缓存、JIT 内联缓存内联块、类型检查消除与强度削减、基于类型的慢路径提取与 outlining、JIT 热冷代码拆分以及 JIT OSR 入口。这些优化要么自动应用,要么由语言实现者通过直观的 API 进行引导。因此,Deegen 生成的解释器、基线 JIT 以及生成的 JIT 代码的反汇编结果,可以与专家在最先进虚拟机中手写的汇编代码相媲美。我们使用 Deegen 实现了 LuaJIT Remake(LJR),这是一个符合标准的 Lua 5.1 虚拟机。在 44 个基准测试中,LJR 的解释器平均比官方 PUC Lua 解释器快 179%,比 LuaJIT 的解释器快 31%。LJR 的基线 JIT 启动延迟可以忽略不计,其执行性能平均比 PUC Lua 快 360%,仅比 LuaJIT 的优化 JIT 慢 33%(但在 44 个基准测试中有 13 个更快)。

英文摘要:

Building a high-performance JIT-capable VM for a dynamic language has traditionally required a tremendous amount of time, money, and expertise. We present Deegen, a meta-compiler that allows users to generate a high-performance JIT-capable VM for their own language at an engineering cost similar to writing a simple interpreter. Deegen takes in the execution semantics of the bytecodes implemented as C++ functions, and automatically generates a two-tier VM execution engine with a state-of-the-art interpreter, a state-of-the-art baseline JIT, and the tier-switching logic that connects them into a self-adaptive system. We are the first to demonstrate the automatic generation of a JIT compiler, and the automatic generation of an interpreter that outperforms the state of the art. Our performance comes from a long list of optimizations supported by Deegen, including bytecode specialization and quickening, register pinning, tag register optimization, call inline caching, generic inline caching, JIT polymorphic IC, JIT IC inline slab, type-check removal and strength reduction, type-based slow-path extraction and outlining, JIT hot-cold code splitting, and JIT OSR-entry. These optimizations are either employed automatically, or guided by the language implementer through intuitive APIs. As a result, the disassembly of the Deegen-generated interpreter, baseline JIT, and the generated JIT code rivals the assembly code hand-written by experts in state-of-the-art VMs. We implement LuaJIT Remake (LJR), a standard-compliant Lua 5.1 VM, using Deegen. Across 44 benchmarks, LJR's interpreter is on average 179% faster than the official PUC Lua interpreter, and 31% faster than LuaJIT's interpreter. LJR's baseline JIT has negligible startup delay, and its execution performance is on average 360% faster than PUC Lua and only 33% slower (but faster on 13/44 benchmarks) than LuaJIT's optimizing JIT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑