More radical ideas about gc and reference counting
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 11 01:59:43 PDT 2014
On 5/11/2014 1:22 AM, Benjamin Thaut wrote:
> 2) Most modern GC algorithms require write-barriers for pointers which are on
> the heap. This is a major problem for D, because structs can be both on the
> stack and on the heap. So if you call a method of a struct, the compiler can not
> know if the write barriers are actually neccessary (for heap based structs) or
> unneccssary (for stack based structs, e.g. inside classes).
I know about write barriers. The thing about D is, far fewer objects are
allocated on the GC heap than in languages like Java, which don't have stack
allocation at all.
The write barrier would have to be there for every write through a pointer. This
is justifiable where every pointer points to the GC heap, but I really do not
believe it is justifiable for D, where only a minority does. D could not be
performance competitive with C++ if write barriers were added.
D also cannot be performance competitive with C++ if pervasive ARC is used and
memory safety is retained. Rust is attempting to solve this problem by using
'borrowed' pointers, but this is unproven technology, see my reply to Manu about it.
More information about the Digitalmars-d
mailing list