Unboxing Virgil ADTs for Fun and Profit
Bradley Wei Jie Teo, Ben L. Titzer

TL;DR
This paper introduces annotation-guided optimizations for algebraic data types in Virgil, enabling more efficient memory use and hardware-specific data manipulation through unboxing and packing annotations.
Contribution
It extends Virgil with #unboxed and #packed annotations, allowing automatic transformation to scalar representations and programmer-controlled bit layouts.
Findings
Reduced memory usage in various workloads
Improved data manipulation aligned with hardware formats
Demonstrated performance benefits of annotations
Abstract
Algebraic Data Types (ADTs) are an increasingly common feature in modern programming languages. In many implementations, values of non-nullary, multi-case ADTs are allocated on the heap, which may reduce performance and increase memory usage. This work explores annotation-guided optimizations to ADT representation in Virgil, a systems-level programming language that compiles to x86, x86-64, Wasm and the Java Virtual Machine. We extend Virgil with annotations: #unboxed to eliminate the overhead of heap allocation via automatic compiler transformation to a scalar representation, and #packed, to enable programmer-expressed bit-layouts. These annotations allow programmers to both save memory and manipulate data in formats dictated by hardware. We dedicate this work as an homage and echo of work done in collaboration with Jens in the work entitled "A Declarative Approach to Generating…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
