skip to main content
10.1145/237721.237791acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article
Free Access

Typed closure conversion

Authors Info & Claims
Published:01 January 1996Publication History

ABSTRACT

Closure conversion is a program transformation used by compilers to separate code from data. Previous accounts of closure conversion use only untyped target languages. Recent studies show that translating to typed target languages is a useful methodology for building compilers, because a compiler can use the types to implement efficient data representations, calling conventions, and tag-free garbage collection. Furthermore, type-based translations facilitate security and debugging through automatic type checking, as well as correctness arguments through the method of logical relations.We present closure conversion as a type-directed, and type-preserving translation for both the simply-typed and the polymorphic λ-calculus. Our translations are based on a simple "closures as objects" principle: higher-order functions are viewed as objects consisting of a single method (the code) and a single instance variable (the environment). In the simply-typed case, the Pierce-Turner model of object typing where objects are packages of existential type suffices. In the polymorphic case, more careful tracking of type sharing is required. We exploit a variant of the Harper-Lillibridge "translucent type" formalism to characterize the types of polymorphic closures.

References

  1. 1.A. W. Appel. Compiling with Contmuations. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 2.A. W. Appel and T. Jim. Continuation-passing, closurepassing style. In A CM Syrup. on Prme#ples of Programmzng Languages, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3.D. E. Britton. Heap storage management for the programming language Pascal. Master's thews, Universlty of Arizona, 1975.Google ScholarGoogle Scholar
  4. 4.L. Cardelli. The functional abstract machine. Polymorph#sm, i(i), 1983.Google ScholarGoogle Scholar
  5. 5.C Cousineau, P-L Curien, and M. Mauny. The categorical abstract machine. In Functional Programming Lanquages and Computer Architecture, pages 50-64, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6.tt Friedman. Equahty between functionals. In R. Parikh, editor, Logic Colloquzum '75 Norh-Holland, 1975.Google ScholarGoogle Scholar
  7. 7.J.-Y. Girard, Y. Lafont, and P. Taylor. Proofs and Types, volume 7 of Cambridge Tracts #n Theoretical Computer Sczence. Cambridge University Press, Cambridge, England, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8.J. Gosling. Java mtermediate bytecodes. In A CM StG- PLAN Workshop on Intermediate Representations (IR'95), Jan. 1995 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9.J. Hannan. A type system for closure conversion. In The Workshop on Types for Proqram Analyszs, 1995.Google ScholarGoogle Scholar
  10. 10.R. Harper and M. Lillibridge. Exphcit polymorphmm and CPS conversion. In ACM Syrup. on Princzples of Programmmg Languages, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11.R. Harper and M. Lillibridge A type-theoretic approach to higher-order modules. In A CM Syrup. on Prznc#ples of Programming Languages, pages 123-137, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 12.R. Harper, D. MacQueen, and R. Milner Standard ML Technical Report ECS-LFCS-86-2, Laboratory for the Foundations of Computer Science# Edinburgh University. Mar. 1986Google ScholarGoogle Scholar
  13. 13.t#. Harper and J. C. Mitchell. On the type structure of 3tandard ML A CM Transaction on Programm#n9 Languages and Systems, 15(2), 1993 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 14.R Harper and G. Morrisett. Complhng potymorphism using intensional type analysis In A CM Syrup. on Prmc#ples of Programmmg Languages, pages 130-141, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 15.T. Johnsson. Lambda lifting- Transformmg programs to recursive equations. In Functional Programming Language and Computer Architecture, LNCS 201, pages 190-203. Springer- Verlag, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 16.R. Kelsey and P. Hudak. Realistic compilation by program translation -detailed summary-. In A CM Syrup. on Pmnc#ples of Programming Languages, pages 281-292, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 17.D. Kranz et al. Orbit: An optimizing compiler for Scheme. In Proc. of the SIGPLAN '86 Syrup. on Compiler Constructzon, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 18.X. Leroy. Unboxed objects and polymorphic typing. In A CM Symp. on Principles o/Programming Languages, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 19.X. Leroy. Manifest types, modules, and separate compilation. In A CM Symp. on Pmnczples of Programming Languages, pages 109-122, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. 20.D. MacQueen. Modules for Standard ML. In Proc. ACM Conf. Lisp and Functional Programmzng, pages 198-207, 1984. Revised version appears in {12}. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 21.Y. Minamide, G. Morrisett, and R. Harper. Typed closure conversion. Technical Report CMU-CS-95-171, School of Computer Science, Carnegie Mellon University, July 1995.Google ScholarGoogle Scholar
  22. 22.J. C. Mitchell and G. D. Plotkin. Abstract types have existential type. A CM Transactwn on Programming Languages and Systems, 10(3), 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 23.G. Morrisett, M. FeIIeisen, and R. Harper. Abstract models of memory management. In Functwnal Programm,ng Languages and Computer Architecture, pages 66-77, June 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 24.R. Morrison, A. Dearle, R. Connor, and A. L. Brown. An ad hoc approach to the implementation of polymorphism. A CM Transactwn on Programming Languages and Systems, 13(3), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 25.A. Ohori. A compilation method for ML-style polymorphic record calculi. In A CM Symp. on Principles of Programming Languages, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 26.B. C Pierce and D. N. T#rner. Simple type-theoretic foundations for object-oriented programming. Journal of Functzonal Programming, 4(2):207-247, Apr. 1994. A preliminary version appeared in Principles of Programming Languages, 1993, and as University of Edinburgh technical report ECS- LFCS-92-225, under the title "Object-Oriented Programming Without Recursive Types".Google ScholarGoogle ScholarCross RefCross Ref
  27. 27.G. D. Plotkin. Lambda-definability in the full type hierarchy. In To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism. Academic Press, 1980.Google ScholarGoogle Scholar
  28. 28.U. S. Reddy. Objects as closures. In Proe. ACM Conf. Lisp and Functional Programming, 1988.Google ScholarGoogle Scholar
  29. 29.J. C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of the Annual A CM Conference, pages 717-740, 1972. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. 30.Z. Shao and A. W. Appel. Space-efficient closure representations. In Proc. A CM Conf. Lzsp and Functional Programming, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 31.Z. Shao and A. W. Appel. A type-based compiler for Standard ML. In Programming Language Design and Its zmplemenation, pages 116-129, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 32.R. Statman. Completeness, invariance, and lambdadefinability. Journal of Symbolic Logic, 47:17-26, 1982.Google ScholarGoogle ScholarCross RefCross Ref
  33. 33.R. Statman. Logical relations and the typed A-calculus. informatzon and Control, 65, 1985.Google ScholarGoogle Scholar
  34. 34.G. L. Steele Jr. Rabbit: A compiler for Scheme. Master's thesis, MIT, 1978.Google ScholarGoogle Scholar
  35. 35.W.W. Tait. Intensionat interpretation of functionals of finite type. Journal of Symbohc Logic, 32(2), 1967.Google ScholarGoogle Scholar
  36. 36.D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: A type-directed optimizing compiler for ML. Technical report, School of Computer Science, Carnegie Mellon University, Oct. 1995. To appear.Google ScholarGoogle Scholar
  37. 37.A. Tolmach. Tag-free garbage collection using explicit type parameters. In Proc. A CM Conf. Lisp and Functional Programmmg, pages 1-11, June 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. 38.R. Wahbe, S. Lucco, T. Anderson, and S. Graham. Efficient software-based fault isolation. In 14th ACM Symposium on Operating Systems Pmnczples, Dec. 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. 39.M. Wand and P. Steckler. Selective and lightweight closure conversion. In A CM Symp. on Principles of Programming Languages, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Typed closure conversion

    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
      POPL '96: Proceedings of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
      January 1996
      423 pages
      ISBN:0897917693
      DOI:10.1145/237721
      • Chairman:
      • Hans-J. Boehm,
      • Conference Chair:
      • Guy Steele

      Copyright © 1996 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: 1 January 1996

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      POPL '96 Paper Acceptance Rate34of148submissions,23%Overall Acceptance Rate824of4,130submissions,20%

      Upcoming Conference

      POPL '25

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader