Changes in the D2 design to help the GC?
Stewart Gordon
smjg_1998 at yahoo.com
Thu Jul 16 12:53:02 PDT 2009
bearophile wrote:
<snip>
> Time ago I have suggested to split the D pointers in two types, the
> GC-managed ones and the ones that work on the C heap, that the GC
> never touches. The type system can assure they never get mixed by
> mistake.
I can imagine this making interfacing external APIs a pain in the rear
end....
> Now I think (just an idea) the type of GC-managed pointers
> can be split in two types: the ones that are fully managed by a
> moving GC (see below) and the ones managed by a conservative GC, such
> memory is pinned, and the GC doesn't move it around. The type system
> will assure such three groups doesn't mix unless the programmer is
> really determined to mix them :-)
<snip>
I'm not sure that having two separate, independent GCs will work. But
having two GC heaps along these lines might.
One way I can see is having an "immovable" type modifier in line with
const and invariant. Anything that isn't allocated as immovable, the GC
may move around if it's clever enough. But an immovable reference could
just as well be implicitly convertible to a non-immovable reference -
the GC'll know which heap it points into.
Immovable might be useful for interfacing external APIs. We could also
spec that only immovable pointer/reference types may be used in a union.
BTW even D1 needs some work in the area of moving GC:
http://d.puremagic.com/issues/show_bug.cgi?id=679
Stewart.
More information about the Digitalmars-d
mailing list