Interview with InformIT part 2/3

Leandro Lucarella luca at llucax.com.ar
Thu Aug 19 08:23:00 PDT 2010


Walter Bright, el 18 de agosto a las 12:25 me escribiste:
> Leandro Lucarella wrote:
> >Walter Bright, el 18 de agosto a las 10:08 me escribiste:
> >>bearophile wrote:
> >>>Currently in the D2 GC there is no notion of pinned/unpinned class instances,
> >>>but eventually an attribute as @pinned may be added to D3, plus its related
> >>>semantics. It adds complexity to the language and it needs to interact with
> >>>the GC, so it will get useful as the D GC becomes more modern (with different
> >>>zones for newly allocated objects, etc).
> >>There is no need for a pin attribute, the gc can determine if a
> >>class needs pinning or not.
> >
> >As long as the precise heap scanning patch is applied (and much better
> >if we can manage to scan the static data precisely too). Otherwise you
> >simply just can't move stuff around because you don't know what is
> >a pointer and what is not (thus you can't update pointer that point to
> >moved stuff).
> 
> Hence the objects with ambiguous references to them get
> automatically pinned by the gc. I've implemented such a gc before,
> it works fine. It's called a "mostly copying collector".

Even when you say is true, the GC can automatically determine if
something should be pinned when *EVERYTHING* is pinned, it's not very
useful :)

> Besides, any scheme where you have to manually mark pinnable objects
> is doomed to have disastrously subtle and hard-to-find bugs.

I'm not arguing in favor of manual pinning, I completely agree is a bad
idea. I'm just saying that, as things are, in D you can't implement
a moving collector, because *ALL* the memory is pinned because if fully
conservative.

With the precise heap scanning patch for DMD the GC can automatically
pin memory, because it has enough information to differentiate between
real pointers and words which types are not really known, so a block can
be moved *only* if is only pointed to by real pointers, otherwise is
pinned because we can't update the words with unknown type if we moved
that block.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Hey you, out there in the cold
Getting lonely, getting old
Can you feel me?


More information about the Digitalmars-d-announce mailing list