TC-H Code to Write
Note
This step is not meant to be completed like other steps. There is more missing code and you should feel free to add or remove anything you deem necessary. You are strongly advised to document yourself on what a GC should and should not do, and learn about common algorithms before implementing anything. You should only consider the following files as a skeleton for a suggested implementation.
- src/llvmgc/runtime/tiger-gc.*
Implement the core of your garbage collector, and override the
mainentry point to incorporate the collector’s and allocator’s initialization logics.- src/llvmgc/runtime/gc-alloc.*
Implement the allocation functions that allocate memory for your program, and calls the collector when necessary.
Note
The following files are optionals, and a working gc can be implemented without completing them. They are not used by default in the provided code.
- src/llvmgc/gc-rewrite-pass.*
This optional LLVM Pass can be used to rewrite parts of the compiled module.
- src/llvmgc/translator.cc.*
Implement the override of llvmtranslator::Translator to adapt the IR translation to the garbage collector. This translator is optional, and can be used to generate gc-friendlier code.