<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Implement WebAssembly module parser"
   href="https://bugs.webkit.org/show_bug.cgi?id=147293#c29">Comment # 29</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Implement WebAssembly module parser"
   href="https://bugs.webkit.org/show_bug.cgi?id=147293">bug 147293</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=147293#c28">comment #28</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=257894&amp;action=diff" name="attach_257894" title="Patch">attachment 257894</a> <a href="attachment.cgi?id=257894&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=257894&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=257894&amp;action=review</a>
&gt; 
&gt; &gt; Source/JavaScriptCore/wasm/WASMReader.cpp:38
&gt; &gt; +    result = m_cursor[0] | m_cursor[1] &lt;&lt; 8 | m_cursor[2] &lt;&lt; 16 | m_cursor[3] &lt;&lt; 24;
&gt; 
&gt; Out of curiosity, why does byte order not matter here but matter below?</span >

Because the shift operator takes care of that. Say, m_cursor[0] = A, m_cursor[1] = B, m_cursor[2] = C, and m_cursor[3] = D.

On a little-endian machine,
A       = A 0 0 0
B &lt;&lt; 8  = 0 B 0 0
C &lt;&lt; 16 = 0 0 C 0
D &lt;&lt; 24 = 0 0 0 D
result  = A B C D

On a big-endian machine,
A       = 0 0 0 A
B &lt;&lt; 8  = 0 0 B 0
C &lt;&lt; 16 = 0 C 0 0
D &lt;&lt; 24 = D 0 0 0
result  = D C B A

which is as it should be.

<span class="quote">&gt; Also, does WASM follow network byte order?</span >

The binary format hasn't been standardized yet. We are using the file format of an experimental WebAssembly polyfill &lt;<a href="https://github.com/WebAssembly/polyfill-prototype-1">https://github.com/WebAssembly/polyfill-prototype-1</a>&gt;, which uses the little endian format.</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>