<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><br>On Nov 26, 2014, at 10:36 AM, Baldeva, Arpit &lt;<a href="mailto:abaldeva@ea.com">abaldeva@ea.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 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;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle18
        {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]-->


<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thanks for the detailed response.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">I talked to some other people in our organization (actual users of our webkit port) and they mentioned even the baseline JIT&nbsp;is at least twice as fast for their
 use case (I understand that benchmarks like Sunspider are much more faster than 2x with JIT support). That is very significant compared to LLInt. As we do not have ability to do runtime JIT, &nbsp;is it&nbsp;“easy” to just plug in pre-generated baseline JIT code if
 we can pre-generate them for some JavaScript?</span></p></div></div></blockquote><div><br></div><div>Short answer: it's not possible.&nbsp;</div><div><br></div><div>Long answer: This is remotely doable but it would be a significant undertaking. It would be a rewrite of the most complex part of the JIT (the online caching).&nbsp;</div><div><br></div><div>A lot of the baseline JIT's performance comes from run-time code patching inside our inline cache code. That is, the code that is initially generated is incomplete and we patch it based on runtime information after the code is already running. This involves directly patching in pointers to heap objects. So, if you tried to generate the code ahead of time, you'd need a really comprehensive "linking" story for either making this patching happen somehow or by finding a way to avoid it. I don't know how to fool a system linker into doing this patching, particularly since system linkers run more eagerly than when this patching is supposed to happen. We want to patch after at least one execution of the subject code.</div><div><br></div><div>If you tried to avoid the patching entirely then you'd probably get worse performance than the LLInt, so I don't recommend that route.&nbsp;</div><div><br></div><div>Otoh, if you improve the LLInt's inline caching as I recommended, you'd probably see very real speedups. I wouldn't expect a 2x speedup, but then again, I wouldn't be terrible surprised if you ended up with 2x if your workload happens to do the kinds of property accesses that the LLInt's online caches currently don't support.&nbsp;</div><br><blockquote type="cite"><div><div class="WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">It was also mentioned that Google’s closure compiler can actually do optimizations similar to some of the following suggestions and they saw significant performance
 boost in some scenarios as a result. Obviously, having it in the engine is always nice to have so I don’t question the need for these optimizations on JavaScriptCore side.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thanks<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Arpit<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> Filip Pizlo [<a href="mailto:fpizlo@apple.com">mailto:fpizlo@apple.com</a>]
<br>
<b>Sent:</b> Tuesday, November 25, 2014 3:24 PM<br>
<b>To:</b> Baldeva, Arpit<br>
<b>Cc:</b> WebKit Development<br>
<b>Subject:</b> Re: [webkit-dev] asm.js optimization path?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">It's definitely possible to make the LLInt faster. &nbsp;I don't think that type inference would necessarily do it. &nbsp;But I think that cold-hearted engineering might do it. &nbsp;We would certainly be happy to review patches that make the LLInt faster.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">I would recommend profiling where you spend your time when running in LLInt mode. &nbsp;I suspect that the following areas could be improved:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">- Inlining the fast paths for typed array access.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Inline caching for prototype accesses.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- Inline caching for polymorphic accesses.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">I could also imagine a strategy that involves fusing some common bytecode ops. &nbsp;Traditionally one of the highest sources of overhead in an interpreter is dispatch from one instruction to the next. &nbsp;Here's a made up example where fusing
 would be profitable: say you found that your program was doing a lot of op_mul's followed by op_add's. &nbsp;Then you would likely benefit from an op_muladd, because no you'd have one fewer instruction dispatches on a hot path. &nbsp;I don't believe anyone has done
 this kind of investigation, but it might be worth doing, and if we found that there were a handful (maybe less than 20?) of super common idioms, then we could consider fusing those. &nbsp;This would be both a bytecode transformation and a change to the LLInt itself.
 &nbsp;You'd also then have to change the other execution engines to know how to handle those fused ops.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">-Filip<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Nov 25, 2014, at 3:10 PM, Baldeva, Arpit &lt;<a href="mailto:abaldeva@ea.com">abaldeva@ea.com</a>&gt; wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Okay. Thanks for the input.</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Let me ask a slightly different question (let me know if this should be a different thread). As background info, we are trying to optimize JavaScript execution
 without JIT support. Due to security restrictions by First Party, we are not allowed to JIT the JavaScript on some platforms. So we are looking for ideas on how to optimize runtime performance.</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">One of the idea we have had internally was what if we could AOT compile normal JavaScript (not same as asm.js) that we do not intend to update. I looked at<a href="http://trac.webkit.org/wiki/JavaScriptCore"><span style="color:#954F72">http://trac.webkit.org/wiki/JavaScriptCore</span></a><span class="apple-converted-space">&nbsp;</span>which
 mentions that type inference/profiling happens in the LLInt/Baseline JIT tier and used in DFG JIT layer. Would it be a bad idea to move/use the type inference in LLInt layer? What if such thing was possible, we preload our JS and make it run say few thousand
 times before actual execution need (so that we get better performance)?</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Is there any other idea we can pursue for better performance by just using LLInt layer? Or the general thought process is that if you want better javascript performance,
 JIT support is expected.</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thanks</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Arpit &nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<div>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span class="apple-converted-space"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span></span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Filip
 Pizlo [<a href="mailto:fpizlo@apple.com">mailto:fpizlo@apple.com</a>]<span class="apple-converted-space">&nbsp;</span><br>
<b>Sent:</b><span class="apple-converted-space">&nbsp;</span>Monday, November 24, 2014 8:19 AM<br>
<b>To:</b><span class="apple-converted-space">&nbsp;</span>Baldeva, Arpit<br>
<b>Cc:</b><span class="apple-converted-space">&nbsp;</span><a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
<b>Subject:</b><span class="apple-converted-space">&nbsp;</span>Re: [webkit-dev] asm.js optimization path?<o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><br>
On Nov 24, 2014, at 7:56 AM, Baldeva, Arpit &lt;<a href="mailto:abaldeva@ea.com"><span style="color:#954F72">abaldeva@ea.com</span></a>&gt; wrote:<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Hi,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">I was wondering if JavaScriptCore community ever considered adding optimization path for asm.js (<a href="http://asmjs.org/"><span style="color:#954F72">http://asmjs.org/</span></a><span class="apple-converted-space">&nbsp;</span>)
 ? I searched webkit bugzilla and did not find any relevant discussions.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Any opinions in favor/against it?<span class="apple-converted-space">&nbsp;</span><o:p></o:p></span></p>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal">&nbsp;<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">We strive to optimize the full JavaScript language rather than a subset.&nbsp;<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">&nbsp;<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">I would be opposed to any change in this strategy.&nbsp;<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">&nbsp;<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">-Filip<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<br>
<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Thanks<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Arpit<o:p></o:p></span></p>
</div>
</div>
</blockquote>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">_______________________________________________<br>
webkit-dev mailing list<br>
<a href="mailto:webkit-dev@lists.webkit.org"><span style="color:#954F72">webkit-dev@lists.webkit.org</span></a><br>
<a href="https://lists.webkit.org/mailman/listinfo/webkit-dev"><span style="color:#954F72">https://lists.webkit.org/mailman/listinfo/webkit-dev</span></a><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p></o:p></span></p>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>


</div></blockquote></body></html>