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

Side by Side Diff: src/compiler/node-cache.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/node-aux-data-inl.h ('k') | src/compiler/node-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_NODE_CACHE_H_
6 #define V8_COMPILER_NODE_CACHE_H_
7
8 #include "src/v8.h"
9
10 #include "src/compiler/node.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace compiler {
15
16 // A cache for nodes based on a key. Useful for implementing canonicalization of
17 // nodes such as constants, parameters, etc.
18 template <typename Key>
19 class NodeCache {
20 public:
21 explicit NodeCache(int max = 256) : entries_(NULL), size_(0), max_(max) {}
22
23 // Search for node associated with {key} and return a pointer to a memory
24 // location in this cache that stores an entry for the key. If the location
25 // returned by this method contains a non-NULL node, the caller can use that
26 // node. Otherwise it is the responsibility of the caller to fill the entry
27 // with a new node.
28 // Note that a previous cache entry may be overwritten if the cache becomes
29 // too full or encounters too many hash collisions.
30 Node** Find(Zone* zone, Key key);
31
32 private:
33 struct Entry {
34 Key key_;
35 Node* value_;
36 };
37
38 Entry* entries_; // lazily-allocated hash entries.
39 int32_t size_;
40 int32_t max_;
41
42 bool Resize(Zone* zone);
43 };
44
45 // Various default cache types.
46 typedef NodeCache<int64_t> Int64NodeCache;
47 typedef NodeCache<int32_t> Int32NodeCache;
48 typedef NodeCache<void*> PtrNodeCache;
49 }
50 }
51 } // namespace v8::internal::compiler
52
53 #endif // V8_COMPILER_NODE_CACHE_H_
OLDNEW
« no previous file with comments | « src/compiler/node-aux-data-inl.h ('k') | src/compiler/node-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698