<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><br><div><div>On Sep 19, 2013, at 1:47 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Very curious about RunFunction then?<br></div></blockquote><div><br></div><div>What about it? ;-)</div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>When I did the JIT aspect I used getPointerToFunction, what are you<br>guys using at the moment in webkit-land?<br></div></blockquote><div><br></div><div>LLVMGetPointerToGlobal().  We create an MCJIT, give it a module and then call LLVMGetPointerToGlobal(), passing it a Value that is the function we want.</div><div><br></div><div>There's other stuff going on, as well - like having a custom memory manager so that WebKit can control where/how all sections get allocated by Dyld.  But the basic workflow if you want to launch a local JIT to generate some code is (1) create the JIT with the module you want to compile, (2) get pointers to your functions with LLVMGetPointerToGlobal().  The latter also forces a compile.</div><div><br></div><div>It's true you can call RunFunction but this is silly for many JIT clients.  You will want to call the generated code directly, either from C or from other JITed code that you have generated. We don't use RunFunction, and don't ever intend to.</div><div><br></div><div>-Filip</div><div><br></div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>-eric<br><br>On Thu, Sep 19, 2013 at 1:46 PM, Filip Pizlo <<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>> wrote:<br><blockquote type="cite">How is that different from LLVMGetPointerToGlobal()?<br><br>And I agree that this should work.  It's great that the JIT could be used<br>for remote execution, but some clients will never use the JIT in that<br>fashion.  They will just want a void*.<br><br>-Filip<br><br><br>On Sep 19, 2013, at 1:36 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br><br>Hrm. That's a good point and one I hadn't thought about... what's the<br>best way forward here? There's definitely a useful need in getting a<br>void * to a function out of the JIT from the C level.<br><br>-eric<br><br>On Thu, Sep 19, 2013 at 1:30 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:<br><br>This isn’t going to work when the execution target isn’t local. The pointer<br>to the function is in the executing process address space and this returns a<br>pointer in the compiler’s address space.<br><br>That’s a fundamental problem with the old JIT, and is semi-baked into the<br>ExecutionEngine API, unfortunately, and cleaning that up is going to be<br>painful. We shouldn’t, however, make the problem worse.<br><br>-Jim<br><br>On Sep 19, 2013, at 12:55 PM, Anders Waldenborg <<a href="mailto:anders@0x63.nu">anders@0x63.nu</a>> wrote:<br><br>Author: andersg<br>Date: Thu Sep 19 14:55:06 2013<br>New Revision: 191030<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=191030&view=rev">http://llvm.org/viewvc/llvm-project?rev=191030&view=rev</a><br>Log:<br>llvm-c: Add LLVMGetPointerToFunction<br><br>Differential Revision: <a href="http://llvm-reviews.chandlerc.com/D1715">http://llvm-reviews.chandlerc.com/D1715</a><br><br><br>Modified:<br> llvm/trunk/include/llvm-c/ExecutionEngine.h<br> llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp<br><br>Modified: llvm/trunk/include/llvm-c/ExecutionEngine.h<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ExecutionEngine.h?rev=191030&r1=191029&r2=191030&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ExecutionEngine.h?rev=191030&r1=191029&r2=191030&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm-c/ExecutionEngine.h (original)<br>+++ llvm/trunk/include/llvm-c/ExecutionEngine.h Thu Sep 19 14:55:06 2013<br>@@ -141,6 +141,8 @@ LLVMGenericValueRef LLVMRunFunction(LLVM<br>                                  unsigned NumArgs,<br>                                  LLVMGenericValueRef *Args);<br><br>+void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);<br>+<br>void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef<br>F);<br><br>void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M);<br><br>Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp<br>URL:<br>http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=191030&r1=191029&r2=191030&view=diff<br>==============================================================================<br>--- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original)<br>+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Thu Sep 19<br>14:55:06 2013<br>@@ -276,6 +276,10 @@ LLVMGenericValueRef LLVMRunFunction(LLVM<br>return wrap(Result);<br>}<br><br>+void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F) {<br>+  return unwrap(EE)->getPointerToFunction(unwrap<Function>(F));<br>+}<br>+<br>void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef<br>F) {<br>unwrap(EE)->freeMachineCodeForFunction(unwrap<Function>(F));<br>}<br><br><br>_______________________________________________<br>llvm-commits mailing list<br>llvm-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br><br><br><br>_______________________________________________<br>llvm-commits mailing list<br>llvm-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br><br><br>_______________________________________________<br>llvm-commits mailing list<br>llvm-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</blockquote></div></blockquote></div><br></body></html>