Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Realistic Realizability: Specifying ABIs You Can Count On

Published: 08 October 2024 Publication History

Abstract

The Application Binary Interface (ABI) for a language defines the interoperability rules for its target platforms, including data layout and calling conventions, such that compliance with the rules ensures “safe” execution and perhaps certain resource usage guarantees. These rules are relied upon by compilers, libraries, and foreign-function interfaces. Unfortunately, ABIs are typically specified in prose, and while type systems for source languages have evolved, ABIs have comparatively stalled, lacking advancements in expressivity and safety. We propose a vision for richer, semantic ABIs to improve interoperability and library integration, supported by a methodology for formally specifying ABIs using realizability models. These semantic ABIs connect abstract, high-level types to unwieldy, but well-behaved, low-level code. We illustrate our approach with a case study formalizing the ABI of a functional source language in terms of a reference-counting implementation in a C-like target language. A key contribution supporting this case study is a graph-based model of separation logic that captures the ownership and accessibility of reference-counted resources using modalities inspired by hybrid logic. To highlight the flexibility of our methodology, we show how various design decisions can be interpreted into the semantic ABI. Finally, we provide the first formalization of library evolution, a distinguishing feature of Swift’s ABI.

Supplemental Material

ZIP File - Technical Appendix
The technical appendix includes supporting definitions and proofs.

References

