Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/ast/ast-numbering.cc

Issue 2755973002: [type profile] Collect return types. (Closed)
Patch Set: Clean up. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 667
658 void AstNumberingVisitor::VisitRewritableExpression( 668 void AstNumberingVisitor::VisitRewritableExpression(
659 RewritableExpression* node) { 669 RewritableExpression* node) {
660 IncrementNodeCount(); 670 IncrementNodeCount();
661 node->set_base_id(ReserveIdRange(RewritableExpression::num_ids())); 671 node->set_base_id(ReserveIdRange(RewritableExpression::num_ids()));
662 Visit(node->expression()); 672 Visit(node->expression());
663 } 673 }
664 674
665 675
666 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { 676 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
677 if (collect_type_profile_) {
678 type_profile_for_return_value_ =
Michael Starzinger 2017/03/20 09:29:26 nit: Please move this down to after the global com
Franzi 2017/03/20 15:38:39 Done.
679 properties_.get_spec()->AddTypeProfileSlot();
680 }
681
667 DeclarationScope* scope = node->scope(); 682 DeclarationScope* scope = node->scope();
668 DCHECK(!scope->HasBeenRemoved()); 683 DCHECK(!scope->HasBeenRemoved());
669 684
670 if (scope->new_target_var() != nullptr || 685 if (scope->new_target_var() != nullptr ||
671 scope->this_function_var() != nullptr) { 686 scope->this_function_var() != nullptr) {
672 DisableFullCodegenAndCrankshaft(kSuperReference); 687 DisableFullCodegenAndCrankshaft(kSuperReference);
673 } 688 }
674 689
675 if (scope->arguments() != nullptr && 690 if (scope->arguments() != nullptr &&
676 !scope->arguments()->IsStackAllocated()) { 691 !scope->arguments()->IsStackAllocated()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698