Changeset 187531 in webkit
- Timestamp:
- Jul 28, 2015 5:55:17 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r187515 r187531 412 412 413 413 wasm/JSWASMModule.cpp 414 wasm/WASMModuleParser.cpp 415 wasm/WASMReader.cpp 414 416 415 417 yarr/RegularExpression.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r187529 r187531 1 2015-07-28 Sukolsak Sakshuwong <sukolsak@gmail.com> 2 3 Implement WebAssembly module parser 4 https://bugs.webkit.org/show_bug.cgi?id=147293 5 6 Reviewed by Geoffrey Garen. 7 8 Implement WebAssembly module parser for WebAssembly files produced by pack-asmjs 9 <https://github.com/WebAssembly/polyfill-prototype-1>. This patch only checks 10 the magic number at the beginning of the files. Parsing of the rest will be 11 implemented in a subsequent patch. 12 13 * CMakeLists.txt: 14 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 15 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 16 * JavaScriptCore.xcodeproj/project.pbxproj: 17 * jsc.cpp: 18 (GlobalObject::finishCreation): 19 (functionLoadWebAssembly): 20 * parser/SourceProvider.h: 21 (JSC::WebAssemblySourceProvider::create): 22 (JSC::WebAssemblySourceProvider::data): 23 (JSC::WebAssemblySourceProvider::WebAssemblySourceProvider): 24 * runtime/JSGlobalObject.cpp: 25 (JSC::JSGlobalObject::init): 26 (JSC::JSGlobalObject::visitChildren): 27 * runtime/JSGlobalObject.h: 28 (JSC::JSGlobalObject::wasmModuleStructure): 29 * wasm/WASMMagicNumber.h: Added. 30 * wasm/WASMModuleParser.cpp: Added. 31 (JSC::WASMModuleParser::WASMModuleParser): 32 (JSC::WASMModuleParser::parse): 33 (JSC::WASMModuleParser::parseModule): 34 (JSC::parseWebAssembly): 35 * wasm/WASMModuleParser.h: Added. 36 * wasm/WASMReader.cpp: Added. 37 (JSC::WASMReader::readUnsignedInt32): 38 (JSC::WASMReader::readFloat): 39 (JSC::WASMReader::readDouble): 40 * wasm/WASMReader.h: Added. 41 (JSC::WASMReader::WASMReader): 42 1 43 2015-07-28 Yusuke Suzuki <utatane.tea@gmail.com> 2 44 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r187515 r187531 869 869 <ClCompile Include="..\tools\JSDollarVMPrototype.cpp" /> 870 870 <ClCompile Include="..\wasm\JSWASMModule.cpp" /> 871 <ClCompile Include="..\wasm\WASMModuleParser.cpp" /> 872 <ClCompile Include="..\wasm\WASMReader.cpp" /> 871 873 <ClCompile Include="..\yarr\RegularExpression.cpp" /> 872 874 <ClCompile Include="..\yarr\YarrCanonicalizeUCS2.cpp" /> … … 1735 1737 <ClInclude Include="..\tools\TieredMMapArray.h" /> 1736 1738 <ClInclude Include="..\wasm\JSWASMModule.h" /> 1739 <ClInclude Include="..\wasm\WASMMagicNumber.h" /> 1740 <ClInclude Include="..\wasm\WASMModuleParser.h" /> 1741 <ClInclude Include="..\wasm\WASMReader.h" /> 1737 1742 <ClInclude Include="..\yarr\RegularExpression.h" /> 1738 1743 <ClInclude Include="..\yarr\Yarr.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r187515 r187531 1798 1798 <Filter>wasm</Filter> 1799 1799 </ClCompile> 1800 <ClCompile Include="..\wasm\WASMModuleParser.cpp"> 1801 <Filter>wasm</Filter> 1802 </ClCompile> 1803 <ClCompile Include="..\wasm\WASMReader.cpp"> 1804 <Filter>wasm</Filter> 1805 </ClCompile> 1800 1806 </ItemGroup> 1801 1807 <ItemGroup> … … 4302 4308 <Filter>wasm</Filter> 4303 4309 </ClInclude> 4310 <ClInclude Include="..\wasm\WASMMagicNumber.h"> 4311 <Filter>wasm</Filter> 4312 </ClInclude> 4313 <ClInclude Include="..\wasm\WASMModuleParser.h"> 4314 <Filter>wasm</Filter> 4315 </ClInclude> 4316 <ClInclude Include="..\wasm\WASMReader.h"> 4317 <Filter>wasm</Filter> 4318 </ClInclude> 4304 4319 </ItemGroup> 4305 4320 <ItemGroup> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r187515 r187531 1022 1022 79EE0BFF1B4AFB85000385C9 /* VariableEnvironment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */; }; 1023 1023 79EE0C001B4AFB85000385C9 /* VariableEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1024 7B39F76D1B62DE2E00360FB4 /* WASMModuleParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */; }; 1025 7B39F76E1B62DE3200360FB4 /* WASMModuleParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1026 7B39F7701B62DE3200360FB4 /* WASMReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B39F76C1B62DE2200360FB4 /* WASMReader.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1027 7B39F7721B63574D00360FB4 /* WASMReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B39F7711B63574B00360FB4 /* WASMReader.cpp */; }; 1028 7B7A5E271B68288C0027CAD0 /* WASMMagicNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1024 1029 7B98D1361B60CD5F0023B1A4 /* JSWASMModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */; }; 1025 1030 7B98D1371B60CD620023B1A4 /* JSWASMModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2770 2775 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VariableEnvironment.cpp; sourceTree = "<group>"; }; 2771 2776 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VariableEnvironment.h; sourceTree = "<group>"; }; 2777 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMModuleParser.cpp; sourceTree = "<group>"; }; 2778 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMModuleParser.h; sourceTree = "<group>"; }; 2779 7B39F76C1B62DE2200360FB4 /* WASMReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMReader.h; sourceTree = "<group>"; }; 2780 7B39F7711B63574B00360FB4 /* WASMReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMReader.cpp; sourceTree = "<group>"; }; 2781 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMMagicNumber.h; sourceTree = "<group>"; }; 2772 2782 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWASMModule.cpp; sourceTree = "<group>"; }; 2773 2783 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWASMModule.h; sourceTree = "<group>"; }; … … 4308 4318 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */, 4309 4319 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */, 4320 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */, 4321 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */, 4322 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */, 4323 7B39F7711B63574B00360FB4 /* WASMReader.cpp */, 4324 7B39F76C1B62DE2200360FB4 /* WASMReader.h */, 4310 4325 ); 4311 4326 path = wasm; … … 6215 6230 0F2B66F517B6B5AB00A7AE3F /* JSGenericTypedArrayViewPrototype.h in Headers */, 6216 6231 0F2B66F617B6B5AB00A7AE3F /* JSGenericTypedArrayViewPrototypeInlines.h in Headers */, 6232 7B39F76E1B62DE3200360FB4 /* WASMModuleParser.h in Headers */, 6217 6233 BC18C4210E16F5CD00B34460 /* JSGlobalObject.h in Headers */, 6218 6234 A5FD0086189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h in Headers */, … … 6426 6442 0FF7168C15A3B235008F5DAA /* PropertyOffset.h in Headers */, 6427 6443 A785F6BC18C553FE00F10626 /* SpillRegistersMode.h in Headers */, 6444 7B7A5E271B68288C0027CAD0 /* WASMMagicNumber.h in Headers */, 6428 6445 BC18C4550E16F5CD00B34460 /* PropertySlot.h in Headers */, 6429 6446 0FB7F39C15ED8E4600F167B2 /* PropertyStorage.h in Headers */, … … 6559 6576 A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */, 6560 6577 0F2E892C16D028AD009E4FD2 /* UnusedPointer.h in Headers */, 6578 7B39F7701B62DE3200360FB4 /* WASMReader.h in Headers */, 6561 6579 0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */, 6562 6580 0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */, … … 7193 7211 0F9D36941AE9CC33000D4DFB /* DFGCleanUpPhase.cpp in Sources */, 7194 7212 A7D89CF717A0B8CC00773AD8 /* DFGFlushFormat.cpp in Sources */, 7213 7B39F76D1B62DE2E00360FB4 /* WASMModuleParser.cpp in Sources */, 7195 7214 0F3A1BF91A9ECB7D000DE01A /* DFGPutStackSinkingPhase.cpp in Sources */, 7196 7215 86EC9DC71328DF82002B2AD7 /* DFGGraph.cpp in Sources */, … … 7607 7626 62D2D38F1ADF103F000206C1 /* FunctionRareData.cpp in Sources */, 7608 7627 0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */, 7628 7B39F7721B63574D00360FB4 /* WASMReader.cpp in Sources */, 7609 7629 1429D8850ED21C3D00B89619 /* SamplingTool.cpp in Sources */, 7610 7630 70EC0EC61AA0D7DA00B6AAFA /* StringIteratorPrototype.cpp in Sources */, -
trunk/Source/JavaScriptCore/jsc.cpp
r187139 r187531 44 44 #include "JSProxy.h" 45 45 #include "JSString.h" 46 #include "JSWASMModule.h" 46 47 #include "ProfilerDatabase.h" 47 48 #include "SamplingTool.h" … … 51 52 #include "TestRunnerUtils.h" 52 53 #include "TypeProfilerLog.h" 54 #include "WASMModuleParser.h" 53 55 #include <math.h> 54 56 #include <stdio.h> … … 493 495 static EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState*); 494 496 static EncodedJSValue JSC_HOST_CALL functionEnableExceptionFuzz(ExecState*); 497 #if ENABLE(WEBASSEMBLY) 498 static EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState*); 499 #endif 495 500 496 501 #if ENABLE(SAMPLING_FLAGS) … … 656 661 addFunction(vm, "enableExceptionFuzz", functionEnableExceptionFuzz, 0); 657 662 663 #if ENABLE(WEBASSEMBLY) 664 addFunction(vm, "loadWebAssembly", functionLoadWebAssembly, 1); 665 #endif 666 658 667 JSArray* array = constructEmptyArray(globalExec(), 0); 659 668 for (size_t i = 0; i < arguments.size(); ++i) … … 1183 1192 return JSValue::encode(jsUndefined()); 1184 1193 } 1194 1195 #if ENABLE(WEBASSEMBLY) 1196 EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState* exec) 1197 { 1198 String fileName = exec->argument(0).toString(exec)->value(exec); 1199 Vector<char> buffer; 1200 if (!fillBufferWithContentsOfFile(fileName, buffer)) 1201 return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Could not open file.")))); 1202 RefPtr<WebAssemblySourceProvider> sourceProvider = WebAssemblySourceProvider::create(reinterpret_cast<Vector<uint8_t>&>(buffer), fileName); 1203 SourceCode source(sourceProvider); 1204 String errorMessage; 1205 JSWASMModule* module = parseWebAssembly(exec, source, errorMessage); 1206 if (!module) 1207 return JSValue::encode(exec->vm().throwException(exec, createSyntaxError(exec, errorMessage))); 1208 return JSValue::encode(module); 1209 } 1210 #endif 1185 1211 1186 1212 // Use SEH for Release builds only to get rid of the crash report dialog -
trunk/Source/JavaScriptCore/parser/SourceProvider.h
r185346 r187531 95 95 }; 96 96 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 97 128 } // namespace JSC 98 129 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r187515 r187531 93 93 #include "JSTypedArrayPrototypes.h" 94 94 #include "JSTypedArrays.h" 95 #include "JSWASMModule.h" 95 96 #include "JSWeakMap.h" 96 97 #include "JSWeakSet.h" … … 341 342 m_promiseStructure.set(vm, this, JSPromise::createStructure(vm, this, m_promisePrototype.get())); 342 343 344 #if ENABLE(WEBASSEMBLY) 345 m_wasmModuleStructure.set(vm, this, JSWASMModule::createStructure(vm, this)); 346 #endif 347 343 348 m_parseIntFunction.set(vm, this, JSFunction::create(vm, this, 2, vm.propertyNames->parseInt.string(), globalFuncParseInt, NoIntrinsic)); 344 349 putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum | Function); … … 802 807 visitor.append(&thisObject->m_internalFunctionStructure); 803 808 visitor.append(&thisObject->m_promiseStructure); 809 #if ENABLE(WEBASSEMBLY) 810 visitor.append(&thisObject->m_wasmModuleStructure); 811 #endif 804 812 805 813 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \ -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r187515 r187531 244 244 WriteBarrier<Structure> m_regExpMatchesArrayStructure; 245 245 WriteBarrier<Structure> m_promiseStructure; 246 #if ENABLE(WEBASSEMBLY) 247 WriteBarrier<Structure> m_wasmModuleStructure; 248 #endif 246 249 247 250 #define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \ … … 476 479 Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); } 477 480 Structure* promiseStructure() const { return m_promiseStructure.get(); } 481 #if ENABLE(WEBASSEMBLY) 482 Structure* wasmModuleStructure() const { return m_wasmModuleStructure.get(); } 483 #endif 478 484 479 485 JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool);
Note: See TracChangeset
for help on using the changeset viewer.