Leveraging Copy-and-Patch JIT for Low-Overhead Dynamic Program Analysis
Authors
Year
2026
Published
MPLR '26: Proceedings of the 23rd ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes. New York: Association for Computing Machinery, 2026. p. 49-60. ISBN 979-8-4007-2433-6.
Type
Proceedings paper
Departments
Annotation
Copy-and-patch compilation is an approach for building baseline just-in-time compilers from AST or bytecode interpreters. It features very fast compilation times while generating good quality code. It has been used as a baseline tier for a number of languages including Lua, Python, and R. In this paper, we explore copy-and-patch as a foundation for dynamic program analysis, and implement four analyses on top of an existing copy-and-patch JIT for R: code instrumentation, code coverage, performance profiling, and native debugging. Two properties make copy-and-patch particularly well-suited for this purpose. First, since the code templates (stencils) are compiled by a standard C compiler, DWARF debug information is available as a by-product. This lets us reuse native tooling for profiling and debugging directly, with R and native code appearing in a single unified view. Second, analyses that operate at the bytecode level reduce to injecting stencils into the bytecode stream at JIT compile time, incurring minimal overhead. Our prototype evaluation yields instrumentation with no measurable overhead; code coverage that is faster than the existing solution while covering 17% more lines; and profiling that remains, on average, faster than GNU R.
Comparing R Bytecode Compilers Written in R, Java, and Rust
Authors
Year
2025
Published
Companion Proceedings of the 9th International Conference on the Art, Science, and Engineering of Programming (Programming 2025) - MoreVMs. Saarbrücken: Dagstuhl Publishing,, 2025. p. 1-6. Dagstuhl Publishing. vol. 134. ISBN 978-3-95977-382-9.
Type
Proceedings paper
Annotation
This paper presents a comparative analysis of three implementations of the R bytecode compiler: the official R implementation, a Java-based compiler, and a Rust-based compiler. The R compiler, written in R itself, poses challenges in terms of performance and maintainability. We evaluate designs of the compilers, their trade-offs, and performance characteristics. The Rust version outperforms the Java version, which itself outperforms the R version.
R4R: Reproducibility for R
Authors
Year
2025
Published
ACM REP '25: Proceedings of the 3rd ACM Conference on Reproducibility and Replicability. New York: Association for Computing Machinery, 2025. p. 132-142. ISSN 2168-4081. ISBN 979-8-4007-1958-5.
Type
Proceedings paper
Annotation
Ensuring reproducibility is a fundamental challenge in computational research. Reproducing results often requires reconstructing complex software environments involving data files, external tools, system libraries, and language-specific packages. While various tools aim to simplify this process, they often rely on user-provided metadata, overlook system dependencies, or produce unnecessarily large environments.
We present r4r, a tool that automates the creation of minimal, user-inspectable, self-contained execution environments through dynamic program analysis techniques. r4r captures all runtime dependencies of a data analysis pipeline and produces a Docker image capable of reproducing the original execution. Although designed with first-class support for the R programming language, r4r also includes a generic fallback mechanism applicable to other languages. We evaluate r4r on a collection of R Markdown notebooks from Kaggle and find that it achieves exact reproducibility for 97.5% of deterministic notebooks.
signatr: A Data-Driven Fuzzing Tool for R
Authors
Year
2022
Published
SLE 2022: Proceedings of the 15th ACM SIGPLAN International Conference on Software Language Engineering. New York: Association for Computing Machinery, 2022. p. 216-221. 15. vol. 1. ISBN 978-1-4503-9919-7.
Type
Proceedings paper
Departments
Annotation
The fast-and-loose, permissive semantics of dynamic programming languages limit the power of static analyses. For that reason, soundness is often traded for precision through dynamic program analysis. Dynamic analysis is only as good as the available runnable code, and relying solely on test suites is fraught as they do not cover the full gamut of possible behaviors. Fuzzing is an approach for automatically exercising code, and could be used to obtain more runnable code. However, the shape of user-defined data in dynamic languages is difficult to intuit, limiting a fuzzer's reach.
We propose a feedback-driven blackbox fuzzing approach which draws inputs from a database of values recorded from existing code. We implement this approach in a tool called signatr for the R language. We present the insights of its design and implementation, and assess signatr's ability to uncover new behaviors by fuzzing 4,829 R functions from 100 R packages, revealing 1,195,184 new signatures.
What we eval in the shadows: A large-scale study of eval in R programs
Authors
Year
2021
Published
Proceedings of the ACM on Programming Languages (PACMPL). 2021, 5(OOPSLA), ISSN 2475-1421.
Type
Article
DOI
Departments
Annotation
Most dynamic languages allow users to turn text into code using various functions, often named eval, with language-dependent semantics. The widespread use of these reflective functions hinders static analysis and prevents compilers from performing optimizations. This paper aims to provide a better sense of why programmers use eval. Understanding why eval is used in practice is key to finding ways to mitigate its negative impact. We have reasons to believe that reflective feature usage is language and application domain-specific; we focus on data science code written in R and compare our results to previous work that analyzed web programming in JavaScript. We analyze 49,296,059 calls to eval from 240,327 scripts extracted from 15,401 R packages. We find that eval is indeed in widespread use; R's eval is more pervasive and arguably dangerous than what was previously reported for JavaScript.