skip to main content
article
Open Access

A region inference algorithm

Published:01 July 1998Publication History
Skip Abstract Section

Abstract

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.

References

  1. AIKEN, A., FAHNDRICH, iV{., AND LEVIEN, R. 1995. Better static memory management: Improving region-based analysis of higher-order languages. In Proc. of the A CM SIGPLAN '95 Conference on Programming Languages and Implementation (PLDI). ACM Press, La Jolla, CA, 174-185. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. APONTE, iV{. V. 1993. Extending record typing to type parametric modules with sharing. In Proc. of the 20th Annual A CM SIGPLAN-SIGA CT Symposium on Principles of Programming Languages (POPL). ACM Press, 465-478. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. BIRKEDAL, L., TOFTE, ~/{., AND VEJLSTRUP, ~/{. 1996. From region inference to yon Neumann machines via region representation inference. In Proceedings of the 23rd ACM SIGPLAN- SIGACT Symposium on Principles of Programming Languages. ACM Press, 171-183. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. DAMAS, L. AND iV{ILNER, R. 1982. Principal type schemes for functional programs. In Proc. 9th Annual A CM Syrup. on Principles of Programming Languages. 207-212. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. DIJKSTRA, E. W. 1960. Recursive programming. Numerische Math 2, 312-318. Also in Rosen: "Programming Systems and Languages", McGraw-Hill, 1967.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. HALLENBERG, N. 1997. ML Kit test report. (Automatically generated test report; available at http:////www, diku. dk//reseat ch-gr o ups//to p ps//act ivi ties//ki t 2//test. ps).Google ScholarGoogle Scholar
  7. HARPER, R., iV{ILNER, R., AND TOFTE, iV{. 1987. A type discipline for program modules. In Proc. Int'l Joint Conf. on Theory and Practice of Software Development (TAPSOFT). Springer- Verlag, 308-319. Lecture Notes in Computer Science, Vol. 250. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. HENGLEIN, F. 1993. Type inference with polymorphic recursion. ACM Transactions on Programruing Languages and Systems 15, 2 (April), 253. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. JOUVELOT, P. AND GIFFORD, D. 1991. Algebraic reconstruction of types and effects. In Proceedings of the 18th A CM Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. KFOURY, A., TIURYN, J., AND URZYCZYN, P. 1990. The undecidability of the semi-unification problem. In Proc. 22nd Annual A CM Syrup. on Theory of Computation (STOC), Baltimore, Maryland. 468-476. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. LEROY, X. 1992. Typage polymophe d'un language Mgorithmique. Ph.D. thesis, University Paris VII. English version: Polymorphic Typing of an Algorithmic Language, INRIA Research Report no. 1778, October 1992.Google ScholarGoogle Scholar
  12. LUCASSEN, J. AND GIFFORD, D. 1988. Polymorphic effect systems. In Proceedings of the 1988 A CM Conference on Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. MILNER, R. 1978. A theory of type polymorphism in programming. J. Computer and System Sciences 17, 348-375.Google ScholarGoogle ScholarCross RefCross Ref
  14. MILNER, R., TOFTE, iV{., HARPER, R., AND iV{ACQUEEN, D. 1997. The Definition of Standard ML (Revised). MIT Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. MYCROFT, A. 1984. Polymorphic type schemes and recursive definitions. In Proc. 6th Int. Conf. on Programming, LNCS 167. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. NAUR, P. 1963. Revised report on the algorithmic language Algol 60. Comm. ACM 1, 1-17. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. NIELSON, F., NIELSON, H. R., AND AMTOFT, T. 1996. Polymorphic subtyping for effect analysis: the algorithm. Tech. Rep. LOMAPS-DAIMI-16, Department of Computer Science, University of Aarhus (DAIMI). April.Google ScholarGoogle Scholar
  18. NIELSON, H. R. AND NIELSON, F. 1994. Higher-order concurrent programs with finite communication topology. In Conference Record of POPL'94: 21st A CM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM Press, 84-97. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. RI~MY, D. 1989. Typechecking records and variants in a natural extension of ML. In Proc. 16th Annual A CM Syrup. on Principles of Programming Languages. ACM, 77-88. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. TALPIN, J.-P. 1993. Theoretical and practical aspects of type and effect inference. Doctoral Dissertation. Also available as Research Report EMP//CRI//A-236, Ecole des Mines de Paris.Google ScholarGoogle Scholar
  21. TALPIN, J.-P. AND JOUVELOT, P. 1992a. Polymorphic type, region and effect inference. Journal of Functional Programming 2, 3.Google ScholarGoogle ScholarCross RefCross Ref
  22. TALPIN, J.-P. AND JOUVELOT, P. 1992b. The type and effect discipline. In Proceedings of the seventh IEEE Conference on Logic in Computer Science. 162-173. Also, (extended version) technical report EMP//CRI//A-206, Ecole des Mines de Paris, April 1992.Google ScholarGoogle ScholarCross RefCross Ref
  23. TOFTE, M. 1988. Operational semantics and polymorphic type inference. Ph.D. thesis, Edinburgh University, Department of Computer Science, Edinburgh University, Mayfield Rd., EH9 3JZ Edinburgh. Available as Technical Report CST-52-88.Google ScholarGoogle Scholar
  24. TOFTE, M. AND BIRKEDAL, L. 1996. Unification and polymorphism in region inference. Submitted to the Milner Festschrift. http ://www. diku. dk/users/tofte/publ/milner, ps.Google ScholarGoogle Scholar
  25. TOFTE, M., BIRKEDAL, L., ELSMAN, M.,, HALLENBERG, N., OLESEN, T. H., SESTOFT, P., AND BERTELSEN, P. 1997. Programming with regions in the ML Kit. Tech. Rep. DIKU-TR-97/12, Dept. of Computer Science, University of Copenhagen. (http://www.diku.dk/research-groups/ topps / activities/kit 2).Google ScholarGoogle Scholar
  26. TOFTE, M. AND TALPIN, J.-P. 1992. Data region inference for polymorphic functional languages (technical summary). Tech. Rep. EMP/CRI/A-229, Ecole des Mines de Paris.Google ScholarGoogle Scholar
  27. TOFTE, M. AND TALPIN, J.-P. 1994. Implementing the call-by-value lambda-calculus using a stack of regions. In Proceedings of the 21st A CM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM Press, 188-201. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. TOFTE, M. AND TALPIN, J.-P. 1997. Region-based memory management. Information and Computation 132, 2, 109-176. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. WILSON, P. R. 1992. Uniprocessor garbage collection techniques. In Memory Management, Proceedings, International Workshop IWMM92, Y. Bekkers and J. Cohen, Eds. Springer-Verlag, Berlin, 1-42. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A region inference algorithm

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM Transactions on Programming Languages and Systems
            ACM Transactions on Programming Languages and Systems  Volume 20, Issue 4
            July 1998
            248 pages
            ISSN:0164-0925
            EISSN:1558-4593
            DOI:10.1145/291891
            Issue’s Table of Contents

            Copyright © 1998 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 July 1998
            Published in toplas Volume 20, Issue 4

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader