| Index: src/wasm/asm-types.cc
|
| diff --git a/src/wasm/asm-types.cc b/src/wasm/asm-types.cc
|
| index 3d58aae1d456993055b878c8d878f6ce2ea3ff0c..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);
|
| }
|
|
|
| @@ -29,6 +35,7 @@ std::string AsmType::Name() {
|
| UNREACHABLE();
|
| }
|
| }
|
| +
|
| return this->AsCallableType()->Name();
|
| }
|
|
|
| @@ -42,6 +49,7 @@ bool AsmType::IsExactly(AsmType* that) {
|
| }
|
| return avt->Bitset() == tavt->Bitset();
|
| }
|
| +
|
| // TODO(jpp): is it useful to allow non-value types to be tested with
|
| // IsExactly?
|
| return that == this;
|
| @@ -58,6 +66,7 @@ bool AsmType::IsA(AsmType* that) {
|
| }
|
| return (avt->Bitset() & tavt->Bitset()) == tavt->Bitset();
|
| }
|
| +
|
| // TODO(jpp): is it useful to allow non-value types to be tested with IsA?
|
| return that == this;
|
| }
|
| @@ -130,6 +139,10 @@ AsmType* AsmType::StoreType() {
|
| }
|
|
|
| std::string AsmFunctionType::Name() {
|
| + if (IsFroundType()) {
|
| + return "fround";
|
| + }
|
| +
|
| std::string ret;
|
| ret += "(";
|
| for (size_t ii = 0; ii < args_.size(); ++ii) {
|
| @@ -155,19 +168,33 @@ class AsmFroundType final : public AsmFunctionType {
|
| private:
|
| friend AsmType;
|
|
|
| - AsmFroundType(Zone* zone, AsmType* src)
|
| - : AsmFunctionType(zone, AsmType::Float()) {
|
| - AddArgument(src);
|
| - }
|
| + explicit AsmFroundType(Zone* zone)
|
| + : AsmFunctionType(zone, AsmType::Float()) {}
|
| +
|
| + AsmType* ValidateCall(AsmType* function_type) override;
|
| };
|
| } // namespace
|
|
|
| -AsmType* AsmType::FroundType(Zone* zone, AsmType* src) {
|
| - DCHECK(src->AsValueType() != nullptr);
|
| - auto* Fround = new (zone) AsmFroundType(zone, src);
|
| +AsmType* AsmType::FroundType(Zone* zone) {
|
| + auto* Fround = new (zone) AsmFroundType(zone);
|
| return reinterpret_cast<AsmType*>(Fround);
|
| }
|
|
|
| +AsmType* AsmFroundType::ValidateCall(AsmType* function_type) {
|
| + auto* callable = function_type->AsFunctionType();
|
| + if (callable->Arguments().size() != 1) {
|
| + return AsmType::None();
|
| + }
|
| +
|
| + auto* arg = callable->Arguments()[0];
|
| + if (!arg->IsA(AsmType::Floatish()) && !arg->IsA(AsmType::DoubleQ()) &&
|
| + !arg->IsA(AsmType::Signed()) && !arg->IsA(AsmType::Unsigned())) {
|
| + return AsmType::None();
|
| + }
|
| +
|
| + return AsmType::Float();
|
| +}
|
| +
|
| namespace {
|
| class AsmMinMaxType final : public AsmFunctionType {
|
| public:
|
| @@ -176,9 +203,10 @@ class AsmMinMaxType final : public AsmFunctionType {
|
| private:
|
| friend AsmType;
|
|
|
| - AsmMinMaxType(Zone* zone, AsmType* type) : AsmFunctionType(zone, type) {
|
| - AddArgument(type);
|
| - AddArgument(type);
|
| + AsmMinMaxType(Zone* zone, AsmType* dest, AsmType* src)
|
| + : AsmFunctionType(zone, dest) {
|
| + AddArgument(src);
|
| + AddArgument(src);
|
| }
|
|
|
| AsmType* ValidateCall(AsmType* function_type) override {
|
| @@ -206,12 +234,28 @@ class AsmMinMaxType final : public AsmFunctionType {
|
| };
|
| } // namespace
|
|
|
| -AsmType* AsmType::MinMaxType(Zone* zone, AsmType* type) {
|
| - DCHECK(type->AsValueType() != nullptr);
|
| - auto* MinMax = new (zone) AsmMinMaxType(zone, type);
|
| +AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) {
|
| + DCHECK(dest->AsValueType() != nullptr);
|
| + DCHECK(src->AsValueType() != nullptr);
|
| + auto* MinMax = new (zone) AsmMinMaxType(zone, dest, 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) {
|
| @@ -270,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) {
|
| + set_signature(function_type);
|
| + }
|
| + return signature_->AsCallableType()->ValidateCall(function_type);
|
| +}
|
| +
|
| } // namespace wasm
|
| } // namespace internal
|
| } // namespace v8
|
|
|