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

从操作语义自动生成控制流图生成器

Automatically Deriving Control-Flow Graph Generators from Operational Semantics

James Koppel, Jackson Kearl, Armando Solar-Lezama

摘要:

我们开发的第一理论的控制流图的第一原则,并使用它来创建一个算法,自动合成的控制流图生成器的许多变种从语言的操作语义。我们的方法首先介绍了一个新的算法转换一个大类的小步操作语义的抽象机器。接下来,它使用一种称为“抽象重写”的技术来自动抽象语言的语义,该技术用于直接从程序生成CFG(“解释模式”),并为任何语言中的程序生成独立代码,类似于人类编写的CFG生成器。我们展示了如何选择两个抽象和投影参数,使我们的方法来合成几个家庭的CFG发电机有用的不同种类的工具。我们证明了生成的图和原始语义之间的对应关系。我们提供并证明了一个自动证明解释模式生成器终止的算法。除了我们的理论结果,我们已经实现了这个算法的一个工具,称为任务,并表明它产生人类可读的代码在两个中等大小的语言与60-80条规则,具有几乎所有的过程内控制结构常见于现代语言。然后,我们展示了这些CFG发生器足以在其上构建两个静态分析仪。我们的工作是一个有前途的一步,能够综合所有所需的工具,从语义的程序设计语言的宏伟愿景。

英文摘要:

We develop the first theory of control-flow graphs from first principles, and use it to create an algorithm for automatically synthesizing many variants of control-flow graph generators from a language's operational semantics. Our approach first introduces a new algorithm for converting a large class of small-step operational semantics to an abstract machine. It next uses a technique called "abstract rewriting" to automatically abstract the semantics of a language, which is used both to directly generate a CFG from a program ("interpreted mode") and to generate standalone code, similar to a human-written CFG generator, for any program in a language. We show how the choice of two abstraction and projection parameters allow our approach to synthesize several families of CFG-generators useful for different kinds of tools. We prove the correspondence between the generated graphs and the original semantics. We provide and prove an algorithm for automatically proving the termination of interpreted-mode generators. In addition to our theoretical results, we have implemented this algorithm in a tool called Mandate, and show that it produces human-readable code on two medium-size languages with 60-80 rules, featuring nearly all intraprocedural control constructs common in modern languages. We then showed these CFG-generators were sufficient to build two static analyzers atop them. Our work is a promising step towards the grand vision of being able to synthesize all desired tools from the semantics of a programming language.

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

↑