<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Pathological performance on first execution of a function called with mismatched argument count"
   href="https://bugs.webkit.org/show_bug.cgi?id=155551#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Pathological performance on first execution of a function called with mismatched argument count"
   href="https://bugs.webkit.org/show_bug.cgi?id=155551">bug 155551</a>
              from <span class="vcard"><a class="email" href="mailto:oliver&#64;apple.com" title="Oliver Hunt &lt;oliver&#64;apple.com&gt;"> <span class="fn">Oliver Hunt</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=155551#c4">comment #4</a>)
<span class="quote">&gt; Here's the case that originally struct me as wrong:
&gt; 
&gt; function f(j) { for (var i = 0 ; i &lt; 10000000; i++) j = (j ?  j * i : 1) ^
&gt; (i &amp; j); };
&gt; 
&gt; var start = new Date; f(); var end = new Date; print(&quot;2nd: &quot; + (end - start)
&gt; + &quot;ms&quot;);
&gt; var start = new Date; f(); var end = new Date; print(&quot;3rd: &quot; + (end - start)
&gt; + &quot;ms&quot;);
&gt; 
&gt; First run is 433ms, second run is 137ms.</span >

Essentially we're spending 300ms longer in the first run than the second. To me that implies that the first run doesn't get to jump into the optimized path. This is further reinforced if i increase the iteration count:

function f(j) { for (var i = 0 ; i &lt; 500000000; i++) j = (j ?  j * i : 1) ^ (i &amp; j); }; var start = new Date; f(); var end = new Date; print(&quot;1st: &quot; + (end - start) + &quot;ms&quot;); var start = new Date; f(); var end = new Date; print(&quot;2nd: &quot; + (end - start) + &quot;ms&quot;);

Producing
1st: 18392ms
2nd: 4166ms

The scaling of runtime implies that the first run is not tiering up in any meaningful way, but we are producing code that is optimised: we hit it the second time we run the function.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>