[LLVMdev] Re: Garbage collection questions

Chris Lattner sabre at nondot.org
Tue Mar 14 16:51:11 PST 2006


On Tue, 14 Mar 2006, Sandro Magi wrote:
>> consider all pointers to be in scope, without causing any "dead" pointers
>> to mark objects.
>
> Does this mean some pointers from the roots might be null?

Well sure, if they are null.  e.g.:

int *X = NULL;

X would be null.  Is that what you mean?

> I figured
> only in-scope variables/roots would be in the llvm_gc_root_chain.

That is correct, "global" roots have to be managed separately.

> Does this list ever shorten?

It changes dynamically based on what functions are currently live.

>> I would suggest doing experiments to determine which has the higher
>> overhead.  Refcounting as a whole is expensive, so you need to find a
>> design that fits your constraints/application.
>
> I don't actually have an application at the moment; I'm just learning
> about garbage collection. Reference counting seemed the most
> straightforward at the time, and LLVM provided an environment free of
> any superfluous distractions in which to learn and experiment with the
> raw algorithms.

Ok, cool!

> I've attached the lazy ref-counting collector if anyone's interested.
> There are a few suggested enhancements in the source for those who
> might want to extend it, such as bounds for real-time constraints, or
> adding generations to reduce the overhead of filtering out the live
> roots. :-)

Unfortunately, I don't have time to look at it, but I hope others will!

Thanks!

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-dev mailing list