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 |
(...skipping 17 matching lines...) Expand all Loading... |
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-nullptr node, the caller can use |
| 39 // that |
39 // node. Otherwise it is the responsibility of the caller to fill the entry | 40 // node. Otherwise it is the responsibility of the caller to fill the entry |
40 // with a new node. | 41 // with a new node. |
41 // Note that a previous cache entry may be overwritten if the cache becomes | 42 // Note that a previous cache entry may be overwritten if the cache becomes |
42 // too full or encounters too many hash collisions. | 43 // too full or encounters too many hash collisions. |
43 Node** Find(Zone* zone, Key key); | 44 Node** Find(Zone* zone, Key key); |
44 | 45 |
45 // Appends all nodes from this cache to {nodes}. | 46 // Appends all nodes from this cache to {nodes}. |
46 void GetCachedNodes(ZoneVector<Node*>* nodes); | 47 void GetCachedNodes(ZoneVector<Node*>* nodes); |
47 | 48 |
48 private: | 49 private: |
(...skipping 17 matching lines...) Expand all Loading... |
66 typedef Int32NodeCache IntPtrNodeCache; | 67 typedef Int32NodeCache IntPtrNodeCache; |
67 #else | 68 #else |
68 typedef Int64NodeCache IntPtrNodeCache; | 69 typedef Int64NodeCache IntPtrNodeCache; |
69 #endif | 70 #endif |
70 | 71 |
71 } // namespace compiler | 72 } // namespace compiler |
72 } // namespace internal | 73 } // namespace internal |
73 } // namespace v8 | 74 } // namespace v8 |
74 | 75 |
75 #endif // V8_COMPILER_NODE_CACHE_H_ | 76 #endif // V8_COMPILER_NODE_CACHE_H_ |
OLD | NEW |