[LLVMdev] ocaml+llvm

Chris Lattner sabre at nondot.org
Mon Aug 13 21:19:32 PDT 2007


On Mon, 13 Aug 2007, Carl Friedrich Bolz wrote:
>> In the LLVM world, you should use the first-class support we already have
>> for accurate GC: http://llvm.org/docs/GarbageCollection.html
>
> I was wondering recently: are there actually any projects that are using
> these facilities? Preferably ones that I could take a look at?

No, unfortunately not.  The one that I was working on years ago (which 
gave me the excuse to build this infrastructure) was not allowed to be 
released.

>> Based on this, you annotate the variables with llvm.gcroot intrinsics, and
>> then walk the stack with the llvm_cg_walk_gcroots function.  Note that
>> these are not well tested and probably have holes in them, but these are
>> the interfaces we want to use :)
>
> How is this function actually implemented? Is there special
> stack-walking code emitted or does LLVM keep an extra stack of roots?

The current implementation is very inefficient.  The algorithm is 
described here:

    "Accurate Garbage Collection in an Uncooperative Environment"
    Fergus Henderson, ISMM, 2002

In practice, going forward, I would like to see the code generators 
develop native support for this, using metadata for each function to 
locate the pointers on the stack.

-Chris

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



More information about the llvm-dev mailing list