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

Unified Diff: src/compiler/typer.cc

Issue 2223873002: [turbofan] Assign proper types to Parameter nodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE and fix. Created 4 years, 1 month 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/compiler/typer.h ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 763fdbf426463c06e8defb661c429755f89287cc..2f508d336e724400e6ef2df31ba00ea2af1cf0f0 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -11,6 +11,7 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/js-operator.h"
+#include "src/compiler/linkage.h"
#include "src/compiler/loop-variable-optimizer.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node.h"
@@ -32,8 +33,9 @@ class Typer::Decorator final : public GraphDecorator {
Typer* const typer_;
};
-Typer::Typer(Isolate* isolate, Graph* graph)
+Typer::Typer(Isolate* isolate, Flags flags, Graph* graph)
: isolate_(isolate),
+ flags_(flags),
graph_(graph),
decorator_(nullptr),
cache_(TypeCache::Get()),
@@ -546,7 +548,34 @@ Type* Typer::Visitor::TypeIfException(Node* node) {
// Common operators.
-Type* Typer::Visitor::TypeParameter(Node* node) { return Type::Any(); }
+Type* Typer::Visitor::TypeParameter(Node* node) {
+ Node* const start = node->InputAt(0);
+ DCHECK_EQ(IrOpcode::kStart, start->opcode());
+ int const parameter_count = start->op()->ValueOutputCount() - 4;
+ DCHECK_LE(1, parameter_count);
+ int const index = ParameterIndexOf(node->op());
+ if (index == Linkage::kJSCallClosureParamIndex) {
+ return Type::Function();
+ } else if (index == 0) {
+ if (typer_->flags() & Typer::kThisIsReceiver) {
+ return Type::Receiver();
+ } else {
+ // Parameter[this] can be the_hole for derived class constructors.
+ return Type::Union(Type::Hole(), Type::NonInternal(), typer_->zone());
+ }
+ } else if (index == Linkage::GetJSCallNewTargetParamIndex(parameter_count)) {
+ if (typer_->flags() & Typer::kNewTargetIsReceiver) {
+ return Type::Receiver();
+ } else {
+ return Type::Union(Type::Receiver(), Type::Undefined(), typer_->zone());
+ }
+ } else if (index == Linkage::GetJSCallArgCountParamIndex(parameter_count)) {
+ return Type::Range(0.0, Code::kMaxArguments, typer_->zone());
+ } else if (index == Linkage::GetJSCallContextParamIndex(parameter_count)) {
+ return Type::OtherInternal();
+ }
+ return Type::NonInternal();
+}
Type* Typer::Visitor::TypeOsrValue(Node* node) { return Type::Any(); }
« no previous file with comments | « src/compiler/typer.h ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698