Functional encapsulation and type reconstruction in a strongly-typed, polymorphic language

Static type systems are traditionally used to prevent run-time type-errors in user programs and to assign appropriate storage representations to objects during compilation. In this thesis, we explore some new ways of using static type information in the design, compilation, and execution of programs written in a strongly-typed, polymorphic language. Programmers often nd it useful to know whether or not a particular data-structure may be updated outside a given control block. Information about an object's non-mutability helps compiler optimizations, improves aliasing and dependence analyses, and permits unrestricted caching of functional data at run-time. In the rst part of this thesis, we present a safe, static mechanism for functional encapsulation of imperative data-structures using a powerful type system based on closure types and regions. We introduce a new language construct called close which delimits the scope of side-e ects on imperative objects and converts them into functional objects outside that scope. This mechanism may be used to build e cient, highlevel, functional data-abstractions within a language using its low-level, imperative constructs. Type-safety and non-mutability of closed objects is guaranteed by a semantic soundness theorem that ensures consistency between the static and the dynamic semantics. The type system is presented in the context of Id, which is a strongly-typed, polymorphic, higher-order language, and it easily simpli es to a rst-order, monomorphic language such as C or Fortran. In the second part of the thesis, we develop a general, compiler-directed methodology for complete type reconstruction of run-time objects in a polymorphic language without using any run-time type-tags. Run-time type reconstruction is carried out by instantiating static type information for each function activation frame present within the dynamic call tree. Additional type-hints are inserted automatically at compile-time and are decoded at run-time to ensure complete type reconstruction. We present the necessary compiler analysis and the type reconstruction algorithm and prove their correctness. This technique has been used successfully for displaying run-time objects within the Id source debugger for Monsoon and to perform tagless garbage collection in the *T architecture. We describe the latter application in detail, comparing its performance with other schemes for automatic storage reclamation.

[1]  Zena M. Ariola,et al.  Properties of a First-Order Functional Language with Sharing , 1995, Theor. Comput. Sci..

[2]  Paul S. Barth,et al.  Atomic data structures for parallel computing , 1992 .

[3]  K. R. Traub,et al.  A COMPILER FOR THE MIT TAGGED-TOKEN DATAFLOW ARCHITECTURE , 1986 .

[4]  Rishiyur S. Nikhil,et al.  Cid: A Parallel, "Shared-Memory" C for Distributed-Memory Machines , 1994, LCPC.

[5]  Luca Cardelli,et al.  Typeful Programming , 1989, Formal Description of Programming Concepts.

[6]  Joannes M. Lucassen Types and Effects Towards the Integration of Functional and Imperative Programming. , 1987 .

[7]  Xavier Leroy,et al.  Polymorphic typing of an algorithmic language , 1992 .

[8]  Pierre Jouvelot,et al.  Algebraic reconstruction of types and effects , 1991, POPL '91.

[9]  Keshav Pingali,et al.  I-structures: data structures for parallel computing , 1986, Graph Reduction.

[10]  Mads Tofte,et al.  A theory of stack allocation in polymorphically typed languages , 1993 .

[11]  Niklaus Wirth,et al.  Pascal User Manual and Report , 1991, Springer New York.

[12]  Uday S. Reddy,et al.  Imperative functional programming , 1996, CSUR.

[13]  Xavier Leroy,et al.  Polymorphic type inference and assignment , 1991, POPL '91.

[14]  Xavier Leroy,et al.  Polymorphism by name for references and continuations , 1993, POPL '93.

[15]  Mads Tofte,et al.  Type Inference for Polymorphic References , 1990, Inf. Comput..

[16]  Adrienne G. Bloss Update analysis and the efficient implementation of functional aggregates , 1989, FPCA.

[17]  Robin Milner,et al.  Definition of standard ML , 1990 .

[18]  Luís Damas,et al.  Type assignment in programming languages , 1984 .

[19]  Arvind,et al.  Compiler-directed storage reclamation using object lifetime analysis , 1992 .

[20]  Harry G. Mairson Deciding ML typability is complete for deterministic exponential time , 1989, POPL '90.

