发表机构
Shopify(Shopify)
机构由 AI 辅助整理,请以论文原文为准。AI 中文总结
针对Ruby局部变量编译难题,提出基于方法的JIT编译器ZJIT,采用SSA形式中间表示将局部变量提升为SSA值,实现更高级优化并解决相关编译问题。
AI 中文摘要
Ruby是一种动态类型的面向对象编程语言,其主要实现CRuby包含一个字节码虚拟机和一个成熟的惰性基本块版本(LBBV)即时(JIT)编译器YJIT。为了实现比YJIT支持的更高级优化并鼓励更多外部贡献,我们提出了一种新的基于方法的JIT编译器ZJIT。与YJIT类似,ZJIT从字节码编译为机器码;但不同的是,ZJIT具有多个全局和局部优化 passes,其高级中间表示采用静态单赋值(SSA)形式。为了优化Ruby的局部变量,ZJIT将局部变量提升为SSA值,这与其他Ruby编译器处理局部变量的方式不同:其他JIT编译器要么将局部变量保留为内存加载和存储,要么进行高级部分求值以从内存恢复SSA值。在实现局部变量的过程中,我们(重新)发现了使Ruby中的局部变量在正确且高效编译方面特别具有挑战性的特性,我们展示了这些特性并说明了在ZJIT中如何解决这些问题。
英文摘要
Ruby is a dynamically typed and object-oriented programming language. Its primary implementation, CRuby, contains a bytecode virtual machine and a mature lazy basic block versioning (LBBV) just-in-time (JIT) compiler called YJIT. In order to both implement more advanced optimizations than YJIT supports and also encourage more outside contributions, we present a new method-based JIT called ZJIT. Like YJIT, ZJIT compiles from bytecode to machine code. Unlike YJIT, ZJIT has multiple global and local optimization passes. ZJIT's high-level intermediate representation is in static single assignment (SSA) form. In order to optimize Ruby's local variables, ZJIT lifts local variables into SSA values. This is a departure from how other Ruby compilers handle locals: other JIT compilers either leave local variables as memory loads and stores or do advanced partial evaluation to recover SSA values from memory. While implementing locals, we (re-)discovered what features make local variables in Ruby especially challenging to compile correctly and efficiently. We demonstrate these features and illustrate how we solved these problems in ZJIT.