Advertisement

Alias Types for Recursive Data Structures

  • David Walker
  • Greg Morrisett
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2071)

Abstract

Linear type systems permit programmers to deallocate or explicitly recycle memory, but are severely restricted by the fact that they admit no aliasing. This paper describes a pseudo-linear type system that allows a degree of aliasing and memory reuse as well as the ability to define complex recursive data structures. Our type system can encode conventional linear data structures such as linear lists and trees as well as more sophisticated data structures including cyclic and doubly-linked lists and trees. In the latter cases, our type system is expressive enough to represent pointer aliasing and yet safely permit destructive operations such as object deallocation.We demonstrate the flexibility of our type system by encoding two common space-conscious algorithms: destination-passing style and Deutsch-Schorr-Waite or “link-reversal” traversal algorithms.

Keywords

Type System Operational Semantic Memory Management Memory Block Memory Object 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Samson Abramsky. Computational interpretations of linear logic. Theoretical Computer Science, 111:3–57, 1993.zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Alexander Aiken, Manuel Fähndrich, and Raph Levien. Better static memory management: Improving region-based analysis of higher-order languages. In ACM Conference on Programming Language Design and Implementation, pages 174–185, La Jolla, California, 1995.Google Scholar
  3. 3.
    Erik Barendsen and Sjaak Smetsers. Conventional and uniqueness typing in graph rewrite systems (extended abstract). In Thirteenth Conference on the Foundations of Software Technology and Theoretical Computer Science, pages 41–51, Bombay, 1993. In Shyamasundar, ed., Springer-Verlag, LNCS 761.Google Scholar
  4. 4.
    Michael Benedikt, Thomas Reps, and Mooly Sagiv. A decidable logic for describing linked data structures. In European Symposium on Programming, pages 2–19, Amsterdam, March 1999.Google Scholar
  5. 5.
    Lars Birkedal, Mads Tofte, and Magnus Vejlstrup. From region inference to von Neumann machines via region representation inference. In Twenty-Third ACM Symposium on Principles of Programming Languages, pages 171–183, St. Petersburg, January 1996.Google Scholar
  6. 6.
    Rodney M. Burstall. Some techniques for proving correctness of programs which alter data structures. In Bernard Meltzer and Donald Michie, editors, Machine Intelligence, pages 23–50, Edinburgh, 1972. Edinburgh University Press.Google Scholar
  7. 7.
    Perry Cheng and Chris Okasaki. Destination-passing style and generational garbage collection. Unpublished., November 1996.Google Scholar
  8. 8.
    Jawahar Chirimar, Carl A. Gunter, and Jon G. Riecke. Reference counting as a computational interpretation of linear logic. Journal of Functional Programming, 6(2):195–244, March 1996. 202 D. Walker and G. MorrisettzbMATHMathSciNetCrossRefGoogle Scholar
  9. 9.
    Stephen Cook and Derek Oppen. An assertion language for data structures. In Second ACM Symposium on Principles of Programming Languages, pages 160–166, New York, 1975. ACM Press.Google Scholar
  10. 10.
    Karl Crary, David Walker, and Greg Morrisett. Typed memory management in a calculus of capabilities. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 262–275, San Antonio, January 1999.Google Scholar
  11. 11.
    Alain Deutsch. Interprocedural may-alias analysis for pointers: Beyond k-limiting. In ACM Conference on Programming Language Design and Implementation, pages 230–241, Orlando, June 1994.Google Scholar
  12. 12.
    Rakesh Ghiya and Laurie J. Hendren. Is it a tree, a DAG, or a cyclic graph? A shape analysis for heap-directed pointers in C. In Twenty-Third ACM Symposium on Principles of Programming Languages, pages 1–15, St. Petersburg Beach, Florida, January 1996.Google Scholar
  13. 13.
    Jean-Yves Girard. Linear logic. Theoretical Computer Science, 50:1–102, 1987.zbMATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Dan Grossman and Greg Morrisett. Scalable certi cation for typed assembly language. In ACM SIGPLAN Workshop on Types in Compilation, Montreal, September 2000.Google Scholar
  15. 15.
    Juan C. Guzmán and Paul Hudak. Single-threaded polymorphic lambda calculus. In Symposium on Logic in Computer Science, pages 333–343, Philadelphia, June 1990. IEEE Computer Society Press.Google Scholar
  16. 16.
    Robert Harper. A simplified account of polymorphic references. Information Processing Letters, 51(4):201–206, August 1994.zbMATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Samin Ishtiaq and Peter O’Hearn. BI as an assertion language for mutable data structures. In Twenty-Eighth ACM Symposium on Principles of Programming Languages, pages 14–26, January 2001.Google Scholar
  18. 18.
    Neil D. Jones and Steven Muchnick, editors. Flow analysis and optimization of Lisp-like structures. Prentice-Hall, 1981.Google Scholar
  19. 19.
    Naoki Kobayashi. Quasi-linear types. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 29–42, San Antonio, January 1999.Google Scholar
  20. 20.
    Yves Lafont. The linear abstract machine. Theoretical Computer Science, 59:157–180, 1988.CrossRefzbMATHMathSciNetGoogle Scholar
  21. 21.
    James R. Larus and Paul N. Hil nger. Detecting conflicts between structure accesses. In ACM Conference on Programming Language Design and Implementation, pages 24–31, June 1988.Google Scholar
  22. 22.
    James Richard Larus. Restructuring Symbolic Programs for Concurrent Execution on Multiprocessors. PhD thesis, University of California at Berkeley, May 1989. Available as Berkeley technical report UCB/CSD 89/502.Google Scholar
  23. 23.
    Erik Meijer, Maarten Fokkinga, and Ross Paterson. Functional programming with bananas, lenses, envelopes, and barbed wire. In ACM Conference on Functional Programming and Computer Architecture, volume 523 of Lecture Notes in Computer Science, Berlin, 1991. Springer-Verlag.Google Scholar
  24. 24.
    Y. Minamide. A functional representation of data structures with a hole. In Twenty-Fifth ACM Symposium on Principles of Programming Languages, pages 75–84, San Diego, January 1998.Google Scholar
  25. 25.
    Y. Minamide, G. Morrisett, and R. Harper. Typed closure conversion. In Twenty-Third ACM Symposium on Principles of Programming Languages, pages 271–283, St. Petersburg, January 1996.Google Scholar
  26. 26.
    Bernhard Möller. Towards pointer algebra. Science of Computer Programming, 21:57–90, 1993. Alias Types for Recursive Data Structures 203zbMATHCrossRefMathSciNetGoogle Scholar
  27. 27.
    Greg Morrisett, Karl Crary, Neal Glew, and David Walker. Stack-based Typed Assembly Language. In Xavier Leroy and Atsushi Ohori, editors, Second International Workshop on Types in Compilation, volume 1473 of Lecture Notes in Computer Science, pages 28–52, Kyoto, March 1998. Springer-Verlag.CrossRefGoogle Scholar
  28. 28.
    Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to Typed Assembly Language. In Twenty-Fifth ACM Symposium on Principles of Programming Languages, pages 85–97, San Diego, January 1998.Google Scholar
  29. 29.
    Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to Typed Assembly Language. ACM Transactions on Programming Languages and Systems, 3(21):528–569, May 1999.Google Scholar
  30. 30.
    George Necula and Peter Lee. The design and implementation of a certifying compiler. In ACM Conference on Programming Language Design and Implementation, pages 333–344, Montreal, June 1998.Google Scholar
  31. 31.
    John C. Reynolds. Syntactic control of interference. In Fifth ACM Symposium on Principles of Programming Languages, pages 39–46, Tucson, 1978.Google Scholar
  32. 32.
    John C. Reynolds. Intuitionistic reasoning about shared mutable data structure. In Millennial Perspectives in Computer Science, Palgrove, 2000.Google Scholar
  33. 33.
    Mooly Sagiv, Thomas Reps, and Reinhard Wilhelm. Solving shape-analysis problems in languages with destructive updating. ACM Transactions on Programming Languages and Systems, 20(1):1–50, January 1998.CrossRefGoogle Scholar
  34. 34.
    Mooly Sagiv, Thomas Reps, and Reinhard Wilhelm. Parametric shape analysis via 3-valued logic. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 105–118, San Antonio, January 1999.Google Scholar
  35. 35.
    H. Schorr and W. M. Waite. An efficient machine-independent procedure for garbage collection in various list structures. Communications of the ACM, 10(8):501–506, August 1967.zbMATHCrossRefGoogle Scholar
  36. 36.
    Frederick Smith, David Walker, and Greg Morrisett. Alias types. In European Symposium on Programming, volume 1782 of Lecture Notes in Computer Science, pages 366–381, Berlin, March 2000. Springer-Verlag.Google Scholar
  37. 37.
    Johnathan Sobel and Daniel Friedman. Recycling continuations. In ACM International Conference on Functional Programming, pages 251–260, Baltimore, September 1998.Google Scholar
  38. 38.
    TALx86. See http://www.cs.cornell.edu/talc for an implementation of Typed Assembly Language based on Intel’s IA32 architecture.
  39. 39.
    Mads Tofte and Jean-Pierre Talpin. Implementation of the typed call-by-value λ-calculus using a stack of regions. In Twenty-First ACM Symposium on Principles of Programming Languages, pages 188–201, Portland, Oregon, January 1994.Google Scholar
  40. 40.
    David N. Turner, Philip Wadler, and Christian Mossin. Once upon a type. In ACM International Conference on Functional Programming and Computer Architecture, San Diego, CA, June 1995.Google Scholar
  41. 41.
    Philip Wadler. Listlessness is Better than Laziness. PhD thesis, Carnegie Mellon University, August 1985. Available as Carnegie Mellon University technical report CMU-CS-85-171.Google Scholar
  42. 42.
    Philip Wadler. Linear types can change the world! In M. Broy and C. Jones, editors, Programming Concepts and Methods, Sea of Galilee, Israel, April 1990. North Holland. IFIP TC 2 Working Conference.Google Scholar
  43. 43.
    David Walker. Typed Memory Management. PhD thesis, Cornell University, January 2001. To appear.Google Scholar
  44. 44.
    Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38–94, 1994. 204 D. Walker and G. MorrisettzbMATHCrossRefMathSciNetGoogle Scholar
  45. 45.
    Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1999.Google Scholar
  46. 46.
    Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 214–227, San Antonio, TX, January 1999.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2001

Authors and Affiliations

  • David Walker
    • 1
  • Greg Morrisett
  1. 1.Carnegie Mellon UniversityUSA

Personalised recommendations