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