Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1303)

Unified Diff: src/wasm/asm-types.cc

Issue 2078053002: V8. ASM-2-WASM. Another asm-types.h revision. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git pull Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/asm-types.h ('k') | test/unittests/wasm/asm-types-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/asm-types.cc
diff --git a/src/wasm/asm-types.cc b/src/wasm/asm-types.cc
index 3648c6bfd48038bf12f4dab62f48c45e83bef330..e5588ae922d3180bfa28da6a9dfd604d19417c09 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);
}
@@ -165,7 +171,8 @@ class AsmFroundType final : public AsmFunctionType {
explicit AsmFroundType(Zone* zone)
: AsmFunctionType(zone, AsmType::Float()) {}
- AsmType* ValidateCall(AsmType* function_type) override;
+ AsmType* ValidateCall(AsmType* return_type,
+ const ZoneVector<AsmType*>& args) override;
};
} // namespace
@@ -174,13 +181,13 @@ AsmType* AsmType::FroundType(Zone* zone) {
return reinterpret_cast<AsmType*>(Fround);
}
-AsmType* AsmFroundType::ValidateCall(AsmType* function_type) {
- auto* callable = function_type->AsFunctionType();
- if (callable->Arguments().size() != 1) {
+AsmType* AsmFroundType::ValidateCall(AsmType* return_type,
+ const ZoneVector<AsmType*>& args) {
+ if (args.size() != 1) {
return AsmType::None();
}
- auto* arg = callable->Arguments()[0];
+ auto* arg = args[0];
if (!arg->IsA(AsmType::Floatish()) && !arg->IsA(AsmType::DoubleQ()) &&
!arg->IsA(AsmType::Signed()) && !arg->IsA(AsmType::Unsigned())) {
return AsmType::None();
@@ -203,22 +210,18 @@ class AsmMinMaxType final : public AsmFunctionType {
AddArgument(src);
}
- AsmType* ValidateCall(AsmType* function_type) override {
- auto* callable = function_type->AsFunctionType();
- if (callable == nullptr) {
- return nullptr;
- }
-
- if (!ReturnType()->IsExactly(callable->ReturnType())) {
+ AsmType* ValidateCall(AsmType* return_type,
+ const ZoneVector<AsmType*>& args) override {
+ if (!ReturnType()->IsExactly(return_type)) {
return AsmType::None();
}
- if (callable->Arguments().size() < 2) {
+ if (args.size() < 2) {
return AsmType::None();
}
for (size_t ii = 0; ii < Arguments().size(); ++ii) {
- if (!Arguments()[0]->IsExactly(callable->Arguments()[ii])) {
+ if (!Arguments()[0]->IsExactly(args[ii])) {
return AsmType::None();
}
}
@@ -235,22 +238,29 @@ AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) {
return reinterpret_cast<AsmType*>(MinMax);
}
-AsmType* AsmFunctionType::ValidateCall(AsmType* function_type) {
- auto* callable = function_type->AsFunctionType();
- if (callable == nullptr) {
- return nullptr;
+AsmType* AsmFFIType::ValidateCall(AsmType* return_type,
+ const ZoneVector<AsmType*>& args) {
+ for (size_t ii = 0; ii < args.size(); ++ii) {
+ if (!args[ii]->IsA(AsmType::Extern())) {
+ return AsmType::None();
+ }
}
- if (!return_type_->IsExactly(callable->return_type_)) {
+ return return_type;
+}
+
+AsmType* AsmFunctionType::ValidateCall(AsmType* return_type,
+ const ZoneVector<AsmType*>& args) {
+ if (!return_type_->IsExactly(return_type)) {
return AsmType::None();
}
- if (args_.size() != callable->args_.size()) {
+ if (args_.size() != args.size()) {
return AsmType::None();
}
for (size_t ii = 0; ii < args_.size(); ++ii) {
- if (!args_[ii]->IsExactly(callable->args_[ii])) {
+ if (!args_[ii]->IsExactly(args[ii])) {
return AsmType::None();
}
}
@@ -271,15 +281,11 @@ std::string AsmOverloadedFunctionType::Name() {
return ret;
}
-AsmType* AsmOverloadedFunctionType::ValidateCall(AsmType* function_type) {
- auto* callable = function_type->AsFunctionType();
- if (callable == nullptr) {
- return AsmType::None();
- }
-
+AsmType* AsmOverloadedFunctionType::ValidateCall(
+ AsmType* return_type, const ZoneVector<AsmType*>& args) {
for (size_t ii = 0; ii < overloads_.size(); ++ii) {
auto* validated_type =
- overloads_[ii]->AsCallableType()->ValidateCall(function_type);
+ overloads_[ii]->AsCallableType()->ValidateCall(return_type, args);
if (validated_type != AsmType::None()) {
return validated_type;
}
@@ -293,6 +299,21 @@ void AsmOverloadedFunctionType::AddOverload(AsmType* overload) {
overloads_.push_back(overload);
}
+AsmFunctionTableType::AsmFunctionTableType(size_t length, AsmType* signature)
+ : length_(length), signature_(signature) {
+ DCHECK(signature_ != nullptr);
+ DCHECK(signature_->AsFunctionType() != nullptr);
+}
+
+std::string AsmFunctionTableType::Name() {
+ return signature_->Name() + "[" + std::to_string(length_) + "]";
Mostyn Bramley-Moore 2016/07/04 20:23:36 std::to_string is in the "C++11 Standard Library F
+}
+
+AsmType* AsmFunctionTableType::ValidateCall(AsmType* return_type,
+ const ZoneVector<AsmType*>& args) {
+ return signature_->AsCallableType()->ValidateCall(return_type, args);
+}
+
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/asm-types.h ('k') | test/unittests/wasm/asm-types-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698