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-numbering.h" | 5 #include "src/ast-numbering.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/scopes.h" | 8 #include "src/scopes.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 class AstNumberingVisitor final : public AstVisitor { | 13 class AstNumberingVisitor final : public AstVisitor { |
14 public: | 14 public: |
15 AstNumberingVisitor(Isolate* isolate, Zone* zone) | 15 AstNumberingVisitor(Isolate* isolate, Zone* zone) |
16 : AstVisitor(), | 16 : AstVisitor(), |
17 isolate_(isolate), | 17 isolate_(isolate), |
| 18 zone_(zone), |
18 next_id_(BailoutId::FirstUsable().ToInt()), | 19 next_id_(BailoutId::FirstUsable().ToInt()), |
19 properties_(zone), | 20 properties_(zone), |
20 slot_cache_(zone), | 21 slot_cache_(zone), |
21 dont_optimize_reason_(kNoReason) { | 22 dont_optimize_reason_(kNoReason) { |
22 InitializeAstVisitor(isolate, zone); | 23 InitializeAstVisitor(isolate); |
23 } | 24 } |
24 | 25 |
25 bool Renumber(FunctionLiteral* node); | 26 bool Renumber(FunctionLiteral* node); |
26 | 27 |
27 private: | 28 private: |
28 // AST node visitor interface. | 29 // AST node visitor interface. |
29 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) override; | 30 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) override; |
30 AST_NODE_LIST(DEFINE_VISIT) | 31 AST_NODE_LIST(DEFINE_VISIT) |
31 #undef DEFINE_VISIT | 32 #undef DEFINE_VISIT |
32 | 33 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 67 |
67 template <typename Node> | 68 template <typename Node> |
68 void ReserveFeedbackSlots(Node* node) { | 69 void ReserveFeedbackSlots(Node* node) { |
69 node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), | 70 node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), |
70 &slot_cache_); | 71 &slot_cache_); |
71 } | 72 } |
72 | 73 |
73 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } | 74 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } |
74 | 75 |
75 Isolate* isolate_; | 76 Isolate* isolate_; |
| 77 Zone* zone_; |
76 int next_id_; | 78 int next_id_; |
77 AstProperties properties_; | 79 AstProperties properties_; |
78 // The slot cache allows us to reuse certain feedback vector slots. | 80 // The slot cache allows us to reuse certain feedback vector slots. |
79 FeedbackVectorSlotCache slot_cache_; | 81 FeedbackVectorSlotCache slot_cache_; |
80 BailoutReason dont_optimize_reason_; | 82 BailoutReason dont_optimize_reason_; |
81 | 83 |
82 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 84 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
83 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); | 85 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
84 }; | 86 }; |
85 | 87 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { | 467 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { |
466 IncrementNodeCount(); | 468 IncrementNodeCount(); |
467 node->set_base_id(ReserveIdRange(node->num_ids())); | 469 node->set_base_id(ReserveIdRange(node->num_ids())); |
468 for (int i = 0; i < node->properties()->length(); i++) { | 470 for (int i = 0; i < node->properties()->length(); i++) { |
469 VisitObjectLiteralProperty(node->properties()->at(i)); | 471 VisitObjectLiteralProperty(node->properties()->at(i)); |
470 } | 472 } |
471 node->BuildConstantProperties(isolate_); | 473 node->BuildConstantProperties(isolate_); |
472 // Mark all computed expressions that are bound to a key that | 474 // Mark all computed expressions that are bound to a key that |
473 // is shadowed by a later occurrence of the same key. For the | 475 // is shadowed by a later occurrence of the same key. For the |
474 // marked expressions, no store code will be is emitted. | 476 // marked expressions, no store code will be is emitted. |
475 node->CalculateEmitStore(zone()); | 477 node->CalculateEmitStore(zone_); |
476 ReserveFeedbackSlots(node); | 478 ReserveFeedbackSlots(node); |
477 } | 479 } |
478 | 480 |
479 | 481 |
480 void AstNumberingVisitor::VisitObjectLiteralProperty( | 482 void AstNumberingVisitor::VisitObjectLiteralProperty( |
481 ObjectLiteralProperty* node) { | 483 ObjectLiteralProperty* node) { |
482 if (node->is_computed_name()) DisableCrankshaft(kComputedPropertyName); | 484 if (node->is_computed_name()) DisableCrankshaft(kComputedPropertyName); |
483 Visit(node->key()); | 485 Visit(node->key()); |
484 Visit(node->value()); | 486 Visit(node->value()); |
485 } | 487 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 } | 574 } |
573 | 575 |
574 | 576 |
575 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 577 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, |
576 FunctionLiteral* function) { | 578 FunctionLiteral* function) { |
577 AstNumberingVisitor visitor(isolate, zone); | 579 AstNumberingVisitor visitor(isolate, zone); |
578 return visitor.Renumber(function); | 580 return visitor.Renumber(function); |
579 } | 581 } |
580 } // namespace internal | 582 } // namespace internal |
581 } // namespace v8 | 583 } // namespace v8 |
OLD | NEW |