Feature Request (for 1.0 as well): add a way to override the GC-perceived top of the stack

Robert Fraser fraserofthenight at gmail.com
Fri Jan 11 09:36:24 PST 2008


downs wrote:
> The Phobos GC presumes a linear stack that stretches from <bottom> to the current ESP.
> 
> This model is normally correct; however, the virtual stacks used in StackThreads or similar
> models kinda break it.
> 
>> Illustration:
>>
>>   Normal stack:
>>
>> [bottom]=====================================[ESP]
>>
>>
>>   StackThreads stack:
>>
>> [bottom]=========|==========[End]   [Heap================================================= ... ]
>>                  |
>>                  +......................[Virtual stack bottom]====================[ESP]
>>
> 
> This is easy to fix; introduce a new Thread function (getStackTop) that checks if a Thread member
> variable (void *overrideStackTop) is set; if yes, return that variable, otherwise return getESP().
> 
> Since this is a rather smallish correction that doesn't require any API change, I'd greatly welcome it
> if this change was applied to 1.0, since because of the way the current GC works, writing reliable
> StackThreads is essentially impossible.
> 
> Thanks for your consideration,
> 
>  --downs

Wouldn't this add the overhead of a function call to every collect cycle?



More information about the Digitalmars-d mailing list