<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Refactor MathIC compilation process in Baseline and DFG to turn temporary registers usage more flexible"
   href="https://bugs.webkit.org/show_bug.cgi?id=160588#c27">Comment # 27</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Refactor MathIC compilation process in Baseline and DFG to turn temporary registers usage more flexible"
   href="https://bugs.webkit.org/show_bug.cgi?id=160588">bug 160588</a>
              from <span class="vcard"><a class="email" href="mailto:ticaiolima&#64;gmail.com" title="Caio Lima &lt;ticaiolima&#64;gmail.com&gt;"> <span class="fn">Caio Lima</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=160588#c26">comment #26</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=291111&amp;action=diff" name="attach_291111" title="Patch">attachment 291111</a> <a href="attachment.cgi?id=291111&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; Something about this patch doesn't sit right with me, and I think I've
&gt; finally figured out what it is.
&gt; This API doesn't seem scalable to adding more math ICs that need more
&gt; scratch registers. I think we need
&gt; to move to a more dynamic API, by either passing in a vector of scratch
&gt; registers, or a RegisterSet of used registers.
&gt; The reason this code feels so weird to me is that you've started to make
&gt; this API more dynamic, yet you're still calling
&gt; the exact same constructors. So it's only pretending to be more dynamic, but
&gt; in reality, it's not.
&gt; Also, the code is just much harder to follow now. 
&gt; I'm not sure what the best API is. Here are two options:
&gt; 1. If we pass in a RegisterSet of used registers, each snippet will now be
&gt; responsible for allocating scratch
&gt; registers using the scratch register allocator.
&gt; 2. Alternatively, we can keep most of your patch like it is now, but pass in
&gt; a vector of scratch registers.
&gt; Each snippet constructor can deconstruct the vector into member variables
&gt; and assert that none are InvalidGPR/FPRReg.
&gt; The vector can have an inlinecapacity of
&gt; scratchGPRRegCount/scratchFPRRegCount and just be the vector of registers.
&gt; 
&gt; I think I prefer 2. Maybe you have other ideas?</span >

I remember discussing with you a long time ago that I proposed to you use a vector, however you gave me an answer that convinced me. The problem is that the vector is going to inflate all ICs, mainly the ones that use just 1 scratch.

If I understood your idea, we could use GPRReg allocatedRegs[scratchGPRRegCount] and pass it to JIT*Generator and the Generator just validate if they are invalid or not. This implementation is going to use sizeof(GPRReg * scratchGPRRegCount) memory, which means sizeof(GPRReg) if scratchGPRRegCount = 1. Is it right? If yes, I can't think in a better solution right now and the idea of Generators being responsible to allocate its scratches doesn't sound right IMO.</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>