skip to main content
research-article
Open access

Cross-Language Interoperability in a Multi-Language Runtime

Published: 28 May 2018 Publication History

Editorial Notes

A corrigendum was issued for this article on November 9, 2018. You can download the corrigendum from the supplemental material section of this citation page.

Abstract

In large-scale software applications, programmers often combine different programming languages because this allows them to use the most suitable language for a given problem, to gradually migrate existing projects from one language to another, or to reuse existing source code. However, different programming languages have fundamentally different implementations, which are hard to combine. The composition of language implementations often results in complex interfaces between languages, insufficient flexibility, or poor performance.
We propose TruffleVM, a virtual machine (VM) that can execute different programming languages and is able to compose them in a seamless way. TruffleVM supports dynamically-typed languages (e.g., JavaScript and Ruby) as well as statically typed low-level languages (e.g., C). It consists of individual language implementations, which translate source code to an intermediate representation that is executed by a shared VM. TruffleVM composes these different language implementations via generic access. Generic access is a language-agnostic mechanism that language implementations use to access foreign data or call foreign functions. It features language-agnostic messages that the TruffleVM resolves to efficient foreign-language-specific operations at runtime. Generic access supports multiple languages, enables an efficient multi-language development, and ensures high performance.
We evaluate generic access with two case studies. The first one explains the transparent composition of JavaScript, Ruby, and C. The second one shows an implementation of the C extensions application programming interface (API) for Ruby. We show that generic access guarantees good runtime performance. It avoids conversion or marshalling of foreign objects at the language boundary and allows the dynamic compiler to perform its optimizations across language boundaries.

Supplementary Material

a18-Grimmer-corrigendum (a18-corrigendum.pdf)
Corrigendum to "Cross-Language Interoperability in a Multi-Language Runtime", by Grimmer et al., ACM Transactions on Programming Languages and Systems (TOPLAS) Volume 40, Issue 2, Article No. 8
ZIP File (a8-grimmer.zip)

References

