* Run-time FFI generation using LLVM
@ 2008-07-13 12:19 Jon Harrop
0 siblings, 0 replies; only message in thread
From: Jon Harrop @ 2008-07-13 12:19 UTC (permalink / raw)
To: caml-list
The latest OCaml Journal article describes how LLVM can be used to generate
FFI code at run-time, allowing OCaml programs to dynamically load C libraries
and call their functions without having to write any C stubs or statically
link any custom libraries.
This technique has the obvious advantage that its potential for reuse is much
better because the bindings are written in OCaml rather than C. However,
there are two disadvantages:
. A significant amount of boilerplate is currently required (that could easily
be amortized into an OCaml library)
. The LLVM execution engine is currently very slow to invoke from OCaml
(taking around 0.5ms for a single function call).
Perhaps the most obvious steps forward are to expose the OCaml macros (e.g.
Field, Wosize_val) as ordinary C functions so they can be called from
LLVM-generated code, and then design and implement a DSL and compiler to ease
the burden of generating FFI code.
As an aside, I think it would also be very interesting to convert OCaml's
bytecode interpreter from C into a JIT using LLVM by partially specializing
the existing C code over a given bytecode.
Anyway, LLVM is certainly a very exciting project for the OCaml community!
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-07-13 12:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-13 12:19 Run-time FFI generation using LLVM Jon Harrop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox