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

Side by Side Diff: src/compiler/state-values-utils.h

Issue 1008213002: [turbofan] Cache for reusing value vector nodes in frame states. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Embed StateValueCache in AstGraphBuilder Created 5 years, 9 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
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/compiler/state-values-utils.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 2015 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_STATE_VALUES_UTILS_H_
6 #define V8_COMPILER_STATE_VALUES_UTILS_H_
7
8 #include "src/compiler/js-graph.h"
9
10 namespace v8 {
11 namespace internal {
12
13 namespace compiler {
14
15 class Graph;
16
17 class StateValuesCache {
18 public:
19 explicit StateValuesCache(JSGraph* js_graph);
20
21 Node* GetNodeForValues(Node** values, size_t count);
22
23 private:
24 static const size_t kMaxInputCount = 8;
25
26 struct NodeKey {
27 Node* node;
28
29 explicit NodeKey(Node* node) : node(node) {}
30 };
31
32 struct StateValuesKey : public NodeKey {
33 // ValueArray - array of nodes ({node} has to be nullptr).
34 size_t count;
35 Node** values;
36
37 StateValuesKey(size_t count, Node** values)
38 : NodeKey(nullptr), count(count), values(values) {}
39 };
40
41 class ValueArrayIterator;
42
43 static bool AreKeysEqual(void* key1, void* key2);
44 static bool IsKeysEqualToNode(StateValuesKey* key, Node* node);
45 static bool AreValueKeysEqual(StateValuesKey* key1, StateValuesKey* key2);
46
47 Node* BuildTree(ValueArrayIterator* it, size_t max_height);
48 NodeVector* GetWorkingSpace(size_t level);
49 Node* GetEmptyStateValues();
50 Node* GetValuesNodeFromCache(Node** nodes, size_t count);
51
52 Graph* graph() { return js_graph_->graph(); }
53 CommonOperatorBuilder* common() { return js_graph_->common(); }
54
55 Zone* zone() { return graph()->zone(); }
56
57 JSGraph* js_graph_;
58 ZoneHashMap hash_map_;
59 ZoneVector<NodeVector*> working_space_; // One working space per level.
60 Node* empty_state_values_;
61 };
62
63 class StateValuesAccess {
64 public:
65 class iterator {
66 public:
67 // Bare minimum of operators needed for range iteration.
68 bool operator!=(iterator& other);
69 iterator& operator++();
70 Node* operator*();
71
72 private:
73 friend class StateValuesAccess;
74
75 iterator() : current_depth_(-1) {}
76 explicit iterator(Node* node);
77
78 Node* node();
79 bool done();
80 void Advance();
81
82 struct StatePos {
83 Node* node;
84 int index;
85
86 explicit StatePos(Node* node) : node(node), index(0) {}
87 StatePos() {}
88 };
89
90 StatePos* Top();
91 void Push(Node* node);
92 void Pop();
93
94 static const int kMaxInlineDepth = 8;
95 StatePos stack_[kMaxInlineDepth];
96 int current_depth_;
97 };
98
99 explicit StateValuesAccess(Node* node) : node_(node) {}
100
101 size_t size();
102 iterator begin() { return iterator(node_); }
103 iterator end() { return iterator(); }
104
105 private:
106 Node* node_;
107 };
108
109 } // namespace compiler
110 } // namespace internal
111 } // namespace v8
112
113 #endif // V8_COMPILER_STATE_VALUES_UTILS_H_
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/compiler/state-values-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698