| 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/zone-containers.h" | 10 #include "src/zone-containers.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 stack.pop(); | 64 stack.pop(); |
| 65 if (stack.empty()) { | 65 if (stack.empty()) { |
| 66 if (++root_begin == root_end) return; | 66 if (++root_begin == root_end) return; |
| 67 current = *root_begin; | 67 current = *root_begin; |
| 68 break; | 68 break; |
| 69 } | 69 } |
| 70 post_order_node = Traits::from(stack.top().first); | 70 post_order_node = Traits::from(stack.top().first); |
| 71 visit = true; | 71 visit = true; |
| 72 } else { | 72 } else { |
| 73 visitor->PreEdge(Traits::from(top.first), top.first.edge().index(), | 73 visitor->PreEdge(Traits::from(top.first), (*top.first).index(), |
| 74 Traits::to(top.first)); | 74 Traits::to(top.first)); |
| 75 current = Traits::to(top.first); | 75 current = Traits::to(top.first); |
| 76 if (!GetVisited(&visited, current->id())) break; | 76 if (!GetVisited(&visited, current->id())) break; |
| 77 } | 77 } |
| 78 top = stack.top(); | 78 top = stack.top(); |
| 79 visitor->PostEdge(Traits::from(top.first), top.first.edge().index(), | 79 visitor->PostEdge(Traits::from(top.first), (*top.first).index(), |
| 80 Traits::to(top.first)); | 80 Traits::to(top.first)); |
| 81 ++stack.top().first; | 81 ++stack.top().first; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 template <class Visitor, class Traits> | 86 template <class Visitor, class Traits> |
| 87 static void Visit(Graph* graph, Zone* zone, typename Traits::Node* current, | 87 static void Visit(Graph* graph, Zone* zone, typename Traits::Node* current, |
| 88 Visitor* visitor) { | 88 Visitor* visitor) { |
| 89 typename Traits::Node* array[] = {current}; | 89 typename Traits::Node* array[] = {current}; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 109 static bool GetVisited(BoolVector* visited, int id) { | 109 static bool GetVisited(BoolVector* visited, int id) { |
| 110 if (id >= static_cast<int>(visited->size())) return false; | 110 if (id >= static_cast<int>(visited->size())) return false; |
| 111 return visited->at(id); | 111 return visited->at(id); |
| 112 } | 112 } |
| 113 }; | 113 }; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 } // namespace v8::internal::compiler | 116 } // namespace v8::internal::compiler |
| 117 | 117 |
| 118 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ | 118 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ |
| OLD | NEW |