[LLVMdev] Garbage Collection

Paul Melis llvm at assumetheposition.nl
Wed Mar 31 12:08:59 PDT 2010


Hi Paul,

On 03/25/10 12:15, Paul van der Ende wrote:
> I want to add garbage collection support to a compiler with a llvm
> backend, using the shadow-stack compiler plugin.
>
> I read the GC tutorial in the LLVM documentation, and the paper about
> shadow-stacks. Im currently adding intrinsics to my generated llvm code,
> and trying to write code to connected it to my (existing) garbage
> collector library. Im not sure yet how everything fits together.
>
> Im particularly interested in how the llvm specific shadow-stack
> transformation works to get a better understanding. Is it possible to
> output the llvm instructions created from the gcroot intrinsics etc after
> the transformation? At what compiler stage is the transformation
> performed? I tried to find out what it does with the llvm instructions
> from looking at the source code of the GCStrategy class, but I like to see
> an example for my own code to see what is really happening. The llvm
> specific cpp code is hard to understand because im not really a llvm
> framework developer.
>
> Another question, the GC tutorial refers to
> "/runtime/GC/SemiSpace/semispace.cpp" (a simple gc on top of the
> shadow-stack) but this file does not exist in the 2.6 release, I was able
> to find it in older releases. Is it out-dated? will there be an example
> garbage collector in the 2.7 release?
>
> Are there any other code examples of garbage collectors written on top of
> the llvm shadow stack?
>   
I had a lot of the same questions as you and just tried to create some
simple proof-of-concept implementation on top of LLVM, using a
semi-space collector. I didn't look at details of GCStrategy back then,
I merely used the LLVM @llvm.gcroot intrinsic (through llvm-gcc) and the
built-in shadow stack support. Here's the code, perhaps it's useful for
you. It's quite clean as I wanted something I could refer too in the
future for myself. But it doesn't do anything else except allocate a few
objects of some class type that reference each other and forces some
collections.

Hoop dat je er wat aan hebt,
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: semigc.tar.gz
Type: application/x-gzip
Size: 5062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100331/a4207889/attachment.bin>


More information about the llvm-dev mailing list