Garbage collection: Multiple copies of a root


As far as I understand now, only stack variables can be marked as gc roots. Our
compiler however can also generate roots that are not necessarily on the stack.
We can solve this by putting it on the stack anyway. So far so good.

The problem is that we want to implement some sort of copying garbage collector.
In this case, the roots on the stack must be updated. However, if this root is also
stored in an IR register, then this pointer should be updated as well. Is there
support for identifying and updating such references in the GC framework, or should we generate
code ourselves to reload the updated references from the stack.



You should generate code to reload the registers from the stack for now. We'd ultimately like to move to a model where LLVM automatically inserts the reloads, only as necessary, but are not there yet.

— Gordon

Another open question is who is responsible for inserting calls to the collector routine (or signaling a collector thread)?

My impression is that this has to be done in the front-end for now since there is no support for doing this at the safe points at the moment.

Is this correct?


Generally, GC is only triggered by an out-of-memory condition. So typically the runtime library will invoke collection from within the memory allocation function.

— Gordon