| 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 ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* |
| 18 eager_inner_functions) |
| 16 : isolate_(isolate), | 19 : isolate_(isolate), |
| 17 zone_(zone), | 20 zone_(zone), |
| 21 eager_inner_functions_(eager_inner_functions), |
| 18 next_id_(BailoutId::FirstUsable().ToInt()), | 22 next_id_(BailoutId::FirstUsable().ToInt()), |
| 19 yield_count_(0), | 23 yield_count_(0), |
| 20 properties_(zone), | 24 properties_(zone), |
| 21 slot_cache_(zone), | 25 slot_cache_(zone), |
| 22 disable_crankshaft_reason_(kNoReason), | 26 disable_crankshaft_reason_(kNoReason), |
| 23 dont_optimize_reason_(kNoReason), | 27 dont_optimize_reason_(kNoReason), |
| 24 catch_prediction_(HandlerTable::UNCAUGHT) { | 28 catch_prediction_(HandlerTable::UNCAUGHT) { |
| 25 InitializeAstVisitor(isolate); | 29 InitializeAstVisitor(isolate); |
| 26 } | 30 } |
| 27 | 31 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 66 } |
| 63 | 67 |
| 64 template <typename Node> | 68 template <typename Node> |
| 65 void ReserveFeedbackSlots(Node* node) { | 69 void ReserveFeedbackSlots(Node* node) { |
| 66 node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), | 70 node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), |
| 67 &slot_cache_); | 71 &slot_cache_); |
| 68 } | 72 } |
| 69 | 73 |
| 70 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } | 74 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } |
| 71 | 75 |
| 76 Zone* zone() const { return zone_; } |
| 77 |
| 72 Isolate* isolate_; | 78 Isolate* isolate_; |
| 73 Zone* zone_; | 79 Zone* zone_; |
| 80 ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* eager_inner_functions_; |
| 74 int next_id_; | 81 int next_id_; |
| 75 int yield_count_; | 82 int yield_count_; |
| 76 AstProperties properties_; | 83 AstProperties properties_; |
| 77 // The slot cache allows us to reuse certain feedback vector slots. | 84 // The slot cache allows us to reuse certain feedback vector slots. |
| 78 FeedbackVectorSlotCache slot_cache_; | 85 FeedbackVectorSlotCache slot_cache_; |
| 79 BailoutReason disable_crankshaft_reason_; | 86 BailoutReason disable_crankshaft_reason_; |
| 80 BailoutReason dont_optimize_reason_; | 87 BailoutReason dont_optimize_reason_; |
| 81 HandlerTable::CatchPrediction catch_prediction_; | 88 HandlerTable::CatchPrediction catch_prediction_; |
| 82 | 89 |
| 83 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 90 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) { | 593 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { |
| 587 for (int i = 0; i < arguments->length(); i++) { | 594 for (int i = 0; i < arguments->length(); i++) { |
| 588 Visit(arguments->at(i)); | 595 Visit(arguments->at(i)); |
| 589 } | 596 } |
| 590 } | 597 } |
| 591 | 598 |
| 592 | 599 |
| 593 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { | 600 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { |
| 594 IncrementNodeCount(); | 601 IncrementNodeCount(); |
| 595 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); | 602 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); |
| 603 if (node->ShouldEagerCompile()) { |
| 604 eager_inner_functions_->Add( |
| 605 new (zone()) ThreadedListZoneEntry<FunctionLiteral*>(node)); |
| 606 } |
| 596 // We don't recurse into the declarations or body of the function literal: | 607 // We don't recurse into the declarations or body of the function literal: |
| 597 // you have to separately Renumber() each FunctionLiteral that you compile. | 608 // you have to separately Renumber() each FunctionLiteral that you compile. |
| 598 } | 609 } |
| 599 | 610 |
| 600 | 611 |
| 601 void AstNumberingVisitor::VisitRewritableExpression( | 612 void AstNumberingVisitor::VisitRewritableExpression( |
| 602 RewritableExpression* node) { | 613 RewritableExpression* node) { |
| 603 IncrementNodeCount(); | 614 IncrementNodeCount(); |
| 604 node->set_base_id(ReserveIdRange(RewritableExpression::num_ids())); | 615 node->set_base_id(ReserveIdRange(RewritableExpression::num_ids())); |
| 605 Visit(node->expression()); | 616 Visit(node->expression()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (disable_crankshaft_reason_ != kNoReason) { | 652 if (disable_crankshaft_reason_ != kNoReason) { |
| 642 PrintF("[enforcing Ignition and TurboFan for %s because: %s\n", | 653 PrintF("[enforcing Ignition and TurboFan for %s because: %s\n", |
| 643 node->debug_name()->ToCString().get(), | 654 node->debug_name()->ToCString().get(), |
| 644 GetBailoutReason(disable_crankshaft_reason_)); | 655 GetBailoutReason(disable_crankshaft_reason_)); |
| 645 } | 656 } |
| 646 } | 657 } |
| 647 | 658 |
| 648 return !HasStackOverflow(); | 659 return !HasStackOverflow(); |
| 649 } | 660 } |
| 650 | 661 |
| 651 | 662 bool AstNumbering::Renumber( |
| 652 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 663 Isolate* isolate, Zone* zone, FunctionLiteral* function, |
| 653 FunctionLiteral* function) { | 664 ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* |
| 654 AstNumberingVisitor visitor(isolate, zone); | 665 eager_inner_functions) { |
| 666 AstNumberingVisitor visitor(isolate, zone, eager_inner_functions); |
| 655 return visitor.Renumber(function); | 667 return visitor.Renumber(function); |
| 656 } | 668 } |
| 657 } // namespace internal | 669 } // namespace internal |
| 658 } // namespace v8 | 670 } // namespace v8 |
| OLD | NEW |