<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Register usage optimization in mathIC when LHS and RHS are constants isn't configured correctly"
   href="https://bugs.webkit.org/show_bug.cgi?id=160802#c13">Comment # 13</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Register usage optimization in mathIC when LHS and RHS are constants isn't configured correctly"
   href="https://bugs.webkit.org/show_bug.cgi?id=160802">bug 160802</a>
              from <span class="vcard"><a class="email" href="mailto:mark.lam&#64;apple.com" title="Mark Lam &lt;mark.lam&#64;apple.com&gt;"> <span class="fn">Mark Lam</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=160802#c12">comment #12</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=285914&amp;action=diff" name="attach_285914" title="Patch">attachment 285914</a> <a href="attachment.cgi?id=285914&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=285914&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=285914&amp;action=review</a>
&gt; 
&gt; &gt;&gt; Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:3474
&gt; &gt;&gt; +    
&gt; &gt; 
&gt; &gt; Thanks for identifying the issue.  A few points come to mind:
&gt; &gt; 
&gt; &gt; 1. I think this is brittle and hacky because you're setting the SnippetOperands here and then overriding it again later in the generator initialization.  However, I'm not entirely satisfied with any alternatives that I can think of at the moment either (need more consideration).  At minimum, we should have a debug build flag in the Generator that says that it isn't (or its snippetOperands aren't) initialized yet, and assert on that flag in JITMathIC::isLeftOperandValidConstant() and isRightOperandValidConstant().
&gt; &gt; 
&gt; &gt; 2. Can you add some tests that shows that this is broken (unless existing tests can already cover this)?  This will come in handy if someone accidentally breaks this in the future.  The assertions suggested in (1) should make it easier to test.
&gt; &gt; 
&gt; &gt; Thanks.
&gt; 
&gt; Caio, I just realized there is a weird dependency here between populating
&gt; the left/right regs, and creating the Generator.
&gt; I agree with mark that it seems brittle to set them here and then overwrite
&gt; them. My suggestion, to a less brittle approach,
&gt; is to simply have isLeftOperandValidConstant(...) and
&gt; isRightOperandValidConstant(...) take SnippetOperand as an argument
&gt; to the function. This won't allow callers to mess this up. You can just make
&gt; them static functions on the JITBlahGenerator. Also, if you make that
&gt; change, you'll need
&gt; to make sure we don't consider left *and* right as constants. We only allow
&gt; for one or the other being a constant. So that means you'll have to change
&gt; the 
&gt; if statement below to be an else if</span >

I do like this idea of making these methods static and explicitly passing the SnippetOperand to them instead.

<span class="quote">&gt; Mark, to address your point (2), this was just removing an optimization, it
&gt; wasn't breaking existing tests AFAIK.</span >

Good point.</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>