| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/scopes.h" | 9 #include "src/scopes.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 | 14 |
| 15 class AstNumberingVisitor FINAL : public AstVisitor { | 15 class AstNumberingVisitor FINAL : public AstVisitor { |
| 16 public: | 16 public: |
| 17 explicit AstNumberingVisitor(Isolate* isolate, Zone* zone) | 17 explicit AstNumberingVisitor(Isolate* isolate, Zone* zone) |
| 18 : AstVisitor(), | 18 : AstVisitor(), |
| 19 next_id_(BailoutId::FirstUsable().ToInt()), | 19 next_id_(BailoutId::FirstUsable().ToInt()), |
| 20 ic_slot_cache_(FLAG_vector_ics ? 4 : 0), |
| 20 dont_optimize_reason_(kNoReason) { | 21 dont_optimize_reason_(kNoReason) { |
| 21 InitializeAstVisitor(isolate, zone); | 22 InitializeAstVisitor(isolate, zone); |
| 22 } | 23 } |
| 23 | 24 |
| 24 bool Renumber(FunctionLiteral* node); | 25 bool Renumber(FunctionLiteral* node); |
| 25 | 26 |
| 26 private: | 27 private: |
| 27 // AST node visitor interface. | 28 // AST node visitor interface. |
| 28 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; | 29 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; |
| 29 AST_NODE_LIST(DEFINE_VISIT) | 30 AST_NODE_LIST(DEFINE_VISIT) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 52 } | 53 } |
| 53 void DisableCaching(BailoutReason reason) { | 54 void DisableCaching(BailoutReason reason) { |
| 54 dont_optimize_reason_ = reason; | 55 dont_optimize_reason_ = reason; |
| 55 DisableSelfOptimization(); | 56 DisableSelfOptimization(); |
| 56 properties_.flags()->Add(kDontCache); | 57 properties_.flags()->Add(kDontCache); |
| 57 } | 58 } |
| 58 | 59 |
| 59 template <typename Node> | 60 template <typename Node> |
| 60 void ReserveFeedbackSlots(Node* node) { | 61 void ReserveFeedbackSlots(Node* node) { |
| 61 FeedbackVectorRequirements reqs = | 62 FeedbackVectorRequirements reqs = |
| 62 node->ComputeFeedbackRequirements(isolate()); | 63 node->ComputeFeedbackRequirements(isolate(), &ic_slot_cache_); |
| 63 if (reqs.slots() > 0) { | 64 if (reqs.slots() > 0) { |
| 64 node->SetFirstFeedbackSlot(FeedbackVectorSlot(properties_.slots())); | 65 node->SetFirstFeedbackSlot(FeedbackVectorSlot(properties_.slots())); |
| 65 properties_.increase_slots(reqs.slots()); | 66 properties_.increase_slots(reqs.slots()); |
| 66 } | 67 } |
| 67 if (reqs.ic_slots() > 0) { | 68 if (reqs.ic_slots() > 0) { |
| 68 int ic_slots = properties_.ic_slots(); | 69 int ic_slots = properties_.ic_slots(); |
| 69 node->SetFirstFeedbackICSlot(FeedbackVectorICSlot(ic_slots)); | 70 node->SetFirstFeedbackICSlot(FeedbackVectorICSlot(ic_slots), |
| 71 &ic_slot_cache_); |
| 70 properties_.increase_ic_slots(reqs.ic_slots()); | 72 properties_.increase_ic_slots(reqs.ic_slots()); |
| 71 if (FLAG_vector_ics) { | 73 if (FLAG_vector_ics) { |
| 72 for (int i = 0; i < reqs.ic_slots(); i++) { | 74 for (int i = 0; i < reqs.ic_slots(); i++) { |
| 73 properties_.SetKind(ic_slots + i, node->FeedbackICSlotKind(i)); | 75 properties_.SetKind(ic_slots + i, node->FeedbackICSlotKind(i)); |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 } | 79 } |
| 78 | 80 |
| 79 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } | 81 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } |
| 80 | 82 |
| 81 int next_id_; | 83 int next_id_; |
| 82 AstProperties properties_; | 84 AstProperties properties_; |
| 85 // The slot cache allows us to reuse certain vector IC slots. It's only used |
| 86 // if FLAG_vector_ics is true. |
| 87 ICSlotCache ic_slot_cache_; |
| 83 BailoutReason dont_optimize_reason_; | 88 BailoutReason dont_optimize_reason_; |
| 84 | 89 |
| 85 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 90 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 86 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); | 91 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
| 87 }; | 92 }; |
| 88 | 93 |
| 89 | 94 |
| 90 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { | 95 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { |
| 91 IncrementNodeCount(); | 96 IncrementNodeCount(); |
| 92 VisitVariableProxy(node->proxy()); | 97 VisitVariableProxy(node->proxy()); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 555 } |
| 551 | 556 |
| 552 | 557 |
| 553 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 558 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, |
| 554 FunctionLiteral* function) { | 559 FunctionLiteral* function) { |
| 555 AstNumberingVisitor visitor(isolate, zone); | 560 AstNumberingVisitor visitor(isolate, zone); |
| 556 return visitor.Renumber(function); | 561 return visitor.Renumber(function); |
| 557 } | 562 } |
| 558 } | 563 } |
| 559 } // namespace v8::internal | 564 } // namespace v8::internal |
| OLD | NEW |