skip to main content
research-article
Open access

Collecting Cyclic Garbage across Foreign Function Interfaces: Who Takes the Last Piece of Cake?

Published: 06 June 2023 Publication History

Abstract

A growing number of libraries written in managed languages, such as Python and JavaScript, are bringing about new demand for a foreign language interface (FFI) between two managed languages. Such an FFI allows a host-language program to seamlessly call a library function written in a foreign language and exchange objects. It is often implemented by a user-level library but such implementation cannot reclaim cyclic garbage, or a group of objects with circular references, across the language boundary. This paper proposes Refgraph GC, which enables FFI implementation that can reclaim cyclic garbage. Refgraph GC coordinates the garbage collectors of two languages and it needs to modify the managed runtime of one language only. It does not modify that of the other language. This paper discusses the soundness and completeness of the proposed algorithm and also shows the results of the experiments with our implementation of FFI with Refgraph GC. This FFI allows a Ruby program to access a JavaScript library.

References

[1]
David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in Reference Counted Systems. In Proceedings of the 15th European Conference on Object-Oriented Programming (ECOOP ’01). Springer-Verlag, Berlin, Heidelberg. 207–235. isbn:3540422064
[2]
Edd Barrett, Carl Friedrich Bolz, Lukas Diekmann, and Laurence Tratt. 2016. Fine-grained Language Composition: A Case Study. In 30th European Conference on Object-Oriented Programming (ECOOP 2016), Shriram Krishnamurthi and Benjamin S. Lerner (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 56). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 3:1–3:27. isbn:978-3-95977-014-9 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2016.3
[3]
DI Bevan. 1987. Distributed garbage collection using reference counting. In PARLE Parallel Architectures and Languages Europe, J. W. de Bakker, A. J. Nijman, and P. C. Treleaven (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 176–187. isbn:978-3-540-47181-3
[4]
Andrew D. Birrell and Bruce Jay Nelson. 1984. Implementing Remote Procedure Calls. ACM Trans. Comput. Syst., 2, 1 (1984), feb, 39–59. issn:0734-2071 https://doi.org/10.1145/2080.357392
[5]
Steven R. Brandt, Hari Krishnan, Costas Busch, and Gokarna Sharma. 2018. Distributed Garbage Collection for General Graphs. In Proceedings of the 2018 ACM SIGPLAN International Symposium on Memory Management (ISMM 2018). Association for Computing Machinery, New York, NY, USA. 29–44. isbn:9781450358019 https://doi.org/10.1145/3210563.3210572
[6]
Shigeru Chiba and Takashi Masuda. 1993. Designing an Extensible Distributed Language with a Meta-Level Architecture. In Proceedings of the 7th European Conference on Object-Oriented Programming (ECOOP ’93). Springer-Verlag, Berlin, Heidelberg. 482–501. isbn:3540571205
[7]
George E. Collins. 1960. A method for overlapping and erasure of lists. Commun. ACM, 3, 12 (1960), 655–657. https://doi.org/10.1145/367487.367501
[8]
Dominique Decouchant. 1986. Design of a Distributed Object Manager for the Smalltalk-80 System. In Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications (OOPSLA ’86). Association for Computing Machinery, New York, NY, USA. 444–452. isbn:0897912047 https://doi.org/10.1145/28697.28743
[9]
Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle Time Garbage Collection Scheduling. In Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’16). Association for Computing Machinery, New York, NY, USA. 570–583. isbn:9781450342612 https://doi.org/10.1145/2908080.2908106
[10]
Ulan Degenbaev, Jochen Eisinger, Kentaro Hara, Marcel Hlopko, Michael Lippautz, and Hannes Payer. 2018. Cross-Component Garbage Collection. Proc. ACM Program. Lang., 2, OOPSLA (2018), Article 151, oct, 24 pages. https://doi.org/10.1145/3276521
[11]
Kevin Donnelly, J. J. Hallett, and Assaf Kfoury. 2006. Formal Semantics of Weak References. In Proceedings of the 5th International Symposium on Memory Management (ISMM ’06). Association for Computing Machinery, New York, NY, USA. 126–137. isbn:1595932216 https://doi.org/10.1145/1133956.1133974
[12]
B. Foote and R. E. Johnson. 1989. Reflective Facilities in Smalltalk-80. In Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications (OOPSLA ’89). Association for Computing Machinery, New York, NY, USA. 327–335. isbn:0897913337 https://doi.org/10.1145/74877.74911
[13]
Matthias Grimmer, Chris Seaton, Roland Schatz, Thomas Würthinger, and Hanspeter Mössenböck. 2015. High-Performance Cross-Language Interoperability in a Multi-Language Runtime. In Proceedings of the 11th Symposium on Dynamic Languages (DLS 2015). Association for Computing Machinery, New York, NY, USA. 78–90. isbn:9781450336901 https://doi.org/10.1145/2816707.2816714
[14]
Richard L. Hudson and J. Eliot B. Moss. 1992. Incremental collection of mature objects. In Memory Management, Yves Bekkers and Jacques Cohen (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 388–403. isbn:978-3-540-47315-2
[15]
Richard E. Jones, Antony L. Hosking, and J. Eliot B. Moss. 2011. The Garbage Collection Handbook: The art of automatic memory management. CRC Press. isbn:978-1-4200-8279-1 http://gchandbook.org/
[16]
Kiyokuni Kawachiya, Mikio Takeuchi, Salikh Zakirov, and Tamiya Onodera. 2012. Distributed Garbage Collection for Managed X10. In Proceedings of the 2012 ACM SIGPLAN X10 Workshop (X10 ’12). Association for Computing Machinery, New York, NY, USA. Article 5, 11 pages. isbn:9781450314916 https://doi.org/10.1145/2246056.2246061
[17]
B. Lang and F. Dupont. 1987. Incremental Incrementally Compacting Garbage Collection. In Papers of the Symposium on Interpreters and Interpretive Techniques (SIGPLAN ’87). Association for Computing Machinery, New York, NY, USA. 253–263. isbn:0897912357 https://doi.org/10.1145/29650.29677
[18]
Pattie Maes. 1987. Concepts and Experiments in Computational Reflection. In Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications (OOPSLA ’87). Association for Computing Machinery, New York, NY, USA. 147–155. isbn:0897912470 https://doi.org/10.1145/38765.38821
[19]
Stefan Marr, Benoit Daloze, and Hanspeter Mössenböck. 2016. Cross-Language Compiler Benchmarking: Are We Fast Yet? In Proceedings of the 12th Symposium on Dynamic Languages (DLS 2016). Association for Computing Machinery, New York, NY, USA. 120–131. isbn:9781450344456 https://doi.org/10.1145/2989225.2989232
[20]
John McCarthy. 1960. Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I. Commun. ACM, 3, 4 (1960), 184–195. https://doi.org/10.1145/367177.367199
[21]
MDN. 2020. FinalizationRegistry. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
[22]
Leo A. Meyerovich and Ariel S. Rabkin. 2013. Empirical Analysis of Programming Language Adoption. In Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’13). Association for Computing Machinery, New York, NY, USA. 1–18. isbn:9781450323741 https://doi.org/10.1145/2509136.2509515
[23]
Koichi Sasada. 2019. Gradual Write-Barrier Insertion into a Ruby Interpreter. In Proceedings of the 2019 ACM SIGPLAN International Symposium on Memory Management (ISMM 2019). Association for Computing Machinery, New York, NY, USA. 115–121. isbn:9781450367226 https://doi.org/10.1145/3315573.3329986
[24]
Marc Shapiro. 1986. Structure and Encapsulation in Distributed Systems: the Proxy Principle. In Int. Conf. on Distr. Comp. Sys. (ICDCS) (Int. Conf. on Distr. Comp. Sys. (ICDCS)). IEEE, Cambridge, MA, USA, United States. 198–204. https://hal.inria.fr/inria-00444651
[25]
Brian Cantwell Smith. 1984. Reflection and Semantics in LISP. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL ’84). Association for Computing Machinery, New York, NY, USA. 23–35. isbn:0897911253 https://doi.org/10.1145/800017.800513
[26]
Tomoharu Ugawa, Richard E. Jones, and Carl G. Ritson. 2014. Reference Object Processing in On-the-Fly Garbage Collection. In Proceedings of the 2014 International Symposium on Memory Management (ISMM ’14). Association for Computing Machinery, New York, NY, USA. 59–69. isbn:9781450329217 https://doi.org/10.1145/2602988.2602991
[27]
David Ungar. 1984. Generation Scavenging: A Non-Disruptive High Performance Storage Reclamation Algorithm. In Proceedings of the First ACM SIGSOFT/SIGPLAN Software Engineering Symposium on Practical Software Development Environments (SDE 1). Association for Computing Machinery, New York, NY, USA. 157–167. isbn:0897911318 https://doi.org/10.1145/800020.808261
[28]
Paul Watson and Ian Watson. 1987. An efficient garbage collection scheme for parallel computer architectures. In PARLE Parallel Architectures and Languages Europe, J. W. de Bakker, A. J. Nijman, and P. C. Treleaven (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 432–443. isbn:978-3-540-47181-3
[29]
Thomas Würthinger, Christian Wimmer, Christian Humer, Andreas Wöß, Lukas Stadler, Chris Seaton, Gilles Duboscq, Doug Simon, and Matthias Grimmer. 2017. Practical Partial Evaluation for High-Performance Dynamic Language Runtimes. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). Association for Computing Machinery, New York, NY, USA. 662–676. isbn:9781450349888 https://doi.org/10.1145/3062341.3062381
[30]
Tetsuro Yamazaki, Tomoki Nakamaru, Ryota Shioya, Tomoharu Ugawa, and Shigeru Chiba. 2023. Artifact – Collecting cyclic garbage across foreign function interfaces. https://doi.org/10.5281/zenodo.7811907

Index Terms

  1. Collecting Cyclic Garbage across Foreign Function Interfaces: Who Takes the Last Piece of Cake?

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 7, Issue PLDI
    June 2023
    2020 pages
    EISSN:2475-1421
    DOI:10.1145/3554310
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution 4.0 International License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 06 June 2023
    Published in PACMPL Volume 7, Issue PLDI

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. FFI
    2. garbage collection
    3. memory management

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 631
      Total Downloads
    • Downloads (Last 12 months)462
    • Downloads (Last 6 weeks)41
    Reflects downloads up to 14 Sep 2024

    Other Metrics

    Citations

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media