Garbage Collection

Hello,

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?

Thanks,
Paul.

Hi Paul,

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

semigc.tar.gz (4.94 KB)