paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Statically Analyzing the Dataflow of R Programs

静态分析 R 程序的数据流
OOPSLA 9(OOPSLA2)2025匹配度 3/10 · 论文属于静态程序分析与程序切片,与用户关注的静态分析领域有交集,但对象是 R 语言及其动态特性,并未涉及 PL→AI(ML/Agent 程序分析)、AI→PL、浮点程序分析或贝叶斯程序分析等核心方向。引用 1 inbox
Florian Sihler, Matthias Tichy
crossref: 2026-09-10

AI 速览

一句话:提出面向 R 的静态数据流分析框架,能处理动态特性并生成数据流图,支持程序切片。

R 广泛用于统计计算,但动态作用域、惰性求值及动态副作用等特性使静态分析困难,生态也缺乏成熟工具。本文提出面向 R 的静态数据流分析框架:对规范化 AST 做带状态折叠,追踪定义/重定义、值、函数调用、副作用、外部文件与动态控制流,为每个程序生成数据流图,并以程序切片作为概念验证。评估使用 779 个真实脚本的人工切片点做输出等价测试,99.7% 保持相同输出;在 4,230 个真实脚本与 20,815 个 CRAN 包上测时间与内存,平均约 576 ms、213 kB;切片器平均减少 84.8% token,显示提升程序理解潜力。

问题
R 的动态作用域、惰性求值与动态副作用等特性使其程序难以静态分析,同时 R 生态缺乏帮助研究者理解与改进代码的分析工具。
方法
提出面向 R 的静态数据流分析框架,将规范化 AST 上的带状态折叠作为核心分析,追踪定义/重定义、值、函数调用、副作用、外部文件与动态控制流,生成数据流图,并实现程序切片作为概念验证。
评估
在 779 个真实脚本的人工切片点上做输出等价测试(99.7% 输出一致),并用系统测试用例和 4,230 个真实脚本及 20,815 个 CRAN 包测量运行时与内存;还评估切片器的召回率、借助 shrinking 的准确率及相对 SOTA 的改进,平均减少 84.8% token。
原文摘要(Abstract)

The R programming language is primarily designed for statistical computing and mostly used by researchers without a background in computer science. R provides a wide range of dynamic features and peculiarities that are difficult to analyze statically like dynamic scoping and lazy evaluation with dynamic side effects. At the same time, the R ecosystem lacks sophisticated analysis tools that support researchers in understanding and improving their code. In this paper, we present a novel static dataflow analysis framework for the R programming language that is capable of handling the dynamic nature of R programs and produces the dataflow graph of given R programs. This graph can be essential in a range of analyses, including program slicing, which we implement as a proof of concept. The core analysis works as a stateful fold over a normalized version of the abstract syntax tree of the R program, which tracks (re-)definitions, values, function calls, side effects, external files, and a dynamic control flow to produce one dataflow graph per program. We evaluate the correctness of our analysis using output equivalence testing on a manually curated dataset of 779 sensible slicing points from executable real-world R scripts. Additionally, we use a set of systematic test cases based on the capabilities of the R language and the implementation of the R interpreter and measure the runtimes well as the memory consumption on a set of 4,230 real-world R scripts and 20,815 packages available on R’s package manager CRAN. Furthermore, we evaluate the recall of our program slicer, its accuracy using shrinking, and its improvement over the state of the art. We correctly analyze almost all programs in our equivalence test suite, preserving the identical output for 99.7 % of the manually curated slicing points. On average, we require 576 ms to analyze the dataflow and around 213 kB to store the graph of a research script. This shows that our analysis is capable of analyzing real-world sources quickly and correctly. Our slicer achieves an average reduction of 84.8 % of tokens indicating its potential to improve program comprehension.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2884,
  title = {Statically Analyzing the Dataflow of R Programs},
  author = {Florian Sihler and Matthias Tichy},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {OOPSLA2},
  year = {2025},
  doi = {10.1145/3763087}
}