Cleverness of GC Scanning

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 9 05:03:43 PDT 2015


On Friday, 7 August 2015 at 18:29:05 UTC, Steven Schveighoffer 
wrote:
> On 8/7/15 1:38 PM, rsw0x wrote:
>
>> Probably a question for Martin Nowak as he seems to do a lot 
>> of the GC
>> work - but I'm curious why the GC takes basically zero 
>> advantage of D's
>> compile time magic(allocations are funneled through a C API,) 
>> is it
>> because build times would be too slow?
>
> Mainly legacy. The D runtime was all runtime before 'druntime' 
> was included, not much compile time introspection. All the 
> hooks to the GC were done via calls with the compiler passing 
> the TypeInfo to the appropriate pre-defined hook.
>
> I think we have much more tools available and greater 
> experience these days, it would be nice for all compiler hooks 
> that do any runtime calls (except for possibly intrinsics) to 
> simply be rewrites to call templates that do the right thing.
>
> The main barrier that I can tell is that the compiler takes 
> liberties in regards to const/pure/etc. that library code 
> cannot take.
>
> -Steve

After taking a bit of time to review, I'm actually disappointed 
in how allocations are handled. The compiler emits 10(!) 
different runtime calls depending on the allocation. This really 
seems like something that could be handled far better in the 
runtime itself, and reduce compiler complexity. But I really 
don't know enough to say that.

There's some serious non-negligible overhead per allocation here 
AFAICT.


More information about the Digitalmars-d mailing list