Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: src/compiler/generic-algorithm.h

Issue 505133003: Introduce subclass wrappers for STL containers that make them a lot easier (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/generic-node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque>
9 #include <stack> 8 #include <stack>
10 9
11 #include "src/compiler/generic-graph.h" 10 #include "src/compiler/generic-graph.h"
12 #include "src/compiler/generic-node.h" 11 #include "src/compiler/generic-node.h"
13 #include "src/zone-containers.h" 12 #include "src/zone-containers.h"
14 13
15 namespace v8 { 14 namespace v8 {
16 namespace internal { 15 namespace internal {
17 namespace compiler { 16 namespace compiler {
18 17
(...skipping 19 matching lines...) Expand all
38 // void PostEdge(Traits::Node* from, int index, Traits::Node* to); 37 // void PostEdge(Traits::Node* from, int index, Traits::Node* to);
39 // } 38 // }
40 template <class Visitor, class Traits, class RootIterator> 39 template <class Visitor, class Traits, class RootIterator>
41 static void Visit(GenericGraphBase* graph, Zone* zone, 40 static void Visit(GenericGraphBase* graph, Zone* zone,
42 RootIterator root_begin, RootIterator root_end, 41 RootIterator root_begin, RootIterator root_end,
43 Visitor* visitor) { 42 Visitor* visitor) {
44 typedef typename Traits::Node Node; 43 typedef typename Traits::Node Node;
45 typedef typename Traits::Iterator Iterator; 44 typedef typename Traits::Iterator Iterator;
46 typedef std::pair<Iterator, Iterator> NodeState; 45 typedef std::pair<Iterator, Iterator> NodeState;
47 typedef zone_allocator<NodeState> ZoneNodeStateAllocator; 46 typedef zone_allocator<NodeState> ZoneNodeStateAllocator;
48 typedef std::deque<NodeState, ZoneNodeStateAllocator> NodeStateDeque; 47 typedef std::stack<NodeState, ZoneDeque<NodeState>> NodeStateStack;
49 typedef std::stack<NodeState, NodeStateDeque> NodeStateStack; 48 NodeStateStack stack((ZoneDeque<NodeState>(zone)));
50 NodeStateStack stack((NodeStateDeque(ZoneNodeStateAllocator(zone)))); 49 BoolVector visited(Traits::max_id(graph), false, zone);
51 BoolVector visited(Traits::max_id(graph), false, ZoneBoolAllocator(zone));
52 Node* current = *root_begin; 50 Node* current = *root_begin;
53 while (true) { 51 while (true) {
54 DCHECK(current != NULL); 52 DCHECK(current != NULL);
55 const int id = current->id(); 53 const int id = current->id();
56 DCHECK(id >= 0); 54 DCHECK(id >= 0);
57 DCHECK(id < Traits::max_id(graph)); // Must be a valid id. 55 DCHECK(id < Traits::max_id(graph)); // Must be a valid id.
58 bool visit = !GetVisited(&visited, id); 56 bool visit = !GetVisited(&visited, id);
59 if (visit) { 57 if (visit) {
60 Control control = visitor->Pre(current); 58 Control control = visitor->Pre(current);
61 visit = !IsSkip(control); 59 visit = !IsSkip(control);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 static bool GetVisited(BoolVector* visited, int id) { 124 static bool GetVisited(BoolVector* visited, int id) {
127 if (id >= static_cast<int>(visited->size())) return false; 125 if (id >= static_cast<int>(visited->size())) return false;
128 return visited->at(id); 126 return visited->at(id);
129 } 127 }
130 }; 128 };
131 } 129 }
132 } 130 }
133 } // namespace v8::internal::compiler 131 } // namespace v8::internal::compiler
134 132
135 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_ 133 #endif // V8_COMPILER_GENERIC_ALGORITHM_H_
OLDNEW
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/generic-node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698