Static Region Analysis for Mercury

  • Quan Phan
  • Gerda Janssens
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4670)

Abstract

Region-based memory management is a form of compile-time memory management, well-known from the functional programming world. This paper describes a static region analysis for the logic programming language Mercury. We use region points-to graphs to model the partitioning of the memory used by a program into separate regions. The algorithm starts with a region points-to analysis that determines the different regions in the program. We then compute the liveness of the regions by using an extended live variable analysis. Finally, a program transformation adds region annotations to the program for region support. These annotations generate data for a region simulator that generates reports on the memory behaviour of region-annotated programs. Our approach obtains good memory consumption for several benchmark programs; for some of them it achieves optimal memory management.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Aiken, A., Fähndrich, M., Levien, R.: Better static memory management: Improving region-based analysis of higher-order languages. In: Proceedings of the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation, pp. 174–185. ACM Press, New York (1995)CrossRefGoogle Scholar
  2. 2.
    Cherem, S., Rugina, R.: Region analysis and transformation for Java programs. In: Proceedings of the 4th International Symposium on Memory Management, pp. 85–96. ACM Press, New York (2004)CrossRefGoogle Scholar
  3. 3.
    Grossman, D., Morrisett, G., Jim, T., Hicks, M., Wang, Y., Cheney, J.: Region-based memory management in Cyclone. In: Proceedings of the ACM Conference on Programming Language Design and Implementation, pp. 282–293. ACM Press, New York (2002)Google Scholar
  4. 4.
    Henglein, F., Makholm, H., Niss, H.: A direct approach to control-flow sensitive region-based memory management. In: Principles and Practice of Declarative Programming, pp. 175–186. ACM Press, New York (2001)CrossRefGoogle Scholar
  5. 5.
    Makholm, H.: A region-based memory manager for Prolog. In: Proceedings of the 2nd International Symposium on Memory Management, pp. 25–34. ACM Press, New York (2000)CrossRefGoogle Scholar
  6. 6.
    Makholm, H.: Region-based memory management in Prolog. Master’s thesis, University of Copenhagen (2000)Google Scholar
  7. 7.
    Makholm, H., Sagonas, K.: On enabling the WAM with region support. In: Stuckey, P.J. (ed.) ICLP 2002. LNCS, vol. 2401, Springer, Heidelberg (2002)CrossRefGoogle Scholar
  8. 8.
    Mazur, N.: Compile-time garbage collection for the declarative language Mercury. PhD thesis, Department of Computer Science, Katholieke Universiteit Leuven (May 2004)Google Scholar
  9. 9.
    Mazur, N., Janssens, G., Bruynooghe, M.: A module based analysis for memory reuse in Mercury. In: Palamidessi, C., Moniz Pereira, L., Lloyd, J.W., Dahl, V., Furbach, U., Kerber, M., Lau, K.-K., Sagiv, Y., Stuckey, P.J. (eds.) CL 2000. LNCS (LNAI), vol. 1861, pp. 1255–1269. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  10. 10.
    Mazur, N., Ross, P., Janssens, G., Bruynooghe, M.: Practical aspects for a working compile time garbage collection system for Mercury. In: Codognet, P. (ed.) ICLP 2001. LNCS, vol. 2237, pp. 105–119. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  11. 11.
    Nielson, F., Nielson, H.R., Hankin, C.: The Principles of Program Analysis. Springer, Heidelberg (1999)Google Scholar
  12. 12.
    Phan, Q., Janssens, G.: Towards region-based memory management for Mercury programs. In: CICLOPS (2006)Google Scholar
  13. 13.
    Phan, Q., Janssens, G.: A proposal for runtime region support for Mercury programs. Technical Report CW482, Department of Computer Science, Katholieke Universiteit Leuven (2007)Google Scholar
  14. 14.
    Somogyi, Z., Henderson, F., Conway, T.: The execution algorithm of Mercury, an efficient purely declarative logic programming language. The Journal of Logic Programming 29(1-3), 17–64 (1996)MATHCrossRefGoogle Scholar
  15. 15.
    Tofte, M., Birkedal, L., Elsman, M., Hallenberg, N.: A retrospective on region-based memory management. Higher-Order and Symbolic Computation 17, 245–265 (2004)MATHCrossRefGoogle Scholar
  16. 16.
    Tofte, M., Talpin, J.-P.: Region-based memory management. Information and Computation. 132(2), 109–176 (1997)MATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Quan Phan
    • 1
  • Gerda Janssens
    • 1
  1. 1.Department of Computer Science, K.U. Leuven, Celestijnenlaan, 200A, B-3001 HeverleeBelgium

Personalised recommendations