<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">OK, let me start by saying that MCJIT does take ownership of the memory manager.  It doesn’t use an OwningPtr, which would make this clear, but it does delete
 the pointer in its destructor.  I think this is happening because we needed some finer control over when the MM got deleted.  I should probably revisit this and at least add some comments to make it clear what’s happening and why.  It might not even be an
 issue anymore, because I did some work a while ago to try to clean up object ownership issues.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">That said, I have been meaning for some time to break apart the JIT and MCJIT interfaces.  The fact that they are both abstracted by ExecutionEngine and EngineBuilder
 complicates that, but it really needs to be done (as you are seeing).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">For now, would it be possible to have the C-interface provide a wrapper that supplies empty implementations of the irrelevant functions when creating a memory
 manager for MCJIT?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<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""> Filip Pizlo [mailto:fpizlo@apple.com]
<br>
<b>Sent:</b> Saturday, April 13, 2013 1:18 AM<br>
<b>To:</b> Kaylor, Andrew<br>
<b>Cc:</b> llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [PATCH][llvm-c] Expose MC JIT<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Ah - good thing you pointed this out.  I just realized that my patch is wrong.  Perhaps I can get some feedback on the best way to architect this.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here's the problem:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">- MCJIT does not take ownership of the memory manager.  Hence allocating one in the constructor is wrong; it'll leak when MCJIT dies.  But deleting the memory manager passed to MCJIT would be a change in behavior, and I'm not sure if it's
 in line with either what existing users expect or what was intended.  Insofar as the JIT instance corresponds to ownership of modules, it feels like it shouldn't also take ownership of the memory manager; for example you might imagine wanting to throw away
 the MCJIT but keep the code it generated and continue to use the memory manager to track it - and eventually free it.  But EngineBuilder currently claims that the ExecutionEngine takes ownership of the JMM - I'm assuming that this is just wrong documentation,
 and that EngineBuilder's use of the same JMM option for both JIT and MCJIT is just not right.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">- I'd like to expose SectionMemoryManager and, eventually in a separate patch, the ability to create custom RTDyldMemoryManagers via the C API.  I'd prefer this to be an RTDyldMemoryManager and not a JITMemoryManager, since the latter has
 a load of methods that are not relevant to MCJIT.  But EngineBuilder wants a JITMemoryManager.  This would mean that the C API would have to pass its RTDyldMemoryManager via a cast to JITMemoryManager just so MCJIT could then use it as an RTDyldMemoryManager
 again.  Seems wrong.  I'm assuming that the correct long-term thing is to fix the EngineBuilder to not pass the JMM to the MCJIT, since it's good to expose the fact that the MCJIT actually just wants an RTDyldMemoryManager instead.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In short, I'd like to have a separate EngineBuilder setting for the RTDyldMemoryManager.  If this is specified and you end up using the JIT and not MCJIT, you get an error.  If you use the MCJIT, then the RTDyldMemoryManager option overrides
 the JMM option.  Or something similar.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Does that make sense?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-Filip<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Apr 12, 2013, at 5:38 PM, Filip Pizlo <<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">Thanks for the feedback!  I will try this change and see what happens. <br>
<br>
-Filip<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
On Apr 12, 2013, at 5:35 PM, "Kaylor, Andrew" <<a href="mailto:andrew.kaylor@intel.com"><span style="color:purple">andrew.kaylor@intel.com</span></a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Filip,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’ll take a closer look at your patches on Monday, but my initial input is that the default memory manager used should be SectionMemoryManager rather than the
 DefaultJITMemoryManager.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Andy</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
</div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<div>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span class="apple-converted-space"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> </span></span><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><a href="mailto:llvm-commits-bounces@cs.uiuc.edu"><span style="color:purple">llvm-commits-bounces@cs.uiuc.edu</span></a><span class="apple-converted-space"> </span>[<a href="mailto:llvm-commits-bounces@cs.uiuc.edu"><span style="color:purple">mailto:llvm-commits-bounces@cs.uiuc.edu</span></a>]<span class="apple-converted-space"> </span><b>On
 Behalf Of<span class="apple-converted-space"> </span></b>Filip Pizlo<br>
<b>Sent:</b><span class="apple-converted-space"> </span>Friday, April 12, 2013 4:49 PM<br>
<b>To:</b><span class="apple-converted-space"> </span><a href="mailto:llvm-commits@cs.uiuc.edu"><span style="color:purple">llvm-commits@cs.uiuc.edu</span></a><br>
<b>Subject:</b><span class="apple-converted-space"> </span>Re: [PATCH][llvm-c] Expose MC JIT</span><o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Revised patches included.<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">I added additional ruggedizing to the LLVMCreateMCJITCompilerForModule function, so that if it detects that the passed struct is larger than expected, it reports an error instead of continuing.<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
</blockquote>
<p class="MsoNormal">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu"><span style="color:purple">llvm-commits@cs.uiuc.edu</span></a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits"><span style="color:purple">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</span></a><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>