论文标题
从操作语义自动得出控制流图生成器
Automatically Deriving Control-Flow Graph Generators from Operational Semantics
论文作者
论文摘要
我们从第一原理开发了控制流图的第一个理论,并使用它来创建一种算法,以自动合成从语言的操作语义中自动综合控制流图生成器的许多变体。我们的方法首先引入了一种新算法,用于将大型的小步骤操作语义转换为抽象机器。接下来,它使用一种称为“抽象重写”的技术来自动抽象一种语言的语义,该语言既可以直接从程序(“解释模式”)直接生成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.