Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: src/compiler/node-cache.h

Issue 624153003: Add C++11 compatible base::hash function object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: NodeCache Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/base/functional.cc ('k') | src/compiler/node-cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/node-cache.h
diff --git a/src/compiler/node-cache.h b/src/compiler/node-cache.h
index 35352ea1eb1e19e93eabe1393a9eedefcb36c803..7741e1ef36a747e90ffca2721958c6edbd977ae9 100644
--- a/src/compiler/node-cache.h
+++ b/src/compiler/node-cache.h
@@ -5,20 +5,30 @@
#ifndef V8_COMPILER_NODE_CACHE_H_
#define V8_COMPILER_NODE_CACHE_H_
-#include "src/v8.h"
-
-#include "src/compiler/node.h"
+#include "src/base/functional.h"
+#include "src/base/macros.h"
namespace v8 {
namespace internal {
+
+// Forward declarations.
+class Zone;
+
+
namespace compiler {
+// Forward declarations.
+class Node;
+
+
// 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
@@ -30,14 +40,15 @@ class NodeCache {
Node** Find(Zone* zone, Key key);
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 +57,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_
« no previous file with comments | « src/base/functional.cc ('k') | src/compiler/node-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698