compiler support added for precise GC

Walter Bright newshound2 at digitalmars.com
Mon Apr 16 13:49:36 PDT 2012


On 4/16/2012 11:02 AM, Sean Kelly wrote:
> On Apr 16, 2012, at 2:25 AM, Walter Bright wrote:
>> It's never going to be easy for anyone to just write their own GC,
>> especially one that works better than one a lot of people have spent a lot
>> of time on.
>
> What I've been going for is to have all functionality that requires knowledge
> of code generation, (most) platform specifics, etc, live in the compiler
> runtime portion of Druntime (i.e. in the "rt" package).  This is all stuff
> that the compiler writer knows by necessity, and the GC writer shouldn't be
> required to know it as well.
>
> As for pointer maps, I think it's reasonable to establish a format that these
> will be made available to the GC, and for them to come from elsewhere in the
> runtime.  I realize that different GC implementations may prefer different
> formats, but hopefully we can settle on one that's pretty generally usable
> and efficient.  I'd really rather avoid expecting GC writers to know how to
> meta-process D types to statically generate this themselves.  Moving this
> into the GC would also eliminate the possibility of having the GC chosen at
> link-time, which is something that's currently still an option.

Either the compiler has to generate the marking stuff, meaning that no user 
designed GC is very practical, or it has to be generated at compile time with a 
template, where a user designed GC can experiment with a much wider range of 
possibilities without needing compiler modifications.

Also, budding GC implementers will have an existing meta-processing code example 
which will go a long way towards helping get up to speed.

Building a GC is a fairly advanced programming project. I don't think it's 
unreasonable to expect them to be pretty familiar with how D works.

Switching GCs at link time will only be possible if the GCInfo data is identical 
between them.


More information about the Digitalmars-d mailing list