skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Finitary polymorphism for optimizing type-directed compilation

Published:30 July 2018Publication History
Skip Abstract Section

Abstract

We develop a type-theoretical method for optimizing type directed compilation of polymorphic languages, implement the method in SML#, which is a full-scale compiler of Standard ML extended with several advanced features that require type-passing operational semantics, and report its effectiveness through performance evaluation. For this purpose, we first define a predicative second-order lambda calculus with finitary polymorphism, where each type abstraction is explicitly constrained to a finite type universe, and establishes the type soundness with respect to a type-passing operational semantics. Different from a calculus with stratified type universes, type universes of the calculus are terms that represent a finite set of instance types. We then develop a universe reconstruction algorithm that takes a term of the standard second-order lambda calculus, checks if the term is typable with finitary polymorphism, and, if typable, constructs a term in the calculus of finitary polymorphism. Based on these results, we present a type-based optimization method for polymorphic functions. Since our formalism is based on the second-order lambda calculus, it can be used to optimize various polymorphic languages. We implement the optimization method for native (tag-free) data representation and record polymorphism, and evaluate its effectiveness through benchmarks. The evaluation shows that 83.79% of type passing abstractions are eliminated, and achieves the average of 15.28% speed-up of compiled code.

Skip Supplemental Material Section

Supplemental Material

a81-ohori.webm

References

  1. F. Barbanera, M. Dezaniciancaglini, and U. Deliguoro. 1995. Intersection and Union Types: Syntax and Semantics. Information and Computation 119, 2 (1995), 202 – 230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Antonio Bucciarelli, Delia Kesner, and Daniel Ventura. 2017. Non-idempotent intersection types for the Lambda-Calculus. Logic Journal of the IGPL 25, 4 (2017), 431–464.Google ScholarGoogle ScholarCross RefCross Ref
  3. Mario Coppo, Mariangiola Dezani-Ciancaglini, and Betti Venneri. 1981. Functional Characters of Solvable Terms. Math. Log. Q. 27, 2-6 (1981), 45–58.Google ScholarGoogle ScholarCross RefCross Ref
  4. Martin Elsman. 1998. Polymorphic equality — No tags required. In Types in Compilation, Xavier Leroy and Atsushi Ohori (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 136–155. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type Classes in Haskell. ACM Trans. Program. Lang. Syst. 18, 2 (March 1996), 109–138. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Robert Harper and Greg Morrisett. 1995. Compiling Polymorphism Using Intensional Type Analysis. In Proceedings of the 22Nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’95) . ACM, New York, NY, USA, 130–141. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Mark P. Jones. 1994. A Theory of Qualified Types. Sci. Comput. Program. 22, 3 (1994), 231–256. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Mark P. Jones. 1995. Dictionary-free overloading by partial evaluation. LISP and Symbolic Computation 8, 3 (01 Sep 1995), 229–248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Simon L. Peyton Jones and John Launchbury. 1991. Unboxed values as first class citizens in a non-strict functional language. In Functional Programming Languages and Computer Architecture, John Hughes (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 636–666. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Daniel Leivant. 1989. Stratified Polymorphism (Extended Summary). In Proceedings of the Fourth Annual Symposium on Logic in Computer Science (LICS ’89), Pacific Grove, California, USA, June 5-8, 1989 . IEEE, 39–47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Daniel Leivant. 1991. Finitely stratified polymorphism. Information and Computation 93, 1 (1991), 93 – 113. Selections from 1989 IEEE Symposium on Logic in Computer Science. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Xavier Leroy. 1992. Unboxed Objects and Polymorphic Typing. In Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’92) . ACM, New York, NY, USA, 177–188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Martin-Löf. 1975. An Intuitionistic Theory of Types: Predicative Part. In Logic Colloquium, H. E. Rose and J. C. Shepherdson (Eds.). Noth Holland, Amsterdam.Google ScholarGoogle Scholar
  14. Huu-Duc Nguyen and Atsushi Ohori. 2006. Compiling ML Polymorphism with Explicit Layout Bitmap. In Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP ’06) . ACM, New York, NY, USA, 237–248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Atsushi Ohori. 1992. A Compilation Method for ML-style Polymorphic Record Calculi. In Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’92) . ACM, New York, NY, USA, 154–165. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Atsushi Ohori. 1995. A Polymorphic Record Calculus and Its Compilation. ACM Trans. Program. Lang. Syst. 17, 6 (Nov. 1995), 844–895. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Atsushi Ohori. 1999. Type-Directed Specialization of Polymorphism. Inf. Comput. 155, 1-2 (1999), 64–107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. JENS PALSBERG and CHRISTINA PAVLOPOULOU. 2001. From Polyvariant flow information to intersection and union types. Journal of Functional Programming 11, 3 (2001), 263–317. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. John Peterson and Mark Jones. 1993. Implementing Type Classes. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation (PLDI ’93) . ACM, New York, NY, USA, 227–236. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. B. Russell. 1908. Mathematical logic based on a theory of types. Americal Journal of Mathematics 30 (1908), 222–262.Google ScholarGoogle ScholarCross RefCross Ref
  21. Zhong Shao. 1997. Flexible Representation Analysis. In Proceedings of the Second ACM SIGPLAN International Conference on Functional Programming (ICFP ’97) . ACM, New York, NY, USA, 85–98. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Olin Grigsby Shivers. 1991. Control-flow Analysis of Higher-order Languages of Taming Lambda. Ph.D. Dissertation. Carnegie Mellon University, Pittsburgh, PA, USA. UMI Order No. GAX91-26964.Google ScholarGoogle Scholar
  23. J.M. Siskind. 1999. Flow-Directed Lightweight Closure Conversion. Technical Report Technical Report 99-190R. NEC Research Institute, Inc.Google ScholarGoogle Scholar
  24. SML#-Project-Team. 2005 – 2018. SML# Project. http://www.riec.tohoku.ac.jp/smlsharp/Google ScholarGoogle Scholar
  25. D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. 1996. TIL: A Type-directed Optimizing Compiler for ML. In Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation (PLDI ’96). ACM, New York, NY, USA, 181–192. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Andrew Tolmach. 1994. Tag-free Garbage Collection Using Explicit Type Parameters. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming (LFP ’94) . ACM, New York, NY, USA, 1–11. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Andrew Tolmach and Dino P. Oliva. 1998. From ML to Ada: Strongly-typed language interoperability via source translation. Journal of Functional Programming 8, 4 (1998), 367–412. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Stephen Weeks. 2006. Whole-program Compilation in MLton. In Proceedings of the 2006 Workshop on ML (ML ’06). ACM, New York, NY, USA, 1–1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. J. B. WELLS, ALLYN DIMOCK, ROBERT MULLER, and FRANKLYN TURBAK. 2002. A calculus with polymorphic and polyvariant flow types. Journal of Functional Programming 12, 3 (2002), 183–227. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Finitary polymorphism for optimizing type-directed compilation

        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

        Full Access

        • Article Metrics

          • Downloads (Last 12 months)34
          • Downloads (Last 6 weeks)1

          Other Metrics

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!