| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_COMPILER_NODE_CACHE_H_ | 5 #ifndef V8_COMPILER_NODE_CACHE_H_ |
| 6 #define V8_COMPILER_NODE_CACHE_H_ | 6 #define V8_COMPILER_NODE_CACHE_H_ |
| 7 | 7 |
| 8 #include "src/base/functional.h" | 8 #include "src/base/functional.h" |
| 9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 // Forward declarations. | 14 // Forward declarations. |
| 15 class Zone; | 15 class Zone; |
| 16 template <typename> | 16 template <typename> |
| 17 class ZoneVector; | 17 class ZoneVector; |
| 18 | 18 |
| 19 | 19 |
| 20 namespace compiler { | 20 namespace compiler { |
| 21 | 21 |
| 22 // Forward declarations. | 22 // Forward declarations. |
| 23 class Node; | 23 class Node; |
| 24 | 24 |
| 25 | 25 |
| 26 // A cache for nodes based on a key. Useful for implementing canonicalization of | 26 // A cache for nodes based on a key. Useful for implementing canonicalization of |
| 27 // nodes such as constants, parameters, etc. | 27 // nodes such as constants, parameters, etc. |
| 28 template <typename Key, typename Hash = base::hash<Key>, | 28 template <typename Key, typename Hash = base::hash<Key>, |
| 29 typename Pred = std::equal_to<Key> > | 29 typename Pred = std::equal_to<Key> > |
| 30 class NodeCache FINAL { | 30 class NodeCache final { |
| 31 public: | 31 public: |
| 32 explicit NodeCache(unsigned max = 256) | 32 explicit NodeCache(unsigned max = 256) |
| 33 : entries_(nullptr), size_(0), max_(max) {} | 33 : entries_(nullptr), size_(0), max_(max) {} |
| 34 ~NodeCache() {} | 34 ~NodeCache() {} |
| 35 | 35 |
| 36 // Search for node associated with {key} and return a pointer to a memory | 36 // Search for node associated with {key} and return a pointer to a memory |
| 37 // location in this cache that stores an entry for the key. If the location | 37 // location in this cache that stores an entry for the key. If the location |
| 38 // returned by this method contains a non-NULL node, the caller can use that | 38 // returned by this method contains a non-NULL node, the caller can use that |
| 39 // node. Otherwise it is the responsibility of the caller to fill the entry | 39 // node. Otherwise it is the responsibility of the caller to fill the entry |
| 40 // with a new node. | 40 // with a new node. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 66 typedef Int32NodeCache IntPtrNodeCache; | 66 typedef Int32NodeCache IntPtrNodeCache; |
| 67 #else | 67 #else |
| 68 typedef Int64NodeCache IntPtrNodeCache; | 68 typedef Int64NodeCache IntPtrNodeCache; |
| 69 #endif | 69 #endif |
| 70 | 70 |
| 71 } // namespace compiler | 71 } // namespace compiler |
| 72 } // namespace internal | 72 } // namespace internal |
| 73 } // namespace v8 | 73 } // namespace v8 |
| 74 | 74 |
| 75 #endif // V8_COMPILER_NODE_CACHE_H_ | 75 #endif // V8_COMPILER_NODE_CACHE_H_ |
| OLD | NEW |