[LLVMdev] Garbage collection questions
Chris Lattner
sabre at nondot.org
Mon Feb 27 14:39:01 PST 2006
On Mon, 27 Feb 2006, Sandro Magi wrote:
> Couple of questions:
Ok, it's been a long while since I've worked on the GC stuff, but I'll try
to help :)
> 1. void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr)
>
> I haven't seen an adequate explanation of these, but I'm guessing:
> void *V: value being written to the field
> void *ObjPtr: current value of the field (ie. ObjPtr == *FieldPtr
> upon entry to llvm_gc_write)
> void **FieldPtr: address of the field being written
Close: ObjPtr is designed to be a pointer to the head of an object. For
example, to codegen:
Obj->Field = Ptr;
you'd want to compile it as:
llvm_gc_write(Ptr, Obj, &Obj->Field);
This is used by the GC if it keeps bits in the object header or other
things. If the GC you plan to use doesn't need this info, you don't need
to provide it obviously. :)
> 2. The current semispace collector includes some code which says it
> should be in a code-generator library. If I were to write a collector,
> should I also include this code for the time being?
Yes, I would suggest including it.
> Or will this soon be refactored into an external interface?
Right now, noone is pushing the GC interfaces forward. Contributions to
help are welcome!
> 3. void %llvm.gcroot(<ty>** %ptrloc, <ty2>* %metadata)
>
> I don't see an implementation of the llvm.gcroot intrinsic in the
> semispace collector, so is it implemented elsewhere? Semispace has a
> function with the same signature, but it's not in the public GC
> interface ( http://llvm.cs.uiuc.edu/cvsweb/cvsweb.cgi/llvm/runtime/GC/GCInterface.h).
> Or is this simply because the llvm_cg_walk_gcroots callback hasn't
> been refactored as an external interface (as per #2 above)?
The llvm.gcroot intrinsic is turned into magic in the code generator that
clients aren't supposed to know about. The public interface to this magic
is the llvm_cg_walk_gcroots API function, which provides the dynamic
values of the roots.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list