Chromium Code Reviews| Index: src/wasm/asm-types.cc |
| diff --git a/src/wasm/asm-types.cc b/src/wasm/asm-types.cc |
| index 3648c6bfd48038bf12f4dab62f48c45e83bef330..02278437f7a770b2e80a902fc041de4686248a77 100644 |
| --- a/src/wasm/asm-types.cc |
| +++ b/src/wasm/asm-types.cc |
| @@ -11,8 +11,14 @@ namespace internal { |
| namespace wasm { |
| AsmCallableType* AsmType::AsCallableType() { |
| + if (AsValueType() != nullptr) { |
| + return nullptr; |
| + } |
| + |
| DCHECK(this->AsFunctionType() != nullptr || |
| - this->AsOverloadedFunctionType() != nullptr); |
| + this->AsOverloadedFunctionType() != nullptr || |
| + this->AsFFIType() != nullptr || |
| + this->AsFunctionTableType() != nullptr); |
| return reinterpret_cast<AsmCallableType*>(this); |
| } |
| @@ -235,6 +241,21 @@ AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) { |
| return reinterpret_cast<AsmType*>(MinMax); |
| } |
| +AsmType* AsmFFIType::ValidateCall(AsmType* function_type) { |
| + auto* callable = function_type->AsFunctionType(); |
| + if (callable == nullptr) { |
| + return nullptr; |
| + } |
| + |
| + for (int ii = 0; ii < callable->Arguments().size(); ++ii) { |
| + if (!callable->Arguments()[ii]->IsA(AsmType::Extern())) { |
| + return AsmType::None(); |
| + } |
| + } |
| + |
| + return callable->ReturnType(); |
| +} |
| + |
| AsmType* AsmFunctionType::ValidateCall(AsmType* function_type) { |
| auto* callable = function_type->AsFunctionType(); |
| if (callable == nullptr) { |
| @@ -293,6 +314,24 @@ void AsmOverloadedFunctionType::AddOverload(AsmType* overload) { |
| overloads_.push_back(overload); |
| } |
| +std::string AsmFunctionTableType::Name() { |
| + std::string base_name = |
| + signature_ == nullptr ? "[unbound]" : signature_->Name(); |
| + return base_name + "[" + std::to_string(length_) + "]"; |
| +} |
| + |
| +void AsmFunctionTableType::set_signature(AsmType* function_type) { |
| + CHECK(function_type->AsFunctionType() != nullptr); |
| + signature_ = function_type; |
| +} |
| + |
| +AsmType* AsmFunctionTableType::ValidateCall(AsmType* function_type) { |
| + if (signature_ == nullptr) { |
|
bradnelson
2016/06/17 23:38:50
Doesn't this need to check that function_type is a
John
2016/06/20 15:09:52
signature_ is now initialized during the construct
|
| + set_signature(function_type); |
| + } |
| + return signature_->AsCallableType()->ValidateCall(function_type); |
| +} |
| + |
| } // namespace wasm |
| } // namespace internal |
| } // namespace v8 |