skip to main content
10.1145/3178372.3179499acmconferencesArticle/Chapter ViewAbstractPublication PagesccConference Proceedingsconference-collections
research-article

Tail call elimination and data representation for functional languages on the Java virtual machine

Published:24 February 2018Publication History

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.

References

  1. Nick Benton, Andrew Kennedy, and George Russell. 1998. Compiling Standard ML to Java Bytecodes. In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Runar Oli Bjarnason. 2012. Stackless Scala With Free Monads.Google ScholarGoogle Scholar
  3. Per Bothner. 1998. Kawa: Compiling Scheme to Java.Google ScholarGoogle Scholar
  4. Paul Chiusano and Rúnar Bjarnason. Functional Programming in Scala. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Xavier Clerc. 2012. OCaml-Java: OCaml on the JVM. In TFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Philippe Codognet, Daniel Diaz, et al. 1995. WAMCC: Compiling Prolog to C. In ICLP.Google ScholarGoogle Scholar
  7. Simon Peyton Jones and David Lester. Implementing Functional Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Kenneth MacKenzie and Nicholas Wolverson. 2003. Camelot and Grail: Resource-aware Functional Programming for the JVM. In TFP.Google ScholarGoogle Scholar
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. Magnus Madsen, Ming-Ho Yee, and Ondrej Lhoták. 2016b. Programming a Dataflow Analysis in Flix. In TAPAS.Google ScholarGoogle Scholar
  11. J Morales, Manuel Carro, and Manuel Hermenegildo. 2004. Improved Compilation of Prolog to C using Moded Types and Determinism Information. PADL (2004).Google ScholarGoogle Scholar
  12. Jose F Morales, Rémy Haemmerlé, Manuel Carro, and Manuel V Hermenegildo. 2012. Lightweight compilation of (C)LP to JavaScript. ICLP (2012).Google ScholarGoogle Scholar
  13. Peter Ross, David Overton, and Zoltan Somogyi. 1999. Making Mercury Programs Tail Recursive. In LOPSTR. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Michel Schinz and Martin Odersky. 2001. Tail Call Elimination on the Java Virtual Machine. In BABEL.Google ScholarGoogle Scholar
  15. Lukas Stadler, Christian Wimmer, Thomas Würthinger, Hanspeter Mössenböck, and John Rose. 2009. Lazy Continuations for Java Virtual Machines. In PPPJ. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle Scholar
  17. Dean Wampler and Alex Payne. Programming Scala: Scalability = Functional Programming + Objects. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Christian Wimmer and Thomas Würthinger. 2012. Truffle: A SelfOptimizing Runtime System. In SPLASH. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Tail call elimination and data representation for functional languages on the Java virtual machine

    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
    • Published in

      cover image ACM Conferences
      CC 2018: Proceedings of the 27th International Conference on Compiler Construction
      February 2018
      206 pages
      ISBN:9781450356442
      DOI:10.1145/3178372

      Copyright © 2018 ACM

      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: 24 February 2018

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader