<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Implement all the arithmetic and logical instructions in WebAssembly"
   href="https://bugs.webkit.org/show_bug.cgi?id=148882#c4">Comment # 4</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Implement all the arithmetic and logical instructions in WebAssembly"
   href="https://bugs.webkit.org/show_bug.cgi?id=148882">bug 148882</a>
              from <span class="vcard"><a class="email" href="mailto:sukolsak&#64;gmail.com" title="Sukolsak Sakshuwong &lt;sukolsak&#64;gmail.com&gt;"> <span class="fn">Sukolsak Sakshuwong</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=148882#c3">comment #3</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=260730&amp;action=diff" name="attach_260730" title="Patch">attachment 260730</a> <a href="attachment.cgi?id=260730&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=260730&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=260730&amp;action=review</a>
&gt; 
&gt; r=me
&gt; 
&gt; &gt; Source/JavaScriptCore/tests/stress/wasm-arithmetic.js:45
&gt; &gt; +        return (6 * 7) | 0;
&gt; 
&gt; What's stopping the WASM compiler from just constant folding this operation
&gt; and just returning a constant (thereby defeating this test)?  Why not pass
&gt; the values into the test functions as arguments?  Unless there's a reason to
&gt; not do so, please pass the args in to the test instead.  I'm fine with doing
&gt; a follow up patch to update all the tests to do this.</span >

pack-asmjs does not do constant folding. (I don't think they will ever do it. Optimization of asm.js should be done by Emscripten's.) But I will do it to be future-proof. It should also make the code easier to read.

<span class="quote">&gt; &gt; Source/JavaScriptCore/tests/stress/wasm-arithmetic.js:192
&gt; &gt; +shouldBe(module.multiplyOverflow(), -2147483648);
&gt; 
&gt; What does it mean to multiplyOverflow?  Does WASM require that we overflow
&gt; silently?</span >

multiplyOverflow = the result from multiplication is larger than INT32_MAX. The WASM spec says &quot;Sign-agnostic operations silently wrap overflowing results into the result type.&quot; It also says that multiplication on 32-bit integers is a sign-agnostic operation. &lt;<a href="https://github.com/WebAssembly/design/blob/master/AstSemantics.md">https://github.com/WebAssembly/design/blob/master/AstSemantics.md</a>&gt;</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>