Computer Software
Print ISSN : 0289-6540
Design and Implementation of Thunk Recycling in the Glasgow Haskell Compiler
Yasunao TAKANOHideya IWASAKIShigeyuki SATO
Author information

2015 Volume 32 Issue 1 Pages 1_253-1_287


The lazy functional programming language Haskell has attracted much attention in recent years. The Glasgow Haskell Compiler (GHC) is a state-of-the-art and de facto standard compiler and runtime system for Haskell. Much of the literature on Haskell has been devoted to GHC and many new mechanism have been introduced into GHC. However, since the implementation of the current GHC is huge and complicated, it is hard to introduce a new mechanism into GHC. In such a situation, our prior work on thunks, which are internal objects to enable lazy evaluation, also incorporated our thunk recycling into GHC and succeeded in reducing memory allocations. The method transforms a program into the program that enables thunk recycling by reusing and updating an already-allocated thunk. Although the essence of thunk recycling has already been published in our paper, it does not cover our overall implementation in GHC, a large and complicated software. In this paper, we present the entire sophisticated implementation of thunk recycling in GHC, explaining various design decisions and implementation techniques and report experimental results of our techniques. Furthermore, we have improved our implementation by using additional techniques based on our knowledge of GHC. As a result, we have reduced the overhead of our method successfully. The knowledge of the implementation obtained from our experience which used GHC for the base of a programming language research is also described. In particular, the fact that GHC is written by Haskell contributes to the extendibility of its implementation.

Content from these authors
© 2015 Japan Society for Software Science and Technology
Previous article