A region inference algorithm

Region Inference is a program analysis which infers lifetimes of values. It is targeted at a runtime model in which the store consists of a stack of regions and memory management predominantly consists of pushing and popping regions, rather than performing garbage collection. Region Inference has previously been specified by a set of inference rules which formalize when regions may be allocated and deallocated. This article presents an algorithm which implements the specification. We prove that the algorithm is sound with respect to the region inference rules and that it always terminates even though the region inference rules permit polymorphic recursion in regions. The algorithm is the result of several years of experiments with region inference algorithms in the ML Kit, a compiler from Standard ML to assembly language. We report on practical experience with the algorithm and give hints on how to implement it.

[1]  Alan Mycroft,et al.  Polymorphic Type Schemes and Recursive Definitions , 1984, Symposium on Programming.

[2]  Martin Elsman,et al.  Programming with regions in the ML Kit , 1997 .

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

[4]  M. Tofte Operational Semantics and Polymorphic Type Inference , 1988 .

[5]  Flemming Nielson,et al.  Polymorphic Subtyping for Effect Analysis: The Algorithm , 1996, LOMAPS.

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

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

[8]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[9]  Lars Birkedal,et al.  Unification and polymorphism in region inference , 2000, Proof, Language, and Interaction.

[10]  Robin Milner,et al.  A Type Discipline for Program Modules , 1987, TAPSOFT, Vol.2.

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

[12]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

[13]  Alexander Aiken,et al.  Better static memory management: improving region-based analysis of higher-order languages , 1995, PLDI '95.

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

[15]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

[16]  Maria-Virginia Aponte Extending record typing to type parametric modules with sharing , 1993, POPL '93.

[17]  E. Dijkstra,et al.  Recursive Programming , 1960 .

[18]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

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

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

[21]  Flemming Nielson,et al.  Higher-order concurrent programs with finite communication topology (extended abstract) , 1994, POPL '94.

[22]  Friedrich L. Bauer,et al.  Revised report on the algorithm language ALGOL 60 , 1963, CACM.

[23]  Mads Tofte,et al.  Region-based Memory Management , 1997, Inf. Comput..

[24]  Jerzy Tiuryn,et al.  The undecidability of the semi-unification problem , 1990, STOC '90.

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

[26]  John McCarthy,et al.  Recursive functions of symbolic expressions and their computation by machine, Part I , 1959, Commun. ACM.

[27]  Lars Birkedal,et al.  From region inference to von Neumann machines via region representation inference , 1996, POPL '96.