Abstract
Lists are ubiquitous in functional programs, thus supporting lists efficiently is a major concern to compiler writers for functional languages. Lists are normally represented as linked cons cells, with each cons cell containing a car (the data) and a cdr (the link); this is inefficient in the use of space, because 50% of the storage is used for links. Loops and recursions on lists are slow on modern machines because of the long chains of control dependencies (in checking for nil) and data dependencies (in fetching cdr fields).
We present a data structure for “unrolled lists”, where each cell has several data items (car fields) and one link (cdr). This reduces the memory used for links, and it significantly shortens the length of control-dependence and data-dependence chains in operations on lists.
We further present an efficient compile-time analysis that transforms programs written for “ordinary” lists into programs on unrolled lists. The use of our new representation requires no change to existing programs.
We sketch the proof of soundness of our analysis—which is based on refinement types—and present some preliminary measurements of our technique.
- 1 William E. Aitken and John H. Reppy. Abstract value constructors. In A CM SIGPLAN Workshop on ML and its Applications, June 1992.Google Scholar
- 2 Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992. Google ScholarDigital Library
- 3 Andrew W. Appel and David B. MacQueen. Standard ML of New Jersey. In Martin Wirsing, editor, Third Int'l Syrup. on Prog. Lang. Implementation and Logic Programming, pages 1-13, New York, August 1991. Springer-Ver}ag.Google Scholar
- 4 Henry G. Baker. List processing in real time on a serial computer. Communications of the A CM, 21(4):280-294, April 1978. Google ScholarDigital Library
- 5 Daniel G. Bobrow. A note on hash linking. Communications of the A CM, 18(7):413-415, July 1975. Google ScholarDigital Library
- 6 Daniel G. Bobrow and Douglas W. Clark. Compact encodings of list structure. A CM Transactions on Programming Languages and Systems, 1(2):267-286, October 1979. Google ScholarDigital Library
- 7 Luca CardeUi. Compiling a functional language. In Proc. of the 198~i A CM Conference on Lisp and Functional Programming, pages 208-217, August 1984. Google ScholarDigital Library
- 8 Douglas W. Clark. List structure: measurements, algorithms, and encodings. PhD thesis, Carnegie Mellon Univ., Pittsburgh, PA, August 1976. Google ScholarDigital Library
- 9 Douglas W. Clark and C. Cordell Green. An empirical study of list structure in llsp. Communications of the ACM, 20(2):78-87, February 1977. Google ScholarDigital Library
- 10 L. P. Deutsch. A lisp machine with very compact programs. In Proc. 3rd IJA CI, pages 697-703, 1973.Google Scholar
- 11 Tim Freeman. Carnegie Mellon University, personal communication, 1992.Google Scholar
- 12 Tim Freeman and Frank Pfenning. Refinement types for ML. In Proc. A CM SIGPLAN '91 Conf. on Prog. Lang. Design and Implementation, pages 268-277, New York, July 1991. ACM Press. Google ScholarDigital Library
- 13 R. Greenblatt. Lisp machine progress report memo 444. TechnicMreport, A.i. Lab., M.I.T., Cambridge, MA, August 1977.Google Scholar
- 14 Cordelia V. Hail. Using hindley-milner type inference to optimize list representation. In 199~ A CM Conference on Lisp and Fucntional Programming, page (to appear), New York, June 1994. ACM Press. Google ScholarDigital Library
- 15 Wilfred J. Hansen. Compact list representation: Definition, garbage collection, and system implementation. Communications of the A CM, 12(9):499-507, Sep 1969. Google ScholarDigital Library
- 16 Paul Hudak, Simon L. Peyton Jones, and Philip Wadler et aI. Report on the programming language Haskell a non-strict, purely functional language version 1.2. SIGPLAN Notices, 21(5), May 1992. Google ScholarDigital Library
- 17 Xavier Leroy. Unboxed objects and polymorphic typing. In Nineteenth Annual A CM Syrup. on Principles of Prog. Languages, New York, Jan 1992. ACM Press. Google ScholarDigital Library
- 18 Kai Li and Paul Hudak. A new list compaction method. Software - Practice and Experience, 16(2):145-163, February 1986. Google ScholarDigital Library
- 19 Robin Milner, Mads Torte, and Robert Harper. The Definition of Standard NIL. MIT Press, Cambridge, Massachusetts, 1990. Google ScholarDigital Library
- 20 Laurence C. Paulson. ML for the Working Programmer. Cambridge University Press, Cambridge, 1992. Google ScholarDigital Library
- 21 Simon L. Peyton Jones and John Launchbury. Unboxed values as first class citizens in a non-strict functional language. In The Fifth International Conference on Functional Programming Languages and Computer Architecture, pages 636-666, New York, August 1991. ACM Press. Google ScholarDigital Library
- 22 Chris Reade. Elements of Functional Programming. Addison-Wesley, Reading, MA, 1989. Google ScholarDigital Library
- 23 Guy L. Steele. Rabbit: a compiler for Scheme. Technical Report AI-TR-474, MIT, Cambridge, MA, 1978. Google ScholarDigital Library
- 24 Philip Wadler. Views: A way for pattern matching to cohabit with data abstractirm. In Fourteenth Annual A CM Syrup. on Principles of Prog. Languages, pages 307-313, New York, Jan 1987. ACM Press. Google Scholar
- 25 D. Weinreb and D. Moon. Lisp machine manual. Technical report, Symolics Corp., Cambridge, Mass., 1981.Google Scholar
Index Terms
- Unrolling lists
Recommendations
Unrolling lists
LFP '94: Proceedings of the 1994 ACM conference on LISP and functional programmingLists are ubiquitous in functional programs, thus supporting lists efficiently is a major concern to compiler writers for functional languages. Lists are normally represented as linked cons cells, with each cons cell containing a car (the data) and a ...
Optimized Unrolling of Nested Loops
Loop unrolling is a well known loop transformation that has been used in optimizing compilers for over three decades. In this paper, we address the problems of automatically selecting unroll factors for perfectly nested loops, and generating compact ...
Optimized unrolling of nested loops
ICS '00: Proceedings of the 14th international conference on SupercomputingIn this paper, we address the problems of automatically selecting unroll factors for perfectly nested loops, and generating compact code for the selected unroll factors. Compared to past work, the contributions of our work include a) a more detailed ...
Comments