| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_STATE_VALUES_UTILS_H_ | 5 #ifndef V8_COMPILER_STATE_VALUES_UTILS_H_ |
| 6 #define V8_COMPILER_STATE_VALUES_UTILS_H_ | 6 #define V8_COMPILER_STATE_VALUES_UTILS_H_ |
| 7 | 7 |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 struct NodeKey { | 27 struct NodeKey { |
| 28 Node* node; | 28 Node* node; |
| 29 | 29 |
| 30 explicit NodeKey(Node* node) : node(node) {} | 30 explicit NodeKey(Node* node) : node(node) {} |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 struct StateValuesKey : public NodeKey { | 33 struct StateValuesKey : public NodeKey { |
| 34 // ValueArray - array of nodes ({node} has to be nullptr). | 34 // ValueArray - array of nodes ({node} has to be nullptr). |
| 35 size_t count; | 35 size_t count; |
| 36 uint32_t mask; |
| 36 Node** values; | 37 Node** values; |
| 37 | 38 |
| 38 StateValuesKey(size_t count, Node** values) | 39 StateValuesKey(size_t count, uint32_t mask, Node** values) |
| 39 : NodeKey(nullptr), count(count), values(values) {} | 40 : NodeKey(nullptr), count(count), mask(mask), values(values) {} |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 class ValueArrayIterator; | 43 class ValueArrayIterator; |
| 43 | 44 |
| 44 static bool AreKeysEqual(void* key1, void* key2); | 45 static bool AreKeysEqual(void* key1, void* key2); |
| 45 static bool IsKeysEqualToNode(StateValuesKey* key, Node* node); | 46 static bool IsKeysEqualToNode(StateValuesKey* key, Node* node); |
| 46 static bool AreValueKeysEqual(StateValuesKey* key1, StateValuesKey* key2); | 47 static bool AreValueKeysEqual(StateValuesKey* key1, StateValuesKey* key2); |
| 47 | 48 |
| 48 Node* BuildTree(ValueArrayIterator* it, size_t max_height); | 49 Node* BuildTree(ValueArrayIterator* it, size_t max_height); |
| 49 NodeVector* GetWorkingSpace(size_t level); | 50 NodeVector* GetWorkingSpace(size_t level); |
| 50 Node* GetEmptyStateValues(); | 51 Node* GetEmptyStateValues(); |
| 51 Node* GetValuesNodeFromCache(Node** nodes, size_t count); | 52 Node* GetValuesNodeFromCache(Node** nodes, size_t count, uint32_t mask); |
| 52 | 53 |
| 53 Graph* graph() { return js_graph_->graph(); } | 54 Graph* graph() { return js_graph_->graph(); } |
| 54 CommonOperatorBuilder* common() { return js_graph_->common(); } | 55 CommonOperatorBuilder* common() { return js_graph_->common(); } |
| 55 | 56 |
| 56 Zone* zone() { return graph()->zone(); } | 57 Zone* zone() { return graph()->zone(); } |
| 57 | 58 |
| 58 JSGraph* js_graph_; | 59 JSGraph* js_graph_; |
| 59 CustomMatcherZoneHashMap hash_map_; | 60 CustomMatcherZoneHashMap hash_map_; |
| 60 ZoneVector<NodeVector*> working_space_; // One working space per level. | 61 ZoneVector<NodeVector*> working_space_; // One working space per level. |
| 61 Node* empty_state_values_; | 62 Node* empty_state_values_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 private: | 80 private: |
| 80 friend class StateValuesAccess; | 81 friend class StateValuesAccess; |
| 81 | 82 |
| 82 iterator() : current_depth_(-1) {} | 83 iterator() : current_depth_(-1) {} |
| 83 explicit iterator(Node* node); | 84 explicit iterator(Node* node); |
| 84 | 85 |
| 85 Node* node(); | 86 Node* node(); |
| 86 MachineType type(); | 87 MachineType type(); |
| 87 bool done(); | 88 bool done(); |
| 88 void Advance(); | 89 void Advance(); |
| 90 void MoveToNextSibling(); |
| 91 void EnsureValid(); |
| 89 | 92 |
| 90 struct StatePos { | 93 struct StatePos { |
| 91 Node* node; | 94 Node* node; |
| 95 uint32_t mask; |
| 92 int index; | 96 int index; |
| 93 | |
| 94 explicit StatePos(Node* node) : node(node), index(0) {} | |
| 95 StatePos() {} | |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 StatePos* Top(); | 99 StatePos* Top(); |
| 99 void Push(Node* node); | 100 void Push(Node* node, uint32_t mask); |
| 100 void Pop(); | 101 void Pop(); |
| 101 | 102 |
| 102 static const int kMaxInlineDepth = 8; | 103 static const int kMaxInlineDepth = 8; |
| 103 StatePos stack_[kMaxInlineDepth]; | 104 StatePos stack_[kMaxInlineDepth]; |
| 104 int current_depth_; | 105 int current_depth_; |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 explicit StateValuesAccess(Node* node) : node_(node) {} | 108 explicit StateValuesAccess(Node* node) : node_(node) {} |
| 108 | 109 |
| 109 size_t size(); | 110 size_t size(); |
| 110 iterator begin() { return iterator(node_); } | 111 iterator begin() { return iterator(node_); } |
| 111 iterator end() { return iterator(); } | 112 iterator end() { return iterator(); } |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 Node* node_; | 115 Node* node_; |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 } // namespace compiler | 118 } // namespace compiler |
| 118 } // namespace internal | 119 } // namespace internal |
| 119 } // namespace v8 | 120 } // namespace v8 |
| 120 | 121 |
| 121 #endif // V8_COMPILER_STATE_VALUES_UTILS_H_ | 122 #endif // V8_COMPILER_STATE_VALUES_UTILS_H_ |
| OLD | NEW |