Changeset 209830 in webkit for trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp
- Timestamp:
- Dec 14, 2016, 1:29:14 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp
r209652 r209830 87 87 bool WARN_UNUSED_RETURN setLocal(uint32_t index, ExpressionType value); 88 88 89 // Globals 90 bool WARN_UNUSED_RETURN getGlobal(uint32_t index, ExpressionType& result); 91 bool WARN_UNUSED_RETURN setGlobal(uint32_t index, ExpressionType value); 92 89 93 // Memory 90 94 bool WARN_UNUSED_RETURN load(LoadOpType, ExpressionType pointer, ExpressionType& result, uint32_t offset); … … 117 121 void dump(const Vector<ControlEntry>& controlStack, const ExpressionList& expressionStack); 118 122 119 bool hasMemory() const { return !!m_m emory; }123 bool hasMemory() const { return !!m_module.memory; } 120 124 121 125 void setErrorMessage(String&& message) { ASSERT(m_errorMessage.isNull()); m_errorMessage = WTFMove(message); } 122 126 String errorMessage() const { return m_errorMessage; } 123 Validate(ExpressionType returnType, const M emoryInformation& memory)127 Validate(ExpressionType returnType, const ModuleInformation& module) 124 128 : m_returnType(returnType) 125 , m_m emory(memory)129 , m_module(module) 126 130 { 127 131 } … … 136 140 Vector<Type> m_locals; 137 141 String m_errorMessage; 138 const M emoryInformation& m_memory;142 const ModuleInformation& m_module; 139 143 }; 140 144 … … 178 182 179 183 m_errorMessage = makeString("Attempt to set local with type: ", toString(localType), " with a variable of type: ", toString(value)); 184 return false; 185 } 186 187 bool Validate::getGlobal(uint32_t index, ExpressionType& result) 188 { 189 if (index < m_module.globals.size()) { 190 result = m_module.globals[index].type; 191 ASSERT(isValueType(result)); 192 return true; 193 } 194 m_errorMessage = ASCIILiteral("Attempt to use unknown global."); 195 return false; 196 } 197 198 bool Validate::setGlobal(uint32_t index, ExpressionType value) 199 { 200 if (index >= m_module.globals.size()) { 201 m_errorMessage = ASCIILiteral("Attempt to use unknown global."); 202 return false; 203 } 204 205 if (m_module.globals[index].mutability == Global::Immutable) { 206 m_errorMessage = ASCIILiteral("Attempt to store to immutable global."); 207 return false; 208 } 209 210 ExpressionType globalType = m_module.globals[index].type; 211 ASSERT(isValueType(globalType)); 212 if (globalType == value) 213 return true; 214 215 m_errorMessage = makeString("Attempt to set global with type: ", toString(globalType), " with a variable of type: ", toString(value)); 180 216 return false; 181 217 } … … 402 438 } 403 439 404 String validateFunction(const uint8_t* source, size_t length, const Signature* signature, const ImmutableFunctionIndexSpace& functionIndexSpace, const ModuleInformation& info)405 { 406 Validate context(signature->returnType, info.memory);407 FunctionParser<Validate> validator(context, source, length, signature, functionIndexSpace, info);440 String validateFunction(const uint8_t* source, size_t length, const Signature* signature, const ImmutableFunctionIndexSpace& functionIndexSpace, const ModuleInformation& module) 441 { 442 Validate context(signature->returnType, module); 443 FunctionParser<Validate> validator(context, source, length, signature, functionIndexSpace, module); 408 444 409 445 if (!validator.parse()) {
Note:
See TracChangeset
for help on using the changeset viewer.