[1]
M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. 1989. Dynamic typing in a statically-typed language. In Proceedings of the 16th Symposium on Principles of Programming Languages (POPL’89). ACM, New York, NY, 213--227.
[2]
M. Arnold, S. J. Fink, D. Grove, M. Hind, and P. F. Sweeney. 2005. A survey of adaptive optimization in virtual machines. Proc. IEEE 93, 2 (2005), 449--466.
[3]
Edd Barrett, Carl Friedrich Bolz, and Laurence Tratt. 2013. Unipycation: A case study in cross-language tracing. In Proceedings of the 7th ACM Workshop on Virtual Machines and Intermediate Languages (VMIL’13). ACM, New York, NY, 31--40.
[4]
Edd Barrett, Carl Friedrich Bolz, and Laurence Tratt. 2014. Approaches to interpreter composition. CoRR abs/1409.0757. Retrieved from http://arxiv.org/abs/1409.0757.
[5]
Edd Barrett, Lukas Diekmann, and Laurence Tratt. 2015. Fine-grained language composition. CoRR abs/1503.08623. Retrieved from http://arxiv.org/abs/1503.08623.
[6]
David M. Beazley and others. 1996. SWIG: An easy to use tool for integrating scripting languages with C and C++. In Proceedings of the 4th USENIX Tcl/Tk Workshop. 129--139.
[7]
Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy. 1990. Lightweight remote procedure call. ACM Trans. Comput. Syst. 8, 1 (Feb. 1990), 37--55.
[8]
Matthias Blume. 2001. No-longer-foreign: Teaching an ML compiler to speak C natively. Electronic Notes in Theoretical Computer Science 59, 1 (2001), 36--52.
[9]
Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, and Armin Rigo. 2009. Tracing the meta-level: PyPy’s tracing JIT compiler. In Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems (ICOOOLPS’09). ACM, New York, NY, 18--25.
[10]
D. Box and C. Sells. 2002. Essential .NET. The Common Language Runtime, vol. I. (2002).
[11]
David Chisnall. 2013. The challenge of cross-language interoperability. Commun. ACM 56, 12 (2013), 50--56.
[12]
Benoit Daloze, Stefan Marr, Daniele Bonetta, and Hanspeter Mössenböck. 2016. Efficient and thread-safe objects for dynamically-typed languages. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2016). ACM, New York, NY, 642--659.
[13]
Gilles Duboscq, Thomas Würthinger, and Hanspeter Mössenböck. 2014. Speculation without regret: Reducing deoptimization meta-data in the graal compiler. In Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools (PPPJ’14). ACM, New York, NY, 187--193.
[14]
Gilles Duboscq, Thomas Würthinger, Lukas Stadler, Christian Wimmer, Doug Simon, and Hanspeter Mössenböck. 2013. An intermediate representation for speculative optimizations in a dynamic compiler. In Proceedings of the 7th ACM Workshop on Virtual Machines and Intermediate Languages (VMIL’13). ACM, New York, NY, 1--10.
[15]
ECMA-International. 2012. Standard ECMA-335. Common Language Infrastructure (CLI). Retrieved from http://www.ecma-international.org/publications/standards/Ecma-335.htm.
[16]
Sigbjorn Finne, Daan Leijen, Erik Meijer, and Simon Peyton Jones. 1999. Calling hell from heaven and heaven from hell. In Proceedings of the Fourth ACM SIGPLAN International Conference on Functional Programming (ICFP’99). ACM, New York, NY, 114--125.
[17]
Philip J. Fleming and John J. Wallace. 1986. How not to lie with statistics: The correct way to summarize benchmark results. Commun. ACM 29, 3 (March 1986), 218--221.
[18]
Yoshihiko Futamura. 1999. Partial evaluation of computation process—An approach to a compiler-compiler. Higher-Order and Symbolic Computation 12, 4 (1999), 381--391.
[19]
Kathryn Gray, Robert Bruce Findler, and Matthew Flatt. 2005. Fine-grained interoperability through mirrors and contracts. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’05). ACM, New York, NY, 231--245.
[20]
Kathryn E. Gray. 2008. Safe cross-language inheritance. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’08). Lecture Notes in Computer Science, Vol. 5142. Springer Berlin, 52--75.
[21]
Matthias Grimmer, Stefan Marr, Mario Kahlhofer, Christian Wimmer, Thomas Würthinger, and Hanspeter Mössenböck. 2017. Applying optimizations for dynamically-typed languages to java. In Proceedings of the 14th International Conference on Managed Languages and Runtimes (ManLang 2017). ACM, New York, NY, 12--22.
[22]
Matthias Grimmer, Manuel Rigger, Roland Schatz, Lukas Stadler, and Hanspeter Mössenböck. 2014. TruffleC: Dynamic execution of C on a java virtual machine. In Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools (PPPJ’14). ACM, New York, NY.
[23]
Matthias Grimmer, Manuel Rigger, Lukas Stadler, Roland Schatz, and Hanspeter Mössenböck. 2013. An efficient native function interface for java. In Proceedings of the 2013 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools (PPPJ’13). ACM, New York, NY, 35--44.
[24]
Matthias Grimmer, Roland Schatz, Chris Seaton, Thomas Würthinger, and Hanspeter Mössenböck. 2015. Memory-safe execution of C on a java VM. In Proceedings of the 10th Workshop on Programming Languages and Analysis for Security (PLAS’15). ACM, New York, NY.
[25]
Matthias Grimmer, Chris Seaton, Roland Schatz, 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’15). ACM, New York, NY.
[26]
Matthias Grimmer, Chris Seaton, Thomas Würthinger, and Hanspeter Mössenböck. 2015. Dynamically composing languages in a modular way: Supporting C extensions for dynamic languages. In Proceedings of the 14th International Conference on Modularity (MODULARITY 2015). ACM, New York, NY, 1--13.
[27]
Matthias Grimmer, Thomas Würthinger, Andreas Wöß, and Hanspeter Mössenböck. 2014. An efficient approach for accessing C data structures from javascript. In Proceedings of 9th International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems PLE - Workshop on Programming Language Evolution, 2014 (ICOOOLPS’14). ACM, New York, NY.
[28]
Jeff Hardy. 2008. The dynamic language runtime and the iron languages. In The Architecture of Open Source Applications, Volume II, Amy Brown and Greg Wilson (Eds.). Retrieved from http://aosabook.org/en/index.html.
[29]
Martin Hirzel and Robert Grimm. 2007. Jeannie: Granting java native interface developers their wishes. In Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-oriented Programming Systems and Applications (OOPSLA’07). ACM, New York, NY, 19--38.
[30]
Urs Hölzle, Craig Chambers, and David Ungar. 1991. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In ECOOP’91 European Conference on Object-Oriented Programming, Pierre America (Ed.). Lecture Notes in Computer Science, Vol. 512. Springer Berlin, 21--38.
[31]
Urs Hölzle, Craig Chambers, and David Ungar. 1992. Debugging optimized code with dynamic deoptimization. In Proceedings of the ACM SIGPLAN 1992 Conference on Programming Language Design and Implementation (PLDI’92). ACM, New York, NY, 32--43.
[32]
International Organization for Standardization. 2007. C99 Standard: ISO/IEX 9899:TC3. Retrieved from www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf.
[33]
Simon Peyton Jones, Thomas Nordin, and Alastair Reid. 1997. GreenCard: A foreign-language interface for Haskell. In Proc. Haskell Workshop.
[34]
Tomas Kalibera and Richard Jones. 2013. Rigorous benchmarking in reasonable time. In Proceedings of the 2013 ACM SIGPLAN International Symposium on Memory Management (ISMM).
[35]
Stephen Kell and Conrad Irwin. 2011. Virtual machines should be invisible. In Proceedings of the Compilation of the Co-located Workshops on DSM’11, TMC’11, AGERE! 2011, AOOPES’11, NEAT’11, & VMIL’11 (SPLASH’11 Workshops). ACM, New York, NY, 289--296.
[36]
F. Klock II. 2007. The layers of Larceny’s foreign function interface. In Scheme and Functional Programming Workshop. Citeseer.
[37]
Byeongcheol Lee, Martin Hirzel, Robert Grimm, and Kathryn S. McKinley. 2009. Debug all your code: Portable mixed-environment debugging. SIGPLAN Not. 44, 10 (Oct. 2009), 207--226.
[38]
Sheng Liang. 1999. Java Native Interface: Programmer’s Guide and Reference (1st ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA.
[39]
Sheng Liang. 1999. The Java Native Interface: Programmer’s Guide and Specification. Addison-Wesley Professional.
[40]
Marr and Ducasse. 2015. Tracing vs. partial evaluation: Comparing meta-compilation approaches for self-optimizing interpreters. In Proceedings of the 2015 ACM International Conference on Object Oriented Programming Systems Languages; Applications (OOPSLA’15). ACM, New York, NY.
[41]
Jacob Matthews and Robert Bruce Findler. 2007. Operational semantics for multi-language programs. In Proceedings of the 34th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’07). ACM, New York, NY, 3--10.
[42]
Erik Meijer and John Gough. 2001. Technical overview of the common language runtime. Language 29 (2001), 7.
[43]
Mozilla Developer Network. 2014. XPCOM Specification. Retrieved from https://developer.mozilla.org/en-US/docs/Mozilla/XPCOM.
[44]
Object Management Group. 2014. Common Object Request Brooker Architecture (CORBA) Specification. Retrievced from http://www.omg.org/spec/CORBA/3.3/.
[45]
John Reppy and Chunyan Song. 2006. Application-specific foreign-interface generation. In Proceedings of the 5th International Conference on Generative Programming and Component Engineering (GPCE’06). ACM, New York, NY, 49--58.
[46]
John R. Rose and Hans Muller. 1992. Integrating the scheme and C languages. In Proceedings of the 1992 ACM Conference on LISP and Functional Programming (LFP’92). ACM, New York, NY, 247--259.
[47]
Chris Seaton, Michael L. Van De Vanter, and Michael Haupt. 2014. Debugging at full speed. In Proceedings of the Workshop on Dynamic Languages and Applications. ACM, 1--13.
[48]
Mark Slee, Aditya Agarwal, and Marc Kwiatkowski. 2007. Thrift: Scalable cross-language services implementation. Facebook White Paper 5 (2007).
[49]
Lukas Stadler, Gilles Duboscq, Hanspeter Mössenböck, and Thomas Würthinger. 2012. Compilation queuing and graph caching for dynamic compilers. In Proceedings of the 6th ACM Workshop on Virtual Machines and Intermediate Languages (VMIL’12). ACM, New York, NY, 49--58.
[50]
Lukas Stadler, Gilles Duboscq, Hanspeter Mössenböck, Thomas Würthinger, and Doug Simon. 2013. An experimental study of the influence of dynamic compiler optimizations on scala performance. In Proceedings of the 4th Workshop on Scala (SCALA’13). ACM, New York, NY, Article 9, 8 pages.
[51]
Lukas Stadler, Thomas Würthinger, and Hanspeter Mössenböck. 2014. Partial escape analysis and scalar replacement for java. In Proceedings of Annual IEEE/ACM International Symposium on Code Generation and Optimization (CGO’14). ACM, New York, NY, Article 165, 10 pages.
[52]
Levon Stepanian, Angela Demke Brown, Allan Kielstra, Gita Koblents, and Kevin Stoodley. 2005. Inlining java native calls at runtime. In Proceedings of the 1st ACM/USENIX International Conference on Virtual Execution Environments (VEE’05). ACM, New York, NY, 121--131.
[53]
TC39. 2016. Official ECMAScript Conformance Test Suite. Retrieved from https://github.com/tc39/test262.
[54]
Valery Trifonov and Zhong Shao. 1999. Safe and Principled Language Interoperation. Springer.
[55]
Nanbor Wang, Douglas C. Schmidt, and Carlos O’Ryan. 2001. Overview of the CORBA component model. In Component-Based Software Engineering. Addison-Wesley Longman, 557--571.
[56]
Michal Wegiel and Chandra Krintz. 2010. Cross-language, type-safe, and transparent object sharing for co-located managed runtimes. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA’10). ACM, New York, NY, 223--240.
[57]
Christian Wimmer and Stefan Brunthaler. 2013. ZipPy on truffle: A fast and simple implementation of python. In Proceedings of the 2013 Companion Publication for Conference on Systems, Programming, Applications: Software for Humanity (SPLASH’13). ACM, New York, NY, 17--18.
[58]
Andreas Wöß, Christian Wirth, Daniele Bonetta, Chris Seaton, Christian Humer, and Hanspeter Mössenböck. 2014. An object storage model for the truffle language implementation framework. In Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools (PPPJ’14). ACM, New York, NY, 133--144.
[59]
Tobias Wrigstad, Francesco Zappa Nardelli, Sylvain Lebresne, Johan Östlund, and Jan Vitek. 2010. Integrating typed and untyped code in a scripting language. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’10). ACM, New York, NY, 377--388.
[60]
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). ACM, New York, NY, 662--676.
[61]
Thomas Würthinger, Christian Wimmer, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Christian Humer, Gregor Richards, Doug Simon, and Mario Wolczko. 2013. One VM to rule them all. In Proceedings of the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software (Onward! 2013). ACM, New York, NY, 187--204.
[62]
Thomas Würthinger, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Doug Simon, and Christian Wimmer. 2012. Self-optimizing AST interpreters. In Proceedings of the 8th Symposium on Dynamic Languages (DLS’12). ACM, New York, NY, 73--82.
[63]
Wei Zhang, Per Larsen, Stefan Brunthaler, and Michael Franz. 2014. Accelerating iterators in optimizing AST interpreters. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages; Applications (OOPSLA’14). ACM, New York, NY, 727--743.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 40, Issue 2
June 2018
223 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/3229520
Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 28 May 2018
Accepted: 01 February 2018
Revised: 01 October 2017
Received: 01 March 2016
Published in TOPLAS Volume 40, Issue 2

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Cross-language
  2. language implementation
  3. language interoperability
  4. optimization
  5. virtual machine

Qualifiers

  • Research-article
  • Research
  • Refereed

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)371
  • Downloads (Last 6 weeks)65
Reflects downloads up to 14 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format.

HTML Format

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media