Typed closure conversion

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.

[1]  Mark Lillibridge,et al.  A type-theoretic approach to higher-order modules with sharing , 1994, POPL '94.

[2]  Andrew P. Tolmach Tag-free garbage collection using explicit type parameters , 1994, LFP '94.

[3]  Andrew W. Appel,et al.  Continuation-passing, closure-passing style , 1989, POPL '89.

[4]  Pierre-Louis Curien,et al.  The Categorical Abstract Machine , 1987, Sci. Comput. Program..

[5]  Luca Cardelli The Functional Abstract Machine , 1983 .

[6]  Martín Abadi,et al.  Explicit substitutions , 1989, POPL '90.

[7]  Mark Lillibridge,et al.  Explicit polymorphism and CPS conversion , 1993, POPL '93.

[8]  GoslingJames Java intermediate bytecodes , 1995 .

[9]  H. Friedman Equality between functionals , 1975 .

[10]  Benjamin C. Pierce,et al.  Simple type-theoretic foundations for object-oriented programming , 1994, Journal of Functional Programming.

[11]  Dianne Ellen Britton,et al.  Heap storage management for the programming language Pascal , 1975 .

[12]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[13]  Mitchell Wand,et al.  Selective and lightweight closure conversion , 1994, POPL '94.

[14]  John C. Mitchell,et al.  Abstract types have existential type , 1988, TOPL.

[15]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[16]  Zhong Shao,et al.  Space-E cient Closure Representations , 1994 .

[17]  Xavier Leroy,et al.  Unboxed objects and polymorphic typing , 1992, POPL '92.

[18]  Andrew W. AppelDepartment Space-eecient Closure Representations , 1994 .

[19]  Andrew W. Appel,et al.  Space-efficient closure representations , 1994, LFP '94.

[20]  John C. Mitchell,et al.  On the type structure of standard ML , 1993, TOPL.

[21]  E AndersonThomas,et al.  Efficient software-based fault isolation , 1993 .

[22]  Robert Wahbe,et al.  Efficient software-based fault isolation , 1994, SOSP '93.

[23]  Xavier Leroy,et al.  Manifest types, modules, and separate compilation , 1994, POPL '94.

[24]  T. Anderson,et al.  Eecient Software-based Fault Isolation , 1993 .

[25]  Matthias Felleisen,et al.  Abstract models of memory management , 1995, FPCA '95.

[26]  J. Girard,et al.  Proofs and types , 1989 .

[27]  Andrew W. Appel,et al.  A type-based compiler for standard ML , 1995, PLDI '95.

[28]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[29]  Thomas Johnsson,et al.  Lambda Lifting: Treansforming Programs to Recursive Equations , 1985, FPCA.

[30]  James Gosling,et al.  Java Intermediate Bytecode , 1995, Intermediate Representations Workshop.

[31]  P. J. Landin The Mechanical Evaluation of Expressions , 1964, Comput. J..

[32]  Paul Hudak,et al.  Realistic compilation by program transformation (detailed summary) , 1989, POPL '89.

[33]  Paul Hudak,et al.  ORBIT: an optimizing compiler for scheme , 1986, SIGPLAN '86.

[34]  J. Roger Hindley,et al.  To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus, and Formalism , 1980 .

[35]  Andrew W. Appel,et al.  Runtime tags aren't necessary , 1989, LISP Symb. Comput..

[36]  Richard Statman,et al.  Completeness, invariance and λ-definability , 1982, Journal of Symbolic Logic.

[37]  M. E. R. “If” , 1921, Definitions.

[38]  Richard C. H. Connor,et al.  An ad hoc approach to the implementation of polymorphism , 1991, TOPL.

[39]  Robert Harper,et al.  TIL: a type-directed optimizing compiler for ML , 1996, PLDI '96.

[40]  David B. MacQueen Modules for standard ML , 1984, LFP '84.

[41]  Jr. Guy L. Steele,et al.  Rabbit: A Compiler for Scheme , 1978 .

[42]  Benjamin C. Pierce,et al.  Object-oriented programming without recursive types , 1993, POPL '93.

[43]  Atsushi Ohori,et al.  A compilation method for ML-style polymorphic record calculi , 1992, POPL '92.

[44]  John C. Reynolds Definitional Interpreters for Higher-Order Programming Languages , 1998, High. Order Symb. Comput..