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_SCHEDULE_H_ | 5 #ifndef V8_COMPILER_SCHEDULE_H_ |
6 #define V8_COMPILER_SCHEDULE_H_ | 6 #define V8_COMPILER_SCHEDULE_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 int ToInt() const { return static_cast<int>(index_); } | 43 int ToInt() const { return static_cast<int>(index_); } |
44 size_t ToSize() const { return index_; } | 44 size_t ToSize() const { return index_; } |
45 static Id FromSize(size_t index) { return Id(index); } | 45 static Id FromSize(size_t index) { return Id(index); } |
46 static Id FromInt(int index) { return Id(static_cast<size_t>(index)); } | 46 static Id FromInt(int index) { return Id(static_cast<size_t>(index)); } |
47 | 47 |
48 private: | 48 private: |
49 explicit Id(size_t index) : index_(index) {} | 49 explicit Id(size_t index) : index_(index) {} |
50 size_t index_; | 50 size_t index_; |
51 }; | 51 }; |
52 | 52 |
53 class RpoNumber { | |
Benedikt Meurer
2014/10/14 03:44:13
Mark as FINAL.
dcarney
2014/10/14 08:14:37
Done.
| |
54 public: | |
55 int ToInt() const { return static_cast<int>(index_); } | |
56 size_t ToSize() const { return index_; } | |
57 static RpoNumber FromInt(int index) { | |
58 return RpoNumber(static_cast<size_t>(index)); | |
59 } | |
60 static RpoNumber Invalid() { return RpoNumber(static_cast<size_t>(-1)); } | |
61 | |
62 bool IsNext(const RpoNumber other) const { | |
63 return other.index_ == this->index_ + 1; | |
64 } | |
65 | |
66 private: | |
67 explicit RpoNumber(size_t index) : index_(index) {} | |
68 size_t index_; | |
69 }; | |
70 | |
53 BasicBlock(Zone* zone, Id id); | 71 BasicBlock(Zone* zone, Id id); |
54 | 72 |
55 Id id() const { return id_; } | 73 Id id() const { return id_; } |
56 | 74 |
57 // Instruction indexes (used by the register allocator). | |
58 int first_instruction_index() { | |
59 DCHECK(code_start_ >= 0); | |
60 DCHECK(code_end_ > 0); | |
61 DCHECK(code_end_ >= code_start_); | |
62 return code_start_; | |
63 } | |
64 int last_instruction_index() { | |
65 DCHECK(code_start_ >= 0); | |
66 DCHECK(code_end_ > 0); | |
67 DCHECK(code_end_ >= code_start_); | |
68 return code_end_ - 1; | |
69 } | |
70 | |
71 // Predecessors and successors. | 75 // Predecessors and successors. |
72 typedef ZoneVector<BasicBlock*> Predecessors; | 76 typedef ZoneVector<BasicBlock*> Predecessors; |
73 Predecessors::iterator predecessors_begin() { return predecessors_.begin(); } | 77 Predecessors::iterator predecessors_begin() { return predecessors_.begin(); } |
74 Predecessors::iterator predecessors_end() { return predecessors_.end(); } | 78 Predecessors::iterator predecessors_end() { return predecessors_.end(); } |
75 size_t PredecessorCount() const { return predecessors_.size(); } | 79 size_t PredecessorCount() const { return predecessors_.size(); } |
76 BasicBlock* PredecessorAt(size_t index) { return predecessors_[index]; } | 80 BasicBlock* PredecessorAt(size_t index) { return predecessors_[index]; } |
77 size_t PredecessorIndexOf(BasicBlock* predecessor); | 81 size_t PredecessorIndexOf(BasicBlock* predecessor); |
78 void AddPredecessor(BasicBlock* predecessor); | 82 void AddPredecessor(BasicBlock* predecessor); |
79 | 83 |
80 typedef ZoneVector<BasicBlock*> Successors; | 84 typedef ZoneVector<BasicBlock*> Successors; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 123 |
120 BasicBlock* loop_header() const { return loop_header_; } | 124 BasicBlock* loop_header() const { return loop_header_; } |
121 void set_loop_header(BasicBlock* loop_header); | 125 void set_loop_header(BasicBlock* loop_header); |
122 | 126 |
123 int32_t loop_depth() const { return loop_depth_; } | 127 int32_t loop_depth() const { return loop_depth_; } |
124 void set_loop_depth(int32_t loop_depth); | 128 void set_loop_depth(int32_t loop_depth); |
125 | 129 |
126 int32_t loop_end() const { return loop_end_; } | 130 int32_t loop_end() const { return loop_end_; } |
127 void set_loop_end(int32_t loop_end); | 131 void set_loop_end(int32_t loop_end); |
128 | 132 |
133 RpoNumber GetRpoNumber() const { return RpoNumber::FromInt(rpo_number_); } | |
129 int32_t rpo_number() const { return rpo_number_; } | 134 int32_t rpo_number() const { return rpo_number_; } |
130 void set_rpo_number(int32_t rpo_number); | 135 void set_rpo_number(int32_t rpo_number); |
131 | 136 |
132 int32_t code_start() const { return code_start_; } | |
133 void set_code_start(int32_t start); | |
134 | |
135 int32_t code_end() const { return code_end_; } | |
136 void set_code_end(int32_t end); | |
137 | |
138 bool deferred() const { return deferred_; } | |
139 | |
140 // Loop membership helpers. | 137 // Loop membership helpers. |
141 inline bool IsLoopHeader() const { return loop_end_ >= 0; } | 138 inline bool IsLoopHeader() const { return loop_end_ >= 0; } |
142 bool LoopContains(BasicBlock* block) const; | 139 bool LoopContains(BasicBlock* block) const; |
143 BasicBlock* ContainingLoop(); | 140 BasicBlock* ContainingLoop(); |
144 | 141 |
145 private: | 142 private: |
146 int32_t rpo_number_; // special RPO number of the block. | 143 int32_t rpo_number_; // special RPO number of the block. |
147 BasicBlock* dominator_; // Immediate dominator of the block. | 144 BasicBlock* dominator_; // Immediate dominator of the block. |
148 BasicBlock* loop_header_; // Pointer to dominating loop header basic block, | 145 BasicBlock* loop_header_; // Pointer to dominating loop header basic block, |
149 // NULL if none. For loop headers, this points to | 146 // NULL if none. For loop headers, this points to |
150 // enclosing loop header. | 147 // enclosing loop header. |
151 int32_t loop_depth_; // loop nesting, 0 is top-level | 148 int32_t loop_depth_; // loop nesting, 0 is top-level |
152 int32_t loop_end_; // end of the loop, if this block is a loop header. | 149 int32_t loop_end_; // end of the loop, if this block is a loop header. |
153 int32_t code_start_; // start index of arch-specific code. | 150 |
154 int32_t code_end_; // end index of arch-specific code. | |
155 bool deferred_; // {true} if this block is considered the slow | |
156 // path. | |
157 Control control_; // Control at the end of the block. | 151 Control control_; // Control at the end of the block. |
158 Node* control_input_; // Input value for control. | 152 Node* control_input_; // Input value for control. |
159 NodeVector nodes_; // nodes of this block in forward order. | 153 NodeVector nodes_; // nodes of this block in forward order. |
160 | 154 |
161 Successors successors_; | 155 Successors successors_; |
162 Predecessors predecessors_; | 156 Predecessors predecessors_; |
163 Id id_; | 157 Id id_; |
164 | 158 |
165 DISALLOW_COPY_AND_ASSIGN(BasicBlock); | 159 DISALLOW_COPY_AND_ASSIGN(BasicBlock); |
166 }; | 160 }; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 BasicBlock* end_; | 235 BasicBlock* end_; |
242 }; | 236 }; |
243 | 237 |
244 std::ostream& operator<<(std::ostream& os, const Schedule& s); | 238 std::ostream& operator<<(std::ostream& os, const Schedule& s); |
245 | 239 |
246 } // namespace compiler | 240 } // namespace compiler |
247 } // namespace internal | 241 } // namespace internal |
248 } // namespace v8 | 242 } // namespace v8 |
249 | 243 |
250 #endif // V8_COMPILER_SCHEDULE_H_ | 244 #endif // V8_COMPILER_SCHEDULE_H_ |
OLD | NEW |