[LLVMdev] Garbage collection

Gordon Henriksen gordonhenriksen at me.com
Mon Mar 2 07:48:02 PST 2009


On Mar 2, 2009, at 05:20, Nicolas Geoffray wrote:

> So LLVM should not be aware of "stop the world" stuff. It's really a  
> matter of your collector. What LLVM should be aware is the position  
> of safe points in the code. That's the case with Gordon's GCStrategy  
> class. However, to implement "stop the world", runtimes should be  
> able to add runtime-specific code at these safe points. If you  
> could, then adding a cooperative, stop-the-world GC would be  
> straightforward. Just poll a variable during the safe-point. When a  
> collection is required, the collector updates that variable and  
> waits for all threads to poll it.
>
> After Gordon's *fantastic* work on GC interfaces in LLVM, I think  
> that's the one thing missing in the design.

Generous of you, Nicolas. :) There are actually several blocking  
features missing, and injecting code at safe points is one of them.

     http://llvm.org/docs/GarbageCollection.html#collector-algos

Major outstanding work that I think blocks entire classes of users  
from started:

   - Emit code at safe points, as you observed.
     This is necessary for supporting threading, as you point out.

   - Add safe points for loops that do not otherwise have them.
     Prevent (for (;;) { }) from blocking collection.

   - Hooks for injecting stack maps into the JIT.
     Something akin to the AsmWriter's GC printer registry.

SSA values as roots, liveness analysis, register maps, and derived  
pointer maps are code quality improvements.

> The other intrinsics let you generate code that should be GC- 
> independent and only need GC implementations. So you can start right  
> away writing your collector(s) :)

Definitely so!

— Gordon



More information about the llvm-dev mailing list