question on the ocaml compatible collector

Browsing

http://llvm.org/releases/2.5/docs/GarbageCollection.html#ocaml

I stumbled across the sentence

"...The ocaml collector does not use read or write barriers, so the
user program may use load and store instead of llvm.gcread and
llvm.gcwrite..."

Which I believe is wrong as the ocaml collector does indeed use a
write barrier (caml_modify). But maybe I misunderstood?

Thanks,

Benedikt Grundmann

Browsing

http://llvm.org/releases/2.5/docs/GarbageCollection.html#ocaml

I stumbled across the sentence

“…The ocaml collector does not use read or write barriers, so the
user program may use load and store instead of llvm.gcread and
llvm.gcwrite…”

Which I believe is wrong as the ocaml collector does indeed use a
write barrier (caml_modify). But maybe I misunderstood?

This is intended to be a very limited statement. The ‘ocaml’-style GC codegen supported by LLVM does not in isolation require the use of the llvm.gcwrite intrinsic. It can be (and is) used with runtimes other than ocaml’s, and such a system might not need the write barrier.

Hope that helps,

Gordon

P.S. If you’re actually interested in using this component in conjunction with ocaml, there are some challenges to overcome.

  1. ocaml uses its own calling convention. Support for it would need to be added to LLVM.

  2. ocaml places exported symbols interior to objects:

.word
sym:

.word
sym2:

LLVM cannot emit this code. The ocaml compiler needs to be modified to emit/expect code like this instead:

sym:
.word

sym2:
.word

References would need to look for sym+(word size) instead of sym. This is surprisingly trivial, but my patch is likely stale, and the ocaml developers were not interested in it when it was not.