Semantic Analysis of Macro Usage for Portability

Semantic Analysis of Macro Usage for Portability
复制标题

可移植性宏用法的语义分析

DOI:
10.1145/3597503.3623323
复制
发表时间:
2024
期刊:
ACM
影响因子:
--
通讯作者:
Gazzillo, Paul
Gazzillo, Paul
中科院分区:
--
文献类型:
--
作者:
Pappas, Brent;Gazzillo, Paul

文献摘要

参考文献

相似文献

C是一种不安全的语言。研究人员一直在开发将C语言移植到更安全的语言(如Rust、Checked C或Go)的工具。然而,现有的工具都是先对源文件进行预处理,然后再移植结果代码,留下难以识别的代码,失去了宏抽象。为了保持宏的使用,移植工具需要能够理解宏行为的分析,以便移植到等效的构造。但是宏语义不同于典型的函数,因此无法进行简单的语法转换来移植它们。我们介绍了第一个用于分析宏使用可移植性的综合框架。我们将宏行为分解为26个细粒度的属性,并实现一个名为Maki的程序分析工具,该工具可以在实际代码中以94%的准确率识别它们。我们将Maki应用于21个程序,这些程序总共包含86,199个宏定义。我们发现,实际的宏比以前所知道的可移植性强得多。超过三分之一(37%)的宏易于移植,Maki为移植更复杂的宏提供了提示。我们发现,与之前的工作相比,平均而言,易于移植的宏增加了2倍,最好的情况下增加了7倍。在Maki输出的指导下,我们在三个实际的程序中找到并移植了宏。我们向Linux维护者提交了转换11个宏的补丁,其中9个已被接受。
C is an unsafe language. Researchers have been developing tools to port C to safer languages such as Rust, Checked C, or Go. Existing tools, however, resort to preprocessing the source file first, then porting the resulting code, leaving barely recognizable code that loses macro abstractions. To preserve macro usage, porting tools need analyses that understand macro behavior to port to equivalent constructs. But macro semantics differ from typical functions, precluding simple syntactic transformations to port them. We introduce the first comprehensive framework for analyzing the portability of macro usage. We decompose macro behavior into 26 fine-grained properties and implement a program analysis tool, called Maki, that identifies them in real-world code with 94% accuracy. We apply Maki to 21 programs containing a total of 86,199 macro definitions. We found that real-world macros are much more portable than previously known. More than a third (37%) are easy-to-port, and Maki provides hints for porting more complicated macros. We find, on average, 2x more easy-to-port macros and up to 7x more in the best case compared to prior work. Guided by Maki's output, we found and hand-ported macros in three real-world programs. We submitted patches to Linux maintainers that transform eleven macros, nine of which have been accepted.
Resugagar:通过语法糖提升评估序列
DOI: 10.1145/2594291.2594319
发表时间: 2014
期刊: Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation
影响因子: --
作者:
Justin Pombrio;S. Krishnamurthi
通讯作者: S. Krishnamurthi
DOI: --
发表时间: 2003
期刊: Proceedings Third IEEE International Workshop on Source Code Analysis and Manipulation
影响因子: --
作者:
J. Favre
通讯作者: J. Favre
DOI: --
发表时间: 2004
期刊: Proceedings. 12th IEEE International Workshop on Program Comprehension, 2004.
影响因子: --
作者:
Christopher A. Mennie;C. Clarke
通讯作者: C. Clarke
用于预处理器感知的 C 源代码分析的框架
DOI: --
发表时间: 2000
期刊: Software, Practice & Experience
影响因子: --
作者:
Greg J. Badros;D. Notkin
通讯作者: D. Notkin
可组合和可编译宏:: 你什么时候想要它?
DOI: --
发表时间: 2002
期刊: ACM SIGPLAN International Conference on Functional Programming
影响因子: --
作者:
M. Flatt
通讯作者: M. Flatt