| 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 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
| 6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
| 7 | 7 |
| 8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
| 9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
| 10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 | 128 |
| 129 // Typedef only introduced to avoid unreadable code. | 129 // Typedef only introduced to avoid unreadable code. |
| 130 typedef ZoneList<Handle<String>> ZoneStringList; | 130 typedef ZoneList<Handle<String>> ZoneStringList; |
| 131 typedef ZoneList<Handle<Object>> ZoneObjectList; | 131 typedef ZoneList<Handle<Object>> ZoneObjectList; |
| 132 | 132 |
| 133 | 133 |
| 134 class FeedbackVectorSlotCache { | 134 class FeedbackVectorSlotCache { |
| 135 public: | 135 public: |
| 136 explicit FeedbackVectorSlotCache(Zone* zone) | 136 explicit FeedbackVectorSlotCache(Zone* zone) |
| 137 : zone_(zone), | 137 : hash_map_(base::HashMap::PointersMatch, |
| 138 hash_map_(base::HashMap::PointersMatch, | |
| 139 ZoneHashMap::kDefaultHashMapCapacity, | 138 ZoneHashMap::kDefaultHashMapCapacity, |
| 140 ZoneAllocationPolicy(zone)) {} | 139 ZoneAllocationPolicy(zone)) {} |
| 141 | 140 |
| 142 void Put(Variable* variable, FeedbackVectorSlot slot) { | 141 void Put(Variable* variable, FeedbackVectorSlot slot) { |
| 143 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( | 142 ZoneHashMap::Entry* entry = |
| 144 variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_)); | 143 hash_map_.LookupOrInsert(variable, ComputePointerHash(variable)); |
| 145 entry->value = reinterpret_cast<void*>(slot.ToInt()); | 144 entry->value = reinterpret_cast<void*>(slot.ToInt()); |
| 146 } | 145 } |
| 147 | 146 |
| 148 ZoneHashMap::Entry* Get(Variable* variable) const { | 147 ZoneHashMap::Entry* Get(Variable* variable) const { |
| 149 return hash_map_.Lookup(variable, ComputePointerHash(variable)); | 148 return hash_map_.Lookup(variable, ComputePointerHash(variable)); |
| 150 } | 149 } |
| 151 | 150 |
| 152 private: | 151 private: |
| 153 Zone* zone_; | |
| 154 ZoneHashMap hash_map_; | 152 ZoneHashMap hash_map_; |
| 155 }; | 153 }; |
| 156 | 154 |
| 157 | 155 |
| 158 class AstProperties final BASE_EMBEDDED { | 156 class AstProperties final BASE_EMBEDDED { |
| 159 public: | 157 public: |
| 160 enum Flag { | 158 enum Flag { |
| 161 kNoFlags = 0, | 159 kNoFlags = 0, |
| 162 kDontSelfOptimize = 1 << 0, | 160 kDontSelfOptimize = 1 << 0, |
| 163 kDontCrankshaft = 1 << 1 | 161 kDontCrankshaft = 1 << 1 |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1468 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| 1471 ZoneAllocationPolicy> { | 1469 ZoneAllocationPolicy> { |
| 1472 public: | 1470 public: |
| 1473 explicit AccessorTable(Zone* zone) | 1471 explicit AccessorTable(Zone* zone) |
| 1474 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1472 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| 1475 ZoneAllocationPolicy>(Literal::Match, | 1473 ZoneAllocationPolicy>(Literal::Match, |
| 1476 ZoneAllocationPolicy(zone)), | 1474 ZoneAllocationPolicy(zone)), |
| 1477 zone_(zone) {} | 1475 zone_(zone) {} |
| 1478 | 1476 |
| 1479 Iterator lookup(Literal* literal) { | 1477 Iterator lookup(Literal* literal) { |
| 1480 Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); | 1478 Iterator it = find(literal, true); |
| 1481 if (it->second == NULL) it->second = new (zone_) ObjectLiteral::Accessors(); | 1479 if (it->second == NULL) it->second = new (zone_) ObjectLiteral::Accessors(); |
| 1482 return it; | 1480 return it; |
| 1483 } | 1481 } |
| 1484 | 1482 |
| 1485 private: | 1483 private: |
| 1486 Zone* zone_; | 1484 Zone* zone_; |
| 1487 }; | 1485 }; |
| 1488 | 1486 |
| 1489 | 1487 |
| 1490 // Node for capturing a regexp literal. | 1488 // Node for capturing a regexp literal. |
| (...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 : NULL; \ | 3533 : NULL; \ |
| 3536 } | 3534 } |
| 3537 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3535 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3538 #undef DECLARE_NODE_FUNCTIONS | 3536 #undef DECLARE_NODE_FUNCTIONS |
| 3539 | 3537 |
| 3540 | 3538 |
| 3541 } // namespace internal | 3539 } // namespace internal |
| 3542 } // namespace v8 | 3540 } // namespace v8 |
| 3543 | 3541 |
| 3544 #endif // V8_AST_AST_H_ | 3542 #endif // V8_AST_AST_H_ |
| OLD | NEW |