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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 slot_cache_(zone), | 26 slot_cache_(zone), |
27 disable_crankshaft_reason_(kNoReason), | 27 disable_crankshaft_reason_(kNoReason), |
28 dont_optimize_reason_(kNoReason), | 28 dont_optimize_reason_(kNoReason), |
29 catch_prediction_(HandlerTable::UNCAUGHT), | 29 catch_prediction_(HandlerTable::UNCAUGHT), |
30 collect_type_profile_(collect_type_profile) { | 30 collect_type_profile_(collect_type_profile) { |
31 InitializeAstVisitor(stack_limit); | 31 InitializeAstVisitor(stack_limit); |
32 } | 32 } |
33 | 33 |
34 bool Renumber(FunctionLiteral* node); | 34 bool Renumber(FunctionLiteral* node); |
35 | 35 |
| 36 FeedbackSlot TypeProfileSlotForReturnValue() const { |
| 37 if (collect_type_profile_) { |
| 38 DCHECK(!type_profile_for_return_value_.IsInvalid()); |
| 39 } |
| 40 return type_profile_for_return_value_; |
| 41 } |
| 42 |
36 private: | 43 private: |
37 // AST node visitor interface. | 44 // AST node visitor interface. |
38 #define DEFINE_VISIT(type) void Visit##type(type* node); | 45 #define DEFINE_VISIT(type) void Visit##type(type* node); |
39 AST_NODE_LIST(DEFINE_VISIT) | 46 AST_NODE_LIST(DEFINE_VISIT) |
40 #undef DEFINE_VISIT | 47 #undef DEFINE_VISIT |
41 | 48 |
42 void VisitVariableProxy(VariableProxy* node, TypeofMode typeof_mode); | 49 void VisitVariableProxy(VariableProxy* node, TypeofMode typeof_mode); |
43 void VisitVariableProxyReference(VariableProxy* node); | 50 void VisitVariableProxyReference(VariableProxy* node); |
44 void VisitPropertyReference(Property* node); | 51 void VisitPropertyReference(Property* node); |
45 void VisitReference(Expression* expr); | 52 void VisitReference(Expression* expr); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 int next_id_; | 104 int next_id_; |
98 int yield_count_; | 105 int yield_count_; |
99 AstProperties properties_; | 106 AstProperties properties_; |
100 LanguageMode language_mode_; | 107 LanguageMode language_mode_; |
101 // The slot cache allows us to reuse certain feedback slots. | 108 // The slot cache allows us to reuse certain feedback slots. |
102 FeedbackSlotCache slot_cache_; | 109 FeedbackSlotCache slot_cache_; |
103 BailoutReason disable_crankshaft_reason_; | 110 BailoutReason disable_crankshaft_reason_; |
104 BailoutReason dont_optimize_reason_; | 111 BailoutReason dont_optimize_reason_; |
105 HandlerTable::CatchPrediction catch_prediction_; | 112 HandlerTable::CatchPrediction catch_prediction_; |
106 bool collect_type_profile_; | 113 bool collect_type_profile_; |
| 114 FeedbackSlot type_profile_for_return_value_; |
107 | 115 |
108 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 116 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
109 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); | 117 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
110 }; | 118 }; |
111 | 119 |
112 | 120 |
113 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { | 121 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { |
114 IncrementNodeCount(); | 122 IncrementNodeCount(); |
115 VisitVariableProxy(node->proxy()); | 123 VisitVariableProxy(node->proxy()); |
116 } | 124 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { | 238 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { |
231 IncrementNodeCount(); | 239 IncrementNodeCount(); |
232 Visit(node->expression()); | 240 Visit(node->expression()); |
233 } | 241 } |
234 | 242 |
235 | 243 |
236 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { | 244 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { |
237 IncrementNodeCount(); | 245 IncrementNodeCount(); |
238 Visit(node->expression()); | 246 Visit(node->expression()); |
239 | 247 |
| 248 node->SetTypeProfileSlot(TypeProfileSlotForReturnValue()); |
| 249 |
240 DCHECK(!node->is_async_return() || | 250 DCHECK(!node->is_async_return() || |
241 properties_.flags() & AstProperties::kMustUseIgnitionTurbo); | 251 properties_.flags() & AstProperties::kMustUseIgnitionTurbo); |
242 } | 252 } |
243 | 253 |
244 | 254 |
245 void AstNumberingVisitor::VisitYield(Yield* node) { | 255 void AstNumberingVisitor::VisitYield(Yield* node) { |
246 node->set_yield_id(yield_count_); | 256 node->set_yield_id(yield_count_); |
247 yield_count_++; | 257 yield_count_++; |
248 IncrementNodeCount(); | 258 IncrementNodeCount(); |
249 node->set_base_id(ReserveIdRange(Yield::num_ids())); | 259 node->set_base_id(ReserveIdRange(Yield::num_ids())); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 if (IsResumableFunction(node->kind())) { | 694 if (IsResumableFunction(node->kind())) { |
685 DisableFullCodegenAndCrankshaft(kGenerator); | 695 DisableFullCodegenAndCrankshaft(kGenerator); |
686 } | 696 } |
687 | 697 |
688 if (IsClassConstructor(node->kind())) { | 698 if (IsClassConstructor(node->kind())) { |
689 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); | 699 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); |
690 } | 700 } |
691 | 701 |
692 LanguageModeScope language_mode_scope(this, node->language_mode()); | 702 LanguageModeScope language_mode_scope(this, node->language_mode()); |
693 | 703 |
| 704 if (collect_type_profile_) { |
| 705 type_profile_for_return_value_ = |
| 706 properties_.get_spec()->AddTypeProfileSlot(); |
| 707 } |
| 708 |
694 VisitDeclarations(scope->declarations()); | 709 VisitDeclarations(scope->declarations()); |
695 VisitStatements(node->body()); | 710 VisitStatements(node->body()); |
696 | 711 |
697 node->set_ast_properties(&properties_); | 712 node->set_ast_properties(&properties_); |
698 node->set_dont_optimize_reason(dont_optimize_reason()); | 713 node->set_dont_optimize_reason(dont_optimize_reason()); |
699 node->set_yield_count(yield_count_); | 714 node->set_yield_count(yield_count_); |
700 | 715 |
701 if (FLAG_trace_opt) { | 716 if (FLAG_trace_opt) { |
702 if (disable_crankshaft_reason_ != kNoReason) { | 717 if (disable_crankshaft_reason_ != kNoReason) { |
703 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of | 718 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of |
(...skipping 19 matching lines...) Expand all Loading... |
723 DisallowHeapAllocation no_allocation; | 738 DisallowHeapAllocation no_allocation; |
724 DisallowHandleAllocation no_handles; | 739 DisallowHandleAllocation no_handles; |
725 DisallowHandleDereference no_deref; | 740 DisallowHandleDereference no_deref; |
726 | 741 |
727 AstNumberingVisitor visitor(stack_limit, zone, eager_literals, | 742 AstNumberingVisitor visitor(stack_limit, zone, eager_literals, |
728 collect_type_profile); | 743 collect_type_profile); |
729 return visitor.Renumber(function); | 744 return visitor.Renumber(function); |
730 } | 745 } |
731 } // namespace internal | 746 } // namespace internal |
732 } // namespace v8 | 747 } // namespace v8 |
OLD | NEW |