skip to main content
10.1145/1806596.1806642acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Mint: Java multi-stage programming using weak separability

Published:05 June 2010Publication History

ABSTRACT

Multi-stage programming (MSP) provides a disciplined approach to run-time code generation. In the purely functional setting, it has been shown how MSP can be used to reduce the overhead of abstractions, allowing clean, maintainable code without paying performance penalties. Unfortunately, MSP is difficult to combine with imperative features, which are prevalent in mainstream languages. The central difficulty is scope extrusion, wherein free variables can inadvertently be moved outside the scopes of their binders. This paper proposes a new approach to combining MSP with imperative features that occupies a "sweet spot" in the design space in terms of how well useful MSP applications can be expressed and how easy it is for programmers to understand. The key insight is that escapes (or "anti-quotes") must be weakly separable from the rest of the code, i.e. the computational effects occurring inside an escape that are visible outside the escape are guaranteed to not contain code. To demonstrate the feasibility of this approach, we formalize a type system based on Lightweight Java which we prove sound, and we also provide an implementation, called Mint, to validate both the expressivity of the type system and the effect of staging on the performance of Java programs.

References

  1. Baris Aktemur. Type Checking Program Generators Using the Record Calculus, 2009. http://loome.cs.uiuc.edu/pubs/transformationForTyping.pdf.Google ScholarGoogle Scholar
  2. Davide Ancona and Eugenio Moggi. A fresh calculus for name management. In GPCE '04: Proceedings of the 3rd International Conference on Generative Programming and Component Engineering, volume 3286, pages 206--224, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  3. Cristiano Calcagno, Eugenio Moggi, and Walid Taha. Closed Types as a Simple Approach to Safe Imperative Multi-stage Programming. In ICALP '00: Proceedings of the 27th International Colloquium on Automata, Languages and Programming, pages 25--36, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Cristiano Calcagno, Eugenio Moggi, and Walid Taha. ML-like inference for classifiers. In ESOP '04: Proceedings of the 13th European Symposium on Programming, pages 79--93, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  5. Cristiano Calcagno, Walid Taha, Liwen Huang, and Xavier Leroy. Implementing multi-stage languages using asts, gensym, and reflection. In GPCE '03: Proceedings of the 2nd International Conference on Generative Programming and Component Engineering, pages 57--76, New York, NY, USA, 2003. Springer-Verlag New York, Inc. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Tim Davis and Yifan Hu. The University of Florida Sparse Matrix Collection. http://www.cise.ufl.edu/research/sparse/matrices/Pajek/Tina DisCal.html.Google ScholarGoogle Scholar
  7. Manuel Fähndrich, Michael Carbin, and James R. Larus. Reflective program generation with patterns. In GPCE '06: Proceedings of the 5th International Conference on Generative Programming and Component Engineering, pages 275--284, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Habanero Multicore Software Research Project. http://habanero.rice.edu.Google ScholarGoogle Scholar
  9. Shan Shan Huang and Yannis Smaragdakis. Expressive and safe static reflection with MorphJ. In PLDI '08: Proceedings of the 2008 ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 79--89, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Shan Shan Huang, David Zook, and Yannis Smaragdakis. Statically safe program generation with safegen. In GPCE '04: Proceedings of the 3rd International Conference on Generative Programming and Component Engineering, pages 309--326, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung chieh Shan. Closing the stage: from staged code to typed closures. In PEPM '08: Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, pages 147--157, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung chieh Shan. Shifting the stage: Staging with delimited control. In PEPM '09: Proceedings of the 2009 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, pages 111--120, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Sam Kamin, Lars Clausen, and Ava Jarvis. Jumbo: Run-time code generation for Java and its applications. In CGO '03: Proceedings of the International Symposium on Code Generation and Optimization, pages 48--56, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Ik-Soon Kim, Kwangkeun Yi, and Cristiano Calcagno. A polymorphic modal type system for lisp-like multi-staged languages. In POPL '06: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 257--268, New York, NY, USA, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Gregory Neverov and Paul Roe. Metaphor: A Multi-stage, Object-Oriented Programming Language. In GPCE '04: Proceedings of the 3rd International Conference on Generative Programming and Component Engineering, pages 168--185, 2004.Google ScholarGoogle Scholar
  16. Yutaka Oiwa, Hidehiko Masuhara, and Akinori Yonezawa. DynJava: Type safe dynamic code generation in Java. In PPL '01: Proceedings of the 3rd JSSST Workshop on Programming and Programming Languages, March 2001.Google ScholarGoogle Scholar
  17. OpenJDK Project. http://openjdk.java.net.Google ScholarGoogle Scholar
  18. Rice PLT. Mint Multi-stage Java Compiler. Available at http://www.javamint.org.Google ScholarGoogle Scholar
  19. Massimiliano Poletto, Wilson C. Hsieh, Dawson R. Engler, and M. Frans Kaashoek. C and tcc: a language and compiler for dynamic code generation. ACM Transactions on Programming Languages and Systems, 21(2):324--369, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. U.P. Schultz and J.L. Lawall C. Consel. Automatic Program Specialization for Java. ACM Transactions on Programming Languages and Systems, 25(4):452--499, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Peter Sestoft. Runtime code generation with JVM and CLR. Available at http://www.dina.dk/sestoft/publications.html, 2002.Google ScholarGoogle Scholar
  22. Jun Shirako, Hironori Kasahara, and Vivek Sarkar. Language extensions in support of compiler parallelization. In Languages and Compilers for Parallel Computing: 20th International Workshop, LCPC 2007, Urbana, IL, USA, October 11-13, 2007, Revised Selected Papers, pages 78--94, Berlin, Heidelberg, 2008. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Frederick Smith, Dan Grossman, J. Gregory Morrisett, Luke Hornof, and Trevor Jim. Compiling for template-based run-time code generation. Journal of Functional Programming, 13(3):677--708, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. SoyLatte Project. http://landonf.bikemonkey.org/static/soylatte/.Google ScholarGoogle Scholar
  25. Rok Strniaa, Peter Sewell, and Matthew Parkinson. The Java module system: Core design and semantic definition. In OOPSLA '07: Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object Oriented Programming Systems and Applications, pages 499--514, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Walid Taha. A gentle introduction to multi-stage programming. In DSPG '03: Proceedings of the International Seminar on Domain-Specific Program Generation, 2003.Google ScholarGoogle Scholar
  27. Walid Taha, Zine el-abidine Benaissa, and Tim Sheard. Multi-Stage Programming: Axiomatization and Type Safety (Extended Abstract). In ICALP'98: 25th International Colloquium on Automata, Languages, and Programming, pages 918--929, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Walid Taha and Michael Florentin Nielsen. Environment classifiers. In POPL '03: Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 26--37, New York, NY, USA, 2003. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Edwin Westbrook, Mathias Ricken, Jun Inoue, Yilong Yao, Tamer Abdelatif, and Walid Taha. Multi-stage Programming for Mainstream Languages. Technical Report TR09-02, Rice University, 2009.Google ScholarGoogle Scholar
  30. David Zook, Shan Shan Huang, and Yannis Smaragdakis. Generating AspectJ Programs with Meta-AspectJ. In GPCE '04: Proceedings of the 3rd International Conference on Generative Programming and Component Engineering, pages 1--18, 2004.Google ScholarGoogle Scholar

Index Terms

  1. Mint: Java multi-stage programming using weak separability

        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
          PLDI '10: Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and Implementation
          June 2010
          514 pages
          ISBN:9781450300193
          DOI:10.1145/1806596
          • cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 45, Issue 6
            PLDI '10
            June 2010
            496 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/1809028
            Issue’s Table of Contents

          Copyright © 2010 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: 5 June 2010

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          Overall Acceptance Rate406of2,067submissions,20%

          Upcoming Conference

          PLDI '24

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader