diff options
Diffstat (limited to 'deps/v8/src/compiler/node-cache.h')
-rw-r--r-- | deps/v8/src/compiler/node-cache.h | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/deps/v8/src/compiler/node-cache.h b/deps/v8/src/compiler/node-cache.h index 35352ea1eb..2622e4d6cc 100644 --- a/deps/v8/src/compiler/node-cache.h +++ b/deps/v8/src/compiler/node-cache.h @@ -5,8 +5,8 @@ #ifndef V8_COMPILER_NODE_CACHE_H_ #define V8_COMPILER_NODE_CACHE_H_ -#include "src/v8.h" - +#include "src/base/functional.h" +#include "src/base/macros.h" #include "src/compiler/node.h" namespace v8 { @@ -15,10 +15,12 @@ namespace compiler { // A cache for nodes based on a key. Useful for implementing canonicalization of // nodes such as constants, parameters, etc. -template <typename Key> -class NodeCache { +template <typename Key, typename Hash = base::hash<Key>, + typename Pred = std::equal_to<Key> > +class NodeCache FINAL { public: - explicit NodeCache(int max = 256) : entries_(NULL), size_(0), max_(max) {} + explicit NodeCache(size_t max = 256) + : entries_(nullptr), size_(0), max_(max) {} // Search for node associated with {key} and return a pointer to a memory // location in this cache that stores an entry for the key. If the location @@ -29,15 +31,18 @@ class NodeCache { // too full or encounters too many hash collisions. Node** Find(Zone* zone, Key key); + void GetCachedNodes(NodeVector* nodes); + private: - struct Entry { - Key key_; - Node* value_; - }; + enum { kInitialSize = 16u, kLinearProbe = 5u }; + + struct Entry; Entry* entries_; // lazily-allocated hash entries. - int32_t size_; - int32_t max_; + size_t size_; + size_t max_; + Hash hash_; + Pred pred_; bool Resize(Zone* zone); }; @@ -46,8 +51,9 @@ class NodeCache { typedef NodeCache<int64_t> Int64NodeCache; typedef NodeCache<int32_t> Int32NodeCache; typedef NodeCache<void*> PtrNodeCache; -} -} -} // namespace v8::internal::compiler + +} // namespace compiler +} // namespace internal +} // namespace v8 #endif // V8_COMPILER_NODE_CACHE_H_ |