Chap 2
Chap 2
Background
5
6 Chapter 2. Background
* A thunk is a function that, when called, evaluates an argument. This defers the
evaluation of the parameter until the thunk is invoked. Lazy (nonstrict) evaluation,
call-by-need, call-by-name, and lexical scoping (late binding) are related terms, which
all involve deferring the evaluation of a value until it is actually needed during the
course of program execution. A thunk is a commonly used mechanism for
implementing these parameter evaluation strategies.
2.1. PROBLEM DEFINITION 7
* See Appendix A for a tutorial on SK-combinators and the Turner Set of SK-combinators.
8 Chapter 2. Background
2.2.1. Miranda
The Miranda (Turner 1985) system is a straightforward commercial
implementation of a lazy functional programming language that uses
combinator graph reduction. Miranda has a reputation in the research
community of being somewhat slow and unsophisticated, but we sur-
mise that there is no more than a factor of two speed increase possible
without a major redesign effort*. Miranda apparently does not make
use of supercombinator compilation or strictness analysis techniques.
For these reasons, Miranda makes a good baseline for comparisons
among graph reducers, since it forms a widely available lower bound on
expected performance.
* The author understands that such a redesign effort is, in fact, in progress as this is
being written
10 Chapter 2. Background
2.2.4. TIM
The Three Instruction Machine (TIM) (Fairbairn & Wray 1987, Wray &
Fairbairn 1988) is an evolution beyond the G-Machine graph reducer
into the realm of closure reducers. An important realization is that
graph reducers must produce suspensions to accomplish lazy evalua-
tion. Pointers to these suspensions are stored in the ancestor nodes to
a combinator in the tree. As the left spine (the leftmost path down the
program graph, which is the path taken by normal order reduction) is
traversed, the stack contains pointers to the ancestor nodes, forming a
list of pointers to the suspension elements. TIM goes a step further, and
copies the top stack elements to a memory location so that they form a
closure. This closure is simply a tuple of elements forming a vector of
data in the memory heap.
The driving force behind TIM is to make closures inexpensive to
create and manipulate. But, since the cost of traversing the spine is not
free, and since the cost of manipulating graphs is not free, TIM also uses
supercombinators to reduce the number of closures that must be created
and manipulated. Costs are greatly reduced by executing code that
pushes pointers directly onto a stack instead of traversing a graph that
incurs overhead for each node to accomplish this same building of a
pointer list on the stack. An important cost of TIM is that memory
bandwidth is expended to copy the top stack elements into a closure
created from heap memory. This is roughly equivalent in cost to a
context switch (where a set of registers are copied out to memory when
switching tasks) for each invocation of a combinator. Furthermore, the
12 Chapter 2. Background
2.2.5. NORMA
The Normal Order Reduction MAchine (NORMA) (Scheevel 1986) at one
time was widely acknowledged to be the highest performance com-
binator graph reducer hardware built. It is special-purpose graph
reduction hardware optimized for the fastest possible operation. Among
NORMA’s features are a 370-bit wide microinstruction, five cooperating
processors, a 64-bit wide memory bus, and extensive use of semicustom
chips to optimize performance. NORMA uses a highly structured node
representation that includes five tag fields in addition to two data fields.
NORMA also uses some of its processors to perform garbage collection
operations and heap allocation in parallel with node processing and
arithmetic operations. NORMA uses the Turner Set of combinators to
accomplish graph reduction.
FUNCTIONAL
SOURCE CODE
LAMBDA CALCULUS
CLOSURE REDUCTION
COMBINATORS
GRAPH REDUCTION
SK-COMBINATORS HYPERLAZY
MIRANDA
TURNER SET
COMBINATORS
NORMA
SUPER-
COMBINATORS
SUPER-
COMBINATORS G-MACHINE
TIM
TIGRE