[LLVMdev] JIT, FFI

Reid Kleckner rnk at mit.edu
Wed Oct 28 08:48:17 PDT 2009


You're right, that probably won't have very good performance.  What we
(unladen-swallow) do is to call getPointerToFunction which gives a
function pointer of type (void*)(void*) which we then cast to the
appropriate function type and then call from C/C++.  That way the
C/C++ compiler for your application can codegen the function call once
instead having the JIT do it many times.

Reid

On Wed, Oct 28, 2009 at 11:33 AM, Christian S. Perone
<christian.perone.listas at gmail.com> wrote:
> But by doing this (freeing the stub function and the machine code) can lead
> to other performance issues, I think that they reuse the same function stub
> when there are repeated calls to runFunction with the same args. I'll try to
> make a patch to see how fast it will became. Very thank you !
>
> On Wed, Oct 28, 2009 at 1:21 PM, Reid Kleckner <rnk at mit.edu> wrote:
>>
>> Ouch, I see what you mean.  It seems this bug can be fixed by freeing
>> the stub function and it's associated machine code before returning
>> from runFunction.  You should file a PR about it.
>>
>> Reid
>>
>> On Wed, Oct 28, 2009 at 10:41 AM, Christian S. Perone
>> <christian.perone.listas at gmail.com> wrote:
>> > Hello, I'm new to LLVM and I had a question about it: when we call the
>> > JIT::runFunction, since llvm doesn't has a full FFI, there are some
>> > cases in
>> > which the JIT needs to codegen a stub function to call the function we
>> > are
>> > interested, my question is: this stub function will remains in the
>> > module
>> > until when ? What are the most efficient way to remove it from the
>> > module
>> > and memory ? For a little quantity of calls this doesn't matter, but
>> > when I
>> > call a function using "runFunction" let's say 100 times with differente
>> > arguments, it will create 100 function stubs.
>> >
>> > Thank you !
>> >
>> > --
>> > Christian S. Perone
>> > http://pyevolve.sourceforge.net/wordpress
>> > "Forgive, O Lord, my little jokes on Thee, and I'll forgive Thy great
>> > big
>> > joke on me."
>> >
>> > _______________________________________________
>> > LLVM Developers mailing list
>> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> >
>> >
>
>
>
> --
> Christian S. Perone
> http://pyevolve.sourceforge.net/wordpress
> "Forgive, O Lord, my little jokes on Thee, and I'll forgive Thy great big
> joke on me."
>




More information about the llvm-dev mailing list