Nhc: a Space-eecient Haskell Compiler
نویسنده
چکیده
Self-compiling implementations of Haskell, i.e., those written in Haskell, have been and, except one, are still space consuming monsters. Object code size for the compilers themselves are 3-8 Mbyte, and they need 12-20 Mbyte to recompile themselves. One reason for the huge demands for memory is that the main goal for these compilers is to produce fast code. However, the compiler described in this paper, called nhc for Nearly a Haskell Compiler, is the above mentioned exception. This compiler concentrates on keeping memory usage down, even at a cost in time. The code produced is not fast but nhc is usable, and the resulting programs can be run, on computers with small memory. The low demand for memory in nhc has two causes: carefully chosen algorithms in the compiler, and a memory eecient abstract machine. The former only aaects memory demands in nhc, but the latter is a win for all programs compiled by nhc. The memory eecient algorithms used in nhc can be used in other Haskell compilers with no, or very small, changes to their run-time systems. They have only a marginal eeect on compile time. The reason for the slow speed is mostly due to the implementation of the abstract machine, a byte coded G-machine. Programs compiled by nhc can produce many diierent heap prooles to facilitate development of more space eecient programs. One example is nhc itself, where these prooles were used to choose between diierent algorithms. The current version of nhc includes heap prooling of live objects. These prooles can show the producers, constructors, retainers or lifetimes of the live objects in the heap. A simple time proole is also available. Time is however neither the main focus of nhc nor of this paper, but there is nevertheless a small section about the speed of nhc. The most notable observation concerning speed is that nhc spends approximately half the time processing interface les, which is much more than is needed 1 Garbage collection, and memory eeciency, in lazy functional languages in, e.g., the type checker. Processing interface les is also the most space consuming part of nhc in most cases. It is only when compiling source les with large sets of mutually recursive functions that more memory is needed to type check than to process interface les.
منابع مشابه
Lag, Drag, Void and Use { Heap Prooling and Space-eecient Compilation Revisited
The context for this paper is functional computation by graph reduction. Our overall aim is more eecient use of memory. The speciic topic is the detection of dormant cells in the live graph | those retained in heap memory though not actually playing a useful role in computation. We describe a prooler that can identify heap consumption by suchùseless' cells. Unlike heap proolers based on travers...
متن کاملNew dimensions in heap pro lingCOLIN
First-generation heap proolers for lazy functional languages have proved to be eeective tools for locating some kinds of space faults, but in other cases they cannot provide suu-cient information to solve the problem. This paper describes the design, implementation and use of a new prooler that goes beyond the two-dimensionaìwho produces what' view of heap cells to provide information about the...
متن کاملnhc - Nearly a Haskell Compiler
This paper describes nhc a compiler for a subset of Haskell. Nhc is the result of the author’s wish to have a Haskell compiler for his Acorn A5000 to play with. Previous the only Haskell system available for A5000 was Mark Jones’ gofer. The disadvantage of gofer is that it is written in C so the play part isn’t as fun as it could be. Nhc is written in Haskell with a small run-time system in C. ...
متن کاملNew dimensions in heap pro ling
First-generation heap proolers for lazy functional languages have proved to be eeective tools for locating some kinds of space faults, but in other cases they cannot provide suucient information to solve the problem. This paper describes the design, implementation and use of a new prooler that goes beyond the two-dimensionaìwho produces what' view of heap cells to provide information about thei...
متن کاملNew Dimensions in Heap Prooling
First-generation heap proolers for lazy functional languages have proved to be eeective tools for locating some kinds of space faults, but in other cases they cannot provide suucient information to solve the problem. This paper describes the design, implementation and use of a new prooler that goes beyond the two-dimensionaìwho produces what' view of heap cells to provide information about thei...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1995