Baby's Second Garbage Collector
2 days ago
- #lisp
- #programming
- #garbage-collection
- Baby's First Garbage Collector has evolved from a precise garbage collector to a conservative one.
- The garbage collector originally tracked all objects precisely but failed to handle objects escaping to the native stack.
- To find escaped objects, the garbage collector was modified to scan the native stack for heap pointers.
- A further challenge arose when objects hid in CPU registers, requiring register spilling via assembly code.
- The solution involved saving registers to the stack and marking them, ensuring all reachable objects are found.
- The test suite now passes, restoring peace in the lisp land with a functional conservative garbage collector.
- Future improvements will focus on the garbage collector cleaning up its own memory (e.g., room cleaning).