Master the fundamental concepts of garbage collection through this focused micro-challenge.
Minor GC scans nursery but must also scan old objects pointing into nursery. Tracking every old object is expensive. Write barriers log stores of old->young pointers into a remembered set or card table. HotSpot and Go use variants.
After old.field = young, barrier marks card containing old as dirty or logs the slot. Minor GC roots include remembered set entries.
cLoading…
Production compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement write barriers for generational GC. This exercise asks you to instrument reference stores and maintain a remembered set so minor collections find all nursery pointers.
Implement write barriers for generational GC.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github