Ignore:
Timestamp:
Jul 31, 2015, 1:34:50 PM (10 years ago)
Author:
[email protected]
Message:

Implement WebAssembly module parser
https://bugs.webkit.org/show_bug.cgi?id=147293

Patch by Sukolsak Sakshuwong <Sukolsak Sakshuwong> on 2015-07-31
Reviewed by Mark Lam.

Re-landing after fix for the "..\..\jsc.cpp(46): fatal error C1083: Cannot open
include file: 'JSWASMModule.h'" issue on Windows.

Implement WebAssembly module parser for WebAssembly files produced by pack-asmjs
<https://github.com/WebAssembly/polyfill-prototype-1>. This patch only checks
the magic number at the beginning of the files. Parsing of the rest will be
implemented in a subsequent patch.

(GlobalObject::finishCreation):
(functionLoadWebAssembly):

  • parser/SourceProvider.h:

(JSC::WebAssemblySourceProvider::create):
(JSC::WebAssemblySourceProvider::data):
(JSC::WebAssemblySourceProvider::WebAssemblySourceProvider):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::wasmModuleStructure):

  • wasm/WASMMagicNumber.h: Added.
  • wasm/WASMModuleParser.cpp: Added.

(JSC::WASMModuleParser::WASMModuleParser):
(JSC::WASMModuleParser::parse):
(JSC::WASMModuleParser::parseModule):
(JSC::parseWebAssembly):

  • wasm/WASMModuleParser.h: Added.
  • wasm/WASMReader.cpp: Added.

(JSC::WASMReader::readUnsignedInt32):
(JSC::WASMReader::readFloat):
(JSC::WASMReader::readDouble):

  • wasm/WASMReader.h: Added.

(JSC::WASMReader::WASMReader):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceProvider.h

    r187560 r187677  
    9595    };
    9696   
     97#if ENABLE(WEBASSEMBLY)
     98    class WebAssemblySourceProvider : public SourceProvider {
     99    public:
     100        static Ref<WebAssemblySourceProvider> create(const Vector<uint8_t>& data, const String& url)
     101        {
     102            return adoptRef(*new WebAssemblySourceProvider(data, url));
     103        }
     104
     105        virtual const String& source() const override
     106        {
     107            return m_source;
     108        }
     109
     110        const Vector<uint8_t>& data() const
     111        {
     112            return m_data;
     113        }
     114
     115    private:
     116        WebAssemblySourceProvider(const Vector<uint8_t>& data, const String& url)
     117            : SourceProvider(url, TextPosition::minimumPosition())
     118            , m_source("[WebAssembly source]")
     119            , m_data(data)
     120        {
     121        }
     122
     123        String m_source;
     124        Vector<uint8_t> m_data;
     125    };
     126#endif
     127
    97128} // namespace JSC
    98129
Note: See TracChangeset for help on using the changeset viewer.