Changeset 216597 in webkit
- Timestamp:
- May 10, 2017 11:15:17 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 19 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r216593 r216597 1 2017-05-10 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: support name section 4 https://bugs.webkit.org/show_bug.cgi?id=171263 5 6 Reviewed by Keith Miller. 7 8 * wasm/function-tests/nameSection.js: Added. 9 (const.compile): 10 * wasm/function-tests/nameSection.wasm: Added. 11 * wasm/function-tests/stack-trace.js: Update format 12 1 13 2017-05-10 Filip Pizlo <fpizlo@apple.com> 2 14 -
trunk/JSTests/wasm/function-tests/stack-trace.js
r215854 r216597 48 48 assert(stacktrace[0].indexOf("imp") !== -1); // the arrow function import named "imp". 49 49 assert(stacktrace[1] === "wasm function@[wasm code]"); // the wasm->js stub 50 assert(stacktrace[2] === "wasm function index: 4@[wasm code]");51 assert(stacktrace[3] === "wasm function index: 2@[wasm code]");52 assert(stacktrace[4] === "wasm function index: 3@[wasm code]");53 assert(stacktrace[5] === "wasm function index: 1@[wasm code]");50 assert(stacktrace[2] === "wasm function: 4@[wasm code]"); 51 assert(stacktrace[3] === "wasm function: 2@[wasm code]"); 52 assert(stacktrace[4] === "wasm function: 3@[wasm code]"); 53 assert(stacktrace[5] === "wasm function: 1@[wasm code]"); 54 54 assert(stacktrace[6] === "wasm function@[wasm code]"); // wasm entry 55 55 -
trunk/Source/JavaScriptCore/CMakeLists.txt
r216481 r216597 952 952 wasm/WasmFaultSignalHandler.cpp 953 953 wasm/WasmFormat.cpp 954 wasm/WasmIndexOrName.cpp 954 955 wasm/WasmMachineThreads.cpp 955 956 wasm/WasmMemory.cpp … … 958 959 wasm/WasmModuleInformation.cpp 959 960 wasm/WasmModuleParser.cpp 961 wasm/WasmNameSectionParser.cpp 960 962 wasm/WasmOMGPlan.cpp 961 963 wasm/WasmOpcodeOrigin.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r216593 r216597 1 2017-05-10 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: support name section 4 5 https://bugs.webkit.org/show_bug.cgi?id=171263 6 7 Reviewed by Keith Miller. 8 9 The name section is an optional custom section in the WebAssembly 10 spec. At least when debugging, developers expect to be able to use 11 this section to obtain intelligible stack traces, otherwise we 12 just number the wasm functions which is somewhat painful. 13 14 This patch parses this section, dropping its content eagerly on 15 error, and if there is a name section then backtraces use their 16 value instead of numbers. Otherwise we stick to numbers as before. 17 18 Note that the format of name sections changed in mid-February: 19 https://github.com/WebAssembly/design/pull/984 20 And binaryen was only updated in early March: 21 https://github.com/WebAssembly/binaryen/pull/933 22 23 * CMakeLists.txt: 24 * JavaScriptCore.xcodeproj/project.pbxproj: 25 * interpreter/Interpreter.cpp: 26 (JSC::GetStackTraceFunctor::operator()): 27 * interpreter/StackVisitor.cpp: 28 (JSC::StackVisitor::readNonInlinedFrame): 29 (JSC::StackVisitor::Frame::functionName): 30 * interpreter/StackVisitor.h: 31 (JSC::StackVisitor::Frame::wasmFunctionIndexOrName): 32 * runtime/StackFrame.cpp: 33 (JSC::StackFrame::functionName): 34 * runtime/StackFrame.h: 35 (JSC::StackFrame::StackFrame): 36 (JSC::StackFrame::wasm): 37 * wasm/WasmBBQPlanInlines.h: 38 (JSC::Wasm::BBQPlan::initializeCallees): 39 * wasm/WasmCallee.cpp: 40 (JSC::Wasm::Callee::Callee): 41 * wasm/WasmCallee.h: 42 (JSC::Wasm::Callee::create): 43 (JSC::Wasm::Callee::indexOrName): 44 * wasm/WasmFormat.cpp: 45 (JSC::Wasm::makeString): 46 * wasm/WasmFormat.h: 47 (JSC::Wasm::isValidExternalKind): 48 (JSC::Wasm::isValidNameType): 49 (JSC::Wasm::NameSection::get): 50 * wasm/WasmIndexOrName.cpp: Copied from Source/JavaScriptCore/wasm/WasmCallee.cpp. 51 (JSC::Wasm::IndexOrName::IndexOrName): 52 (JSC::Wasm::makeString): 53 * wasm/WasmIndexOrName.h: Copied from Source/JavaScriptCore/wasm/WasmFormat.cpp. 54 * wasm/WasmModuleInformation.h: 55 * wasm/WasmModuleParser.cpp: 56 * wasm/WasmName.h: Copied from Source/JavaScriptCore/wasm/WasmCallee.cpp. 57 * wasm/WasmNameSectionParser.cpp: Added. 58 * wasm/WasmNameSectionParser.h: Copied from Source/JavaScriptCore/wasm/WasmCallee.cpp. 59 (JSC::Wasm::NameSectionParser::NameSectionParser): 60 * wasm/WasmOMGPlan.cpp: 61 (JSC::Wasm::OMGPlan::work): 62 * wasm/WasmParser.h: 63 (JSC::Wasm::Parser<SuccessType>::consumeUTF8String): 64 1 65 2017-05-10 Filip Pizlo <fpizlo@apple.com> 2 66 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r216481 r216597 2146 2146 AD4B1DF91DF244E20071AE32 /* WasmBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */; }; 2147 2147 AD4B1DFA1DF244E20071AE32 /* WasmBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4B1DF81DF244D70071AE32 /* WasmBinding.h */; }; 2148 AD5B416F1EBAFB77008EFA43 /* WasmName.h in Headers */ = {isa = PBXBuildFile; fileRef = AD5B416E1EBAFB65008EFA43 /* WasmName.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2148 2149 AD7438C01E0457A400FD0C2A /* WasmSignature.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7438BF1E04579200FD0C2A /* WasmSignature.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2149 2150 AD7438C11E0457AA00FD0C2A /* WasmSignature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */; }; 2150 2151 AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2152 AD8FF3971EB5BDA80087FF82 /* WasmIndexOrName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */; }; 2153 AD8FF3981EB5BDB20087FF82 /* WasmIndexOrName.h in Headers */ = {isa = PBXBuildFile; fileRef = AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2151 2154 AD9E852F1E8A0C7C008DE39E /* JSWebAssemblyCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2152 2155 ADB6F67D1E15D7600082F384 /* WasmPageCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */; }; 2153 2156 ADBC54D41DF8EA2B005BF738 /* WebAssemblyToJSCallee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADBC54D21DF8EA00005BF738 /* WebAssemblyToJSCallee.cpp */; }; 2154 2157 ADBC54D51DF8EA2B005BF738 /* WebAssemblyToJSCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = ADBC54D31DF8EA00005BF738 /* WebAssemblyToJSCallee.h */; }; 2158 ADD8FA451EB3078E00DF542F /* WasmNameSectionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */; }; 2159 ADD8FA461EB3079700DF542F /* WasmNameSectionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */; }; 2155 2160 ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2156 2161 ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; }; … … 4774 4779 AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmBinding.cpp; sourceTree = "<group>"; }; 4775 4780 AD4B1DF81DF244D70071AE32 /* WasmBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmBinding.h; sourceTree = "<group>"; }; 4781 AD5B416E1EBAFB65008EFA43 /* WasmName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmName.h; sourceTree = "<group>"; }; 4776 4782 AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmSignature.cpp; sourceTree = "<group>"; }; 4777 4783 AD7438BF1E04579200FD0C2A /* WasmSignature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmSignature.h; sourceTree = "<group>"; }; 4778 4784 AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; }; 4785 AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmIndexOrName.h; sourceTree = "<group>"; }; 4786 AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmIndexOrName.cpp; sourceTree = "<group>"; }; 4779 4787 AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyCodeBlock.h; path = js/JSWebAssemblyCodeBlock.h; sourceTree = "<group>"; }; 4780 4788 ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPageCount.cpp; sourceTree = "<group>"; }; 4781 4789 ADBC54D21DF8EA00005BF738 /* WebAssemblyToJSCallee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyToJSCallee.cpp; path = js/WebAssemblyToJSCallee.cpp; sourceTree = "<group>"; }; 4782 4790 ADBC54D31DF8EA00005BF738 /* WebAssemblyToJSCallee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyToJSCallee.h; path = js/WebAssemblyToJSCallee.h; sourceTree = "<group>"; }; 4791 ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmNameSectionParser.h; sourceTree = "<group>"; }; 4792 ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmNameSectionParser.cpp; sourceTree = "<group>"; }; 4783 4793 ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; }; 4784 4794 ADE802931E08F1C90058DE78 /* JSWebAssemblyLinkError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyLinkError.cpp; path = js/JSWebAssemblyLinkError.cpp; sourceTree = "<group>"; }; … … 6410 6420 AD412B321E7B2E8A008AF157 /* WasmContext.h */, 6411 6421 79DAE2791E03C82200B526AA /* WasmExceptionType.h */, 6422 5381B9361E60E9660090F794 /* WasmFaultSignalHandler.cpp */, 6423 5381B9381E60E97D0090F794 /* WasmFaultSignalHandler.h */, 6412 6424 AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */, 6413 6425 7BC547D21B69599B00959B58 /* WasmFormat.h */, 6414 6426 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */, 6427 AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */, 6428 AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */, 6415 6429 53E9E0A91EAE83DE00FEE251 /* WasmMachineThreads.cpp */, 6416 6430 53E9E0AA1EAE83DE00FEE251 /* WasmMachineThreads.h */, 6417 790081361E95A8EC0052D7CD /* WasmModule.cpp */,6418 790081371E95A8EC0052D7CD /* WasmModule.h */,6419 6431 535557151D9DFA32006D583B /* WasmMemory.cpp */, 6420 6432 535557131D9D9EA5006D583B /* WasmMemory.h */, 6421 6433 79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */, 6422 6434 79B759721DFA4C600052174C /* WasmMemoryInformation.h */, 6435 790081361E95A8EC0052D7CD /* WasmModule.cpp */, 6436 790081371E95A8EC0052D7CD /* WasmModule.h */, 6423 6437 53E777E11E92E265007CBEC4 /* WasmModuleInformation.cpp */, 6424 6438 53E777E21E92E265007CBEC4 /* WasmModuleInformation.h */, 6425 6439 53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */, 6426 6440 53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */, 6441 AD5B416E1EBAFB65008EFA43 /* WasmName.h */, 6442 ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */, 6443 ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */, 6427 6444 5311BD481EA581E500525281 /* WasmOMGPlan.cpp */, 6428 6445 5311BD491EA581E500525281 /* WasmOMGPlan.h */, 6429 ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */,6430 5381B9361E60E9660090F794 /* WasmFaultSignalHandler.cpp */,6431 5381B9381E60E97D0090F794 /* WasmFaultSignalHandler.h */,6432 6446 53C6FEF01E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp */, 6433 6447 53C6FEEE1E8ADFA900B18425 /* WasmOpcodeOrigin.h */, 6448 ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */, 6434 6449 79B759731DFA4C600052174C /* WasmPageCount.h */, 6435 6450 53F40E8C1D5901F20099A1B6 /* WasmParser.h */, … … 8218 8233 0F40E4A71C497F7400A577FA /* AirOpcode.h in Headers */, 8219 8234 0F40E4A81C497F7400A577FA /* AirOpcodeGenerated.h in Headers */, 8235 AD8FF3981EB5BDB20087FF82 /* WasmIndexOrName.h in Headers */, 8220 8236 0F40E4A91C497F7400A577FA /* AirOpcodeUtils.h in Headers */, 8221 8237 0FB387901BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h in Headers */, … … 8336 8352 0F4C91661C29F4F2004341A6 /* B3OriginDump.h in Headers */, 8337 8353 0FEC85261BDACDAC0080FF74 /* B3PatchpointSpecial.h in Headers */, 8354 ADD8FA461EB3079700DF542F /* WasmNameSectionParser.h in Headers */, 8338 8355 0FEC85281BDACDAC0080FF74 /* B3PatchpointValue.h in Headers */, 8339 8356 799EF7C41C56ED96002B0534 /* B3PCToOriginMap.h in Headers */, … … 8655 8672 79FC8A081E32E9F000D88F0E /* DFGRegisteredStructure.h in Headers */, 8656 8673 7980C16D1E3A940E00B71615 /* DFGRegisteredStructureSet.h in Headers */, 8674 AD5B416F1EBAFB77008EFA43 /* WasmName.h in Headers */, 8657 8675 0F2FCCFC18A60070001A27F8 /* DFGSafepoint.h in Headers */, 8658 8676 A77A424317A0BBFD00A8DB81 /* DFGSafeToExecute.h in Headers */, … … 10984 11002 0FE0502C1AA9095600D33B33 /* VarOffset.cpp in Sources */, 10985 11003 0F20C2591A8013AB00DA3229 /* VirtualRegister.cpp in Sources */, 11004 AD8FF3971EB5BDA80087FF82 /* WasmIndexOrName.cpp in Sources */, 10986 11005 0F952AA21DF7860D00E06FBD /* VisitRaceKey.cpp in Sources */, 10987 11006 E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */, … … 11040 11059 86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */, 11041 11060 86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */, 11061 ADD8FA451EB3078E00DF542F /* WasmNameSectionParser.cpp in Sources */, 11042 11062 321D9E4CFB67423A97F191A7 /* ModuleNamespaceAccessCase.cpp in Sources */, 11043 11063 ); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r216428 r216597 481 481 if (m_remainingCapacityForFrameCapture) { 482 482 if (visitor->isWasmFrame()) { 483 std::optional<unsigned> wasmFunctionIndex = visitor->wasmFunctionIndex(); 484 m_results.append(StackFrame::wasm(wasmFunctionIndex ? *wasmFunctionIndex : StackFrame::invalidWasmIndex)); 483 m_results.append(StackFrame::wasm(visitor->wasmFunctionIndexOrName())); 485 484 } else if (!!visitor->codeBlock() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) { 486 485 m_results.append( -
trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp
r215854 r216597 33 33 #include "JSCInlines.h" 34 34 #include "WasmCallee.h" 35 #include "WasmIndexOrName.h" 35 36 #include <wtf/text/StringBuilder.h> 36 37 … … 167 168 CalleeBits bits = callFrame->callee(); 168 169 if (bits.isWasm()) 169 m_frame.m_wasmFunctionIndex = bits.asWasmCallee()->index();170 m_frame.m_wasmFunctionIndexOrName = bits.asWasmCallee()->indexOrName(); 170 171 #endif 171 172 } else { … … 284 285 switch (codeType()) { 285 286 case CodeType::Wasm: 286 if (m_wasmFunctionIndex )287 traceLine = makeString("wasm function index: ", String::number(*m_wasmFunctionIndex));287 if (m_wasmFunctionIndexOrName.isEmpty()) 288 traceLine = makeString("wasm function"); 288 289 else 289 traceLine = ASCIILiteral("wasm function");290 traceLine = makeString("wasm function: ", makeString(m_wasmFunctionIndexOrName)); 290 291 break; 291 292 case CodeType::Eval: -
trunk/Source/JavaScriptCore/interpreter/StackVisitor.h
r215854 r216597 28 28 #include "CalleeBits.h" 29 29 #include "VMEntryRecord.h" 30 #include "WasmIndexOrName.h" 30 31 #include <functional> 31 32 #include <wtf/Indenter.h> … … 78 79 bool isInlinedFrame() const { return !!inlineCallFrame(); } 79 80 bool isWasmFrame() const; 80 std::optional<unsigned> const wasmFunctionIndex()81 Wasm::IndexOrName const wasmFunctionIndexOrName() 81 82 { 82 83 ASSERT(isWasmFrame()); 83 return m_wasmFunctionIndex ;84 return m_wasmFunctionIndexOrName; 84 85 } 85 86 … … 122 123 size_t m_argumentCountIncludingThis; 123 124 unsigned m_bytecodeOffset; 124 std::optional<unsigned> m_wasmFunctionIndex;125 Wasm::IndexOrName m_wasmFunctionIndexOrName; 125 126 bool m_callerIsVMEntryFrame : 1; 126 127 bool m_isWasmFrame : 1; -
trunk/Source/JavaScriptCore/runtime/StackFrame.cpp
r215854 r216597 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 59 59 { 60 60 if (m_isWasmFrame) { 61 if (m_wasmFunctionIndex == invalidWasmIndex)61 if (m_wasmFunctionIndexOrName.isEmpty()) 62 62 return ASCIILiteral("wasm function"); 63 return makeString("wasm function index: ", String::number(m_wasmFunctionIndex));63 return makeString("wasm function: ", makeString(m_wasmFunctionIndexOrName)); 64 64 } 65 65 -
trunk/Source/JavaScriptCore/runtime/StackFrame.h
r215854 r216597 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include "Strong.h" 29 #include "WasmIndexOrName.h" 29 30 #include <limits.h> 30 31 … … 36 37 class StackFrame { 37 38 public: 38 StackFrame() = default; 39 StackFrame() 40 : m_bytecodeOffset(UINT_MAX) 41 { } 39 42 40 43 StackFrame(VM& vm, JSCell* callee) … … 49 52 { } 50 53 51 static constexpr unsigned invalidWasmIndex = UINT_MAX; 52 static StackFrame wasm(unsigned index) 54 static StackFrame wasm(Wasm::IndexOrName indexOrName) 53 55 { 54 56 StackFrame result; 55 57 result.m_isWasmFrame = true; 56 result.m_wasmFunctionIndex = index;58 result.m_wasmFunctionIndexOrName = indexOrName; 57 59 return result; 58 60 } … … 79 81 union { 80 82 unsigned m_bytecodeOffset; 81 unsigned m_wasmFunctionIndex;83 Wasm::IndexOrName m_wasmFunctionIndexOrName; 82 84 }; 83 85 bool m_isWasmFrame { false }; -
trunk/Source/JavaScriptCore/wasm/WasmBBQPlanInlines.h
r215854 r216597 44 44 MacroAssembler::repatchPointer(function->jsToWasmCalleeMoveLocation, CalleeBits::boxWasm(jsEntrypointCallee.ptr())); 45 45 46 Ref<Wasm::Callee> wasmEntrypointCallee = Wasm::Callee::create(WTFMove(function->wasmEntrypoint), internalFunctionIndex + m_moduleInformation->importFunctionCount()); 46 size_t functionIndexSpace = internalFunctionIndex + m_moduleInformation->importFunctionCount(); 47 Ref<Wasm::Callee> wasmEntrypointCallee = Wasm::Callee::create(WTFMove(function->wasmEntrypoint), functionIndexSpace, m_moduleInformation->nameSection.get(functionIndexSpace)); 47 48 MacroAssembler::repatchPointer(function->wasmCalleeMoveLocation, CalleeBits::boxWasm(wasmEntrypointCallee.ptr())); 48 49 -
trunk/Source/JavaScriptCore/wasm/WasmCallee.cpp
r215854 r216597 33 33 namespace JSC { namespace Wasm { 34 34 35 Callee::Callee(Entrypoint&& entrypoint , unsigned index)35 Callee::Callee(Entrypoint&& entrypoint) 36 36 : m_entrypoint(WTFMove(entrypoint)) 37 , m_index(index) 37 { 38 registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end()); 39 } 40 41 Callee::Callee(Entrypoint&& entrypoint, size_t index, const Name* name) 42 : m_entrypoint(WTFMove(entrypoint)) 43 , m_indexOrName(index, name) 38 44 { 39 45 registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end()); -
trunk/Source/JavaScriptCore/wasm/WasmCallee.h
r215854 r216597 31 31 #include "RegisterAtOffsetList.h" 32 32 #include "WasmFormat.h" 33 #include "WasmIndexOrName.h" 33 34 #include <wtf/ThreadSafeRefCounted.h> 34 35 … … 38 39 WTF_MAKE_FAST_ALLOCATED; 39 40 public: 41 static Ref<Callee> create(Wasm::Entrypoint&& entrypoint) 42 { 43 Callee* callee = new Callee(WTFMove(entrypoint)); 44 return adoptRef(*callee); 45 } 40 46 41 // We use this when we're the JS entrypoint, we don't ascribe an index to those. 42 static constexpr unsigned invalidCalleeIndex = UINT_MAX; 43 44 static Ref<Callee> create(Wasm::Entrypoint&& entrypoint, unsigned index = invalidCalleeIndex) 47 static Ref<Callee> create(Wasm::Entrypoint&& entrypoint, size_t index, const Name* name) 45 48 { 46 Callee* callee = new Callee(WTFMove(entrypoint), index );49 Callee* callee = new Callee(WTFMove(entrypoint), index, name); 47 50 return adoptRef(*callee); 48 51 } … … 51 54 52 55 RegisterAtOffsetList* calleeSaveRegisters() { return &m_entrypoint.calleeSaveRegisters; } 53 std::optional<unsigned> index() const 54 { 55 if (m_index == invalidCalleeIndex) 56 return std::nullopt; 57 return m_index; 58 } 56 IndexOrName indexOrName() const { return m_indexOrName; } 59 57 60 58 private: 61 JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&, unsigned index); 59 JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&); 60 JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&, size_t, const Name*); 62 61 63 62 Wasm::Entrypoint m_entrypoint; 64 unsigned m_index;63 IndexOrName m_indexOrName; 65 64 }; 66 65 -
trunk/Source/JavaScriptCore/wasm/WasmFormat.cpp
r214919 r216597 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 56 56 } 57 57 58 String makeString(const Vector<LChar>& characters)58 String makeString(const Name& characters) 59 59 { 60 60 String result = String::fromUTF8(characters); -
trunk/Source/JavaScriptCore/wasm/WasmFormat.h
r215843 r216597 34 34 #include "RegisterAtOffsetList.h" 35 35 #include "WasmMemoryInformation.h" 36 #include "WasmName.h" 36 37 #include "WasmOps.h" 37 38 #include "WasmPageCount.h" … … 75 76 76 77 template<typename Int> 77 staticbool isValidExternalKind(Int val)78 inline bool isValidExternalKind(Int val) 78 79 { 79 80 switch (val) { … … 83 84 case static_cast<Int>(ExternalKind::Global): 84 85 return true; 85 default: 86 return false; 87 } 86 } 87 return false; 88 88 } 89 89 … … 106 106 107 107 struct Import { 108 const Vector<LChar>module;109 const Vector<LChar>field;108 const Name module; 109 const Name field; 110 110 ExternalKind kind; 111 111 unsigned kindIndex; // Index in the vector of the corresponding kind. … … 113 113 114 114 struct Export { 115 const Vector<LChar>field;115 const Name field; 116 116 ExternalKind kind; 117 117 unsigned kindIndex; // Index in the vector of the corresponding kind. 118 118 }; 119 119 120 String makeString(const Vector<LChar>& characters);120 String makeString(const Name& characters); 121 121 122 122 struct Global { … … 232 232 233 233 struct CustomSection { 234 Vector<LChar>name;234 Name name; 235 235 Vector<uint8_t> payload; 236 }; 237 238 enum class NameType : uint8_t { 239 Function = 1, 240 Local = 2, 241 }; 242 243 template<typename Int> 244 inline bool isValidNameType(Int val) 245 { 246 switch (val) { 247 case static_cast<Int>(NameType::Function): 248 case static_cast<Int>(NameType::Local): 249 return true; 250 } 251 return false; 252 } 253 254 struct NameSection { 255 Vector<Name> functionNames; 256 const Name* get(size_t functionIndexSpace) 257 { 258 return functionIndexSpace < functionNames.size() ? &functionNames[functionIndexSpace] : nullptr; 259 } 236 260 }; 237 261 -
trunk/Source/JavaScriptCore/wasm/WasmIndexOrName.cpp
r216596 r216597 1 1 /* 2 * Copyright (C) 201 6-2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include "WasmCallee.h" 28 29 #if ENABLE(WEBASSEMBLY) 30 31 #include "WasmFaultSignalHandler.h" 27 #include "WasmIndexOrName.h" 32 28 33 29 namespace JSC { namespace Wasm { 34 30 35 Callee::Callee(Entrypoint&& entrypoint, unsigned index) 36 : m_entrypoint(WTFMove(entrypoint)) 37 , m_index(index) 31 IndexOrName::IndexOrName(Index index, const Name* name) 38 32 { 39 registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end()); 33 static_assert(sizeof(m_index) == sizeof(m_name), "bit-tagging depends on sizes being equal"); 34 static_assert(sizeof(m_index) == sizeof(*this), "bit-tagging depends on object being the size of the union's types"); 35 36 if ((index & allTags) || (bitwise_cast<Index>(name) & allTags)) 37 *this = IndexOrName(); 38 else if (name) 39 m_name = name; 40 else 41 m_index = indexTag | index; 40 42 } 41 43 44 String makeString(const IndexOrName& ion) 45 { 46 if (ion.isEmpty()) 47 return String(); 48 if (ion.isIndex()) 49 return String::number(ion.m_index & ~IndexOrName::indexTag); 50 return String(ion.m_name->data(), ion.m_name->size()); 51 }; 52 42 53 } } // namespace JSC::Wasm 43 44 #endif // ENABLE(WEBASSEMBLY) -
trunk/Source/JavaScriptCore/wasm/WasmIndexOrName.h
r216596 r216597 1 1 /* 2 * Copyright (C) 201 6Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 # include "config.h"26 #pragma once 27 27 28 #include "WasmFormat.h" 29 30 #if ENABLE(WEBASSEMBLY) 31 32 #include "WasmMemory.h" 33 #include <wtf/FastMalloc.h> 28 #include "WasmName.h" 29 #include <wtf/StdLibExtras.h> 30 #include <wtf/text/WTFString.h> 34 31 35 32 namespace JSC { namespace Wasm { 36 33 37 Segment* Segment::create(I32InitExpr offset, uint32_t sizeInBytes) 38 { 39 auto allocated = tryFastCalloc(sizeof(Segment) + sizeInBytes, 1); 40 Segment* segment; 41 if (!allocated.getValue(segment)) 42 return nullptr; 43 segment->offset = offset; 44 segment->sizeInBytes = sizeInBytes; 45 return segment; 46 } 34 struct IndexOrName { 35 typedef size_t Index; 47 36 48 void Segment::destroy(Segment *segment) 49 { 50 fastFree(segment); 51 } 37 IndexOrName() 38 : m_index(emptyTag) 39 { } 40 IndexOrName(Index, const Name*); 41 bool isEmpty() const { return bitwise_cast<Index>(*this) & emptyTag; } 42 bool isIndex() const { return bitwise_cast<Index>(*this) & indexTag; } 43 bool isName() const { return !(isEmpty() || isName()); } 52 44 53 Segment::Ptr Segment::adoptPtr(Segment* segment) 54 { 55 return Ptr(segment, &Segment::destroy); 56 } 45 friend String makeString(const IndexOrName&); 57 46 58 String makeString(const Vector<LChar>& characters) 59 { 60 String result = String::fromUTF8(characters); 61 ASSERT(result); 62 return result; 63 } 47 private: 48 union { 49 Index m_index; 50 const Name* m_name; 51 }; 52 53 // Use the top bits as tags. Neither pointers nor the function index space should use them. 54 static constexpr Index indexTag = 1ull << (CHAR_BIT * sizeof(Index) - 1); 55 static constexpr Index emptyTag = 1ull << (CHAR_BIT * sizeof(Index) - 2); 56 static constexpr Index allTags = indexTag | emptyTag; 57 }; 58 59 String makeString(const IndexOrName&); 64 60 65 61 } } // namespace JSC::Wasm 66 67 #endif // ENABLE(WEBASSEMBLY) -
trunk/Source/JavaScriptCore/wasm/WasmModuleInformation.h
r214919 r216597 75 75 unsigned firstInternalGlobal { 0 }; 76 76 Vector<CustomSection> customSections; 77 77 NameSection nameSection; 78 78 }; 79 79 -
trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp
r214919 r216597 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "IdentifierInlines.h" 32 32 #include "JSWebAssemblyTable.h" 33 #include "WasmFormat.h"34 33 #include "WasmMemoryInformation.h" 34 #include "WasmNameSectionParser.h" 35 35 #include "WasmOps.h" 36 36 #include "WasmSections.h" 37 38 #include <sys/mman.h>39 37 40 38 namespace JSC { namespace Wasm { … … 157 155 uint32_t moduleLen; 158 156 uint32_t fieldLen; 159 Vector<LChar>moduleString;160 Vector<LChar>fieldString;157 Name moduleString; 158 Name fieldString; 161 159 ExternalKind kind; 162 160 unsigned kindIndex { 0 }; … … 369 367 for (uint32_t exportNumber = 0; exportNumber < exportCount; ++exportNumber) { 370 368 uint32_t fieldLen; 371 Vector<LChar>fieldString;369 Name fieldString; 372 370 ExternalKind kind; 373 371 unsigned kindIndex; … … 606 604 section.payload.uncheckedAppend(byte); 607 605 } 608 606 607 Name nameName = { 'n', 'a', 'm', 'e' }; 608 if (section.name == nameName) { 609 NameSectionParser nameSectionParser(section.payload.begin(), section.payload.size(), m_info); 610 if (auto nameSection = nameSectionParser.parse()) 611 m_info->nameSection = WTFMove(*nameSection); 612 } 613 609 614 m_info->customSections.uncheckedAppend(WTFMove(section)); 610 615 -
trunk/Source/JavaScriptCore/wasm/WasmName.h
r216596 r216597 1 1 /* 2 * Copyright (C) 201 6-2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #include "config.h" 27 #include "WasmCallee.h" 26 #pragma once 28 27 29 #if ENABLE(WEBASSEMBLY) 28 #include <wtf/Vector.h> 29 #include <wtf/text/LChar.h> 30 30 31 #include "WasmFaultSignalHandler.h" 31 namespace JSC { 32 32 33 namespace JSC { namespaceWasm {33 namespace Wasm { 34 34 35 Callee::Callee(Entrypoint&& entrypoint, unsigned index) 36 : m_entrypoint(WTFMove(entrypoint)) 37 , m_index(index) 38 { 39 registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end()); 40 } 35 using Name = Vector<LChar>; 41 36 42 37 } } // namespace JSC::Wasm 43 44 #endif // ENABLE(WEBASSEMBLY) -
trunk/Source/JavaScriptCore/wasm/WasmNameSectionParser.h
r216596 r216597 1 1 /* 2 * Copyright (C) 201 6-2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #include "config.h" 27 #include "WasmCallee.h" 26 #pragma once 28 27 29 28 #if ENABLE(WEBASSEMBLY) 30 29 31 #include "WasmFaultSignalHandler.h" 30 #include "WasmFormat.h" 31 #include "WasmParser.h" 32 32 33 33 namespace JSC { namespace Wasm { 34 34 35 Callee::Callee(Entrypoint&& entrypoint, unsigned index) 36 : m_entrypoint(WTFMove(entrypoint)) 37 , m_index(index) 38 { 39 registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end()); 40 } 35 class NameSectionParser : public Parser<NameSection> { 36 public: 37 NameSectionParser(const uint8_t* sourceBuffer, size_t sourceLength, const ModuleInformation& info) 38 : Parser(sourceBuffer, sourceLength) 39 , m_info(info) 40 { 41 } 42 43 Result WARN_UNUSED_RETURN parse(); 44 45 private: 46 const ModuleInformation& m_info; 47 }; 41 48 42 49 } } // namespace JSC::Wasm -
trunk/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp
r215896 r216597 99 99 { 100 100 ASSERT(m_codeBlock.ptr() == m_module->codeBlockFor(mode())); 101 Ref<Callee> callee = Callee::create(WTFMove(omgEntrypoint), functionIndexSpace );101 Ref<Callee> callee = Callee::create(WTFMove(omgEntrypoint), functionIndexSpace, m_moduleInformation->nameSection.get(functionIndexSpace)); 102 102 MacroAssembler::repatchPointer(parseAndCompileResult.value()->wasmCalleeMoveLocation, CalleeBits::boxWasm(callee.ptr())); 103 103 ASSERT(!m_codeBlock->m_optimizedCallees[m_functionIndex]); -
trunk/Source/JavaScriptCore/wasm/WasmParser.h
r214919 r216597 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 63 63 bool WARN_UNUSED_RETURN consumeCharacter(char); 64 64 bool WARN_UNUSED_RETURN consumeString(const char*); 65 bool WARN_UNUSED_RETURN consumeUTF8String( Vector<LChar>&, size_t);65 bool WARN_UNUSED_RETURN consumeUTF8String(Name&, size_t); 66 66 67 67 bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t&); … … 143 143 144 144 template<typename SuccessType> 145 ALWAYS_INLINE bool Parser<SuccessType>::consumeUTF8String( Vector<LChar>& result, size_t stringLength)145 ALWAYS_INLINE bool Parser<SuccessType>::consumeUTF8String(Name& result, size_t stringLength) 146 146 { 147 147 if (length() < stringLength || m_offset > length() - stringLength)
Note: See TracChangeset
for help on using the changeset viewer.