[LLVMdev] ocaml+llvm

Chris Lattner sabre at nondot.org
Mon Aug 13 13:33:16 PDT 2007


>>  maybe current infrastructure used for eh/debug info emission can be 
>>  extended to handle ocaml data?
>
> Perhaps. I'm pretty sure the code to generate this stuff doesn't belong in 
> LLVM proper like DWARF support does, though; this is not even a vague 
> approximation of a standard. :)

>From your original email:

>The biggest problem is a data structure called the frame table, a
>simple structure for which LLVM seems ill-prepared. For each call
>site in the program, ocaml emits an entry into this table:
>
>     key   : the return address of the call site
>     value : the stack offset of every variable live after return
>
>The garbage collector uses this when walking the stack to find
>live objects.

I don't think you want to try to have the LLVM code generator build this 
table.  The table is a contract between the specific codegen you're using 
and the GC runtime you're using.  This contract is specific to the current 
ocaml code generator.

In the LLVM world, you should use the first-class support we already have 
for accurate GC: http://llvm.org/docs/GarbageCollection.html

Based on this, you annotate the variables with llvm.gcroot intrinsics, and 
then walk the stack with the llvm_cg_walk_gcroots function.  Note that 
these are not well tested and probably have holes in them, but these are 
the interfaces we want to use :)

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list