OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/ast/ast-numbering.h" | 5 #include "src/ast/ast-numbering.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/zone/zone-containers.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 | 13 |
13 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { | 14 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { |
14 public: | 15 public: |
15 AstNumberingVisitor(Isolate* isolate, Zone* zone) | 16 AstNumberingVisitor(Isolate* isolate, Zone* zone, |
| 17 ZoneVector<FunctionLiteral*>* eager_inner_functions) |
16 : isolate_(isolate), | 18 : isolate_(isolate), |
17 zone_(zone), | 19 zone_(zone), |
| 20 eager_inner_functions_(eager_inner_functions), |
18 next_id_(BailoutId::FirstUsable().ToInt()), | 21 next_id_(BailoutId::FirstUsable().ToInt()), |
19 yield_count_(0), | 22 yield_count_(0), |
20 properties_(zone), | 23 properties_(zone), |
21 slot_cache_(zone), | 24 slot_cache_(zone), |
22 disable_crankshaft_reason_(kNoReason), | 25 disable_crankshaft_reason_(kNoReason), |
23 dont_optimize_reason_(kNoReason), | 26 dont_optimize_reason_(kNoReason), |
24 catch_prediction_(HandlerTable::UNCAUGHT) { | 27 catch_prediction_(HandlerTable::UNCAUGHT) { |
25 InitializeAstVisitor(isolate); | 28 InitializeAstVisitor(isolate); |
26 } | 29 } |
27 | 30 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 template <typename Node> | 67 template <typename Node> |
65 void ReserveFeedbackSlots(Node* node) { | 68 void ReserveFeedbackSlots(Node* node) { |
66 node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), | 69 node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), |
67 &slot_cache_); | 70 &slot_cache_); |
68 } | 71 } |
69 | 72 |
70 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } | 73 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } |
71 | 74 |
72 Isolate* isolate_; | 75 Isolate* isolate_; |
73 Zone* zone_; | 76 Zone* zone_; |
| 77 ZoneVector<FunctionLiteral*>* eager_inner_functions_; |
74 int next_id_; | 78 int next_id_; |
75 int yield_count_; | 79 int yield_count_; |
76 AstProperties properties_; | 80 AstProperties properties_; |
77 // The slot cache allows us to reuse certain feedback vector slots. | 81 // The slot cache allows us to reuse certain feedback vector slots. |
78 FeedbackVectorSlotCache slot_cache_; | 82 FeedbackVectorSlotCache slot_cache_; |
79 BailoutReason disable_crankshaft_reason_; | 83 BailoutReason disable_crankshaft_reason_; |
80 BailoutReason dont_optimize_reason_; | 84 BailoutReason dont_optimize_reason_; |
81 HandlerTable::CatchPrediction catch_prediction_; | 85 HandlerTable::CatchPrediction catch_prediction_; |
82 | 86 |
83 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 87 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { | 590 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { |
587 for (int i = 0; i < arguments->length(); i++) { | 591 for (int i = 0; i < arguments->length(); i++) { |
588 Visit(arguments->at(i)); | 592 Visit(arguments->at(i)); |
589 } | 593 } |
590 } | 594 } |
591 | 595 |
592 | 596 |
593 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { | 597 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { |
594 IncrementNodeCount(); | 598 IncrementNodeCount(); |
595 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); | 599 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); |
| 600 if (node->ShouldEagerCompile()) eager_inner_functions_->push_back(node); |
596 // We don't recurse into the declarations or body of the function literal: | 601 // We don't recurse into the declarations or body of the function literal: |
597 // you have to separately Renumber() each FunctionLiteral that you compile. | 602 // you have to separately Renumber() each FunctionLiteral that you compile. |
598 } | 603 } |
599 | 604 |
600 | 605 |
601 void AstNumberingVisitor::VisitRewritableExpression( | 606 void AstNumberingVisitor::VisitRewritableExpression( |
602 RewritableExpression* node) { | 607 RewritableExpression* node) { |
603 IncrementNodeCount(); | 608 IncrementNodeCount(); |
604 node->set_base_id(ReserveIdRange(RewritableExpression::num_ids())); | 609 node->set_base_id(ReserveIdRange(RewritableExpression::num_ids())); |
605 Visit(node->expression()); | 610 Visit(node->expression()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 if (disable_crankshaft_reason_ != kNoReason) { | 646 if (disable_crankshaft_reason_ != kNoReason) { |
642 PrintF("[enforcing Ignition and TurboFan for %s because: %s\n", | 647 PrintF("[enforcing Ignition and TurboFan for %s because: %s\n", |
643 node->debug_name()->ToCString().get(), | 648 node->debug_name()->ToCString().get(), |
644 GetBailoutReason(disable_crankshaft_reason_)); | 649 GetBailoutReason(disable_crankshaft_reason_)); |
645 } | 650 } |
646 } | 651 } |
647 | 652 |
648 return !HasStackOverflow(); | 653 return !HasStackOverflow(); |
649 } | 654 } |
650 | 655 |
651 | 656 bool AstNumbering::Renumber( |
652 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 657 Isolate* isolate, Zone* zone, FunctionLiteral* function, |
653 FunctionLiteral* function) { | 658 ZoneVector<FunctionLiteral*>* eager_inner_functions) { |
654 AstNumberingVisitor visitor(isolate, zone); | 659 AstNumberingVisitor visitor(isolate, zone, eager_inner_functions); |
655 return visitor.Renumber(function); | 660 return visitor.Renumber(function); |
656 } | 661 } |
657 } // namespace internal | 662 } // namespace internal |
658 } // namespace v8 | 663 } // namespace v8 |
OLD | NEW |