A constraint-based region inference algorithm

Abstract Region inference is a type-based technique for determining run time memory management at compile time. 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. Region inference has previously been specified by a set of inference rules, which formalize when regions may be allocated and deallocated. We present a constraint-based algorithm which implements the specification. It consists of a constraint-based formulation of region inference and a rewriting algorithm for solving a set of constraints. We prove that the constraint-based formulation of region inference is sound with respect to the region inference rules. Moreover we prove “restricted completeness” of the constraint-based formulation, that is, we define an “implementation-oriented” formulation of region inference and show that every derivation in the implementation-oriented formulation can be obtained by a solution to a corresponding constraint problem. We show that rewriting of a constraint problem always terminates with a solution to the original system.

[1]  Peter Aczel,et al.  An Introduction to Inductive Definitions , 1977 .

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

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

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

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

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

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

[8]  Jerzy Tiuryn,et al.  Type reconstruction in the presence of polymorphic recursion , 1993, TOPL.

[9]  Lars Birkedal,et al.  A region inference algorithm , 1998, TOPL.

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

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

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

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

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

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

[16]  Mark Halpern Variable-width tables with binary-search facility , 1958, CACM.

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