[Webkit-unassigned] [Bug 147293] Implement WebAssembly module parser

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jul 31 01:04:21 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=147293

--- Comment #29 from Sukolsak Sakshuwong <sukolsak at gmail.com> ---
(In reply to comment #28)
> Comment on attachment 257894 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=257894&action=review
> 
> > Source/JavaScriptCore/wasm/WASMReader.cpp:38
> > +    result = m_cursor[0] | m_cursor[1] << 8 | m_cursor[2] << 16 | m_cursor[3] << 24;
> 
> Out of curiosity, why does byte order not matter here but matter below?

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 << 8  = 0 B 0 0
C << 16 = 0 0 C 0
D << 24 = 0 0 0 D
result  = A B C D

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

which is as it should be.

> Also, does WASM follow network byte order?

The binary format hasn't been standardized yet. We are using the file format of an experimental WebAssembly polyfill <https://github.com/WebAssembly/polyfill-prototype-1>, which uses the little endian format.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150731/27d36dd1/attachment-0001.html>


More information about the webkit-unassigned mailing list