Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 class BitVector; | |
|
Benedikt Meurer
2015/03/16 10:18:33
That seems to be unused in this header.
Jarin
2015/03/16 10:26:33
Removed.
| |
| 14 | |
| 15 namespace compiler { | |
| 16 | |
| 17 class Graph; | |
| 18 | |
| 19 class StateValuesCache { | |
| 20 public: | |
| 21 explicit StateValuesCache(JSGraph* js_graph); | |
| 22 | |
| 23 Node* GetNodeForValues(Node** values, size_t count); | |
| 24 | |
| 25 private: | |
| 26 static const size_t kMaxInputCount = 8; | |
| 27 | |
| 28 struct NodeKey { | |
| 29 Node* node; | |
| 30 | |
| 31 explicit NodeKey(Node* node) : node(node) {} | |
| 32 }; | |
| 33 | |
| 34 struct StateValuesKey : public NodeKey { | |
| 35 // ValueArray - array of nodes ({node} has to be nullptr). | |
| 36 size_t count; | |
| 37 Node** values; | |
| 38 | |
| 39 StateValuesKey(size_t count, Node** values) | |
| 40 : NodeKey(nullptr), count(count), values(values) {} | |
| 41 }; | |
| 42 | |
| 43 class ValueArrayIterator; | |
| 44 | |
| 45 static bool AreKeysEqual(void* key1, void* key2); | |
| 46 static bool IsKeysEqualToNode(StateValuesKey* key, Node* node); | |
| 47 static bool AreValueKeysEqual(StateValuesKey* key1, StateValuesKey* key2); | |
| 48 | |
| 49 Node* BuildTree(ValueArrayIterator* it, size_t max_height); | |
| 50 NodeVector* GetWorkingSpace(size_t level); | |
| 51 Node* GetEmptyStateValues(); | |
| 52 Node* GetValuesNodeFromCache(Node** nodes, size_t count); | |
| 53 | |
| 54 Graph* graph() { return js_graph_->graph(); } | |
| 55 CommonOperatorBuilder* common() { return js_graph_->common(); } | |
| 56 | |
| 57 Zone* zone() { return graph()->zone(); } | |
| 58 | |
| 59 JSGraph* js_graph_; | |
| 60 ZoneHashMap hash_map_; | |
| 61 ZoneVector<NodeVector*> working_space_; // One working space per level. | |
| 62 Node* empty_state_values_; | |
| 63 }; | |
| 64 | |
| 65 class StateValuesAccess { | |
| 66 public: | |
| 67 class iterator { | |
| 68 public: | |
| 69 // Bare minimum of operators needed for range iteration. | |
| 70 bool operator!=(iterator& other); | |
| 71 iterator& operator++(); | |
| 72 Node* operator*(); | |
| 73 | |
| 74 private: | |
| 75 friend class StateValuesAccess; | |
| 76 | |
| 77 iterator() : current_depth_(-1) {} | |
| 78 explicit iterator(Node* node); | |
| 79 | |
| 80 Node* node(); | |
| 81 bool done(); | |
| 82 void Advance(); | |
| 83 | |
| 84 struct StatePos { | |
| 85 Node* node; | |
| 86 int index; | |
| 87 | |
| 88 explicit StatePos(Node* node) : node(node), index(0) {} | |
| 89 StatePos() {} | |
| 90 }; | |
| 91 | |
| 92 StatePos* Top(); | |
| 93 void Push(Node* node); | |
| 94 void Pop(); | |
| 95 | |
| 96 static const int kMaxInlineDepth = 8; | |
| 97 StatePos stack_[kMaxInlineDepth]; | |
| 98 int current_depth_; | |
| 99 }; | |
| 100 | |
| 101 explicit StateValuesAccess(Node* node) : node_(node) {} | |
| 102 | |
| 103 size_t size(); | |
| 104 iterator begin() { return iterator(node_); } | |
| 105 iterator end() { return iterator(); } | |
| 106 | |
| 107 private: | |
| 108 Node* node_; | |
| 109 }; | |
| 110 | |
| 111 } // namespace compiler | |
| 112 } // namespace internal | |
| 113 } // namespace v8 | |
| 114 | |
| 115 #endif // V8_COMPILER_STATE_VALUES_UTILS_H_ | |
| OLD | NEW |