[LLVMdev] OCaml bindings to LLVM

Jon Harrop jonathandeanharrop at googlemail.com
Mon Sep 8 12:10:46 PDT 2008


On Monday 08 September 2008 17:23:48 Daniel Dunbar wrote:
> On Fri, Sep 5, 2008 at 8:26 PM, Jon Harrop
>
> <jonathandeanharrop at googlemail.com> wrote:
> > Firstly, I noticed that the execute engine is very slow, taking
> > milliseconds to call a JIT compiled function. Is this an inherent
> > overhead or am I calling it incorrectly or is this something that can be
> > optimized in the OCaml bindings?
>
> What is the signature of the function you are calling?

  unit -> unit

So I am passing zero arguments and returning void.

> When calling a generated function via runFunction, the JIT handles some
> common signatures but if it doesn't recognize the function signature it
> falls back on generating
> a stub function on the fly. This generation is fairly expensive and is
> probably the overhead
> you are seeing. There should be little more inherent overhead than the
> cost of a function
> call if the stub path isn't being taken.
>
> The simple solution (aside from fixing JIT) is to change your
> signature to match one
> of the ones the JIT special cases (see JIT::runFunction). A nullary
> one with arguments
> passed in globals works fine, if thread safety isn't a concern.

I see. Looking at JIT::runFunction, passing one dummy int32 argument should do 
the trick.

I'll see if I can write something a little cleverer on the OCaml side to 
run-time compile stubs either so that partial application can be used to 
share them or just memoize to reuse them.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list