Hybrid eager and lazy evaluation for efficient compilation of Haskell

Thesis (Ph. D.)--Massachusetts Institute of Technology, Dept. of Electrical Engineering and Computer Science, 2002. === Includes bibliographical references (p. 208-220). === This electronic version was submitted by the student author. The certified thesis is available in the Institute Archives and...

Full description

Bibliographic Details
Main Author: Maessen, Jan-Willem
Other Authors: Arvind.
Format: Others
Language:English
Published: Massachusetts Institute of Technology 2005
Subjects:
Online Access:http://hdl.handle.net/1721.1/16844
id ndltd-MIT-oai-dspace.mit.edu-1721.1-16844
record_format oai_dc
spelling ndltd-MIT-oai-dspace.mit.edu-1721.1-168442019-05-02T16:38:29Z Hybrid eager and lazy evaluation for efficient compilation of Haskell Maessen, Jan-Willem Arvind. Massachusetts Institute of Technology. Dept. of Electrical Engineering and Computer Science. Massachusetts Institute of Technology. Dept. of Electrical Engineering and Computer Science. Electrical Engineering and Computer Science. Thesis (Ph. D.)--Massachusetts Institute of Technology, Dept. of Electrical Engineering and Computer Science, 2002. Includes bibliographical references (p. 208-220). This electronic version was submitted by the student author. The certified thesis is available in the Institute Archives and Special Collections. The advantage of a non-strict, purely functional language such as Haskell lies in its clean equational semantics. However, lazy implementations of Haskell fall short: they cannot express tail recursion gracefully without annotation. We describe resource-bounded hybrid evaluation, a mixture of strict and lazy evaluation, and its realization in Eager Haskell. From the programmer's perspective, Eager Haskell is simply another implementation of Haskell with the same clean equational semantics. Iteration can be expressed using tail recursion, without the need to resort to program annotations. Under hybrid evaluation, computations are ordinarily executed in program order just as in a strict functional language. When particular stack, heap, or time bounds are exceeded, suspensions are generated for all outstanding computations. These suspensions are re-started in a demand-driven fashion from the root. The Eager Haskell compiler translates Ac, the compiler's intermediate representation, to efficient C code. We use an equational semantics for Ac to develop simple correctness proofs for program transformations, and connect actions in the run-time system to steps in the hybrid evaluation strategy. (cont.) The focus of compilation is efficiency in the common case of straight-line execution; the handling of non-strictness and suspension are left to the run-time system. Several additional contributions have resulted from the implementation of hybrid evaluation. Eager Haskell is the first eager compiler to use a call stack. Our generational garbage collector uses this stack as an additional predictor of object lifetime. Objects above a stack watermark are assumed to be likely to die; we avoid promoting them. Those below are likely to remain untouched and therefore are good candidates for promotion. To avoid eagerly evaluating error checks, they are compiled into special bottom thunks, which are treated specially by the run-time system. The compiler identifies error handling code using a mixture of strictness and type information. This information is also used to avoid inlining error handlers, and to enable aggressive program transformation in the presence of error handling. by Jan-Willem Maessen. Ph.D. 2005-05-19T15:00:04Z 2005-05-19T15:00:04Z 2002 2002 Thesis http://hdl.handle.net/1721.1/16844 51442780 eng M.I.T. theses are protected by copyright. They may be viewed from this source for any purpose, but reproduction or distribution in any format is prohibited without written permission. See provided URL for inquiries about permission. http://dspace.mit.edu/handle/1721.1/7582 222 p. 706155 bytes 705889 bytes application/pdf application/pdf application/pdf Massachusetts Institute of Technology
collection NDLTD
language English
format Others
sources NDLTD
topic Electrical Engineering and Computer Science.
spellingShingle Electrical Engineering and Computer Science.
Maessen, Jan-Willem
Hybrid eager and lazy evaluation for efficient compilation of Haskell
description Thesis (Ph. D.)--Massachusetts Institute of Technology, Dept. of Electrical Engineering and Computer Science, 2002. === Includes bibliographical references (p. 208-220). === This electronic version was submitted by the student author. The certified thesis is available in the Institute Archives and Special Collections. === The advantage of a non-strict, purely functional language such as Haskell lies in its clean equational semantics. However, lazy implementations of Haskell fall short: they cannot express tail recursion gracefully without annotation. We describe resource-bounded hybrid evaluation, a mixture of strict and lazy evaluation, and its realization in Eager Haskell. From the programmer's perspective, Eager Haskell is simply another implementation of Haskell with the same clean equational semantics. Iteration can be expressed using tail recursion, without the need to resort to program annotations. Under hybrid evaluation, computations are ordinarily executed in program order just as in a strict functional language. When particular stack, heap, or time bounds are exceeded, suspensions are generated for all outstanding computations. These suspensions are re-started in a demand-driven fashion from the root. The Eager Haskell compiler translates Ac, the compiler's intermediate representation, to efficient C code. We use an equational semantics for Ac to develop simple correctness proofs for program transformations, and connect actions in the run-time system to steps in the hybrid evaluation strategy. === (cont.) The focus of compilation is efficiency in the common case of straight-line execution; the handling of non-strictness and suspension are left to the run-time system. Several additional contributions have resulted from the implementation of hybrid evaluation. Eager Haskell is the first eager compiler to use a call stack. Our generational garbage collector uses this stack as an additional predictor of object lifetime. Objects above a stack watermark are assumed to be likely to die; we avoid promoting them. Those below are likely to remain untouched and therefore are good candidates for promotion. To avoid eagerly evaluating error checks, they are compiled into special bottom thunks, which are treated specially by the run-time system. The compiler identifies error handling code using a mixture of strictness and type information. This information is also used to avoid inlining error handlers, and to enable aggressive program transformation in the presence of error handling. === by Jan-Willem Maessen. === Ph.D.
author2 Arvind.
author_facet Arvind.
Maessen, Jan-Willem
author Maessen, Jan-Willem
author_sort Maessen, Jan-Willem
title Hybrid eager and lazy evaluation for efficient compilation of Haskell
title_short Hybrid eager and lazy evaluation for efficient compilation of Haskell
title_full Hybrid eager and lazy evaluation for efficient compilation of Haskell
title_fullStr Hybrid eager and lazy evaluation for efficient compilation of Haskell
title_full_unstemmed Hybrid eager and lazy evaluation for efficient compilation of Haskell
title_sort hybrid eager and lazy evaluation for efficient compilation of haskell
publisher Massachusetts Institute of Technology
publishDate 2005
url http://hdl.handle.net/1721.1/16844
work_keys_str_mv AT maessenjanwillem hybrideagerandlazyevaluationforefficientcompilationofhaskell
_version_ 1719044262468780032