D-Programming-Language/druntime — pull request #1057 by rainers (2014-12-05 13:50:34+00:00)
Title: Alternate precise GC implementation

This version of the precise GC saves type info in allocated memory.

The memory footprint of this version is different from the original GC (https://github.com/D-Programming-Language/druntime/pull/1022) which allocated a pointer bitmap alongside every memory pool (one bit per size_t):
- one bit per possible allocation block (i.e. per 16 bytes for standard pools, per 4kB for large object pools)
- if the allocation block is not NO_SCAN or must be scanned conservatively, one pointer at the end of the allocation block, i.e. only adds additional memory if the allocation size is just below a power of 2, but then the size doubles.

Some more notes:
- The runtime overhead for allocation is less because no pointer bitmap has to be filled.
- The mark phase has to go through an indirection to get the pointer bitmap of a type, but it now has the abitlity to only scan the memory actually requested and skip padded memory
- The RTInfo can contain a delegate to call instead of standard marking. This is used for arrays to only scan the currently used area of the allocation block. It also allows to easily change memory interpretation for large/small arrays which caused troubles in the other GC. For AAs this currently only skips the hash value, there is too little type information available to scan key and value precisely.
- compilation does not yet use the optimized trait (https://github.com/D-Programming-Language/dmd/pull/4192).

The druntime benchmark suite runs a few percent slower than the non-precise version, unless it hits false pointers. That doesn't seem to happen very often for the test suite, though.