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

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

Issue 2764113002: [type-profile] Handle returns correctly. (Closed)
Patch Set: Private slot. 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
43 private: 36 private:
44 // AST node visitor interface. 37 // AST node visitor interface.
45 #define DEFINE_VISIT(type) void Visit##type(type* node); 38 #define DEFINE_VISIT(type) void Visit##type(type* node);
46 AST_NODE_LIST(DEFINE_VISIT) 39 AST_NODE_LIST(DEFINE_VISIT)
47 #undef DEFINE_VISIT 40 #undef DEFINE_VISIT
48 41
49 void VisitVariableProxy(VariableProxy* node, TypeofMode typeof_mode); 42 void VisitVariableProxy(VariableProxy* node, TypeofMode typeof_mode);
50 void VisitVariableProxyReference(VariableProxy* node); 43 void VisitVariableProxyReference(VariableProxy* node);
51 void VisitPropertyReference(Property* node); 44 void VisitPropertyReference(Property* node);
52 void VisitReference(Expression* expr); 45 void VisitReference(Expression* expr);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 int next_id_; 97 int next_id_;
105 int yield_count_; 98 int yield_count_;
106 AstProperties properties_; 99 AstProperties properties_;
107 LanguageMode language_mode_; 100 LanguageMode language_mode_;
108 // The slot cache allows us to reuse certain feedback slots. 101 // The slot cache allows us to reuse certain feedback slots.
109 FeedbackSlotCache slot_cache_; 102 FeedbackSlotCache slot_cache_;
110 BailoutReason disable_crankshaft_reason_; 103 BailoutReason disable_crankshaft_reason_;
111 BailoutReason dont_optimize_reason_; 104 BailoutReason dont_optimize_reason_;
112 HandlerTable::CatchPrediction catch_prediction_; 105 HandlerTable::CatchPrediction catch_prediction_;
113 bool collect_type_profile_; 106 bool collect_type_profile_;
114 FeedbackSlot type_profile_for_return_value_;
115 107
116 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 108 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
117 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); 109 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
118 }; 110 };
119 111
120 112
121 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { 113 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) {
122 IncrementNodeCount(); 114 IncrementNodeCount();
123 VisitVariableProxy(node->proxy()); 115 VisitVariableProxy(node->proxy());
124 } 116 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { 230 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) {
239 IncrementNodeCount(); 231 IncrementNodeCount();
240 Visit(node->expression()); 232 Visit(node->expression());
241 } 233 }
242 234
243 235
244 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { 236 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) {
245 IncrementNodeCount(); 237 IncrementNodeCount();
246 Visit(node->expression()); 238 Visit(node->expression());
247 239
248 node->SetTypeProfileSlot(TypeProfileSlotForReturnValue());
249
250 DCHECK(!node->is_async_return() || 240 DCHECK(!node->is_async_return() ||
251 properties_.flags() & AstProperties::kMustUseIgnitionTurbo); 241 properties_.flags() & AstProperties::kMustUseIgnitionTurbo);
252 } 242 }
253 243
254 244
255 void AstNumberingVisitor::VisitYield(Yield* node) { 245 void AstNumberingVisitor::VisitYield(Yield* node) {
256 node->set_yield_id(yield_count_); 246 node->set_yield_id(yield_count_);
257 yield_count_++; 247 yield_count_++;
258 IncrementNodeCount(); 248 IncrementNodeCount();
259 node->set_base_id(ReserveIdRange(Yield::num_ids())); 249 node->set_base_id(ReserveIdRange(Yield::num_ids()));
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 418 }
429 419
430 420
431 void AstNumberingVisitor::VisitAssignment(Assignment* node) { 421 void AstNumberingVisitor::VisitAssignment(Assignment* node) {
432 IncrementNodeCount(); 422 IncrementNodeCount();
433 node->set_base_id(ReserveIdRange(Assignment::num_ids())); 423 node->set_base_id(ReserveIdRange(Assignment::num_ids()));
434 424
435 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); 425 if (node->is_compound()) VisitBinaryOperation(node->binary_operation());
436 VisitReference(node->target()); 426 VisitReference(node->target());
437 Visit(node->value()); 427 Visit(node->value());
438 node->AssignFeedbackSlots(properties_.get_spec(), language_mode_, 428 ReserveFeedbackSlots(node);
439 &slot_cache_, collect_type_profile_);
440 } 429 }
441 430
442 431
443 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) { 432 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) {
444 IncrementNodeCount(); 433 IncrementNodeCount();
445 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids())); 434 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids()));
446 Visit(node->left()); 435 Visit(node->left());
447 Visit(node->right()); 436 Visit(node->right());
448 ReserveFeedbackSlots(node); 437 ReserveFeedbackSlots(node);
449 } 438 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 DisableFullCodegenAndCrankshaft(kGenerator); 684 DisableFullCodegenAndCrankshaft(kGenerator);
696 } 685 }
697 686
698 if (IsClassConstructor(node->kind())) { 687 if (IsClassConstructor(node->kind())) {
699 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); 688 DisableFullCodegenAndCrankshaft(kClassConstructorFunction);
700 } 689 }
701 690
702 LanguageModeScope language_mode_scope(this, node->language_mode()); 691 LanguageModeScope language_mode_scope(this, node->language_mode());
703 692
704 if (collect_type_profile_) { 693 if (collect_type_profile_) {
705 type_profile_for_return_value_ = 694 node->SetTypeProfileSlot(properties_.get_spec()->AddTypeProfileSlot());
706 properties_.get_spec()->AddTypeProfileSlot();
707 } 695 }
708 696
709 VisitDeclarations(scope->declarations()); 697 VisitDeclarations(scope->declarations());
710 VisitStatements(node->body()); 698 VisitStatements(node->body());
711 699
712 node->set_ast_properties(&properties_); 700 node->set_ast_properties(&properties_);
713 node->set_dont_optimize_reason(dont_optimize_reason()); 701 node->set_dont_optimize_reason(dont_optimize_reason());
714 node->set_yield_count(yield_count_); 702 node->set_yield_count(yield_count_);
715 703
716 if (FLAG_trace_opt) { 704 if (FLAG_trace_opt) {
(...skipping 21 matching lines...) Expand all
738 DisallowHeapAllocation no_allocation; 726 DisallowHeapAllocation no_allocation;
739 DisallowHandleAllocation no_handles; 727 DisallowHandleAllocation no_handles;
740 DisallowHandleDereference no_deref; 728 DisallowHandleDereference no_deref;
741 729
742 AstNumberingVisitor visitor(stack_limit, zone, eager_literals, 730 AstNumberingVisitor visitor(stack_limit, zone, eager_literals,
743 collect_type_profile); 731 collect_type_profile);
744 return visitor.Renumber(function); 732 return visitor.Renumber(function);
745 } 733 }
746 } // namespace internal 734 } // namespace internal
747 } // namespace v8 735 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/feedback-vector.h » ('j') | src/runtime/runtime-object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698