caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Run-time FFI generation using LLVM
Date: Sun, 13 Jul 2008 13:19:33 +0100	[thread overview]
Message-ID: <200807131319.33126.jon@ffconsultancy.com> (raw)


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


                 reply	other threads:[~2008-07-13 12:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200807131319.33126.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).