Re: DConf 2013 Day 2 Talk 5: A Precise Garbage Collector for D by Rainer Schütze

Rainer Schuetze r.sagitario at gmx.de
Wed Jun 5 23:28:12 PDT 2013



On 05.06.2013 16:14, bearophile wrote:
> Andrei Alexandrescu:
>
>> http://www.reddit.com/r/programming/comments/1fpw2r/dconf_2013_day_2_talk_5_a_precise_garbage/
>>
>
> Is this useful to make the GC precise regarding the stack too?
>
> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19.5570

I was imagining something similar too. The part about multi-threading in 
the paper isn't too convincing, though. Especially the need for GC safe 
points in tight loops to block a thread during collection will not get 
many friends in the D community.

As parameters to function are covered by the callee, the approach won't 
work if you pass a temporary reference to a C function, which does a 
callback into code that has a safe point. The temporary on the stack 
will not be seen during a collection. Example:

/// D
void main() { c_func(toStringz(to!string(3))); }
bool gc_running() { gc_check(); return true; }

/// C
void c_func(const char* s) { if(gc_running()) printf("s=%s\n", s); }

My idea is to generate a description of the stack with information where 
pointers might be found within the functions stack space. If this 
includes parameters to called functions you might not even have problems 
with pausing a thread inside a C callback. This is slightly less precise 
because some stack fields might be used by both pointers and 
non-pointers. The runtime overhead would be similar to the 
implementation in the paper: insert/remove descriptors from a single 
linked list.



More information about the Digitalmars-d-announce mailing list