4 ms·
You can always use less of the GC, but there are no way not to use pointers. For example, I sell products in D which disable the GC completely, I certainly don'
by p0nce 10y ago
You can always use less of the GC, but there are no way not to use pointers.
For example, I sell products in D which disable the GC completely, I certainly don't want write barriers.
- pcwalton 10y agoIf you can safely disable the GC, then you can safely disable write barriers.
- p0nce 10y agoAnd if I use only a bit of the GC, can I use only a bit of write barriers? Walter Bright was right about segmented stacks, I'm tempted to think he's right about write barriers too.
- pcwalton 10y agoIf the compiler can statically tell which pointers point to GC memory (something it usually needs to know anyway), yes.
- p0nce 10y agoIn D this is indeed known only at runtime, one of the decision was that "there should be only one type of pointers". immutable(T) doesn't guarantee it isn't in the GC heap from what I can gather. shared(T) could perhaps do it, but it's rather unpopular.
- pcwalton 10y agoIf you really don't know until runtime what heap a pointer is in, then write barriers will have some kind of cost, but it should be low (definitely not atomic). However, if you don't know statically what kind of heap a pointer is in, you're going to have a poorly performing GC system no matter what.