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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/typer.h" 5 #include "src/compiler/typer.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/flags.h" 9 #include "src/base/flags.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
11 #include "src/compiler/common-operator.h" 11 #include "src/compiler/common-operator.h"
12 #include "src/compiler/graph-reducer.h" 12 #include "src/compiler/graph-reducer.h"
13 #include "src/compiler/js-operator.h" 13 #include "src/compiler/js-operator.h"
14 #include "src/compiler/linkage.h"
14 #include "src/compiler/loop-variable-optimizer.h" 15 #include "src/compiler/loop-variable-optimizer.h"
15 #include "src/compiler/node-properties.h" 16 #include "src/compiler/node-properties.h"
16 #include "src/compiler/node.h" 17 #include "src/compiler/node.h"
17 #include "src/compiler/operation-typer.h" 18 #include "src/compiler/operation-typer.h"
18 #include "src/compiler/simplified-operator.h" 19 #include "src/compiler/simplified-operator.h"
19 #include "src/compiler/type-cache.h" 20 #include "src/compiler/type-cache.h"
20 #include "src/objects-inl.h" 21 #include "src/objects-inl.h"
21 22
22 namespace v8 { 23 namespace v8 {
23 namespace internal { 24 namespace internal {
24 namespace compiler { 25 namespace compiler {
25 26
26 class Typer::Decorator final : public GraphDecorator { 27 class Typer::Decorator final : public GraphDecorator {
27 public: 28 public:
28 explicit Decorator(Typer* typer) : typer_(typer) {} 29 explicit Decorator(Typer* typer) : typer_(typer) {}
29 void Decorate(Node* node) final; 30 void Decorate(Node* node) final;
30 31
31 private: 32 private:
32 Typer* const typer_; 33 Typer* const typer_;
33 }; 34 };
34 35
35 Typer::Typer(Isolate* isolate, Graph* graph) 36 Typer::Typer(Isolate* isolate, Flags flags, Graph* graph)
36 : isolate_(isolate), 37 : isolate_(isolate),
38 flags_(flags),
37 graph_(graph), 39 graph_(graph),
38 decorator_(nullptr), 40 decorator_(nullptr),
39 cache_(TypeCache::Get()), 41 cache_(TypeCache::Get()),
40 operation_typer_(isolate, zone()) { 42 operation_typer_(isolate, zone()) {
41 Zone* zone = this->zone(); 43 Zone* zone = this->zone();
42 Factory* const factory = isolate->factory(); 44 Factory* const factory = isolate->factory();
43 45
44 singleton_false_ = Type::HeapConstant(factory->false_value(), zone); 46 singleton_false_ = Type::HeapConstant(factory->false_value(), zone);
45 singleton_true_ = Type::HeapConstant(factory->true_value(), zone); 47 singleton_true_ = Type::HeapConstant(factory->true_value(), zone);
46 singleton_the_hole_ = Type::HeapConstant(factory->the_hole_value(), zone); 48 singleton_the_hole_ = Type::HeapConstant(factory->the_hole_value(), zone);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // Control operators. 541 // Control operators.
540 542
541 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); } 543 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); }
542 544
543 Type* Typer::Visitor::TypeIfException(Node* node) { 545 Type* Typer::Visitor::TypeIfException(Node* node) {
544 return Type::NonInternal(); 546 return Type::NonInternal();
545 } 547 }
546 548
547 // Common operators. 549 // Common operators.
548 550
549 Type* Typer::Visitor::TypeParameter(Node* node) { return Type::Any(); } 551 Type* Typer::Visitor::TypeParameter(Node* node) {
552 Node* const start = node->InputAt(0);
553 DCHECK_EQ(IrOpcode::kStart, start->opcode());
554 int const parameter_count = start->op()->ValueOutputCount() - 4;
555 DCHECK_LE(1, parameter_count);
556 int const index = ParameterIndexOf(node->op());
557 if (index == Linkage::kJSCallClosureParamIndex) {
558 return Type::Function();
559 } else if (index == 0) {
560 if (typer_->flags() & Typer::kThisIsReceiver) {
561 return Type::Receiver();
562 } else {
563 // Parameter[this] can be the_hole for derived class constructors.
564 return Type::Union(Type::Hole(), Type::NonInternal(), typer_->zone());
565 }
566 } else if (index == Linkage::GetJSCallNewTargetParamIndex(parameter_count)) {
567 if (typer_->flags() & Typer::kNewTargetIsReceiver) {
568 return Type::Receiver();
569 } else {
570 return Type::Union(Type::Receiver(), Type::Undefined(), typer_->zone());
571 }
572 } else if (index == Linkage::GetJSCallArgCountParamIndex(parameter_count)) {
573 return Type::Range(0.0, Code::kMaxArguments, typer_->zone());
574 } else if (index == Linkage::GetJSCallContextParamIndex(parameter_count)) {
575 return Type::OtherInternal();
576 }
577 return Type::NonInternal();
578 }
550 579
551 Type* Typer::Visitor::TypeOsrValue(Node* node) { return Type::Any(); } 580 Type* Typer::Visitor::TypeOsrValue(Node* node) { return Type::Any(); }
552 581
553 Type* Typer::Visitor::TypeOsrGuard(Node* node) { 582 Type* Typer::Visitor::TypeOsrGuard(Node* node) {
554 switch (OsrGuardTypeOf(node->op())) { 583 switch (OsrGuardTypeOf(node->op())) {
555 case OsrGuardType::kUninitialized: 584 case OsrGuardType::kUninitialized:
556 return Type::None(); 585 return Type::None();
557 case OsrGuardType::kSignedSmall: 586 case OsrGuardType::kSignedSmall:
558 return Type::SignedSmall(); 587 return Type::SignedSmall();
559 case OsrGuardType::kAny: 588 case OsrGuardType::kAny:
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { 1734 Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
1706 if (Type::IsInteger(*value)) { 1735 if (Type::IsInteger(*value)) {
1707 return Type::Range(value->Number(), value->Number(), zone()); 1736 return Type::Range(value->Number(), value->Number(), zone());
1708 } 1737 }
1709 return Type::NewConstant(value, zone()); 1738 return Type::NewConstant(value, zone());
1710 } 1739 }
1711 1740
1712 } // namespace compiler 1741 } // namespace compiler
1713 } // namespace internal 1742 } // namespace internal
1714 } // namespace v8 1743 } // namespace v8
OLDNEW
« 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