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

Side by Side Diff: src/compiler/schedule.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/raw-machine-assembler.h ('k') | src/compiler/scheduler.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_SCHEDULE_H_ 5 #ifndef V8_COMPILER_SCHEDULE_H_
6 #define V8_COMPILER_SCHEDULE_H_ 6 #define V8_COMPILER_SCHEDULE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 explicit BasicBlockData(Zone* zone) 56 explicit BasicBlockData(Zone* zone)
57 : rpo_number_(-1), 57 : rpo_number_(-1),
58 loop_header_(NULL), 58 loop_header_(NULL),
59 loop_depth_(0), 59 loop_depth_(0),
60 loop_end_(-1), 60 loop_end_(-1),
61 code_start_(-1), 61 code_start_(-1),
62 code_end_(-1), 62 code_end_(-1),
63 deferred_(false), 63 deferred_(false),
64 control_(kNone), 64 control_(kNone),
65 control_input_(NULL), 65 control_input_(NULL),
66 nodes_(NodeVector::allocator_type(zone)) {} 66 nodes_(zone) {}
67 67
68 inline bool IsLoopHeader() const { return loop_end_ >= 0; } 68 inline bool IsLoopHeader() const { return loop_end_ >= 0; }
69 inline bool LoopContains(BasicBlockData* block) const { 69 inline bool LoopContains(BasicBlockData* block) const {
70 // RPO numbers must be initialized. 70 // RPO numbers must be initialized.
71 DCHECK(rpo_number_ >= 0); 71 DCHECK(rpo_number_ >= 0);
72 DCHECK(block->rpo_number_ >= 0); 72 DCHECK(block->rpo_number_ >= 0);
73 if (loop_end_ < 0) return false; // This is not a loop. 73 if (loop_end_ < 0) return false; // This is not a loop.
74 return block->rpo_number_ >= rpo_number_ && block->rpo_number_ < loop_end_; 74 return block->rpo_number_ >= rpo_number_ && block->rpo_number_ < loop_end_;
75 } 75 }
76 int first_instruction_index() { 76 int first_instruction_index() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 reverse_iterator rbegin() { return nodes_.rbegin(); } 138 reverse_iterator rbegin() { return nodes_.rbegin(); }
139 reverse_iterator rend() { return nodes_.rend(); } 139 reverse_iterator rend() { return nodes_.rend(); }
140 140
141 private: 141 private:
142 DISALLOW_COPY_AND_ASSIGN(BasicBlock); 142 DISALLOW_COPY_AND_ASSIGN(BasicBlock);
143 }; 143 };
144 144
145 typedef GenericGraphVisit::NullNodeVisitor<BasicBlockData, BasicBlock> 145 typedef GenericGraphVisit::NullNodeVisitor<BasicBlockData, BasicBlock>
146 NullBasicBlockVisitor; 146 NullBasicBlockVisitor;
147 147
148 typedef zone_allocator<BasicBlock*> BasicBlockPtrZoneAllocator; 148 typedef ZoneVector<BasicBlock*> BasicBlockVector;
149 typedef std::vector<BasicBlock*, BasicBlockPtrZoneAllocator> BasicBlockVector;
150 typedef BasicBlockVector::iterator BasicBlockVectorIter; 149 typedef BasicBlockVector::iterator BasicBlockVectorIter;
151 typedef BasicBlockVector::reverse_iterator BasicBlockVectorRIter; 150 typedef BasicBlockVector::reverse_iterator BasicBlockVectorRIter;
152 151
153 // A schedule represents the result of assigning nodes to basic blocks 152 // A schedule represents the result of assigning nodes to basic blocks
154 // and ordering them within basic blocks. Prior to computing a schedule, 153 // and ordering them within basic blocks. Prior to computing a schedule,
155 // a graph has no notion of control flow ordering other than that induced 154 // a graph has no notion of control flow ordering other than that induced
156 // by the graph's dependencies. A schedule is required to generate code. 155 // by the graph's dependencies. A schedule is required to generate code.
157 class Schedule : public GenericGraph<BasicBlock> { 156 class Schedule : public GenericGraph<BasicBlock> {
158 public: 157 public:
159 explicit Schedule(Zone* zone) 158 explicit Schedule(Zone* zone)
160 : GenericGraph<BasicBlock>(zone), 159 : GenericGraph<BasicBlock>(zone),
161 zone_(zone), 160 zone_(zone),
162 all_blocks_(BasicBlockVector::allocator_type(zone)), 161 all_blocks_(zone),
163 nodeid_to_block_(BasicBlockVector::allocator_type(zone)), 162 nodeid_to_block_(zone),
164 rpo_order_(BasicBlockVector::allocator_type(zone)), 163 rpo_order_(zone),
165 immediate_dominator_(BasicBlockVector::allocator_type(zone)) { 164 immediate_dominator_(zone) {
166 SetStart(NewBasicBlock()); // entry. 165 SetStart(NewBasicBlock()); // entry.
167 SetEnd(NewBasicBlock()); // exit. 166 SetEnd(NewBasicBlock()); // exit.
168 } 167 }
169 168
170 // Return the block which contains {node}, if any. 169 // Return the block which contains {node}, if any.
171 BasicBlock* block(Node* node) const { 170 BasicBlock* block(Node* node) const {
172 if (node->id() < static_cast<NodeId>(nodeid_to_block_.size())) { 171 if (node->id() < static_cast<NodeId>(nodeid_to_block_.size())) {
173 return nodeid_to_block_[node->id()]; 172 return nodeid_to_block_[node->id()];
174 } 173 }
175 return NULL; 174 return NULL;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // dominator, indexed by block 319 // dominator, indexed by block
321 // id. 320 // id.
322 }; 321 };
323 322
324 OStream& operator<<(OStream& os, const Schedule& s); 323 OStream& operator<<(OStream& os, const Schedule& s);
325 } 324 }
326 } 325 }
327 } // namespace v8::internal::compiler 326 } // namespace v8::internal::compiler
328 327
329 #endif // V8_COMPILER_SCHEDULE_H_ 328 #endif // V8_COMPILER_SCHEDULE_H_
OLDNEW
« no previous file with comments | « src/compiler/raw-machine-assembler.h ('k') | src/compiler/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698