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

Cited By

View all
  • (2024)Tail Call Optimization Tailored for Native Stack Utilization in JavaScript RuntimesIEEE Access10.1109/ACCESS.2024.344175012(111801-111817)Online publication date: 2024
  • (2022)The Principles of the Flix Programming LanguageProceedings of the 2022 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3563835.3567661(112-127)Online publication date: 29-Nov-2022
  • (2019)An Object Proxy-Based Dynamic Layer Replacement to Protect IoMT ApplicationsSecurity and Communication Networks10.1155/2019/27985712019Online publication date: 1-Jan-2019

Index Terms

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

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    CC '18: Proceedings of the 27th International Conference on Compiler Construction
    February 2018
    206 pages
    ISBN:9781450356442
    DOI:10.1145/3178372
    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]

    Sponsors

    In-Cooperation

    • IEEE-CS: Computer Society

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 24 February 2018

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. java
    2. jvm
    3. tag tuple fusion
    4. tail call elimination

    Qualifiers

    • Research-article

    Conference

    CGO '18

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)18
    • Downloads (Last 6 weeks)3
    Reflects downloads up to 15 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Tail Call Optimization Tailored for Native Stack Utilization in JavaScript RuntimesIEEE Access10.1109/ACCESS.2024.344175012(111801-111817)Online publication date: 2024
    • (2022)The Principles of the Flix Programming LanguageProceedings of the 2022 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3563835.3567661(112-127)Online publication date: 29-Nov-2022
    • (2019)An Object Proxy-Based Dynamic Layer Replacement to Protect IoMT ApplicationsSecurity and Communication Networks10.1155/2019/27985712019Online publication date: 1-Jan-2019

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media