Changeset 209652 in webkit for trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp
- Timestamp:
- Dec 9, 2016, 11:12:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp
r209630 r209652 111 111 bool WARN_UNUSED_RETURN addEndToUnreachable(ControlEntry&); 112 112 113 113 // Calls 114 114 bool WARN_UNUSED_RETURN addCall(unsigned calleeIndex, const Signature*, const Vector<ExpressionType>& args, ExpressionType& result); 115 bool WARN_UNUSED_RETURN addCallIndirect(const Signature*, const Vector<ExpressionType>& args, ExpressionType& result); 115 116 116 117 void dump(const Vector<ControlEntry>& controlStack, const ExpressionList& expressionStack); … … 348 349 } 349 350 351 bool Validate::addCallIndirect(const Signature* signature, const Vector<ExpressionType>& args, ExpressionType& result) 352 { 353 const auto argumentCount = signature->arguments.size(); 354 if (argumentCount != args.size() - 1) { 355 StringBuilder builder; 356 builder.append("Arity mismatch in call_indirect, expected: "); 357 builder.appendNumber(signature->arguments.size()); 358 builder.append(" but got: "); 359 builder.appendNumber(args.size()); 360 m_errorMessage = builder.toString(); 361 return false; 362 } 363 364 for (unsigned i = 0; i < argumentCount; ++i) { 365 if (args[i] != signature->arguments[i]) { 366 m_errorMessage = makeString("Expected argument type: ", toString(signature->arguments[i]), " does not match passed argument type: ", toString(args[i])); 367 return false; 368 } 369 } 370 371 if (args.last() != I32) { 372 m_errorMessage = makeString("Expected call_indirect target index to have type: i32 but got type: ", toString(args.last())); 373 return false; 374 } 375 376 result = signature->returnType; 377 return true; 378 } 379 350 380 bool Validate::unify(const ExpressionList& values, const ControlType& block) 351 381 { … … 372 402 } 373 403 374 String validateFunction(const uint8_t* source, size_t length, const Signature* signature, const FunctionIndexSpace& functionIndexSpace, const MemoryInformation& memory) 375 { 376 Validate context(signature->returnType, memory); 377 FunctionParser<Validate> validator(context, source, length, signature, functionIndexSpace); 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); 408 378 409 if (!validator.parse()) { 379 410 // FIXME: add better location information here. see: https://bugs.webkit.org/show_bug.cgi?id=164288
Note:
See TracChangeset
for help on using the changeset viewer.