Can I use GC OCaml with the GC LLVM interface?

For my LLVM backend for PHP, I would like to try GC OCaml. Can I use it with LLVM? Special:

  • Is OCaml GC decoupled enough for use outside the compiler?
  • Is the GC LLVM interface mature enough for use with the OCaml GC?
+4
source share
2 answers

This should not be too much work, since OCaml GC is already somehow handled in LLVM: http://llvm.org/docs/GarbageCollection.html#the-erlang-and-ocaml-gcs . This means that freeze descriptors are correctly emitted for function calls (not the smallest ones, but this should improve with current developments in LLVM GC processing). An old version of the LLVM documentation states that OCaml gc does not use write barriers, which is erroneous. Therefore, you must be careful that the generated code is correct for assignments.

For the LLVM GC interface, the current version is rather limited and does not allow generating very efficient code, but this should be enough for the prototype, waiting for the next version, which should contain some important changes on this side.

+2
source

Although it seems that it would be relatively easy to pull OCaml GC and Frankenstein into another project, I'm not sure if this is really what you would like to do in practice.

The OCaml garbage collector was designed with a functional programming style , and this GC architecture may be responsible for a language such as PHP, which is not commonly used in a functional style.

If you are configured for this, I would suggest either waiting a few months for multicore support to be accepted into the OCaml compiler / runtime, or using one of the various projects currently trying to support multicore OCaml support (the most serious ones are probably this project is people in OCamllabs). Currently, GC OCaml does not have reliable multi-core support, and although in practice this is practically not a problem, some people cannot live without it.

+2
source

All Articles