Huawei Research Journal 2024
Balancing the Yin and Yang of Dynamic Compilation and Execution - Opportunities for HW/SW Co-Design
Rene Mueller
Abstract
Modern language implementations leverage dynamic or just-in-time (JIT) compilation and take advantage of their unique opportunity to observe the state of a program as it is being executed. By collecting dynamic information about control flow, types and values, the compiler is able to apply speculative optimizations when generating machine code. The more is known about the program's execution, the more aggressive the speculation can be and the higher the performance gain. However, speculations are not free. Profiling information about the program's state must be collected through instrumentation, which constitutes a run-time overhead. Furthermore, non-provable assumptions made by the compiler that enable speculations need to be checked at run-time and a deoptimization mechanism must be provided for the case they fail. This further increases the run-time overhead. Hence, current JIT compilers are very risk-averse. A reduction of both overheads would allow more accurate profiles and also enable more risk-seeking speculations in the compiler. In this paper, we argue that language runtime implementations offer an interesting avenue for hardware/software co-design to build better dynamic compilers and processors that execute dynamically compiled programs. While observing the increasing importance of high-productivity languages, we ask how one would build a hardware-assisted execution platform for such languages. In addition to better informed hardware we are advocating for better informed software. Software-directed narrowly-focused profiling in hardware, either by using novel profiling units or by leveraging the existing Performance Monitoring Units, provides more detailed profiles at low overhead. We are also proposing hardware-assisted deoptimization and assertions with user-level trap handlers to further lower the checks and deoptimization costs. We outline interesting areas in the Yin-Yang between JIT compilation and the execution, peak performance and overhead, and better hardware and JIT software for dynamically compiled languages.
