| 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/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { | 15 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { |
| 16 public: | 16 public: |
| 17 AstNumberingVisitor(uintptr_t stack_limit, Zone* zone, | 17 AstNumberingVisitor(uintptr_t stack_limit, Zone* zone, |
| 18 Compiler::EagerInnerFunctionLiterals* eager_literals) | 18 Compiler::EagerInnerFunctionLiterals* eager_literals, |
| 19 bool collect_type_profile = false) |
| 19 : zone_(zone), | 20 : zone_(zone), |
| 20 eager_literals_(eager_literals), | 21 eager_literals_(eager_literals), |
| 21 next_id_(BailoutId::FirstUsable().ToInt()), | 22 next_id_(BailoutId::FirstUsable().ToInt()), |
| 22 yield_count_(0), | 23 yield_count_(0), |
| 23 properties_(zone), | 24 properties_(zone), |
| 24 language_mode_(SLOPPY), | 25 language_mode_(SLOPPY), |
| 25 slot_cache_(zone), | 26 slot_cache_(zone), |
| 26 disable_crankshaft_reason_(kNoReason), | 27 disable_crankshaft_reason_(kNoReason), |
| 27 dont_optimize_reason_(kNoReason), | 28 dont_optimize_reason_(kNoReason), |
| 28 catch_prediction_(HandlerTable::UNCAUGHT) { | 29 catch_prediction_(HandlerTable::UNCAUGHT), |
| 30 collect_type_profile_(collect_type_profile) { |
| 29 InitializeAstVisitor(stack_limit); | 31 InitializeAstVisitor(stack_limit); |
| 30 } | 32 } |
| 31 | 33 |
| 32 bool Renumber(FunctionLiteral* node); | 34 bool Renumber(FunctionLiteral* node); |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 // AST node visitor interface. | 37 // AST node visitor interface. |
| 36 #define DEFINE_VISIT(type) void Visit##type(type* node); | 38 #define DEFINE_VISIT(type) void Visit##type(type* node); |
| 37 AST_NODE_LIST(DEFINE_VISIT) | 39 AST_NODE_LIST(DEFINE_VISIT) |
| 38 #undef DEFINE_VISIT | 40 #undef DEFINE_VISIT |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Compiler::EagerInnerFunctionLiterals* eager_literals_; | 96 Compiler::EagerInnerFunctionLiterals* eager_literals_; |
| 95 int next_id_; | 97 int next_id_; |
| 96 int yield_count_; | 98 int yield_count_; |
| 97 AstProperties properties_; | 99 AstProperties properties_; |
| 98 LanguageMode language_mode_; | 100 LanguageMode language_mode_; |
| 99 // The slot cache allows us to reuse certain feedback slots. | 101 // The slot cache allows us to reuse certain feedback slots. |
| 100 FeedbackSlotCache slot_cache_; | 102 FeedbackSlotCache slot_cache_; |
| 101 BailoutReason disable_crankshaft_reason_; | 103 BailoutReason disable_crankshaft_reason_; |
| 102 BailoutReason dont_optimize_reason_; | 104 BailoutReason dont_optimize_reason_; |
| 103 HandlerTable::CatchPrediction catch_prediction_; | 105 HandlerTable::CatchPrediction catch_prediction_; |
| 106 bool collect_type_profile_; |
| 104 | 107 |
| 105 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 108 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 106 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); | 109 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 | 112 |
| 110 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { | 113 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { |
| 111 IncrementNodeCount(); | 114 IncrementNodeCount(); |
| 112 VisitVariableProxy(node->proxy()); | 115 VisitVariableProxy(node->proxy()); |
| 113 } | 116 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 418 } |
| 416 | 419 |
| 417 | 420 |
| 418 void AstNumberingVisitor::VisitAssignment(Assignment* node) { | 421 void AstNumberingVisitor::VisitAssignment(Assignment* node) { |
| 419 IncrementNodeCount(); | 422 IncrementNodeCount(); |
| 420 node->set_base_id(ReserveIdRange(Assignment::num_ids())); | 423 node->set_base_id(ReserveIdRange(Assignment::num_ids())); |
| 421 | 424 |
| 422 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); | 425 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); |
| 423 VisitReference(node->target()); | 426 VisitReference(node->target()); |
| 424 Visit(node->value()); | 427 Visit(node->value()); |
| 425 ReserveFeedbackSlots(node); | 428 node->AssignFeedbackSlots(properties_.get_spec(), language_mode_, |
| 429 &slot_cache_, collect_type_profile_); |
| 426 } | 430 } |
| 427 | 431 |
| 428 | 432 |
| 429 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) { | 433 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) { |
| 430 IncrementNodeCount(); | 434 IncrementNodeCount(); |
| 431 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids())); | 435 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids())); |
| 432 Visit(node->left()); | 436 Visit(node->left()); |
| 433 Visit(node->right()); | 437 Visit(node->right()); |
| 434 ReserveFeedbackSlots(node); | 438 ReserveFeedbackSlots(node); |
| 435 } | 439 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 node->debug_name()->ToCString().get(), | 711 node->debug_name()->ToCString().get(), |
| 708 GetBailoutReason(disable_crankshaft_reason_)); | 712 GetBailoutReason(disable_crankshaft_reason_)); |
| 709 } | 713 } |
| 710 } | 714 } |
| 711 | 715 |
| 712 return !HasStackOverflow(); | 716 return !HasStackOverflow(); |
| 713 } | 717 } |
| 714 | 718 |
| 715 bool AstNumbering::Renumber( | 719 bool AstNumbering::Renumber( |
| 716 uintptr_t stack_limit, Zone* zone, FunctionLiteral* function, | 720 uintptr_t stack_limit, Zone* zone, FunctionLiteral* function, |
| 717 Compiler::EagerInnerFunctionLiterals* eager_literals) { | 721 Compiler::EagerInnerFunctionLiterals* eager_literals, |
| 722 bool collect_type_profile) { |
| 718 DisallowHeapAllocation no_allocation; | 723 DisallowHeapAllocation no_allocation; |
| 719 DisallowHandleAllocation no_handles; | 724 DisallowHandleAllocation no_handles; |
| 720 DisallowHandleDereference no_deref; | 725 DisallowHandleDereference no_deref; |
| 721 | 726 |
| 722 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); | 727 AstNumberingVisitor visitor(stack_limit, zone, eager_literals, |
| 728 collect_type_profile); |
| 723 return visitor.Renumber(function); | 729 return visitor.Renumber(function); |
| 724 } | 730 } |
| 725 } // namespace internal | 731 } // namespace internal |
| 726 } // namespace v8 | 732 } // namespace v8 |
| OLD | NEW |