在有效的PDKEEPAAA中生成经过正式验证的本机代码--或者:将CompCert后端转换为经过正式验证的JIT生成器
Formally Verified Native Code Generation in an Effectful JIT -- or: Turning the CompCert Backend into a Formally Verified JIT Compiler
摘要:
现代即时编译器(或JIT)通常交错使用几种机制来执行程序。为了更快的启动时间和观察执行的初始行为,最初可以使用解释。但是过了一段时间,JIT会动态地为它们经常执行的程序部分生成本机代码。尽管动态编译花费了一些时间,但这种机制使得程序执行的剩余时间更快。这样的编译器是具有各种组件的复杂软件,并且在很大程度上依赖于正在执行的不同语言之间的精确相互作用,包括栈上替换。像CompCert这样的传统静态编译器已经在证明助手中实现了机械化,但是JIT到目前为止几乎没有正式化,部分原因是它们的不纯性质和它们的众多组件。这项工作提出了一个模型JIT与动态生成的本地代码,实现和正式验证Coq。虽然JIT的某些部分不能用Coq编写,但我们提出了一种证明方法来界定,指定和推理JIT的不纯影响。我们认为,正式验证一个完整的JIT的艰巨任务应该利用现有的本地代码生成的证据。为此,我们的工作成功地重用CompCert及其正确性证明在动态编译。最后,我们的原型可以提取和执行。
英文摘要:
Modern Just-in-Time compilers (or JITs) typically interleave several mechanisms to execute a program. For faster startup times and to observe the initial behavior of an execution, interpretation can be initially used. But after a while, JITs dynamically produce native code for parts of the program they execute often. Although some time is spent compiling dynamically, this mechanism makes for much faster times for the remaining of the program execution. Such compilers are complex pieces of software with various components, and greatly rely on a precise interplay between the different languages being executed, including on-stack-replacement. Traditional static compilers like CompCert have been mechanized in proof assistants, but JITs have been scarcely formalized so far, partly due to their impure nature and their numerous components. This work presents a model JIT with dynamic generation of native code, implemented and formally verified in Coq. Although some parts of a JIT cannot be written in Coq, we propose a proof methodology to delimit, specify and reason on the impure effects of a JIT. We argue that the daunting task of formally verifying a complete JIT should draw on existing proofs of native code generation. To this end, our work successfully reuses CompCert and its correctness proofs during dynamic compilation. Finally, our prototype can be extracted and executed.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。