next up previous contents index
Next: References Up: The transformer Previous: The engine transformation

Explicit store

With many thousands of top level environments it is necessary to carefully manage the size of the top level environment. MIT Scheme's first class environments are too heavy-weight. There are several reasons for this, but the most important is that compiled programs are linked against an environment, which requires separate copies of the compiled code for each processor.

The transformed programs use an explicit store, similar to this:

(define (fib k fuel st n)
  (if (< n 2)
      (k (- fuel 1) st 1)
      ((global-ref st '#(fib #F #F))
       (lambda (fib-of-n-1 fuel st)
         ((global-ref st '#(fib #F #F))
          (lambda (fib-of-n-2 fuel st)
            (k (+ fib-of-n-1 fib-of-n-2) (- fuel 1) st))
          (- fuel 1)
          (- n 2)))
       (- fuel 2)
       (- n 1))))

The variable st is also linear.

By using an explicit store it is possible to factor the environment into a shared part and a per-processor part. Each global gunk variable is allocated to a slot in the store. The allocation is dynamic, but each gunk processor uses the same store slot for the same variable.

Erik Rauch
Sat May 8 16:42:57 EDT 1999