OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_GENERIC_ALGORITHM_H_ | 5 #ifndef V8_COMPILER_GENERIC_ALGORITHM_H_ |
6 #define V8_COMPILER_GENERIC_ALGORITHM_H_ | 6 #define V8_COMPILER_GENERIC_ALGORITHM_H_ |
7 | 7 |
8 #include <stack> | 8 #include <stack> |
9 | 9 |
10 #include "src/compiler/generic-graph.h" | 10 #include "src/compiler/generic-graph.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // void PreEdge(Traits::Node* from, int index, Traits::Node* to); | 36 // void PreEdge(Traits::Node* from, int index, Traits::Node* to); |
37 // void PostEdge(Traits::Node* from, int index, Traits::Node* to); | 37 // void PostEdge(Traits::Node* from, int index, Traits::Node* to); |
38 // } | 38 // } |
39 template <class Visitor, class Traits, class RootIterator> | 39 template <class Visitor, class Traits, class RootIterator> |
40 static void Visit(GenericGraphBase* graph, Zone* zone, | 40 static void Visit(GenericGraphBase* graph, Zone* zone, |
41 RootIterator root_begin, RootIterator root_end, | 41 RootIterator root_begin, RootIterator root_end, |
42 Visitor* visitor) { | 42 Visitor* visitor) { |
43 typedef typename Traits::Node Node; | 43 typedef typename Traits::Node Node; |
44 typedef typename Traits::Iterator Iterator; | 44 typedef typename Traits::Iterator Iterator; |
45 typedef std::pair<Iterator, Iterator> NodeState; | 45 typedef std::pair<Iterator, Iterator> NodeState; |
46 typedef zone_allocator<NodeState> ZoneNodeStateAllocator; | |
47 typedef std::stack<NodeState, ZoneDeque<NodeState>> NodeStateStack; | 46 typedef std::stack<NodeState, ZoneDeque<NodeState>> NodeStateStack; |
48 NodeStateStack stack((ZoneDeque<NodeState>(zone))); | 47 NodeStateStack stack((ZoneDeque<NodeState>(zone))); |
49 BoolVector visited(Traits::max_id(graph), false, zone); | 48 BoolVector visited(Traits::max_id(graph), false, zone); |
50 Node* current = *root_begin; | 49 Node* current = *root_begin; |
51 while (true) { | 50 while (true) { |
52 DCHECK(current != NULL); | 51 DCHECK(current != NULL); |
53 const int id = current->id(); | 52 const int id = current->id(); |
54 DCHECK(id >= 0); | 53 DCHECK(id >= 0); |
55 DCHECK(id < Traits::max_id(graph)); // Must be a valid id. | 54 DCHECK(id < Traits::max_id(graph)); // Must be a valid id. |
56 bool visit = !GetVisited(&visited, id); | 55 bool visit = !GetVisited(&visited, id); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 static bool GetVisited(BoolVector* visited, int id) { | 123 static bool GetVisited(BoolVector* visited, int id) { |
125 if (id >= static_cast<int>(visited->size())) return false; | 124 if (id >= static_cast<int>(visited->size())) return false; |
126 return visited->at(id); | 125 return visited->at(id); |
127 } | 126 } |
128 }; | 127 }; |
129 } | 128 } |
130 } | 129 } |
131 } // namespace v8::internal::compiler | 130 } // namespace v8::internal::compiler |
132 | 131 |
133 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ | 132 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ |
OLD | NEW |