OLD | NEW |
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 "src/base/flags.h" | 7 #include "src/base/flags.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class Typer::Decorator final : public GraphDecorator { | 24 class Typer::Decorator final : public GraphDecorator { |
25 public: | 25 public: |
26 explicit Decorator(Typer* typer) : typer_(typer) {} | 26 explicit Decorator(Typer* typer) : typer_(typer) {} |
27 void Decorate(Node* node) final; | 27 void Decorate(Node* node) final; |
28 | 28 |
29 private: | 29 private: |
30 Typer* const typer_; | 30 Typer* const typer_; |
31 }; | 31 }; |
32 | 32 |
33 Typer::Typer(Isolate* isolate, Graph* graph, Flags flags, | 33 Typer::Typer(Isolate* isolate, Graph* graph, Flags flags, |
34 CompilationDependencies* dependencies, FunctionType* function_type) | 34 CompilationDependencies* dependencies) |
35 : isolate_(isolate), | 35 : isolate_(isolate), |
36 graph_(graph), | 36 graph_(graph), |
37 flags_(flags), | 37 flags_(flags), |
38 dependencies_(dependencies), | 38 dependencies_(dependencies), |
39 function_type_(function_type), | |
40 decorator_(nullptr), | 39 decorator_(nullptr), |
41 cache_(TypeCache::Get()), | 40 cache_(TypeCache::Get()), |
42 operation_typer_(isolate, zone()) { | 41 operation_typer_(isolate, zone()) { |
43 Zone* zone = this->zone(); | 42 Zone* zone = this->zone(); |
44 Factory* const factory = isolate->factory(); | 43 Factory* const factory = isolate->factory(); |
45 | 44 |
46 Type* infinity = Type::Constant(factory->infinity_value(), zone); | 45 Type* infinity = Type::Constant(factory->infinity_value(), zone); |
47 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); | 46 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); |
48 // Unfortunately, the infinities created in other places might be different | 47 // Unfortunately, the infinities created in other places might be different |
49 // ones (eg the result of NewNumber in TypeNumberConstant). | 48 // ones (eg the result of NewNumber in TypeNumberConstant). |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 617 |
619 // Control operators. | 618 // Control operators. |
620 | 619 |
621 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); } | 620 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); } |
622 | 621 |
623 Type* Typer::Visitor::TypeIfException(Node* node) { return Type::Any(); } | 622 Type* Typer::Visitor::TypeIfException(Node* node) { return Type::Any(); } |
624 | 623 |
625 | 624 |
626 // Common operators. | 625 // Common operators. |
627 | 626 |
628 | 627 Type* Typer::Visitor::TypeParameter(Node* node) { return Type::Any(); } |
629 Type* Typer::Visitor::TypeParameter(Node* node) { | |
630 if (FunctionType* function_type = typer_->function_type()) { | |
631 int const index = ParameterIndexOf(node->op()); | |
632 if (index >= 0 && index < function_type->Arity()) { | |
633 return function_type->Parameter(index); | |
634 } | |
635 } | |
636 return Type::Any(); | |
637 } | |
638 | |
639 | 628 |
640 Type* Typer::Visitor::TypeOsrValue(Node* node) { return Type::Any(); } | 629 Type* Typer::Visitor::TypeOsrValue(Node* node) { return Type::Any(); } |
641 | 630 |
642 | 631 |
643 Type* Typer::Visitor::TypeInt32Constant(Node* node) { | 632 Type* Typer::Visitor::TypeInt32Constant(Node* node) { |
644 double number = OpParameter<int32_t>(node); | 633 double number = OpParameter<int32_t>(node); |
645 return Type::Intersect(Type::Range(number, number, zone()), | 634 return Type::Intersect(Type::Range(number, number, zone()), |
646 Type::UntaggedIntegral32(), zone()); | 635 Type::UntaggedIntegral32(), zone()); |
647 } | 636 } |
648 | 637 |
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 } | 2529 } |
2541 if (Type::IsInteger(*value)) { | 2530 if (Type::IsInteger(*value)) { |
2542 return Type::Range(value->Number(), value->Number(), zone()); | 2531 return Type::Range(value->Number(), value->Number(), zone()); |
2543 } | 2532 } |
2544 return Type::Constant(value, zone()); | 2533 return Type::Constant(value, zone()); |
2545 } | 2534 } |
2546 | 2535 |
2547 } // namespace compiler | 2536 } // namespace compiler |
2548 } // namespace internal | 2537 } // namespace internal |
2549 } // namespace v8 | 2538 } // namespace v8 |
OLD | NEW |