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

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

Issue 2676583002: [ic] Encode [Keyed]StoreIC's language mode in slot kind instead of code object's flags. (Closed)
Patch Set: Rebasing Created 3 years, 10 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"
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 : zone_(zone), 19 : zone_(zone),
20 eager_literals_(eager_literals), 20 eager_literals_(eager_literals),
21 next_id_(BailoutId::FirstUsable().ToInt()), 21 next_id_(BailoutId::FirstUsable().ToInt()),
22 yield_count_(0), 22 yield_count_(0),
23 properties_(zone), 23 properties_(zone),
24 language_mode_(SLOPPY),
24 slot_cache_(zone), 25 slot_cache_(zone),
25 disable_crankshaft_reason_(kNoReason), 26 disable_crankshaft_reason_(kNoReason),
26 dont_optimize_reason_(kNoReason), 27 dont_optimize_reason_(kNoReason),
27 catch_prediction_(HandlerTable::UNCAUGHT) { 28 catch_prediction_(HandlerTable::UNCAUGHT) {
28 InitializeAstVisitor(stack_limit); 29 InitializeAstVisitor(stack_limit);
29 } 30 }
30 31
31 bool Renumber(FunctionLiteral* node); 32 bool Renumber(FunctionLiteral* node);
32 33
33 private: 34 private:
34 // AST node visitor interface. 35 // AST node visitor interface.
35 #define DEFINE_VISIT(type) void Visit##type(type* node); 36 #define DEFINE_VISIT(type) void Visit##type(type* node);
36 AST_NODE_LIST(DEFINE_VISIT) 37 AST_NODE_LIST(DEFINE_VISIT)
37 #undef DEFINE_VISIT 38 #undef DEFINE_VISIT
38 39
39 void VisitVariableProxyReference(VariableProxy* node); 40 void VisitVariableProxyReference(VariableProxy* node);
40 void VisitPropertyReference(Property* node); 41 void VisitPropertyReference(Property* node);
41 void VisitReference(Expression* expr); 42 void VisitReference(Expression* expr);
42 43
44 void VisitStatementsAndDeclarations(Block* node);
43 void VisitStatements(ZoneList<Statement*>* statements); 45 void VisitStatements(ZoneList<Statement*>* statements);
44 void VisitDeclarations(Declaration::List* declarations); 46 void VisitDeclarations(Declaration::List* declarations);
45 void VisitArguments(ZoneList<Expression*>* arguments); 47 void VisitArguments(ZoneList<Expression*>* arguments);
46 void VisitLiteralProperty(LiteralProperty* property); 48 void VisitLiteralProperty(LiteralProperty* property);
47 49
48 int ReserveIdRange(int n) { 50 int ReserveIdRange(int n) {
49 int tmp = next_id_; 51 int tmp = next_id_;
50 next_id_ += n; 52 next_id_ += n;
51 return tmp; 53 return tmp;
52 } 54 }
53 55
54 void IncrementNodeCount() { properties_.add_node_count(1); } 56 void IncrementNodeCount() { properties_.add_node_count(1); }
55 void DisableSelfOptimization() { 57 void DisableSelfOptimization() {
56 properties_.flags() |= AstProperties::kDontSelfOptimize; 58 properties_.flags() |= AstProperties::kDontSelfOptimize;
57 } 59 }
58 void DisableOptimization(BailoutReason reason) { 60 void DisableOptimization(BailoutReason reason) {
59 dont_optimize_reason_ = reason; 61 dont_optimize_reason_ = reason;
60 DisableSelfOptimization(); 62 DisableSelfOptimization();
61 } 63 }
62 void DisableFullCodegenAndCrankshaft(BailoutReason reason) { 64 void DisableFullCodegenAndCrankshaft(BailoutReason reason) {
63 disable_crankshaft_reason_ = reason; 65 disable_crankshaft_reason_ = reason;
64 properties_.flags() |= AstProperties::kMustUseIgnitionTurbo; 66 properties_.flags() |= AstProperties::kMustUseIgnitionTurbo;
65 } 67 }
66 68
67 template <typename Node> 69 template <typename Node>
68 void ReserveFeedbackSlots(Node* node) { 70 void ReserveFeedbackSlots(Node* node) {
69 node->AssignFeedbackVectorSlots(properties_.get_spec(), &slot_cache_); 71 node->AssignFeedbackVectorSlots(properties_.get_spec(), language_mode_,
72 &slot_cache_);
70 } 73 }
71 74
75 class LanguageModeScope {
76 public:
77 LanguageModeScope(AstNumberingVisitor* visitor, LanguageMode language_mode)
78 : visitor_(visitor), outer_language_mode_(visitor->language_mode_) {
79 visitor_->language_mode_ = language_mode;
80 }
81 ~LanguageModeScope() { visitor_->language_mode_ = outer_language_mode_; }
82
83 private:
84 AstNumberingVisitor* visitor_;
85 LanguageMode outer_language_mode_;
86 };
87
72 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } 88 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
73 89
74 Zone* zone() const { return zone_; } 90 Zone* zone() const { return zone_; }
75 91
76 Zone* zone_; 92 Zone* zone_;
77 Compiler::EagerInnerFunctionLiterals* eager_literals_; 93 Compiler::EagerInnerFunctionLiterals* eager_literals_;
78 int next_id_; 94 int next_id_;
79 int yield_count_; 95 int yield_count_;
80 AstProperties properties_; 96 AstProperties properties_;
97 LanguageMode language_mode_;
81 // The slot cache allows us to reuse certain feedback vector slots. 98 // The slot cache allows us to reuse certain feedback vector slots.
82 FeedbackVectorSlotCache slot_cache_; 99 FeedbackVectorSlotCache slot_cache_;
83 BailoutReason disable_crankshaft_reason_; 100 BailoutReason disable_crankshaft_reason_;
84 BailoutReason dont_optimize_reason_; 101 BailoutReason dont_optimize_reason_;
85 HandlerTable::CatchPrediction catch_prediction_; 102 HandlerTable::CatchPrediction catch_prediction_;
86 103
87 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 104 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
88 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); 105 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
89 }; 106 };
90 107
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 IncrementNodeCount(); 259 IncrementNodeCount();
243 node->set_base_id(ReserveIdRange(CountOperation::num_ids())); 260 node->set_base_id(ReserveIdRange(CountOperation::num_ids()));
244 Visit(node->expression()); 261 Visit(node->expression());
245 ReserveFeedbackSlots(node); 262 ReserveFeedbackSlots(node);
246 } 263 }
247 264
248 265
249 void AstNumberingVisitor::VisitBlock(Block* node) { 266 void AstNumberingVisitor::VisitBlock(Block* node) {
250 IncrementNodeCount(); 267 IncrementNodeCount();
251 node->set_base_id(ReserveIdRange(Block::num_ids())); 268 node->set_base_id(ReserveIdRange(Block::num_ids()));
252 if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations()); 269 Scope* scope = node->scope();
270 // TODO(ishell): remove scope->NeedsContext() condition once v8:5927 is fixed.
271 // Current logic mimics what BytecodeGenerator::VisitBlock() does.
272 if (scope != NULL && scope->NeedsContext()) {
273 LanguageModeScope language_mode_scope(this, scope->language_mode());
274 VisitStatementsAndDeclarations(node);
275 } else {
276 VisitStatementsAndDeclarations(node);
277 }
278 }
279
280 void AstNumberingVisitor::VisitStatementsAndDeclarations(Block* node) {
281 Scope* scope = node->scope();
282 if (scope) VisitDeclarations(scope->declarations());
253 VisitStatements(node->statements()); 283 VisitStatements(node->statements());
254 } 284 }
255 285
256
257 void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) { 286 void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) {
258 IncrementNodeCount(); 287 IncrementNodeCount();
259 VisitVariableProxy(node->proxy()); 288 VisitVariableProxy(node->proxy());
260 VisitFunctionLiteral(node->fun()); 289 VisitFunctionLiteral(node->fun());
261 } 290 }
262 291
263 292
264 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { 293 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
265 IncrementNodeCount(); 294 IncrementNodeCount();
266 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); 295 node->set_base_id(ReserveIdRange(CallRuntime::num_ids()));
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 662 }
634 663
635 if (IsResumableFunction(node->kind())) { 664 if (IsResumableFunction(node->kind())) {
636 DisableFullCodegenAndCrankshaft(kGenerator); 665 DisableFullCodegenAndCrankshaft(kGenerator);
637 } 666 }
638 667
639 if (IsClassConstructor(node->kind())) { 668 if (IsClassConstructor(node->kind())) {
640 DisableFullCodegenAndCrankshaft(kClassConstructorFunction); 669 DisableFullCodegenAndCrankshaft(kClassConstructorFunction);
641 } 670 }
642 671
672 LanguageModeScope language_mode_scope(this, node->language_mode());
673
643 VisitDeclarations(scope->declarations()); 674 VisitDeclarations(scope->declarations());
644 VisitStatements(node->body()); 675 VisitStatements(node->body());
645 676
646 node->set_ast_properties(&properties_); 677 node->set_ast_properties(&properties_);
647 node->set_dont_optimize_reason(dont_optimize_reason()); 678 node->set_dont_optimize_reason(dont_optimize_reason());
648 node->set_yield_count(yield_count_); 679 node->set_yield_count(yield_count_);
649 680
650 if (FLAG_trace_opt) { 681 if (FLAG_trace_opt) {
651 if (disable_crankshaft_reason_ != kNoReason) { 682 if (disable_crankshaft_reason_ != kNoReason) {
652 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of 683 // TODO(leszeks): This is a quick'n'dirty fix to allow the debug name of
(...skipping 17 matching lines...) Expand all
670 Compiler::EagerInnerFunctionLiterals* eager_literals) { 701 Compiler::EagerInnerFunctionLiterals* eager_literals) {
671 DisallowHeapAllocation no_allocation; 702 DisallowHeapAllocation no_allocation;
672 DisallowHandleAllocation no_handles; 703 DisallowHandleAllocation no_handles;
673 DisallowHandleDereference no_deref; 704 DisallowHandleDereference no_deref;
674 705
675 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); 706 AstNumberingVisitor visitor(stack_limit, zone, eager_literals);
676 return visitor.Renumber(function); 707 return visitor.Renumber(function);
677 } 708 }
678 } // namespace internal 709 } // namespace internal
679 } // namespace v8 710 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/builtins/builtins.h » ('j') | src/compiler/bytecode-graph-builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698