ABSTRACT
The Java Virtual Machine (JVM) offers an attractive runtime environment for programming language implementers. The JVM has a simple bytecode format, excellent performance, multiple state-of-the art garbage collectors, robust backwards compatibility, and it runs on almost all platforms. Further, the Java ecosystem grants access to a plethora of libraries and tooling, including debuggers and profilers.
Yet, the JVM was originally designed for Java, and its representation of code and data may cause difficulties for other languages. In this paper, we discuss how to efficiently implement functional languages on the JVM. We focus on two overall challenges: (a) how to efficiently represent algebraic data types in the presence of tags and tuples, option types, newtypes, and parametric polymorphism, and (b) how to support full tail call elimination on the JVM.
We present two technical contributions: A fused representation of tags and tuples and a full tail call elimination strategy that is thread-safe. We implement these techniques in the Flix language and evaluate their performance.
- Nick Benton, Andrew Kennedy, and George Russell. 1998. Compiling Standard ML to Java Bytecodes. In ICFP. Google ScholarDigital Library
- Runar Oli Bjarnason. 2012. Stackless Scala With Free Monads.Google Scholar
- Per Bothner. 1998. Kawa: Compiling Scheme to Java.Google Scholar
- Paul Chiusano and Rúnar Bjarnason. Functional Programming in Scala. Google ScholarDigital Library
- Xavier Clerc. 2012. OCaml-Java: OCaml on the JVM. In TFP. Google ScholarDigital Library
- Philippe Codognet, Daniel Diaz, et al. 1995. WAMCC: Compiling Prolog to C. In ICLP.Google Scholar
- Simon Peyton Jones and David Lester. Implementing Functional Languages. Google ScholarDigital Library
- Kenneth MacKenzie and Nicholas Wolverson. 2003. Camelot and Grail: Resource-aware Functional Programming for the JVM. In TFP.Google Scholar
- Magnus Madsen, Ming-Ho Yee, and Ondřej Lhoták. 2016a. From Datalog to Flix: A Declarative Language for Fixed Points on Lattices. In PLDI. Google ScholarDigital Library
- Magnus Madsen, Ming-Ho Yee, and Ondrej Lhoták. 2016b. Programming a Dataflow Analysis in Flix. In TAPAS.Google Scholar
- J Morales, Manuel Carro, and Manuel Hermenegildo. 2004. Improved Compilation of Prolog to C using Moded Types and Determinism Information. PADL (2004).Google Scholar
- Jose F Morales, Rémy Haemmerlé, Manuel Carro, and Manuel V Hermenegildo. 2012. Lightweight compilation of (C)LP to JavaScript. ICLP (2012).Google Scholar
- Peter Ross, David Overton, and Zoltan Somogyi. 1999. Making Mercury Programs Tail Recursive. In LOPSTR. Google ScholarDigital Library
- Michel Schinz and Martin Odersky. 2001. Tail Call Elimination on the Java Virtual Machine. In BABEL.Google Scholar
- Lukas Stadler, Christian Wimmer, Thomas Würthinger, Hanspeter Mössenböck, and John Rose. 2009. Lazy Continuations for Java Virtual Machines. In PPPJ. Google ScholarDigital Library
- Tomáš Tauber, Xuan Bi, Zhiyuan Shi, Weixin Zhang, Huang Li, Zhenrui Zhang, and Bruno Oliveira. 2015. Memory-Efficient Tail Calls in the JVM with Imperative Functional Objects. In APLAS.Google Scholar
- Dean Wampler and Alex Payne. Programming Scala: Scalability = Functional Programming + Objects. Google ScholarDigital Library
- Christian Wimmer and Thomas Würthinger. 2012. Truffle: A SelfOptimizing Runtime System. In SPLASH. Google ScholarDigital Library
Index Terms
- Tail call elimination and data representation for functional languages on the Java virtual machine
Recommendations
A java virtual machine architecture for very small devices
Special Issue: Proceedings of the 2003 ACM SIGPLAN conference on Language, compiler, and tool support for embedded systems (San Diego, CA).The smallest complete Java™ virtual machine implementations in use today are based on the CLDC standard and are deployed in mobile phones and PDAs. These implementations require several tens of kilobytes. Smaller Java-like implementations also exist, ...
A java virtual machine architecture for very small devices
LCTES '03: Proceedings of the 2003 ACM SIGPLAN conference on Language, compiler, and tool for embedded systemsThe smallest complete Java™ virtual machine implementations in use today are based on the CLDC standard and are deployed in mobile phones and PDAs. These implementations require several tens of kilobytes. Smaller Java-like implementations also exist, ...
Evaluating the Java Native Interface JNI: Leveraging Existing Native Code, Libraries and Threads to a Running Java Virtual Machine
This article aims to explore JNI features and to discover fundamental operations of the Java programming language, such as arrays, objects, classes, threads and exception handling, and to illustrate these by using various algorithms and code samples. ...
Comments