3 ms·
Yes, my LISP(-like) did have a primitive GC. The heap consisted of fixed 4-byte cons cells (2 byte car, 2 byte cdr). The cdr value was assumed to always be a p
by fred256 10y ago
Yes, my LISP(-like) did have a primitive GC.
The heap consisted of fixed 4-byte cons cells (2 byte car, 2 byte cdr). The cdr value was assumed to always be a pointer, which meant that since the cells were aligned at a 4-byte boundary, I had a few spare bits to implement mark-and-sweep GC and track which data type the car value was (number, atom, list or function).
Edit: I got curious and dug up the code. The entire GC code is less than 100 lines of Z80 assembler (admittedly some of the hairiest code in the interpreter, though)
- qwertyuiop924 10y agoHuh. Not so bad after all. Ah well. The other problem becomes space efficiency, but that's not unsolvable.