[1]
Amal Ahmed. 2006. Step-indexed syntactic logical relations for recursive and quantified types. In European Symposium on Programming. 69–83. https://doi.org/10.1007/11693024_6
[2]
Amal Ahmed and Matthias Blume. 2008. Typed closure conversion preserves observational equivalence. In Proceedings of the 13th ACM SIGPLAN international conference on Functional programming. 157–168. https://doi.org/10.1145/1411204.1411227
[3]
Amal Ahmed, Matthew Fluet, and Greg Morrisett. 2007. L3: a linear language with locations. Fundamenta Informaticae, 77, 4 (2007), 397–449.
[4]
Amal Jamil Ahmed. 2004. Semantics of Types for Mutable State. Ph. D. Dissertation. Princeton University.
[5]
Emilio Cobos Álvarez. 2018. i128 / u128 are not compatible with C’s definition. https://github.com/rust-lang/rust/issues/54341 GitHub issue #54341
[6]
ANSSI-FR. 2022. Rust Guide: Foreign Function Interface. https://github.com/ANSSI-FR/rust-guide/blob/master/src/en/07_ffi.md
[7]
Andrew W Appel. 2014. Program logics for certified compilers. Cambridge University Press. https://doi.org/10.1017/cbo9781107256552
[8]
Andrew W Appel and David McAllester. 2001. An indexed model of recursive types for foundational proof-carrying code. ACM Transactions on Programming Languages and Systems (TOPLAS), 23, 5 (2001), 657–683. https://doi.org/10.1145/504709.504712
[9]
Andrew W Appel, Paul-André Mellies, Christopher D Richards, and Jérôme Vouillon. 2007. A very modal model of a modern, major, general type system. In Proceedings of the 34th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 109–122. https://doi.org/10.1145/1190215.1190235
[10]
Apple. 2015. Library Evolution. https://github.com/apple/swift/blob/main/docs/LibraryEvolution.rst
[11]
Apple. 2017. ABI Stability Manifesto. https://github.com/apple/swift/blob/main/docs/ABIStabilityManifesto.md
[12]
Apple. 2024. The Swift Book: Access Control—Default Memberwise Initializers. https://github.com/apple/swift-book/blob/main/TSPL.docc/LanguageGuide/AccessControl.md#default-memberwise-initializers-for-structure-types
[13]
Apple. 2024. The Swift Book: Automatic Reference Counting. https://github.com/apple/swift-book/blob/main/TSPL.docc/LanguageGuide/AutomaticReferenceCounting.md
[14]
Apple. 2024. The Swift Book: Switch Statement. https://github.com/apple/swift-book/blob/8b7826c2a1809b5d93651d92555510a9c46502dd/TSPL.docc/ReferenceManual/Statements.md#switch-statement
[15]
Kevin Atkinson, Matthew Flatt, and Gary Lindstrom. 2010. ABI compatibility through a customizable language. In Proceedings of the ninth international conference on Generative programming and component engineering. 147–156. https://doi.org/10.1145/1868294.1868316
[16]
Stephanie Balzer, Bernardo Toninho, and Frank Pfenning. 2019. Manifest Deadlock-Freedom for Shared Session Types. In Programming Languages and Systems - 28th European Symposium on Programming, ESOP 2019, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2019, Prague, Czech Republic, April 6-11, 2019, Proceedings, Luís Caires (Ed.) (Lecture Notes in Computer Science, Vol. 11423). Springer, 611–639. https://doi.org/10.1007/978-3-030-17184-1_22
[17]
Nick Benton. 2006. Abstracting allocation: The new new thing. In International Workshop on Computer Science Logic. 182–196.
[18]
Nick Benton and Nicolas Tabareau. 2009. Compiling functional types to relational specifications for low level imperative code. In Proceedings of the 4th international workshop on Types in language design and implementation. 3–14. https://doi.org/10.1145/1481861.1481864
[19]
Nick Benton and Uri Zarfaty. 2007. Formalizing and verifying semantic type soundness of a simple compiler. In Proceedings of the 9th ACM SIGPLAN international conference on Principles and practice of declarative programming. 1–12. https://doi.org/10.1145/1273920.1273922
[20]
Lars Birkedal, Noah Torp-Smith, and Hongseok Yang. 2006. Semantics of separation-logic typing and higher-order frame rules for Algol-like languages. Logical Methods in Computer Science, 2 (2006), https://doi.org/10.2168/lmcs-2(5:1)2006
[21]
Aleš Bizjak, Daniel Gratzer, Robbert Krebbers, and Lars Birkedal. 2019. Iron: Managing obligations in higher-order concurrent separation logic. Proceedings of the ACM on Programming Languages, 3, POPL (2019), 1–30. https://doi.org/10.1145/3290378
[22]
Maximilian C Bolingbroke and Simon L Peyton Jones. 2009. Types are calling conventions. In Proceedings of the 2nd ACM SIGPLAN symposium on Haskell. 1–12. https://doi.org/10.1145/1596638.1596640
[23]
Torben Braüner and Valeria de Paiva. 2006. Intuitionistic hybrid logic. Journal of Applied Logic, 4, 3 (2006), 231–255. https://doi.org/10.1016/j.jal.2005.06.009
[24]
Luís Caires, Jorge A. Pérez, Frank Pfenning, and Bernardo Toninho. 2019. Domain-Aware Session Types. In 30th International Conference on Concurrency Theory, CONCUR 2019, August 27-30, 2019, Amsterdam, the Netherlands, Wan J. Fokkink and Rob van Glabbeek (Eds.) (LIPIcs, Vol. 140). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 39:1–39:17. https://doi.org/10.4230/LIPICS.CONCUR.2019.39
[25]
Tony Chen and David Chisnall. 2019. Pointer Tagging for Memory Safety.
[26]
Aria Desires. 2023. abi-cafe. https://github.com/Gankra/abi-cafe
[27]
Thomas Dinsdale-Young, Lars Birkedal, Philippa Gardner, Matthew Parkinson, and Hongseok Yang. 2013. Views: compositional reasoning for concurrent programs. In Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on principles of programming languages. 287–300. https://doi.org/10.1145/2480359.2429104
[28]
Marko Doko and Viktor Vafeiadis. 2017. Tackling real-life relaxed concurrency with FSL++. In Programming Languages and Systems: 26th European Symposium on Programming, ESOP 2017, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2017, Uppsala, Sweden, April 22–29, 2017, Proceedings 26. 448–475. https://doi.org/10.1007/978-3-662-54434-1_17
[29]
Paul Downen, Zena M Ariola, Simon Peyton Jones, and Richard A Eisenberg. 2020. Kinds are calling conventions. Proceedings of the ACM on Programming Languages, 4, ICFP (2020), 1–29. https://doi.org/10.1145/3408986
[30]
Derek Dreyer, Amal Ahmed, and Lars Birkedal. 2011. Logical step-indexed logical relations. Logical Methods in Computer Science, 7 (2011), https://doi.org/10.2168/lmcs-7(2:16)2011
[31]
Sophia Drossopoulou, David Wragg, and Susan Eisenbach. 1998. What is Java binary compatibility? In Proceedings of the 13th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications. 341–361. https://doi.org/10.1145/286936.286974
[32]
Michael Emmi, Ranjit Jhala, Eddie Kohler, and Rupak Majumdar. 2009. Verifying reference counting implementations. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems. 352–367. https://doi.org/10.1007/978-3-642-00768-2_30
[33]
Michael Fitzgibbons, Zoe Paraskevopoulou, Noble Mushtak, Michelle Thalakottur, Jose Sulaiman Manzur, and Amal Ahmed. 2024. RichWasm: Bringing Safe, Fine-Grained, Shared-Memory Interoperability Down to WebAssembly. Proceedings of the ACM on Programming Languages, 8, PLDI (2024), 1656–1679. https://doi.org/10.1145/3656444
[34]
Python Software Foundation. 2023. Python/C API Reference Manual. https://docs.python.org/3/c-api/intro.html#reference-counts
[35]
Andreas Haas, Andreas Rossberg, Derek L Schuff, Ben L Titzer, Michael Holman, Dan Gohman, Luke Wagner, Alon Zakai, and JF Bastien. 2017. Bringing the web up to speed with WebAssembly. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation. 185–200. https://doi.org/10.1145/3140587.3062363
[36]
Michael Hicks, Jonathan T Moore, and Scott Nettles. 2001. Dynamic software updating. ACM SIGPLAN Notices, 36, 5 (2001), 13–23. https://doi.org/10.1145/381694.378798
[37]
Jules Jacobs, Jonas Kastberg Hinrichsen, and Robbert Krebbers. 2024. Deadlock-Free Separation Logic: Linearity Yields Progress for Dependent Higher-Order Message Passing. Proceedings of the ACM on Programming Languages, 8, POPL (2024), 1385–1417. https://doi.org/10.1145/3632889
[38]
Jonas B Jensen, Nick Benton, and Andrew Kennedy. 2013. High-level separation logic for low-level code. In Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 301–314. https://doi.org/10.1145/2480359.2429105
[39]
Simon L Peyton Jones and John Launchbury. 1991. Unboxed values as first class citizens in a non-strict functional language. In Functional Programming Languages and Computer Architecture: 5th ACM Conference Cambridge, MA, USA, August 26–30, 1991 Proceedings 5. 636–666. https://doi.org/10.1007/3540543961_30
[40]
Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2017. RustBelt: Securing the foundations of the Rust programming language. Proceedings of the ACM on Programming Languages, 2, POPL (2017), 1–34. https://doi.org/10.1145/3158154
[41]
Ralf Jung, Robbert Krebbers, Jacques-Henri Jourdan, Aleš Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. Journal of Functional Programming, 28 (2018), e20. https://doi.org/10.1017/s0956796818000151
[42]
Chaitanya Koparkar. 2022. A primer on pointer tagging. XRDS: Crossroads, The ACM Magazine for Students, 29, 1 (2022), 66–68. https://doi.org/10.1145/3558200
[43]
Juneyoung Lee, Yoonseung Kim, Youngju Song, Chung-Kil Hur, Sanjoy Das, David Majnemer, John Regehr, and Nuno P Lopes. 2017. Taming undefined behavior in LLVM. ACM SIGPLAN Notices, 52, 6 (2017), 633–647. https://doi.org/10.1145/3062341.3062343
[44]
Xavier Leroy. 2023. The CompCert C verified compiler: Documentation and user’s manual. Ph. D. Dissertation. Inria.
[45]
Xavier Leroy, Andrew W. Appel, Sandrine Blazy, and Gordon Stewart. 2014. The CompCert memory model. In Program Logics for Certified Compilers, Andrew W. Appel (Ed.). Cambridge University Press. http://vst.cs.princeton.edu/
[46]
Ruy Ley-Wild and Aleksandar Nanevski. 2013. Subjective auxiliary state for coarse-grained concurrency. In Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 561–574. https://doi.org/10.1145/2480359.2429134
[47]
Anton Lorenzen, Daan Leijen, and Wouter Swierstra. 2023. FP^2: Fully in-Place Functional Programming. Proc. ACM Program. Lang., 7, ICFP (2023), 275–304. https://doi.org/10.1145/3607840
[48]
Jean-Marie Madiot and François Pottier. 2022. A separation logic for heap space under garbage collection. Proceedings of the ACM on Programming Languages, 6, POPL (2022), 1–28. https://doi.org/10.1145/3498672
[49]
Simon Marlow, Alexey Rodriguez Yakushev, and Simon Peyton Jones. 2007. Faster laziness using dynamic pointer tagging. Acm sigplan notices, 42, 9 (2007), 277–288. https://doi.org/10.1145/1291151.1291194
[50]
Phillip Mates, Jamie Perconti, and Amal Ahmed. 2019. Under control: Compositionally correct closure conversion with mutable state. In Proceedings of the 21st International Symposium on Principles and Practice of Declarative Programming. 1–15. https://doi.org/10.1145/3354166.3354181
[51]
Greg Morrisett, David Walker, Karl Crary, and Neal Glew. 1999. From System F to typed assembly language. ACM Transactions on Programming Languages and Systems (TOPLAS), 21, 3 (1999), 527–568. https://doi.org/10.1145/319301.319345
[52]
Ike Mulder, Robbert Krebbers, and Herman Geuvers. 2022. Diaframe: automated verification of fine-grained concurrent programs in Iris. In PLDI ’22: 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation, San Diego, CA, USA, June 13 - 17, 2022, Ranjit Jhala and Isil Dillig (Eds.). ACM, 809–824. https://doi.org/10.1145/3519939.3523432
[53]
Hiroshi Nakano. 2000. A modality for recursion. In Proceedings Fifteenth Annual IEEE Symposium on Logic in Computer Science (Cat. No. 99CB36332). 255–266.
[54]
Peter O’Hearn, John Reynolds, and Hongseok Yang. 2001. Local reasoning about programs that alter data structures. In Computer Science Logic: 15th International Workshop, CSL 2001 10th Annual Conference of the EACSL Paris, France, September 10–13, 2001, Proceedings 15. 1–19. https://doi.org/10.1007/3-540-44802-0_1
[55]
Daniel Patterson, Noble Mushtak, Andrew Wagner, and Amal Ahmed. 2022. Semantic soundness for language interoperability. In Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation. 609–624. https://doi.org/10.1145/3519939.3523703
[56]
Daniel Patterson, Andrew Wagner, and Amal Ahmed. 2023. Semantic Encapsulation using Linking Types. In Proceedings of the 8th ACM SIGPLAN International Workshop on Type-Driven Development. 14–28. https://doi.org/10.1145/3609027.3609405
[57]
Alex Reinking, Ningning Xie, Leonardo de Moura, and Daan Leijen. 2021. Perceus: Garbage free reference counting with reuse. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation. 96–111. https://doi.org/10.1145/3453483.3454032
[58]
John C Reynolds. 1983. Types, abstraction and parametric polymorphism. In Information Processing 83, Proceedings of the IFIP 9th World Computer Congres. 513–523.
[59]
John C Reynolds. 2002. Separation logic: A logic for shared mutable data structures. In Proceedings 17th Annual IEEE Symposium on Logic in Computer Science. 55–74.
[60]
Rust Language RFCs. 2023. #3470: crABI v1. https://github.com/rust-lang/rfcs/pull/3470
[61]
Rust. 2023. rust-bindgen. https://github.com/rust-lang/rust-bindgen
[62]
Rust. 2023. The Rust Book: Variables and Data Interacting with Move. https://github.com/rust-lang/book/blob/main/src/ch04-01-what-is-ownership.md#variables-and-data-interacting-with-move
[63]
Rust. 2023. Unsafe Code Guidelines: Data Layout—Enums. https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/enums.md
[64]
Rust. 2023. Unsafe Code Guidelines: Glossary—Niche. https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/glossary.md#niche
[65]
Rust. 2024. The Rust Reference: The non_exhaustive Attribute. https://github.com/rust-lang/reference/blob/master/src/attributes/type_system.md#the-non_exhaustive-attribute
[66]
Peter Sewell, Gareth Stoyle, Michael Hicks, Gavin Bierman, and Keith Wansbrough. 2008. Dynamic rebinding for marshalling and update, via redex-time and destruct-time reduction. Journal of Functional Programming, 18, 4 (2008), 437–502.
[67]
Gareth Stoyle, Michael Hicks, Gavin Bierman, Peter Sewell, and Iulian Neamtiu. 2005. Mutatis mutandis: safe and predictable dynamic software updating. ACM SIGPLAN Notices, 40, 1 (2005), 183–194. https://doi.org/10.1145/1040305.1040321
[68]
David Tarditi, Greg Morrisett, Perry Cheng, Chris Stone, Robert Harper, and Peter Lee. 1996. TIL: A type-directed optimizing compiler for ML. ACM Sigplan Notices, 31, 5 (1996), 181–192. https://doi.org/10.21236/ada306265
[69]
Amin Timany, Robbert Krebbers, Derek Dreyer, and Lars Birkedal. 2022. A Logical Approach to Type Soundness. Reported under submission on https://iris-project. org/(2022). https://iris-project. org/pdfs/2022-submitted-logical-type-soundness. pdf, https://doi.org/10.1145/3676954
[70]
Harvey Tuch, Gerwin Klein, and Michael Norrish. 2007. Types, bytes, and separation logic. In Proceedings of the 34th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 97–108. https://doi.org/10.1145/1190215.1190234
[71]
Andrew Wagner, Zachary Eisbach, and Amal Ahmed. 2024. Realistic Realizability: Specifying ABIs You Can Count On (Supplementary Material). Proc. ACM Program. Lang., 8, OOPSLA2, Article 315 (2024), Oct., https://doi.org/10.1145/3689755
[72]
Yuting Wang, Xiangzhe Xu, Pierre Wilke, and Zhong Shao. 2020. CompCertELF: verified separate compilation of C programs into ELF object files. Proceedings of the ACM on Programming Languages, 4, OOPSLA (2020), 1–28. https://doi.org/10.1145/3428265
[73]
WebAssembly. 2023. Component Model. https://github.com/WebAssembly/component-model
[74]
Matt Windsor, Mike Dodds, Ben Simner, and Matthew J. Parkinson. 2017. Starling: Lightweight Concurrency Verification with Views. In Computer Aided Verification - 29th International Conference, CAV 2017, Heidelberg, Germany, July 24-28, 2017, Proceedings, Part I, Rupak Majumdar and Viktor Kuncak (Eds.) (Lecture Notes in Computer Science, Vol. 10426). Springer, 544–569. https://doi.org/10.1007/978-3-319-63387-9_27

Cited By

View all
  • (2024)Realistic Realizability: Specifying ABIs You Can Count OnProceedings of the ACM on Programming Languages10.1145/36897558:OOPSLA2(1249-1278)Online publication date: 8-Oct-2024

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 8, Issue OOPSLA2
October 2024
2691 pages
EISSN:2475-1421
DOI:10.1145/3554319
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 08 October 2024
Published in PACMPL Volume 8, Issue OOPSLA2

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. application binary interfaces
  2. logical relations
  3. program logics
  4. reference counting
  5. semantics
  6. separation logic
  7. type soundness

Qualifiers

  • Research-article

Funding Sources

  • Defense Advanced Research Projects Agency

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)315
  • Downloads (Last 6 weeks)83
Reflects downloads up to 26 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Realistic Realizability: Specifying ABIs You Can Count OnProceedings of the ACM on Programming Languages10.1145/36897558:OOPSLA2(1249-1278)Online publication date: 8-Oct-2024

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media