<div dir="ltr">OK, so I have some *preliminary* results, which are on the whole quite encouraging!<div><div><br></div><div>I haven't had a great deal of time, but I have managed to get Extempore up and </div><div>running with function (actually lexical closures so composed of quite a bit of additional</div>
<div>guff) level compilation using Andy's multi module suggestion. I also have on-the-fly </div><div>recompilation of existing closures working (caveats below) so from an end-user </div><div>perspective this means that Extempore appears functionally equivalent with MCJIT </div>
<div>and the old legacy JIT - hot-swapping audio signal processing code on-the-fly using </div><div>MCJIT for example.</div><div><div style><div><br></div><div>Firstly multi-module definitely proved to be considerably easier than attempting to hack</div>
</div><div style>solutions for incremental *monolithic* module builds - which I also investigated.</div><div style><br></div><div style>So the only major obstacle that I have run into so far are page permissions in relation</div>
<div style>to code relocations. I have a *safe* hack which is to toggle section permissions between</div><div style>rw and exec/ro in-between new object injections - however this is obviously problematic </div><div style>
for code that is executing concurrently (i.e. secondary threads). I also have an *unsafe*</div><div style>hack, (purely for experimentation :-) whereby exec sections are left rw, and although </div><div style>very evil it works for test purposes (i.e. the audio example mentioned above). These </div>
<div style>solutions are obviously both inappropriate and I will investigate a *real* solution when </div><div style>I find some time.</div><div style><br></div><div style>Also I didn't bother to implement section erasure, at the moment I'm just allocating </div>
<div style>new sections for each compile regardless of whether the new code replaces existing</div><div style>functionality. Having said that I don't see this as much of an issue, I was just to</div><div style>lazy to bother implementing it. I'll check this when I have some further free time.</div>
<div style><br></div><div style>FYI this is all under x86. I did try to run under ARM but bombed out on an assertion error </div><div style>in the ARM ELF relocation code - specifically assert((*TargetPtr & 0x000F0FFF) == 0);</div>
<div style>I assume this is a result of something evil that I have done but I haven't yet had time to </div><div style>investigate any further. Again I'll let you know when I have some more time.</div><div style>
<br></div><div style>Just a quick heads up but In general my initial thoughts are that MCJIT is really not </div><div style>that far off.</div><div style><br></div><div style>Cheers,</div><div style>Andrew.</div><div style>
<br></div><div style><br></div><div style><br></div><div style> </div><div style><br></div><div style> </div><div style><br></div><div style><br></div><div style><br></div></div></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Fri, Feb 8, 2013 at 7:36 AM, Kaylor, Andrew <span dir="ltr"><<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">That’s awesome!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I think at this point having people try out various approaches and seeing what works and what doesn’t is our biggest need in this area. Please do keep me informed
about what you find out.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-Andy<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Andrew Sorensen [mailto:<a href="mailto:digegoo@gmail.com" target="_blank">digegoo@gmail.com</a>]
<br>
<b>Sent:</b> Wednesday, February 06, 2013 4:33 PM<br>
<b>To:</b> Kaylor, Andrew<br>
<b>Cc:</b> <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [LLVMdev] MCJIT and Lazy Compilation<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Thanks for the update Andy.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I'm very happy to be involved in anyway that is helpful. If you would like me to test ideas, or contribute to further discussions, then please let me know.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I currently have extempore running nicely with MCJIT for the "monolithic" case and am working on various LLVM hacks to better understand the issues involved with non-monolithic approaches - in particular I'm starting with your multi-module
approach. I will report back when (and if) I have something useful to contribute.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Andrew.<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Feb 6, 2013 at 4:08 AM, Kaylor, Andrew <<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Andrew,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I was about to write a belated reply to this message (sorry for the delay), but then I realized that
pretty much everything useful that I have to say on the subject is contained in this message (which is in a thread Albert Graef already linked to):</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><a href="https://groups.google.com/d/msg/llvm-dev/Rk9cWdRX0Wg/Fa1Mn6cyS9UJ" target="_blank">https://groups.google.com/d/msg/llvm-dev/Rk9cWdRX0Wg/Fa1Mn6cyS9UJ</a></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Generally, I do hope that MCJIT will be capable of replacing the old JIT someday soon, though obviously
it cannot do so until it provides equivalent functionality. I doubt it will ever be a “drop-in” replacement, but I hope that minimal rework will be needed. Most significantly, as can be seen in earlier discussions, things will need to be made Module-centric
rather than Function-centric. It ought to be possible to write a utility class that takes a monolithic Module and breaks it up into sub-Modules for individual functions, but I think that would need to happen outside of the MCJIT engine because not all clients
would want that kind of granularity.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">There’s definitely a lot of work to be done here to get this right, and hopefully we’ll get active
participation in any design discussions to make sure the solution meets everyone’s needs. I don’t have a time table for this right now. I will file a Bugzilla report as soon as the LLVM server is ready.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-Andy</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:llvmdev-bounces@cs.uiuc.edu" target="_blank">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu" target="_blank">llvmdev-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Andrew Sorensen<br>
<b>Sent:</b> Thursday, January 31, 2013 7:56 PM<br>
<b>To:</b> <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><br>
<b>Subject:</b> [LLVMdev] MCJIT and Lazy Compilation</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">Does anyone have a roadmap for MCJIT with what I think people are <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">calling lazy compilation.<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Is this even on the cards?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I spent the last few hours moving my project (<a href="http://extempore.moso.com.au" target="_blank">extempore.moso.com.au</a>) <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">over to MCJIT (particularly for ARM), and am a little horrified to discover <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">no ability to compile, and just as importantly to recompile, at a function level. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">This is absolutely mandatory for my project. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I have been looking enviously at MCJIT's ARM+DWARF support for a <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">couple of years and was under the misapprehension that MCJIT was <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">attempting to be a *drop-in* replacement for JIT. So I wasn't overly<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">concerned about the primary JIT being largely neglected. This is obviously<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">my fault, I wasn't paying close enough attention.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I am now wondering what the LLVM project, in the large, plans regarding <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">just-in-time compilation moving forward. Is MCJIT the future, and<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">if so what kind of roadmap is there to replicate current JIT functionality. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">In my case in relation to function level (re)compilation.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I appreciate everyones efforts, and that we all have our own agendas.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I'm just trying to put my own roadmap in place.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Andrew.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</blockquote></div><br></div>