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 std::stack<NodeState, ZoneDeque<NodeState>> NodeStateStack; | 46 typedef std::stack<NodeState, ZoneDeque<NodeState> > NodeStateStack; |
47 NodeStateStack stack((ZoneDeque<NodeState>(zone))); | 47 NodeStateStack stack((ZoneDeque<NodeState>(zone))); |
48 BoolVector visited(Traits::max_id(graph), false, zone); | 48 BoolVector visited(Traits::max_id(graph), false, zone); |
49 Node* current = *root_begin; | 49 Node* current = *root_begin; |
50 while (true) { | 50 while (true) { |
51 DCHECK(current != NULL); | 51 DCHECK(current != NULL); |
52 const int id = current->id(); | 52 const int id = current->id(); |
53 DCHECK(id >= 0); | 53 DCHECK(id >= 0); |
54 DCHECK(id < Traits::max_id(graph)); // Must be a valid id. | 54 DCHECK(id < Traits::max_id(graph)); // Must be a valid id. |
55 bool visit = !GetVisited(&visited, id); | 55 bool visit = !GetVisited(&visited, id); |
56 if (visit) { | 56 if (visit) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 static bool GetVisited(BoolVector* visited, int id) { | 123 static bool GetVisited(BoolVector* visited, int id) { |
124 if (id >= static_cast<int>(visited->size())) return false; | 124 if (id >= static_cast<int>(visited->size())) return false; |
125 return visited->at(id); | 125 return visited->at(id); |
126 } | 126 } |
127 }; | 127 }; |
128 } | 128 } |
129 } | 129 } |
130 } // namespace v8::internal::compiler | 130 } // namespace v8::internal::compiler |
131 | 131 |
132 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ | 132 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ |
OLD | NEW |