skip to main content
research-article
Free Access

Cross-Language Interoperability in a Multi-Language Runtime

Published:28 May 2018Publication History
Skip Editorial Notes Section

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.

Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. D. Box and C. Sells. 2002. Essential .NET. The Common Language Runtime, vol. I. (2002). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. David Chisnall. 2013. The challenge of cross-language interoperability. Commun. ACM 56, 12 (2013), 50--56. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. ECMA-International. 2012. Standard ECMA-335. Common Language Infrastructure (CLI). Retrieved from http://www.ecma-international.org/publications/standards/Ecma-335.htm.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  33. Simon Peyton Jones, Thomas Nordin, and Alastair Reid. 1997. GreenCard: A foreign-language interface for Haskell. In Proc. Haskell Workshop.Google ScholarGoogle Scholar
  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). Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. F. Klock II. 2007. The layers of Larceny’s foreign function interface. In Scheme and Functional Programming Workshop. Citeseer.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Sheng Liang. 1999. Java Native Interface: Programmer’s Guide and Reference (1st ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Sheng Liang. 1999. The Java Native Interface: Programmer’s Guide and Specification. Addison-Wesley Professional. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Erik Meijer and John Gough. 2001. Technical overview of the common language runtime. Language 29 (2001), 7.Google ScholarGoogle Scholar
  43. Mozilla Developer Network. 2014. XPCOM Specification. Retrieved from https://developer.mozilla.org/en-US/docs/Mozilla/XPCOM.Google ScholarGoogle Scholar
  44. Object Management Group. 2014. Common Object Request Brooker Architecture (CORBA) Specification. Retrievced from http://www.omg.org/spec/CORBA/3.3/.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Mark Slee, Aditya Agarwal, and Marc Kwiatkowski. 2007. Thrift: Scalable cross-language services implementation. Facebook White Paper 5 (2007).Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. TC39. 2016. Official ECMAScript Conformance Test Suite. Retrieved from https://github.com/tc39/test262.Google ScholarGoogle Scholar
  54. Valery Trifonov and Zhong Shao. 1999. Safe and Principled Language Interoperation. Springer.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

(auto-classified)
  1. Cross-Language Interoperability in a Multi-Language Runtime

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader

          HTML Format

          View this article in HTML Format .

          View HTML Format
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!