RUSTY: Effective C to Rust Conversion Via Unstructured Control Specialization

Xiangjun Han,Baojian Hua,Yang Wang,Ziyao Zhang
DOI: https://doi.org/10.1109/qrs-c57518.2022.00122
2022-01-01
Abstract:Rust is an emerging programming language designed for both performance and security, and thus many research efforts have been conducted recently to migrate legacy code bases in C/C++ to Rust to exploit Rust's safety benefits. Unfortunately, prior studies on C to Rust conversion still have three limitations: 1) complex structure; 2) code explosion; and 3) poor performance. These limitations greatly affect the effectiveness and usefulness of such conversions. This paper presents RUSTY, the first system for effective C to Rust code conversion via unstructured control specialization. The key technical insight of RUSTY is to implement C-style syntactic sugars on top of Rust, thus eliminating the discrepancies between the two languages. We have implemented a software prototype for RUSTY and conducted experiments to evaluate the effectiveness and testify the usefulness of it by applying RUSTY to micro-benchmarks, as well as 3 realworld C projects: 1) Vim; 2) cURL; and 3) the silver searcher. And experimental results demonstrated that RUSTY is effective in eliminating unstructured controls, reducing the code size by 16% on average with acceptable overhead (less than 61 microseconds per line of C code).
What problem does this paper attempt to address?