What's the go with the GC these days?

Neia Neutuladh neia at ikeran.org
Sun Jan 6 18:18:21 UTC 2019


On Sat, 05 Jan 2019 23:58:55 -0800, Manu wrote:
> Could D insert such code, and also effectively elide it where @nogc is
> used (or inferred)?

Write barriers are how the GC maintains the graph of which memory points 
to which other memory, so it is very difficult to avoid them.

You don't need to include them for writes to non-pointers. For injected 
runtime calls, this means any non-pointer. For mprotect(), it means the 
entire block of memory must be pointer-free.

You could use @nogc as a means to prove that you don't have to call the 
"pointer was written" code multiple times for the same address. The 
compiler has to prove that it's the same address, that no other thread 
could have written to that data, and that the GC couldn't have run in 
between. But D as is can't prove any of that.


More information about the Digitalmars-d mailing list