3.5 Binding-Stack Format

Each entry of the binding-stack consists of two boxed (32-bit) words. Pushed first is a pointer to the symbol being bound. Pushed second is the symbol’s old value (any boxed item) that is to be restored when the binding stack is popped.

4 Storage Management

New objects are allocated from the lowest unused addresses within the specified space. Each allocation call specifies how many words are wanted, and a Free-Storage pointer is incremented by that amount. There is one of these Free-Storage pointers for each space, and it points to the lowest free address in the space. There is also a Clean-Space pointer associated with each space that is used during garbage collection. These pointers are stored in a table which is indexed by the type and space code. The address of the Free-Storage pointer for a given space is

	(+ alloc-table-base (lsh type 5) (lsh space 3)).

The address of the Clean-Space pointer is

	(+ alloc-table-base (lsh type 5) (lsh space 3) 4).

Common Lisp on the IBM RT PC uses a stop-and-copy garbage collector to reclaim storage. The Collect-Garbage miscop performs a full GC. The algorithm used is a degenerate form of Baker’s incremental garbage collection scheme. When the Collect-Garbage miscop is executed, the following happens:

  1. The current newspace becomes oldspace, and the current oldspace becomes newspace.
  2. The newspace Free-Storage and Clean-Space pointers are initialized to point to the beginning of their spaces.
  3. The objects pointed at by contents of all the registers containing Lisp objects are transported if necessary.
  4. The control stack and binding stack are scavenged.
  5. Each static pointer space is scavenged.
  6. Each new dynamic space is scavenged. The scavenging of the dynamic spaces continues until an entire pass through all of them does not result in anything being transported. At this point, every live object is in newspace.

A Lisp-level GC function returns the oldspace pages to Mach.