Bit-Stealing Made Legal: Compilation for Custom Memory Representations of Algebraic Data Types

Author:

Baudon Thaïs1ORCID,Radanne Gabriel2ORCID,Gonnord Laure3ORCID

Affiliation:

1. University of Lyon, France / ENS Lyon, France / UCBL, France / CNRS, France / Inria, France / LIP, France

2. Inria, France / ENS Lyon, France / UCBL, France / CNRS, France / LIP, France

3. University Grenoble Alpes, France / Grenoble INP, France / LCIS, France / LIP, France

Abstract

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.

Publisher

Association for Computing Machinery (ACM)

Subject

Safety, Risk, Reliability and Quality,Software

Reference41 articles.

1. 2023. ECMAScript Language Types. ". https://262.ecma-international.org/14.0/#sec-ecmascript-language-types [Online; accessed 17-July-2023]

2. 2023. AoS and SoA. https://en.wikipedia.org/w/index.php?title=AoS_and_SoA&oldid=1068565041 [Online; accessed 22-February-2023]

3. Lennart Augustsson. 1985. Compiling pattern matching. In Functional Programming Languages and Computer Architecture, Jean-Pierre Jouannaud (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 368–381. isbn:978-3-540-39677-2

4. Rod M Burstall. 1977. Design considerations for a functional programming language. The software revolution.

5. HOPE

Cited by 1 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. Unboxed Data Constructors: Or, How cpp Decides a Halting Problem;Proceedings of the ACM on Programming Languages;2024-01-05

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3