Bit-Stealing Made Legal - Inria - Institut national de recherche en sciences et technologies du numérique
Article Dans Une Revue Proceedings of the ACM on Programming Languages Année : 2023

Bit-Stealing Made Legal

Résumé

Initially present only in functional languages such as OCaml and Haskell, Algebraic Data Types (ADTs) have now become pervasive in mainstream languages, providing nice data abstractions and an elegant way to express functions through pattern matching. Unfortunately, ADTs remain seldom used in low-level programming. One reason is that their increased convenience comes at the cost of abstracting away the exact memory layout of values. Even Rust, which tries to optimize data layout, severely limits control over memory representation. In this article, we present a new approach to specify the data layout of rich data types based on a dual view: a source type, providing a high-level description available in the rest of the code, along with a memory type, providing full control over the memory layout. This dual view allows for better reasoning about memory layout, both for correctness, with dedicated validity criteria linking the two views, and for optimizations that manipulate the memory view. We then provide algorithms to compile constructors and destructors, including pattern matching, to their low-level memory representation. We prove our compilation algorithms correct, implement them in a tool called ribbit that compiles to LLVM IR, and show some early experimental results.
Fichier principal
Vignette du fichier
main.pdf (1.11 Mo) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)
Licence

Dates et versions

hal-04165615 , version 1 (19-07-2023)

Licence

Identifiants

Citer

Thaïs Baudon, Gabriel Radanne, Laure Gonnord. Bit-Stealing Made Legal. Proceedings of the ACM on Programming Languages, 2023, ICFP, 7 (ICFP), pp.813-846. ⟨10.1145/3607858⟩. ⟨hal-04165615⟩
2313 Consultations
6520 Téléchargements

Altmetric

Partager

More