Context: Just-in-Time (JIT) compilers are able to specialize the code they generate according to a continuous profiling of the running programs. This gives them an advantage when compared to Ahead-of-Time (AoT) compilers that must choose the code to generate once for all. Inquiry: Is it possible to improve the performance of AoT compilers by adding Dynamic Binary Modification (DBM) to the executions? Approach: We added to the Hopc AoT JavaScript compiler a new optimization based on DBM to the inline cache (IC), a classical optimization dynamic languages use to implement object property accesses efficiently. Knowledge: Reducing the number of memory accesses as the new optimization does, does not shorten execution times on contemporary architectures. Grounding: The DBM optimization we have implemented is fully operational on x86_64 architectures. We have conducted several experiments to evaluate its impact on performance and to study the reasons of the lack of acceleration. Importance: The (negative) result we present in this paper sheds new light on the best strategy to be used to implement dynamic languages. It tells that the old days were removing instructions or removing memory reads always yielded to speed up is over. Nowadays, implementing sophisticated compiler optimizations is only worth the effort if the processor is not able by itself to accelerate the code. This result applies to AoT compilers as well as JIT compilers.
翻译:背景:即时(JIT)编译器能够根据对运行程序的持续性能分析,专门化其生成的代码。与必须一次性确定生成代码的预先(AoT)编译器相比,这赋予了JIT编译器优势。研究问题:通过在执行过程中添加动态二进制修改(DBM),能否提升AoT编译器的性能?方法:我们在Hopc AoT JavaScript编译器中,针对内联缓存(IC)——一种动态语言用于高效实现对象属性访问的经典优化技术——新增了基于DBM的优化。认知:正如新优化所做的那样减少内存访问次数,在当代体系结构上并不能缩短执行时间。基础:我们实现的DBM优化在x86_64架构上完全可运行。我们进行了多项实验以评估其对性能的影响,并探究缺乏加速效果的原因。意义:本文呈现的(负面)结果为实现动态语言的最佳策略提供了新视角。它表明,那个仅通过减少指令或内存读取就能提升性能的时代已经结束。如今,只有当处理器自身无法加速代码时,实施复杂的编译器优化才值得投入精力。这一结论同时适用于AoT编译器与JIT编译器。