D-Programming-Language/druntime — pull request #1022 by rainers (2014-11-14 19:47:43+00:00)
Title: [WIP] precise GC as presented at DConf 2013

This is the precise GC as presented at DConf 2013. It generates pointer bitmaps for each type T using RTInfo!T and stores a bitmap alongside pool memory to use for following only pointer references.

RTInfo generation isn't working properly at the moment (needs https://github.com/D-Programming-Language/dmd/pull/3958 or https://github.com/D-Programming-Language/dmd/pull/2480), but using the compiler default will just scan some types conservatively instead of precisely.

Some notes:
- only the heap is scanned precisely, not stacks or the data/TLS segments
- compilation is slower: I measured 3:46min for the "quick" test suite on Win32 instead of 3:26 for master (we might need a special trait to avoid a lot of CTFE)
- execution is slower: the allocation heavy druntime benchmarks take 58sec instead of 51sec (unfortunately there are 2 list-benchmark which don't give reliable timings).
- associative arrays need a dirty hack to support precise scanning of the key/value pairs in Entry: the TypeInfo for that is geneerated at runtime and stored in the Impl struct of each instance.
- dynamic arrays need to "re-emplace" their type info pointer bitmaps for large arrays, because data is "sometimes" placed at an offset of 16 bytes

I'm opening this as a pull request to verify building on other platforms aswell as making it more publically visible and open for review/discussion.

I plan to create another version that stores type info per allocation block and use this during scanning. This can avoid the troubles for the arrays, but will not allow reassigning new types to partial memory blocks (e.g. when using std.emplace on fields of a class).