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.)
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.)
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.