Hi Bruno,<br><br><div class="gmail_quote">On Wed, Jun 20, 2012 at 3:04 PM, Bruno Daniel <span dir="ltr"><<a href="mailto:abml@mailoo.org" target="_blank">abml@mailoo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear developers,<br>
<br>
Are there any benchmarks for the performance of Java Native Interface (JNI)<br>
calls in VMKit? Since VMKit is based on LLVM which can also run C++ code<br>
(maybe in the same just-in-time compiler?) I guess calls from Java to C++ and<br>
back could be much faster than in Sun's JVM which has extremely slow C++ -><br>
Java callbacks.<br>
<br>
If this was the case, this would be a big advantage of VMKit over all other<br>
JVMs and mixing existing C/C++ libraries with Java would be as easy as in the<br>
glue language Python.<br></blockquote><div><br></div><div>While mixing C/C++/Java with the same compiler seems appealing for performance, Java has a garbage collector, and a garbage collector does not cope well with native frames. It requires object indirection when leaving Java boundaries, as well as being able to interrupt the execution of a thread for initiating a collection.</div>
<div><br></div><div>Note that it is possible to do it: VMKit is written in C/C++ and objects are being passed directly, and a C++ frame, since it is compiled by clang can be interrupted. However, it is very subtle how it works, and a slight omission of a GC object declaration leads to crashes that are hard to detect. It's always possible to do better, like defining a convention that will tell clang which objects are being used by the GC, but it hasn't been worked on yet.</div>
<div><br></div><div>If you don't care about a GC, then sure, you can compiler C/C++/Java into a single native executable, where performance of inter-language calls are the same as intra-language calls.</div><div><br></div>
<div>Also, note that there were some works on trying to optimize JNI calls through inlining at runtime (<a href="http://dl.acm.org/citation.cfm?id=1064997">http://dl.acm.org/citation.cfm?id=1064997</a>). I don't know if the optimization is actually being used in existing JVMs.</div>
<div><br></div><div>Hope this helps!</div><div>Nicolas</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
All the best<br>
<span class="HOEnZb"><font color="#888888"> Bruno Daniel<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</font></span></blockquote></div><br>