[21]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[22]  Robin Milner,et al.  Commentary on standard ML , 1990 .

[23]  Andrew W. Appel,et al.  A runtime system , 1990, LISP Symb. Comput..

[24]  Paul R. Wilson,et al.  Uniprocessor Garbage Collection Techniques , 1992, IWMM.

[25]  J. A. Robinson,et al.  A Machine-Oriented Logic Based on the Resolution Principle , 1965, JACM.

[26]  James E. Hicks,et al.  Garbage collection for strongly-typed languages using run-time type reconstruction , 1994, LFP '94.

[27]  Pierre Jouvelot,et al.  The Type and Effect Discipline , 1994, Inf. Comput..

[28]  Hans-Juergen Boehm,et al.  Garbage collection in an uncooperative environment , 1988, Softw. Pract. Exp..

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

[30]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.

[31]  Benjamin Goldberg,et al.  Polymorphic type reconstruction for garbage collection without tags , 1992, LFP '92.

[32]  M. F.,et al.  Bibliography , 1985, Experimental Gerontology.

[33]  A. K. Wmght Polymorphism for imperative languages without imperative types , 1993 .

[34]  P. J. Plauger The Standard C Library , 1991 .

[35]  Paul Hudak,et al.  Mutable abstract datatypes -or- how to have your state and mange it too , 1992 .

[36]  M. J. Beckerle,et al.  T: integrated building blocks for parallel computing , 1993, Supercomputing '93.

[37]  Pierre Jouvelot,et al.  Report on the FX-91 Programming Language , 1992 .

[38]  Benjamin Goldberg,et al.  Higher Order Escape Analysis: Optimizing Stack Allocation in Functional Program Implementations , 1990, ESOP.

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

[40]  Joel F. Bartlett,et al.  Compacting garbage collection with ambiguous roots , 1988, LIPO.

[41]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[42]  Benjamin Goldberg,et al.  Reference escape analysis: optimizing reference counting based on the lifetime of references , 1991, PEPM '91.

[43]  Simon L. Peyton Jones,et al.  Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine , 1992, Journal of Functional Programming.

[44]  Benjamin Goldberg,et al.  Tag-free garbage collection for strongly typed programming languages , 1991, PLDI '91.

[45]  Ramesh Viswanathan,et al.  Standard ML-NJ weak polymorphism and imperative constructs , 1993, [1993] Proceedings Eighth Annual IEEE Symposium on Logic in Computer Science.

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

[47]  S. A. Gupta AN INCREMENTAL TYPE INFERENCE SYSTEM FOR THE PROGRAMMING LANGUAGE ID , 1990 .

[48]  Guy L. Steele,et al.  Common Lisp the Language , 1984 .

[49]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[50]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.

[51]  James W. O'Toole Type Abstraction Rules for References: A Comparison of Four which have Achieved Notoriety , 1991 .

[52]  D. A. Turner,et al.  Miranda: A Non-Strict Functional language with Polymorphic Types , 1985, FPCA.

[53]  Alejandro Caro,et al.  Compiler-directed type reconstruction for polymorphic languages , 1993, FPCA '93.

[54]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[55]  Zena M. Ariola,et al.  Compilation of Id , 1991, LCPC.

[56]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.

[57]  Alfred V. Aho,et al.  The Design and Analysis of Computer Algorithms , 1974 .

[58]  Williams Ludwell Harrison,et al.  The interprocedural analysis and automatic parallelization of Scheme programs , 1990, LISP Symb. Comput..

[59]  James R. Larus,et al.  Application-specific protocols for user-level shared memory , 1994, Proceedings of Supercomputing '94.

[60]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[61]  James Hicks,et al.  Experiences with compiler-directed storage reclamation , 1993, FPCA '93.

[62]  Arvind,et al.  T: A Multithreaded Massively Parallel Architecture , 1992, [1992] Proceedings the 19th Annual International Symposium on Computer Architecture.

[63]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[64]  Arvind,et al.  M-Structures: Extending a Parallel, Non-strict, Functional Language with State , 1991, FPCA.

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