Changeset 205309 in webkit
- Timestamp:
- Sep 1, 2016 1:04:02 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r205304 r205309 1 2016-09-01 Keith Miller <keith_miller@apple.com> 2 3 Rename WASM classes dropping the WASM prefix 4 https://bugs.webkit.org/show_bug.cgi?id=161500 5 6 Reviewed by Mark Lam. 7 8 Having to write WASM::WASMModule seems silly. Also, this patch 9 merges WASMFunctionReturnType and WASMValueType into one type 10 that is a typedef of B3::Type. Using B3::Type as the WASM 11 primitive type makes it trivial to convert a Vector of WASM 12 types into a Vector of B3 types. 13 14 * b3/B3Type.h: 15 * wasm/JSWASMModule.h: 16 (JSC::JSWASMModule::signatures): 17 (JSC::JSWASMModule::functionImports): 18 (JSC::JSWASMModule::functionImportSignatures): 19 (JSC::JSWASMModule::globalVariableTypes): 20 (JSC::JSWASMModule::functionDeclarations): 21 (JSC::JSWASMModule::functionPointerTables): 22 * wasm/WASMB3IRGenerator.cpp: 23 (JSC::WASM::toB3Op): 24 (JSC::WASM::B3IRGenerator::addLocal): 25 (JSC::WASM::B3IRGenerator::unaryOp): 26 (JSC::WASM::B3IRGenerator::binaryOp): 27 (JSC::WASM::B3IRGenerator::addConstant): 28 (JSC::WASM::parseAndCompile): 29 * wasm/WASMB3IRGenerator.h: 30 * wasm/WASMFormat.h: 31 * wasm/WASMFunctionParser.h: 32 (JSC::WASM::FunctionParser<Context>::FunctionParser): 33 (JSC::WASM::FunctionParser<Context>::parse): 34 (JSC::WASM::FunctionParser<Context>::parseBlock): 35 (JSC::WASM::FunctionParser<Context>::parseExpression): 36 (JSC::WASM::WASMFunctionParser<Context>::WASMFunctionParser): Deleted. 37 (JSC::WASM::WASMFunctionParser<Context>::parse): Deleted. 38 (JSC::WASM::WASMFunctionParser<Context>::parseBlock): Deleted. 39 (JSC::WASM::WASMFunctionParser<Context>::parseExpression): Deleted. 40 * wasm/WASMModuleParser.cpp: 41 (JSC::WASM::ModuleParser::parse): 42 (JSC::WASM::ModuleParser::parseFunctionTypes): 43 (JSC::WASM::ModuleParser::parseFunctionSignatures): 44 (JSC::WASM::ModuleParser::parseFunctionDefinitions): 45 (JSC::WASM::WASMModuleParser::parse): Deleted. 46 (JSC::WASM::WASMModuleParser::parseFunctionTypes): Deleted. 47 (JSC::WASM::WASMModuleParser::parseFunctionSignatures): Deleted. 48 (JSC::WASM::WASMModuleParser::parseFunctionDefinitions): Deleted. 49 * wasm/WASMModuleParser.h: 50 (JSC::WASM::ModuleParser::ModuleParser): 51 (JSC::WASM::ModuleParser::functionInformation): 52 (JSC::WASM::WASMModuleParser::WASMModuleParser): Deleted. 53 (JSC::WASM::WASMModuleParser::functionInformation): Deleted. 54 * wasm/WASMOps.h: 55 * wasm/WASMParser.h: 56 (JSC::WASM::Parser::Parser): 57 (JSC::WASM::Parser::consumeCharacter): 58 (JSC::WASM::Parser::consumeString): 59 (JSC::WASM::Parser::parseUInt32): 60 (JSC::WASM::Parser::parseUInt7): 61 (JSC::WASM::Parser::parseVarUInt1): 62 (JSC::WASM::Parser::parseValueType): 63 (JSC::WASM::WASMParser::WASMParser): Deleted. 64 (JSC::WASM::WASMParser::consumeCharacter): Deleted. 65 (JSC::WASM::WASMParser::consumeString): Deleted. 66 (JSC::WASM::WASMParser::parseUInt32): Deleted. 67 (JSC::WASM::WASMParser::parseUInt7): Deleted. 68 (JSC::WASM::WASMParser::parseVarUInt1): Deleted. 69 (JSC::WASM::WASMParser::parseValueType): Deleted. 70 * wasm/WASMPlan.cpp: 71 (JSC::WASM::Plan::Plan): 72 * wasm/WASMSections.cpp: 73 (JSC::WASM::Sections::lookup): 74 (JSC::WASM::WASMSections::lookup): Deleted. 75 * wasm/WASMSections.h: 76 (JSC::WASM::Sections::validateOrder): 77 (JSC::WASM::WASMSections::validateOrder): Deleted. 78 1 79 2016-09-01 Filip Pizlo <fpizlo@apple.com> 2 80 -
trunk/Source/JavaScriptCore/b3/B3Type.h
r194858 r205309 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 41 41 enum Type : int8_t { 42 Void,43 42 Int32, 44 43 Int64, 45 44 Float, 46 Double 45 Double, 46 LastValueType = Double, 47 Void 47 48 }; 48 49 -
trunk/Source/JavaScriptCore/wasm/JSWASMModule.h
r205021 r205309 76 76 Vector<float>& f32Constants() { return m_f32Constants; } 77 77 Vector<double>& f64Constants() { return m_f64Constants; } 78 Vector<WASM Signature>& signatures() { return m_signatures; }79 Vector<WASM FunctionImport>& functionImports() { return m_functionImports; }80 Vector<WASM FunctionImportSignature>& functionImportSignatures() { return m_functionImportSignatures; }81 Vector<WASM ValueType>& globalVariableTypes() { return m_globalVariableTypes; }82 Vector<WASM FunctionDeclaration>& functionDeclarations() { return m_functionDeclarations; }83 Vector<WASM FunctionPointerTable>& functionPointerTables() { return m_functionPointerTables; }78 Vector<WASM::Signature>& signatures() { return m_signatures; } 79 Vector<WASM::FunctionImport>& functionImports() { return m_functionImports; } 80 Vector<WASM::FunctionImportSignature>& functionImportSignatures() { return m_functionImportSignatures; } 81 Vector<WASM::Type>& globalVariableTypes() { return m_globalVariableTypes; } 82 Vector<WASM::FunctionDeclaration>& functionDeclarations() { return m_functionDeclarations; } 83 Vector<WASM::FunctionPointerTable>& functionPointerTables() { return m_functionPointerTables; } 84 84 85 85 const JSArrayBuffer* arrayBuffer() const { return m_arrayBuffer.get(); } … … 96 96 Vector<float> m_f32Constants; 97 97 Vector<double> m_f64Constants; 98 Vector<WASM Signature> m_signatures;99 Vector<WASM FunctionImport> m_functionImports;100 Vector<WASM FunctionImportSignature> m_functionImportSignatures;101 Vector<WASM ValueType> m_globalVariableTypes;102 Vector<WASM FunctionDeclaration> m_functionDeclarations;103 Vector<WASM FunctionPointerTable> m_functionPointerTables;98 Vector<WASM::Signature> m_signatures; 99 Vector<WASM::FunctionImport> m_functionImports; 100 Vector<WASM::FunctionImportSignature> m_functionImportSignatures; 101 Vector<WASM::Type> m_globalVariableTypes; 102 Vector<WASM::FunctionDeclaration> m_functionDeclarations; 103 Vector<WASM::FunctionPointerTable> m_functionPointerTables; 104 104 105 105 WriteBarrier<JSArrayBuffer> m_arrayBuffer; -
trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp
r205021 r205309 42 42 using namespace B3; 43 43 44 inline B3::Opcode toB3Op( WASMBinaryOpType op)44 inline B3::Opcode toB3Op(BinaryOpType op) 45 45 { 46 46 switch (op) { 47 #define CREATE_CASE(name, op, b3op) case WASMBinaryOpType::name: return b3op;47 #define CREATE_CASE(name, op, b3op) case BinaryOpType::name: return b3op; 48 48 FOR_EACH_WASM_BINARY_OP(CREATE_CASE) 49 49 #undef CREATE_CASE … … 52 52 } 53 53 54 inline B3::Opcode toB3Op( WASMUnaryOpType op)54 inline B3::Opcode toB3Op(UnaryOpType op) 55 55 { 56 56 switch (op) { 57 #define CREATE_CASE(name, op, b3op) case WASMUnaryOpType::name: return b3op;57 #define CREATE_CASE(name, op, b3op) case UnaryOpType::name: return b3op; 58 58 FOR_EACH_WASM_UNARY_OP(CREATE_CASE) 59 59 #undef CREATE_CASE … … 68 68 B3IRGenerator(Procedure&); 69 69 70 void addLocal( WASMValueType, uint32_t);71 ExpressionType addConstant( WASMValueType, uint64_t);72 73 bool WARN_UNUSED_RETURN binaryOp( WASMBinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result);74 bool WARN_UNUSED_RETURN unaryOp( WASMUnaryOpType, ExpressionType arg, ExpressionType& result);70 void addLocal(Type, uint32_t); 71 ExpressionType addConstant(Type, uint64_t); 72 73 bool WARN_UNUSED_RETURN binaryOp(BinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result); 74 bool WARN_UNUSED_RETURN unaryOp(UnaryOpType, ExpressionType arg, ExpressionType& result); 75 75 76 76 bool WARN_UNUSED_RETURN addBlock(); … … 97 97 } 98 98 99 void B3IRGenerator::addLocal( WASMValueType, uint32_t)99 void B3IRGenerator::addLocal(Type, uint32_t) 100 100 { 101 101 // TODO: Add locals. 102 102 } 103 103 104 bool B3IRGenerator::unaryOp( WASMUnaryOpType op, ExpressionType arg, ExpressionType& result)104 bool B3IRGenerator::unaryOp(UnaryOpType op, ExpressionType arg, ExpressionType& result) 105 105 { 106 106 result = m_currentBlock->appendNew<Value>(m_proc, toB3Op(op), Origin(), arg); … … 108 108 } 109 109 110 bool B3IRGenerator::binaryOp( WASMBinaryOpType op, ExpressionType left, ExpressionType right, ExpressionType& result)110 bool B3IRGenerator::binaryOp(BinaryOpType op, ExpressionType left, ExpressionType right, ExpressionType& result) 111 111 { 112 112 result = m_currentBlock->appendNew<Value>(m_proc, toB3Op(op), Origin(), left, right); … … 114 114 } 115 115 116 B3IRGenerator::ExpressionType B3IRGenerator::addConstant( WASMValueType type, uint64_t value)116 B3IRGenerator::ExpressionType B3IRGenerator::addConstant(Type type, uint64_t value) 117 117 { 118 118 switch (type) { 119 case WASMValueType::I32:119 case Int32: 120 120 return m_currentBlock->appendNew<Const32Value>(m_proc, Origin(), static_cast<int32_t>(value)); 121 case WASMValueType::I64:121 case Int64: 122 122 return m_currentBlock->appendNew<Const64Value>(m_proc, Origin(), value); 123 case WASMValueType::F32:123 case Float: 124 124 return m_currentBlock->appendNew<ConstFloatValue>(m_proc, Origin(), bitwise_cast<float>(static_cast<int32_t>(value))); 125 case WASMValueType::F64:125 case Double: 126 126 return m_currentBlock->appendNew<ConstDoubleValue>(m_proc, Origin(), bitwise_cast<double>(value)); 127 127 default: … … 206 206 } 207 207 208 std::unique_ptr<Compilation> parseAndCompile(VM& vm, Vector<uint8_t>& source, WASMFunctionInformation info, unsigned optLevel)208 std::unique_ptr<Compilation> parseAndCompile(VM& vm, Vector<uint8_t>& source, FunctionInformation info, unsigned optLevel) 209 209 { 210 210 Procedure procedure; 211 211 B3IRGenerator context(procedure); 212 WASMFunctionParser<B3IRGenerator> parser(context, source, info);212 FunctionParser<B3IRGenerator> parser(context, source, info); 213 213 if (!parser.parse()) 214 214 RELEASE_ASSERT_NOT_REACHED(); -
trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.h
r205021 r205309 36 36 namespace WASM { 37 37 38 std::unique_ptr<B3::Compilation> parseAndCompile(VM&, Vector<uint8_t>&, WASMFunctionInformation, unsigned optLevel = 1);38 std::unique_ptr<B3::Compilation> parseAndCompile(VM&, Vector<uint8_t>&, FunctionInformation, unsigned optLevel = 1); 39 39 40 40 } // namespace WASM -
trunk/Source/JavaScriptCore/wasm/WASMFormat.h
r205021 r205309 45 45 #if ENABLE(WEBASSEMBLY) 46 46 47 #include "B3Type.h" 47 48 #include <wtf/Vector.h> 48 49 #include <wtf/text/WTFString.h> … … 52 53 class JSFunction; 53 54 54 enum class WASMValueType : uint8_t { 55 I32, 56 I64, 57 F32, 58 F64, 59 NumberOfTypes 55 namespace WASM { 56 57 using B3::Type; 58 using B3::Int32; 59 using B3::Int64; 60 using B3::Float; 61 using B3::Double; 62 63 static_assert(Int32 == 0, "WASM needs B3::Type::Int32 to have the value 0"); 64 static_assert(Int64 == 1, "WASM needs B3::Type::Int64 to have the value 1"); 65 static_assert(Float == 2, "WASM needs B3::Type::Float to have the value 2"); 66 static_assert(Double == 3, "WASM needs B3::Type::Double to have the value 3"); 67 68 struct Signature { 69 Type returnType; 70 Vector<Type> arguments; 60 71 }; 61 72 62 enum class WASMFunctionReturnType : uint8_t { 63 I32, 64 I64, 65 F32, 66 F64, 67 Void, 68 NumberOfExpressionTypes 69 }; 70 71 struct WASMSignature { 72 WASMFunctionReturnType returnType; 73 Vector<WASMValueType> arguments; 74 }; 75 76 struct WASMFunctionImport { 73 struct FunctionImport { 77 74 String functionName; 78 75 }; 79 76 80 struct WASMFunctionImportSignature {77 struct FunctionImportSignature { 81 78 uint32_t signatureIndex; 82 79 uint32_t functionImportIndex; 83 80 }; 84 81 85 struct WASMFunctionDeclaration {82 struct FunctionDeclaration { 86 83 uint32_t signatureIndex; 87 84 }; 88 85 89 struct WASMFunctionPointerTable {86 struct FunctionPointerTable { 90 87 uint32_t signatureIndex; 91 88 Vector<uint32_t> functionIndices; … … 93 90 }; 94 91 95 struct WASMFunctionInformation {92 struct FunctionInformation { 96 93 size_t start; 97 94 size_t end; 98 95 }; 99 96 97 } // namespace WASM 98 100 99 } // namespace JSC 101 100 -
trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h
r205021 r205309 36 36 37 37 template<typename Context> 38 class WASMFunctionParser : public WASMParser {38 class FunctionParser : public Parser { 39 39 public: 40 40 typedef typename Context::ExpressionType ExpressionType; 41 41 42 WASMFunctionParser(Context&, const Vector<uint8_t>& sourceBuffer, const WASMFunctionInformation&);42 FunctionParser(Context&, const Vector<uint8_t>& sourceBuffer, const FunctionInformation&); 43 43 44 44 bool WARN_UNUSED_RETURN parse(); … … 48 48 49 49 bool WARN_UNUSED_RETURN parseBlock(); 50 bool WARN_UNUSED_RETURN parseExpression( WASMOpType);50 bool WARN_UNUSED_RETURN parseExpression(OpType); 51 51 bool WARN_UNUSED_RETURN unifyControl(Vector<ExpressionType>&, unsigned level); 52 52 … … 58 58 59 59 template<typename Context> 60 WASMFunctionParser<Context>::WASMFunctionParser(Context& context, const Vector<uint8_t>& sourceBuffer, const WASMFunctionInformation& info)61 : WASMParser(sourceBuffer, info.start, info.end)60 FunctionParser<Context>::FunctionParser(Context& context, const Vector<uint8_t>& sourceBuffer, const FunctionInformation& info) 61 : Parser(sourceBuffer, info.start, info.end) 62 62 , m_context(context) 63 63 { … … 65 65 66 66 template<typename Context> 67 bool WASMFunctionParser<Context>::parse()67 bool FunctionParser<Context>::parse() 68 68 { 69 69 uint32_t localCount; … … 76 76 return false; 77 77 78 WASMValueType typeOfLocal;78 Type typeOfLocal; 79 79 if (!parseValueType(typeOfLocal)) 80 80 return false; 81 81 82 m_context.addLocal(typeOfLocal, numberOfLocalsWithType);83 82 } 84 83 … … 87 86 88 87 template<typename Context> 89 bool WASMFunctionParser<Context>::parseBlock()88 bool FunctionParser<Context>::parseBlock() 90 89 { 91 90 while (true) { … … 94 93 return false; 95 94 96 if (!parseExpression(static_cast< WASMOpType>(op))) {95 if (!parseExpression(static_cast<OpType>(op))) { 97 96 if (verbose) 98 97 dataLogLn("failed to process op:", op); … … 100 99 } 101 100 102 if (op == WASMOpType::End)101 if (op == OpType::End) 103 102 break; 104 103 } … … 108 107 109 108 template<typename Context> 110 bool WASMFunctionParser<Context>::parseExpression(WASMOpType op)109 bool FunctionParser<Context>::parseExpression(OpType op) 111 110 { 112 111 switch (op) { … … 116 115 ExpressionType right = m_expressionStack.takeLast(); 117 116 ExpressionType result; 118 if (!m_context.binaryOp(static_cast< WASMBinaryOpType>(op), left, right, result))117 if (!m_context.binaryOp(static_cast<BinaryOpType>(op), left, right, result)) 119 118 return false; 120 119 m_expressionStack.append(result); … … 125 124 ExpressionType arg = m_expressionStack.takeLast(); 126 125 ExpressionType result; 127 if (!m_context.unaryOp(static_cast< WASMUnaryOpType>(op), arg, result))126 if (!m_context.unaryOp(static_cast<UnaryOpType>(op), arg, result)) 128 127 return false; 129 128 m_expressionStack.append(result); … … 132 131 #undef CREATE_CASE 133 132 134 case WASMOpType::I32Const: {133 case OpType::I32Const: { 135 134 uint32_t constant; 136 135 if (!parseVarUInt32(constant)) 137 136 return false; 138 m_expressionStack.append(m_context.addConstant( WASMValueType::I32, constant));137 m_expressionStack.append(m_context.addConstant(Int32, constant)); 139 138 return true; 140 139 } 141 140 142 case WASMOpType::Block: {141 case OpType::Block: { 143 142 if (!m_context.addBlock()) 144 143 return false; … … 146 145 } 147 146 148 case WASMOpType::Return: {147 case OpType::Return: { 149 148 uint8_t returnCount; 150 149 if (!parseVarUInt1(returnCount)) … … 157 156 } 158 157 159 case WASMOpType::End:158 case OpType::End: 160 159 return m_context.endBlock(m_expressionStack); 161 160 -
trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp
r205021 r205309 39 39 static const bool verbose = false; 40 40 41 bool WASMModuleParser::parse()41 bool ModuleParser::parse() 42 42 { 43 43 if (m_sourceLength < 8) … … 60 60 dataLogLn("Passed processing header."); 61 61 62 WASMSections::Section previousSection = WASMSections::Section::Unknown;62 Sections::Section previousSection = Sections::Unknown; 63 63 while (m_offset < m_sourceLength) { 64 64 if (verbose) … … 72 72 return false; 73 73 74 WASMSections::Section section = WASMSections::lookup(m_source.data() + m_offset, sectionNameLength);75 if (! WASMSections::validateOrder(previousSection, section))74 Sections::Section section = Sections::lookup(m_source.data() + m_offset, sectionNameLength); 75 if (!Sections::validateOrder(previousSection, section)) 76 76 return false; 77 77 m_offset += sectionNameLength; … … 84 84 85 85 switch (section) { 86 case WASMSections::Section::End:86 case Sections::End: 87 87 return true; 88 88 89 case WASMSections::Section::FunctionTypes: {89 case Sections::FunctionTypes: { 90 90 if (verbose) 91 91 dataLogLn("Parsing types."); … … 95 95 } 96 96 97 case WASMSections::Section::Signatures: {97 case Sections::Signatures: { 98 98 if (verbose) 99 99 dataLogLn("Parsing function signatures."); … … 103 103 } 104 104 105 case WASMSections::Section::Definitions: {105 case Sections::Definitions: { 106 106 if (verbose) 107 107 dataLogLn("Parsing function definitions."); … … 111 111 } 112 112 113 case WASMSections::Section::Unknown: {113 case Sections::Unknown: { 114 114 if (verbose) 115 115 dataLogLn("Unknown section, skipping."); … … 132 132 } 133 133 134 bool WASMModuleParser::parseFunctionTypes()134 bool ModuleParser::parseFunctionTypes() 135 135 { 136 136 uint32_t count; … … 158 158 dataLogLn("argumentCount: ", argumentCount); 159 159 160 Vector<WASMValueType> argumentTypes; 160 Vector<Type> argumentTypes; 161 argumentTypes.resize(argumentCount); 162 161 163 for (unsigned i = 0; i < argumentCount; ++i) { 162 if (!parseUInt7(type) || type >= static_cast<uint8_t>( WASMValueType::NumberOfTypes))163 return false; 164 argumentTypes.append(static_cast< WASMValueType>(type));164 if (!parseUInt7(type) || type >= static_cast<uint8_t>(Type::LastValueType)) 165 return false; 166 argumentTypes.append(static_cast<Type>(type)); 165 167 } 166 168 167 169 if (!parseVarUInt1(type)) 168 170 return false; 169 WASMFunctionReturnType returnType;171 Type returnType; 170 172 171 173 if (verbose) … … 173 175 174 176 if (type) { 175 WASMValueType value;177 Type value; 176 178 if (!parseValueType(value)) 177 179 return false; 178 returnType = static_cast< WASMFunctionReturnType>(value);180 returnType = static_cast<Type>(value); 179 181 } else 180 returnType = WASMFunctionReturnType::Void;182 returnType = Type::Void; 181 183 182 184 // TODO: Actually do something with this data... … … 186 188 } 187 189 188 bool WASMModuleParser::parseFunctionSignatures()190 bool ModuleParser::parseFunctionSignatures() 189 191 { 190 192 uint32_t count; … … 203 205 } 204 206 205 bool WASMModuleParser::parseFunctionDefinitions()207 bool ModuleParser::parseFunctionDefinitions() 206 208 { 207 209 uint32_t count; … … 217 219 return false; 218 220 219 WASMFunctionInformation& info = m_functions[i];221 FunctionInformation& info = m_functions[i]; 220 222 info.start = m_offset; 221 223 info.end = m_offset + functionSize; -
trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h
r205021 r205309 36 36 namespace WASM { 37 37 38 class WASMModuleParser : public WASMParser {38 class ModuleParser : public Parser { 39 39 public: 40 40 41 41 static const unsigned magicNumber = 0xc; 42 42 43 WASMModuleParser(const Vector<uint8_t>& sourceBuffer)44 : WASMParser(sourceBuffer, 0, sourceBuffer.size())43 ModuleParser(const Vector<uint8_t>& sourceBuffer) 44 : Parser(sourceBuffer, 0, sourceBuffer.size()) 45 45 { 46 46 } … … 48 48 bool WARN_UNUSED_RETURN parse(); 49 49 50 const Vector< WASMFunctionInformation>& functionInformation() { return m_functions; }50 const Vector<FunctionInformation>& functionInformation() { return m_functions; } 51 51 52 52 private: … … 56 56 bool WARN_UNUSED_RETURN parseFunctionDefinition(uint32_t number); 57 57 bool WARN_UNUSED_RETURN parseBlock(); 58 bool WARN_UNUSED_RETURN parseExpression( WASMOpType);58 bool WARN_UNUSED_RETURN parseExpression(OpType); 59 59 60 Vector< WASMFunctionInformation> m_functions;60 Vector<FunctionInformation> m_functions; 61 61 }; 62 62 -
trunk/Source/JavaScriptCore/wasm/WASMOps.h
r204588 r205309 107 107 #define CREATE_ENUM_VALUE(name, id, b3op) name = id, 108 108 109 enum WASMOpType : uint8_t {109 enum OpType : uint8_t { 110 110 FOR_EACH_WASM_OP(CREATE_ENUM_VALUE) 111 111 }; 112 112 113 enum class WASMBinaryOpType : uint8_t {113 enum class BinaryOpType : uint8_t { 114 114 FOR_EACH_WASM_BINARY_OP(CREATE_ENUM_VALUE) 115 115 }; 116 116 117 enum class WASMUnaryOpType : uint8_t {117 enum class UnaryOpType : uint8_t { 118 118 FOR_EACH_WASM_UNARY_OP(CREATE_ENUM_VALUE) 119 119 }; -
trunk/Source/JavaScriptCore/wasm/WASMParser.h
r205021 r205309 39 39 namespace WASM { 40 40 41 class WASMParser {41 class Parser { 42 42 protected: 43 WASMParser(const Vector<uint8_t>&, size_t start, size_t end);43 Parser(const Vector<uint8_t>&, size_t start, size_t end); 44 44 45 45 bool WARN_UNUSED_RETURN consumeCharacter(char); … … 52 52 53 53 54 bool WARN_UNUSED_RETURN parseValueType( WASMValueType& result);54 bool WARN_UNUSED_RETURN parseValueType(Type& result); 55 55 56 56 const Vector<uint8_t>& m_source; … … 59 59 }; 60 60 61 ALWAYS_INLINE WASMParser::WASMParser(const Vector<uint8_t>& sourceBuffer, size_t start, size_t end)61 ALWAYS_INLINE Parser::Parser(const Vector<uint8_t>& sourceBuffer, size_t start, size_t end) 62 62 : m_source(sourceBuffer) 63 63 , m_sourceLength(end) … … 68 68 } 69 69 70 ALWAYS_INLINE bool WASMParser::consumeCharacter(char c)70 ALWAYS_INLINE bool Parser::consumeCharacter(char c) 71 71 { 72 72 if (m_offset >= m_sourceLength) … … 79 79 } 80 80 81 ALWAYS_INLINE bool WASMParser::consumeString(const char* str)81 ALWAYS_INLINE bool Parser::consumeString(const char* str) 82 82 { 83 83 unsigned start = m_offset; … … 91 91 } 92 92 93 ALWAYS_INLINE bool WASMParser::parseUInt32(uint32_t& result)93 ALWAYS_INLINE bool Parser::parseUInt32(uint32_t& result) 94 94 { 95 95 if (m_offset + 4 >= m_sourceLength) … … 100 100 } 101 101 102 ALWAYS_INLINE bool WASMParser::parseUInt7(uint8_t& result)102 ALWAYS_INLINE bool Parser::parseUInt7(uint8_t& result) 103 103 { 104 104 if (m_offset >= m_sourceLength) … … 108 108 } 109 109 110 ALWAYS_INLINE bool WASMParser::parseVarUInt1(uint8_t& result)110 ALWAYS_INLINE bool Parser::parseVarUInt1(uint8_t& result) 111 111 { 112 112 uint32_t temp; … … 117 117 } 118 118 119 ALWAYS_INLINE bool WASMParser::parseValueType(WASMValueType& result)119 ALWAYS_INLINE bool Parser::parseValueType(Type& result) 120 120 { 121 121 uint8_t value; 122 122 if (!parseUInt7(value)) 123 123 return false; 124 if (value >= static_cast<uint8_t>( WASMValueType::NumberOfTypes))124 if (value >= static_cast<uint8_t>(Type::LastValueType)) 125 125 return false; 126 result = static_cast< WASMValueType>(value);126 result = static_cast<Type>(value); 127 127 return true; 128 128 } -
trunk/Source/JavaScriptCore/wasm/WASMPlan.cpp
r205021 r205309 44 44 if (verbose) 45 45 dataLogLn("Starting plan."); 46 WASMModuleParser moduleParser(source);46 ModuleParser moduleParser(source); 47 47 if (!moduleParser.parse()) { 48 48 dataLogLn("Parsing module failed."); … … 53 53 dataLogLn("Parsed module."); 54 54 55 for (const WASMFunctionInformation& info : moduleParser.functionInformation()) {55 for (const FunctionInformation& info : moduleParser.functionInformation()) { 56 56 if (verbose) 57 57 dataLogLn("Processing funcion starting at: ", info.start, " and ending at: ", info.end); -
trunk/Source/JavaScriptCore/wasm/WASMSections.cpp
r205021 r205309 43 43 static const bool verbose = false; 44 44 45 static const unsigned sectionDataLength = static_cast<unsigned>( WASMSections::Section::Unknown);45 static const unsigned sectionDataLength = static_cast<unsigned>(Sections::Unknown); 46 46 static const SectionData sectionData[sectionDataLength] { 47 47 #define CREATE_SECTION_DATA(name, str) { sizeof(str) - 1, str }, … … 50 50 }; 51 51 52 WASMSections::Section WASMSections::lookup(const uint8_t* name, unsigned length)52 Sections::Section Sections::lookup(const uint8_t* name, unsigned length) 53 53 { 54 54 if (verbose) … … 58 58 continue; 59 59 if (!memcmp(name, sectionData[i].name, length)) 60 return static_cast< WASMSections::Section>(i);60 return static_cast<Sections::Section>(i); 61 61 } 62 return WASMSections::Section::Unknown;62 return Sections::Unknown; 63 63 } 64 64 -
trunk/Source/JavaScriptCore/wasm/WASMSections.h
r204484 r205309 39 39 macro(End, "end") 40 40 41 struct WASMSections {42 enum classSection {41 struct Sections { 42 enum Section { 43 43 #define CREATE_SECTION_ENUM(name, str) name, 44 44 FOR_EACH_WASM_SECTION_TYPE(CREATE_SECTION_ENUM) … … 51 51 // This allows unknown sections after End, which I doubt will ever be supported but 52 52 // there is no reason to potentially break backwards compatability. 53 if (previous == Section::Unknown)53 if (previous == Unknown) 54 54 return true; 55 55 return previous < next;
Note: See TracChangeset
for help on using the changeset viewer.