More on garbage collection

Wednesday, February 2, 2011
I have to say, one requirement of implementing a garbage collector is that it really forces you to take a holistic view of your code generation process. You have to consider every possible object reference that could be generated, because if you miss one, the garbage collector will cheerfully free your object before you're done with it.

A discussion on the llvm-dev mailing list has yielded some valuable new information: LLVM metadata nodes can refer to global variables. LLVM supports the concept of arbitrary metadata associated with a module, and these metadata can contain arbitrary language-specific information which is ignored by the various LLVM optimization passes. Moreover, if a value gets eliminated during an optimization pass, the pointer in the metadata node will automatically get changed to NULL.

This is exactly what I need - I want the optimizer to be able to eliminate any garbage collection roots that are never used, and then after it's done, I want to take the roots that are left over and string them together into a table.


Post a Comment