maclisp’s gc

So, today in Compilers Olin told us a nifty story. He emphasized that the register set is, from the perspective of resource management, the most precious resource for the compiler-writer. If your function has to go off to main memory to grab the value of a variable, you might as well get a cup of coffee: it’s that much slower in comparison to a register access.

In order to stress the speed contrast a bit more, Olin told us the story of MacLisp’s garbage collector on the PDP-10. The PDP-10 had 16 registers accumulators (but I’m going to keep calling them registers). Furthermore, the PDP-10 had one crucial feature: the register set was mapped into the address space. So (e.g.) 0x0-0xF were actually “addresses” for registers 0-15. (I’m not sure these were the actual register addresses, but they’ll suffice, for explanatory purposes.)

Now, sweep ran in a tight loop, and was very small — 10 or 12 instructions, according to Olin — and most of the GC’s time was spent there. So, the compiler-writers came up with an ingenious hack: load the instructions for sweep into the register set addresses, and jump to them. They ran part of the GC in the registers. It ran very quickly.

I had never heard of running anything in the registers. Very cool.

About these ads

2 thoughts on “maclisp’s gc

  1. (Old post, but I only just found it.) They were called accumulators, not registers. It’s been nearly 35 years, but I used to write simple (very simple) programs in the PDP-10′s accumulators (which were mapped to addresses 0-15) using DDT. The simplest and possibly the fastest infinite loop required one instruction: ‘XCT 0′ in AC 0. That is, execute the instruction at address 0.

  2. Wow that was odd. I just wrote an very long comment but after I clicked submit my
    comment didn’t appear. Grrrr… well I’m not writing all that over again.
    Anyway, just wanted to say fantastic blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s