A Simple Region Inference Algorithm for a First-Order Functional Language [chapter]

Manuel Montenegro, Ricardo Peña, Clara Segura
2010 Lecture Notes in Computer Science  
Safe is a first-order eager language with facilities for programmer controlled destruction and copying of data structures. It provides also regions, i.e. disjoint parts of the heap, where the program allocates data structures. The runtime system does not need a garbage collector and all allocation/deallocation actions are done in constant time. The language is aimed at inferring and certifying upper bounds for memory consumption in a Proof Carrying Code environment. Some of its analyses have
more » ... n presented elsewhere [4, 6, 7] . In this paper we present a simple region inference algorithm for annotating programs with regions arguments and region types. Programmers are assumed to write programs and to declare datatypes without any reference to regions. The algorithm decides the regions that will be needed by every function and type. We show convincing examples of programs before and after region annotation, prove the correctness and optimality of the inference algorithm and give its asymptotic cost. INTRODUCTION Many imperative languages offer low level mechanisms to allocate and free heap memory, which the programmer may use in order to dynamically create and destroy pointer based data structures. These mechanisms give the programmer complete control over memory usage but are very error prone. Well known problems
doi:10.1007/978-3-642-11999-6_10 fatcat:tffzt7yrtvfs5iurjabhairroa