Changeset 188778 in webkit
- Timestamp:
- Aug 21, 2015 2:46:22 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 added
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r188752 r188778 424 424 425 425 wasm/JSWASMModule.cpp 426 wasm/WASMFunctionParser.cpp 426 427 wasm/WASMModuleParser.cpp 427 428 wasm/WASMReader.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r188776 r188778 1 2015-08-21 Sukolsak Sakshuwong <sukolsak@gmail.com> 2 3 Implement WebAssembly function parser 4 https://bugs.webkit.org/show_bug.cgi?id=147738 5 6 Reviewed by Filip Pizlo. 7 8 Implement WebAssembly function parser for WebAssembly files produced by pack-asmjs 9 <https://github.com/WebAssembly/polyfill-prototype-1>. This patch parses only 10 some instructions on statements and int32 expressions. Parsing of the rest 11 will be implemented in subsequent patches. The instruction lists in WASMConstants.h 12 are slightly modified from 13 <https://github.com/WebAssembly/polyfill-prototype-1/blob/master/src/shared.h>. 14 15 * CMakeLists.txt: 16 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 17 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 18 * JavaScriptCore.xcodeproj/project.pbxproj: 19 * wasm/WASMConstants.h: Added. 20 * wasm/WASMFormat.h: 21 * wasm/WASMFunctionParser.cpp: Added. 22 (JSC::WASMFunctionParser::checkSyntax): 23 (JSC::WASMFunctionParser::parseFunction): 24 (JSC::WASMFunctionParser::parseLocalVariables): 25 (JSC::WASMFunctionParser::parseStatement): 26 (JSC::WASMFunctionParser::parseSetLocalStatement): 27 (JSC::WASMFunctionParser::parseReturnStatement): 28 (JSC::WASMFunctionParser::parseBlockStatement): 29 (JSC::WASMFunctionParser::parseExpression): 30 (JSC::WASMFunctionParser::parseExpressionI32): 31 (JSC::WASMFunctionParser::parseImmediateExpressionI32): 32 * wasm/WASMFunctionParser.h: Added. 33 (JSC::WASMFunctionParser::WASMFunctionParser): 34 * wasm/WASMFunctionSyntaxChecker.h: Renamed from Source/JavaScriptCore/wasm/WASMMagicNumber.h. 35 * wasm/WASMModuleParser.cpp: 36 (JSC::WASMModuleParser::WASMModuleParser): 37 (JSC::WASMModuleParser::parseFunctionDefinitionSection): 38 (JSC::WASMModuleParser::parseFunctionDefinition): 39 * wasm/WASMModuleParser.h: 40 * wasm/WASMReader.cpp: 41 (JSC::WASMReader::readType): 42 (JSC::WASMReader::readExpressionType): 43 (JSC::WASMReader::readExportFormat): 44 (JSC::WASMReader::readOpStatement): 45 (JSC::WASMReader::readOpExpressionI32): 46 (JSC::WASMReader::readVariableTypes): 47 (JSC::WASMReader::readOp): 48 * wasm/WASMReader.h: 49 (JSC::WASMReader::offset): 50 (JSC::WASMReader::setOffset): 51 1 52 2015-08-21 Filip Pizlo <fpizlo@apple.com> 2 53 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r188752 r188778 893 893 <ClCompile Include="..\tools\JSDollarVMPrototype.cpp" /> 894 894 <ClCompile Include="..\wasm\JSWASMModule.cpp" /> 895 <ClCompile Include="..\wasm\WASMFunctionParser.cpp" /> 895 896 <ClCompile Include="..\wasm\WASMModuleParser.cpp" /> 896 897 <ClCompile Include="..\wasm\WASMReader.cpp" /> … … 1787 1788 <ClInclude Include="..\tools\TieredMMapArray.h" /> 1788 1789 <ClInclude Include="..\wasm\JSWASMModule.h" /> 1790 <ClInclude Include="..\wasm\WASMConstants.h" /> 1789 1791 <ClInclude Include="..\wasm\WASMFormat.h" /> 1790 <ClInclude Include="..\wasm\WASMMagicNumber.h" /> 1792 <ClInclude Include="..\wasm\WASMFunctionParser.h" /> 1793 <ClInclude Include="..\wasm\WASMFunctionSyntaxChecker.h" /> 1791 1794 <ClInclude Include="..\wasm\WASMModuleParser.h" /> 1792 1795 <ClInclude Include="..\wasm\WASMReader.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r188752 r188778 1842 1842 <Filter>wasm</Filter> 1843 1843 </ClCompile> 1844 <ClCompile Include="..\wasm\WASMFunctionParser.cpp"> 1845 <Filter>wasm</Filter> 1846 </ClCompile> 1844 1847 <ClCompile Include="..\wasm\WASMModuleParser.cpp"> 1845 1848 <Filter>wasm</Filter> … … 4421 4424 <Filter>wasm</Filter> 4422 4425 </ClInclude> 4426 <ClInclude Include="..\wasm\WASMConstants.h"> 4427 <Filter>wasm</Filter> 4428 </ClInclude> 4423 4429 <ClInclude Include="..\wasm\WASMFormat.h"> 4424 4430 <Filter>wasm</Filter> 4425 4431 </ClInclude> 4426 <ClInclude Include="..\wasm\WASMMagicNumber.h"> 4432 <ClInclude Include="..\wasm\WASMFunctionParser.h"> 4433 <Filter>wasm</Filter> 4434 </ClInclude> 4435 <ClInclude Include="..\wasm\WASMFunctionSyntaxChecker.h"> 4427 4436 <Filter>wasm</Filter> 4428 4437 </ClInclude> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r188752 r188778 1033 1033 79EE0BFF1B4AFB85000385C9 /* VariableEnvironment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */; }; 1034 1034 79EE0C001B4AFB85000385C9 /* VariableEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1035 7B0247551B8682DD00542440 /* WASMConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B0247521B8682D500542440 /* WASMConstants.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1036 7B0247561B8682E100542440 /* WASMFunctionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B0247531B8682D500542440 /* WASMFunctionParser.cpp */; }; 1037 7B0247571B8682E400542440 /* WASMFunctionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B0247541B8682D500542440 /* WASMFunctionParser.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1038 7B0247591B868EB700542440 /* WASMFunctionSyntaxChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B0247581B868EAE00542440 /* WASMFunctionSyntaxChecker.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1035 1039 7B39F76D1B62DE2E00360FB4 /* WASMModuleParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */; }; 1036 1040 7B39F76E1B62DE3200360FB4 /* WASMModuleParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1037 1041 7B39F7701B62DE3200360FB4 /* WASMReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B39F76C1B62DE2200360FB4 /* WASMReader.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1038 1042 7B39F7721B63574D00360FB4 /* WASMReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B39F7711B63574B00360FB4 /* WASMReader.cpp */; }; 1039 7B7A5E271B68288C0027CAD0 /* WASMMagicNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */; settings = {ATTRIBUTES = (Private, ); }; };1040 1043 7B98D1361B60CD5F0023B1A4 /* JSWASMModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */; }; 1041 1044 7B98D1371B60CD620023B1A4 /* JSWASMModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2843 2846 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VariableEnvironment.cpp; sourceTree = "<group>"; }; 2844 2847 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VariableEnvironment.h; sourceTree = "<group>"; }; 2848 7B0247521B8682D500542440 /* WASMConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMConstants.h; sourceTree = "<group>"; }; 2849 7B0247531B8682D500542440 /* WASMFunctionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMFunctionParser.cpp; sourceTree = "<group>"; }; 2850 7B0247541B8682D500542440 /* WASMFunctionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMFunctionParser.h; sourceTree = "<group>"; }; 2851 7B0247581B868EAE00542440 /* WASMFunctionSyntaxChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMFunctionSyntaxChecker.h; sourceTree = "<group>"; }; 2845 2852 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMModuleParser.cpp; sourceTree = "<group>"; }; 2846 2853 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMModuleParser.h; sourceTree = "<group>"; }; 2847 2854 7B39F76C1B62DE2200360FB4 /* WASMReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMReader.h; sourceTree = "<group>"; }; 2848 2855 7B39F7711B63574B00360FB4 /* WASMReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMReader.cpp; sourceTree = "<group>"; }; 2849 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMMagicNumber.h; sourceTree = "<group>"; };2850 2856 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWASMModule.cpp; sourceTree = "<group>"; }; 2851 2857 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWASMModule.h; sourceTree = "<group>"; }; … … 4445 4451 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */, 4446 4452 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */, 4453 7B0247521B8682D500542440 /* WASMConstants.h */, 4447 4454 7BC547D21B69599B00959B58 /* WASMFormat.h */, 4448 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */, 4455 7B0247531B8682D500542440 /* WASMFunctionParser.cpp */, 4456 7B0247541B8682D500542440 /* WASMFunctionParser.h */, 4457 7B0247581B868EAE00542440 /* WASMFunctionSyntaxChecker.h */, 4449 4458 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */, 4450 4459 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */, … … 5972 5981 86E116B10FE75AC800B512BC /* CodeLocation.h in Headers */, 5973 5982 0FBD7E691447999600481315 /* CodeOrigin.h in Headers */, 5983 7B0247591B868EB700542440 /* WASMFunctionSyntaxChecker.h in Headers */, 5974 5984 0F21C27D14BE727A00ADC64B /* CodeSpecializationKind.h in Headers */, 5975 5985 0F0B83A714BCF50700885B4F /* CodeType.h in Headers */, … … 6231 6241 0FCEFAE0180738C000472CE4 /* FTLLocation.h in Headers */, 6232 6242 A1587D701B4DC14100D69849 /* IntlDateTimeFormatConstructor.h in Headers */, 6243 7B0247571B8682E400542440 /* WASMFunctionParser.h in Headers */, 6233 6244 0FEA0A10170513DB00BB722C /* FTLLowerDFGToLLVM.h in Headers */, 6234 6245 A7D89D0217A0B90400773AD8 /* FTLLoweredNodeValue.h in Headers */, … … 6619 6630 BC18C4510E16F5CD00B34460 /* ProfileNode.h in Headers */, 6620 6631 0FF729A5166AD351000F5BA3 /* ProfilerBytecode.h in Headers */, 6632 7B0247551B8682DD00542440 /* WASMConstants.h in Headers */, 6621 6633 0FF729B9166AD360000F5BA3 /* ProfilerBytecodes.h in Headers */, 6622 6634 0F13912A16771C36009CCB07 /* ProfilerBytecodeSequence.h in Headers */, … … 6642 6654 0FF7168C15A3B235008F5DAA /* PropertyOffset.h in Headers */, 6643 6655 A785F6BC18C553FE00F10626 /* SpillRegistersMode.h in Headers */, 6644 7B7A5E271B68288C0027CAD0 /* WASMMagicNumber.h in Headers */,6645 6656 BC18C4550E16F5CD00B34460 /* PropertySlot.h in Headers */, 6646 6657 0FB7F39C15ED8E4600F167B2 /* PropertyStorage.h in Headers */, … … 7576 7587 E33637A51B63220200EE0840 /* ReflectObject.cpp in Sources */, 7577 7588 147F39CB107EC37600427A48 /* FunctionConstructor.cpp in Sources */, 7589 7B0247561B8682E100542440 /* WASMFunctionParser.cpp in Sources */, 7578 7590 0FF0F19F16B72A17005DF95B /* FunctionExecutableDump.cpp in Sources */, 7579 7591 52B310FD1974AE870080857C /* FunctionHasExecutedCache.cpp in Sources */, -
trunk/Source/JavaScriptCore/wasm/WASMFormat.h
r188099 r188778 66 66 }; 67 67 68 enum class WASMExportFormat : uint8_t {69 Default,70 Record,71 NumberOfExportFormats72 };73 74 68 struct WASMSignature { 75 69 WASMExpressionType returnType; -
trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h
r188776 r188778 24 24 */ 25 25 26 #ifndef WASM MagicNumber_h27 #define WASM MagicNumber_h26 #ifndef WASMFunctionSyntaxChecker_h 27 #define WASMFunctionSyntaxChecker_h 28 28 29 29 #if ENABLE(WEBASSEMBLY) … … 31 31 namespace JSC { 32 32 33 static const uint32_t wasmMagicNumber = 0x6d736177; 33 class WASMFunctionSyntaxChecker { 34 public: 35 typedef int Expression; 36 typedef int Statement; 37 }; 34 38 35 39 } // namespace JSC … … 37 41 #endif // ENABLE(WEBASSEMBLY) 38 42 39 #endif // WASM MagicNumber_h43 #endif // WASMFunctionSyntaxChecker_h -
trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp
r188099 r188778 32 32 #include "JSWASMModule.h" 33 33 #include "StrongInlines.h" 34 #include "WASMMagicNumber.h" 34 #include "WASMConstants.h" 35 #include "WASMFunctionParser.h" 35 36 #include <wtf/MathExtras.h> 36 37 … … 50 51 51 52 WASMModuleParser::WASMModuleParser(const SourceCode& source) 52 : m_reader(static_cast<WebAssemblySourceProvider*>(source.provider())->data()) 53 : m_source(source) 54 , m_reader(static_cast<WebAssemblySourceProvider*>(source.provider())->data()) 53 55 { 54 56 } … … 248 250 void WASMModuleParser::parseFunctionDefinitionSection() 249 251 { 250 for (size_t i = 0; i < m_module->functionDeclarations().size(); ++i) {251 parseFunctionDefinition( );252 for (size_t functionIndex = 0; functionIndex < m_module->functionDeclarations().size(); ++functionIndex) { 253 parseFunctionDefinition(functionIndex); 252 254 PROPAGATE_ERROR(); 253 255 } 254 256 } 255 257 256 void WASMModuleParser::parseFunctionDefinition() 257 { 258 // FIXME: Support any functions. https://bugs.webkit.org/show_bug.cgi?id=147738 259 // Currently, we only support functions that have "return 0;" as their only statement. 260 // These functions consist of exactly 4 bytes, i.e. 261 // 1. The number of local variables (0) [0x80] 262 // 2. The number of statements (1) [0x01] 263 // 3. The return statement [0x0f] 264 // 4. The immediate expression (0) [0xa0] 265 uint32_t functionDefinitionBytes; 266 READ_UINT32_OR_FAIL(functionDefinitionBytes, "Cannot read the function definition."); 267 FAIL_IF_FALSE(functionDefinitionBytes == 0xa00f0180, "Only functions that have \"return 0;\" " 268 "as their only statement are supported at the moment."); 258 void WASMModuleParser::parseFunctionDefinition(size_t functionIndex) 259 { 260 unsigned startOffsetInSource = m_reader.offset(); 261 unsigned endOffsetInSource; 262 String errorMessage; 263 if (!WASMFunctionParser::checkSyntax(m_module.get(), m_source, functionIndex, startOffsetInSource, endOffsetInSource, errorMessage)) { 264 m_errorMessage = errorMessage; 265 return; 266 } 267 m_reader.setOffset(endOffsetInSource); 269 268 } 270 269 -
trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h
r188099 r188778 55 55 void parseFunctionPointerTableSection(); 56 56 void parseFunctionDefinitionSection(); 57 void parseFunctionDefinition( );57 void parseFunctionDefinition(size_t functionIndex); 58 58 void parseExportSection(); 59 59 60 const SourceCode& m_source; 60 61 WASMReader m_reader; 61 62 Strong<JSWASMModule> m_module; -
trunk/Source/JavaScriptCore/wasm/WASMReader.cpp
r188099 r188778 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * ========================================================================= 26 * 27 * Copyright (c) 2015 by the repository authors of 28 * WebAssembly/polyfill-prototype-1. 29 * 30 * Licensed under the Apache License, Version 2.0 (the "License"); 31 * you may not use this file except in compliance with the License. 32 * You may obtain a copy of the License at 33 * 34 * http://www.apache.org/licenses/LICENSE-2.0 35 * 36 * Unless required by applicable law or agreed to in writing, software 37 * distributed under the License is distributed on an "AS IS" BASIS, 38 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 39 * See the License for the specific language governing permissions and 40 * limitations under the License. 24 41 */ 25 42 … … 114 131 bool WASMReader::readType(WASMType& result) 115 132 { 116 return readByte<WASMType>(result, (uint8_t)WASMType::NumberOfTypes);133 return readByte<WASMType>(result, static_cast<uint8_t>(WASMType::NumberOfTypes)); 117 134 } 118 135 119 136 bool WASMReader::readExpressionType(WASMExpressionType& result) 120 137 { 121 return readByte<WASMExpressionType>(result, (uint8_t)WASMExpressionType::NumberOfExpressionTypes);138 return readByte<WASMExpressionType>(result, static_cast<uint8_t>(WASMExpressionType::NumberOfExpressionTypes)); 122 139 } 123 140 124 141 bool WASMReader::readExportFormat(WASMExportFormat& result) 125 142 { 126 return readByte<WASMExportFormat>(result, (uint8_t)WASMExportFormat::NumberOfExportFormats);143 return readByte<WASMExportFormat>(result, static_cast<uint8_t>(WASMExportFormat::NumberOfExportFormats)); 127 144 } 128 145 … … 137 154 } 138 155 156 bool WASMReader::readOpStatement(bool& hasImmediate, WASMOpStatement& op, WASMOpStatementWithImmediate& opWithImmediate, uint8_t& immediate) 157 { 158 return readOp(hasImmediate, op, opWithImmediate, immediate, 159 static_cast<uint8_t>(WASMOpStatement::NumberOfWASMOpStatements), 160 static_cast<uint8_t>(WASMOpStatementWithImmediate::NumberOfWASMOpStatementWithImmediates)); 161 } 162 163 bool WASMReader::readOpExpressionI32(bool& hasImmediate, WASMOpExpressionI32& op, WASMOpExpressionI32WithImmediate& opWithImmediate, uint8_t& immediate) 164 { 165 return readOp(hasImmediate, op, opWithImmediate, immediate, 166 static_cast<uint8_t>(WASMOpExpressionI32::NumberOfWASMOpExpressionI32s), 167 static_cast<uint8_t>(WASMOpExpressionI32WithImmediate::NumberOfWASMOpExpressionI32WithImmediates)); 168 } 169 170 bool WASMReader::readVariableTypes(bool& hasImmediate, WASMVariableTypes& variableTypes, WASMVariableTypesWithImmediate& variableTypesWithImmediate, uint8_t& immediate) 171 { 172 return readOp(hasImmediate, variableTypes, variableTypesWithImmediate, immediate, 173 static_cast<uint8_t>(WASMVariableTypes::NumberOfVariableTypes), 174 static_cast<uint8_t>(WASMVariableTypesWithImmediate::NumberOfVariableTypesWithImmediates)); 175 } 176 177 template <class T, class TWithImmediate> 178 bool WASMReader::readOp(bool& hasImmediate, T& op, TWithImmediate& opWithImmediate, uint8_t& immediate, uint8_t numberOfValues, uint8_t numberOfValuesWithImmediate) 179 { 180 CHECK_READ(1); 181 uint8_t byte = *m_cursor++; 182 183 if (!(byte & hasImmediateInOpFlag)) { 184 if (byte >= numberOfValues) 185 return false; 186 hasImmediate = false; 187 op = T(byte); 188 return true; 189 } 190 191 uint8_t byteWithoutImmediate = (byte >> immediateBits) & (opWithImmediateLimit - 1); 192 if (byteWithoutImmediate >= numberOfValuesWithImmediate) 193 return false; 194 hasImmediate = true; 195 opWithImmediate = TWithImmediate(byteWithoutImmediate); 196 immediate = byte & (immediateLimit - 1); 197 return true; 198 } 199 139 200 } // namespace JSC 140 201 -
trunk/Source/JavaScriptCore/wasm/WASMReader.h
r188099 r188778 29 29 #if ENABLE(WEBASSEMBLY) 30 30 31 #include "WASMConstants.h" 31 32 #include "WASMFormat.h" 32 33 #include <wtf/Vector.h> … … 42 43 } 43 44 45 unsigned offset() const { return m_cursor - m_buffer.data(); } 46 void setOffset(unsigned offset) { m_cursor = m_buffer.data() + offset; } 47 44 48 bool readUInt32(uint32_t& result); 45 49 bool readFloat(float& result); … … 50 54 bool readExpressionType(WASMExpressionType& result); 51 55 bool readExportFormat(WASMExportFormat& result); 56 bool readOpStatement(bool& hasImmediate, WASMOpStatement&, WASMOpStatementWithImmediate&, uint8_t& immediate); 57 bool readOpExpressionI32(bool& hasImmediate, WASMOpExpressionI32&, WASMOpExpressionI32WithImmediate&, uint8_t& immediate); 58 bool readVariableTypes(bool& hasImmediate, WASMVariableTypes&, WASMVariableTypesWithImmediate&, uint8_t& immediate); 52 59 53 60 private: … … 55 62 56 63 template <class T> bool readByte(T& result, uint8_t numberOfValues); 64 template <class T, class TWithImmediate> bool readOp(bool& hasImmediate, T&, TWithImmediate&, uint8_t& immediate, uint8_t numberOfValues, uint8_t numberOfValuesWithImmediate); 57 65 58 66 const Vector<uint8_t>& m_buffer;
Note: See TracChangeset
for help on using the changeset viewer.