ABSTRACT
Programmers combine different programming languages because it 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, existing cross-language mechanisms suffer from complex interfaces, insufficient flexibility, or poor performance. We present the TruffleVM, a multi-language runtime that allows composing different language implementations in a seamless way. It reduces the amount of required boiler-plate code to a minimum by allowing programmers to access foreign functions or objects by using the notation of the host language. We compose language implementations that translate source code to an intermediate representation (IR), which is executed on top of a shared runtime system. Language implementations use language-independent messages that the runtime resolves at their first execution by transforming them to efficient foreign-language-specific operations. The TruffleVM avoids conversion or marshaling of foreign objects at the language boundary and allows the dynamic compiler to perform its optimizations across language boundaries, which guarantees high performance. This paper presents an implementation of our ideas based on the Truffle system and its guest language implementations JavaScript, Ruby, and C.
- M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. Dynamic Typing in a Statically-typed Language. In Proceedings of POPL, 1989. URL http://doi.acm.org/10.1145/75277. Google ScholarDigital Library
- 75296.Google Scholar
- E. Barrett, C. F. Bolz, and L. Tratt. Unipycation: A Case Study in Cross-language Tracing. In Proceedings of the 7th VMIL, 2013. URL http://doi.acm.org/10.1145/2542142. Google ScholarDigital Library
- 2542146.Google Scholar
- E. Barrett, L. Diekmann, and L. Tratt. Fine-grained Language Composition. CoRR, abs/1503.08623, 2015.Google Scholar
- D. M. Beazley et al. SWIG: An easy to use tool for integrating scripting languages with C and C++. In Proceedings of USENIX Tcl/Tk workshop, 1996. Google ScholarDigital Library
- M. Blume. No-longer-foreign: Teaching an ML compiler to speak C natively. Electronic Notes in Theoretical Computer Science, 2001.Google Scholar
- D. Box and C. Sells. Essential .NET. The Common Language Runtime, 2002. Google ScholarDigital Library
- S. Brunthaler. Efficient Interpretation Using Quickening. In Proceedings of DLS, 2010. URL http://doi.acm.org/10. 1145/1869631.1869633. Google ScholarDigital Library
- D. Chisnall. The Challenge of Cross-language Interoperability. Commun. ACM, 2013. URL http://doi.acm.org/10. 1145/2534706.2534719. Google ScholarDigital Library
- S. Finne, D. Leijen, E. Meijer, and S. Peyton Jones. Calling Hell from Heaven and Heaven from Hell. In Proceedings of ICFP, 1999. URL http://doi.acm.org/10.1145/317636. Google ScholarDigital Library
- 317790.Google Scholar
- P. J. Fleming and J. J. Wallace. How not to lie with statistics: The correct way to summarize benchmark results. 1986. URL http://doi.acm.org/10.1145/5666.5673. Google ScholarDigital Library
- K. Gray. Safe Cross-Language Inheritance. In ECOOP. 2008. URL http://dx.doi.org/10.1007/978-3-540-70592-5_4. Google ScholarDigital Library
- K. E. Gray, R. B. Findler, and M. Flatt. Fine-grained Interoperability Through Mirrors and Contracts. In Proceedings of OOPSLA, 2005. URL http://doi.acm.org/10.1145/ 1094811.1094830. Google ScholarDigital Library
- M. Grimmer. High-performance language interoperability in multi-language runtimes. In Proceedings of SPLASH, 2014. URL http://doi.acm.org/10.1145/2660252.2660256. Google ScholarDigital Library
- M. Grimmer, M. Rigger, R. Schatz, L. Stadler, and H. Mössenböck. TruffleC: Dynamic Execution of C on a Java Virtual Machine. In Proceedings of PPPJ, 2014. URL http://dx.doi.org/10.1145/2647508.2647528. Google ScholarCross Ref
- M. Grimmer, T. Würthinger, A. Wöß, and H. Mössenböck. An Efficient Approach for Accessing C Data Structures from JavaScript. In Proceedings of ICOOOLPS, 2014. URL http: //dx.doi.org/10.1145/2633301.2633302. Google ScholarDigital Library
- M. Grimmer, R. Schatz, C. Seaton, T. Würthinger, and H. Mössenböck. Memory-safe Execution of C on a Java VM. In Proceedings of PLAS, 2015. URL http://doi.acm.org/ 10.1145/2786558.2786565. Google ScholarDigital Library
- M. Grimmer, C. Seaton, T. Wuerthinger, and H. Moessenboeck. Dynamically Composing Languages in a Modular Way: Supporting C Extensions for Dynamic Languages. In Proceedings of MODULARITY, 2015. URL http://doi.acm. org/10.1145/2724525.2728790. Google ScholarDigital Library
- M. Hirzel and R. Grimm. Jeannie: Granting Java Native Interface Developers Their Wishes. In Proceedings of OOPSLA, 2007. URL http://doi.acm.org/10.1145/1297027. Google ScholarDigital Library
- 1297030.Google Scholar
- U. Hölzle, C. Chambers, and D. Ungar. Optimizing Dynamically-typed Object-oriented Languages with Polymorphic Inline Caches. In ECOOP. 1991.. URL http: //dx.doi.org/10.1007/BFb0057013. Google ScholarDigital Library
- U. Hölzle, C. Chambers, and D. Ungar. Debugging Optimized Code with Dynamic Deoptimization. In Proceedings of PLDI, 1992. URL http://doi.acm.org/10.1145/143095.143114. Google ScholarDigital Library
- S. P. Jones, T. Nordin, and A. Reid. Greencard: a foreignlanguage interface for haskell. In Proc. Haskell Workshop, 1997.Google Scholar
- S. Kell and C. Irwin. Virtual machines should be invisible. In Proceedings of SPLASH, 2011. URL http://doi.acm.org/ 10.1145/2095050.2095099. Google ScholarDigital Library
- F. Klock II. The layers of larcenys foreign function interface. In Scheme and Functional Programming Workshop. Citeseer, 2007.Google Scholar
- S. Liang. Java Native Interface: Programmer’s Guide and Reference. Boston, MA, USA, 1st edition, 1999. Google ScholarDigital Library
- J. Matthews and R. B. Findler. Operational semantics for multi-language programs. In Proceedings of POPL, 2007. URL http://doi.acm.org/10.1145/1190216.1190220. Google ScholarDigital Library
- M. D. Network. XPCOM Specification. https://developer. mozilla.org/en-US/docs/Mozilla/XPCOM, 2014.Google Scholar
- Oracle. OpenJDK: Graal project. http://openjdk.java. net/projects/graal/, 2013.Google Scholar
- J. Reppy and C. Song. Application-specific Foreign-interface Generation. In Proceedings of GPCE, 2006.. URL http: //doi.acm.org/10.1145/1173706.1173714. Google ScholarDigital Library
- J. R. Rose and H. Muller. Integrating the scheme and c languages. In Proceedings of LFP, 1992. URL http://doi. acm.org/10.1145/141471.141559. Google ScholarDigital Library
- M. Slee, A. Agarwal, and M. Kwiatkowski. Thrift: Scalable cross-language services implementation. Facebook White Paper, 2007.Google Scholar
- L. Stadler, T. Würthinger, and H. Mössenböck. Partial Escape Analysis and Scalar Replacement for Java. In Proceedings of CGO, 2014.. URL http://doi.acm.org/10.1145/2544137. Google ScholarDigital Library
- 2544157.Google Scholar
- L. Stepanian, A. D. Brown, A. Kielstra, G. Koblents, and K. Stoodley. Inlining Java Native Calls at Runtime. In Proceedings of VEE, 2005. URL http://doi.acm.org/10. 1145/1064979.1064997. Google ScholarDigital Library
- V. Trifonov and Z. Shao. Safe and principled language interoperation. 1999.Google Scholar
- N. Wang, D. C. Schmidt, and C. O’Ryan. Overview of the CORBA Component Model. In Component-Based Software Engineering, 2001. Google ScholarDigital Library
- M. Wegiel and C. Krintz. Cross-language, Type-safe, and Transparent Object Sharing for Co-located Managed Runtimes. In Proceedings of OOPSLA, 2010. URL http://doi. acm.org/10.1145/1869459.1869479. Google ScholarDigital Library
- A. Wöß, C. Wirth, D. Bonetta, C. Seaton, C. Humer, and H. Mössenböck. An Object Storage Model for the Truffle Language Implementation Framework. In Proceedings of PPPJ, 2014. URL http://dx.doi.org/10.1145/2647508. Google ScholarCross Ref
- 2647517.Google Scholar
- T. Wrigstad, F. Z. Nardelli, S. Lebresne, J. Östlund, and J. Vitek. Integrating typed and untyped code in a scripting language. In Proceedings of POPL, 2010. Google ScholarDigital Library
- . URL http://doi.acm.org/10.1145/1706299.1706343.Google Scholar
- T. Würthinger, A. Wöß, L. Stadler, G. Duboscq, D. Simon, and C. Wimmer. Self-optimizing AST interpreters. In Proceedings of DLS, 2012.. URL http://doi.acm.org/10. 1145/2384577.2384587. Google ScholarDigital Library
- T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of ONWARD!, 2013. Google ScholarDigital Library
Index Terms
- High-performance cross-language interoperability in a multi-language runtime
Recommendations
Cross-Language Interoperability in a Multi-Language Runtime
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 ...
An object storage model for the truffle language implementation framework
PPPJ '14: Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java platform: Virtual machines, Languages, and ToolsTruffle is a Java-based framework for developing high-performance language runtimes. Language implementers aiming at developing new runtimes have to design all the runtime mechanisms for managing dynamically typed objects from scratch. This not only ...
Practical partial evaluation for high-performance dynamic language runtimes
PLDI 2017: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and ImplementationMost high-performance dynamic language virtual machines duplicate language semantics in the interpreter, compiler, and runtime system. This violates the principle to not repeat yourself. In contrast, we define languages solely by writing an ...
Comments