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

Side by Side Diff: src/compiler/schedule.cc

Issue 864293002: [turbofan] Cleanup Schedule and related classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address auto comments. Created 5 years, 11 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
« no previous file with comments | « src/compiler/schedule.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 #include "src/compiler/schedule.h"
6
5 #include "src/compiler/node.h" 7 #include "src/compiler/node.h"
6 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
7 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
8 #include "src/compiler/schedule.h"
9 #include "src/ostreams.h" 10 #include "src/ostreams.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 namespace compiler { 14 namespace compiler {
14 15
15 BasicBlock::BasicBlock(Zone* zone, Id id) 16 BasicBlock::BasicBlock(Zone* zone, Id id)
16 : loop_number_(-1), 17 : loop_number_(-1),
17 rpo_number_(-1), 18 rpo_number_(-1),
18 deferred_(false), 19 deferred_(false),
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 229 }
229 230
230 231
231 void Schedule::AddSuccessor(BasicBlock* block, BasicBlock* succ) { 232 void Schedule::AddSuccessor(BasicBlock* block, BasicBlock* succ) {
232 block->AddSuccessor(succ); 233 block->AddSuccessor(succ);
233 succ->AddPredecessor(block); 234 succ->AddPredecessor(block);
234 } 235 }
235 236
236 237
237 void Schedule::MoveSuccessors(BasicBlock* from, BasicBlock* to) { 238 void Schedule::MoveSuccessors(BasicBlock* from, BasicBlock* to) {
238 for (BasicBlock::Predecessors::iterator i = from->successors_begin(); 239 for (BasicBlock* const successor : from->successors()) {
239 i != from->successors_end(); ++i) { 240 to->AddSuccessor(successor);
240 BasicBlock* succ = *i; 241 for (BasicBlock*& predecessor : successor->predecessors()) {
241 to->AddSuccessor(succ); 242 if (predecessor == from) predecessor = to;
242 for (BasicBlock::Predecessors::iterator j = succ->predecessors_begin();
243 j != succ->predecessors_end(); ++j) {
244 if (*j == from) *j = to;
245 } 243 }
246 } 244 }
247 from->ClearSuccessors(); 245 from->ClearSuccessors();
248 } 246 }
249 247
250 248
251 void Schedule::SetControlInput(BasicBlock* block, Node* node) { 249 void Schedule::SetControlInput(BasicBlock* block, Node* node) {
252 block->set_control_input(node); 250 block->set_control_input(node);
253 SetBlockForNode(block, node); 251 SetBlockForNode(block, node);
254 } 252 }
255 253
256 254
257 void Schedule::SetBlockForNode(BasicBlock* block, Node* node) { 255 void Schedule::SetBlockForNode(BasicBlock* block, Node* node) {
258 int length = static_cast<int>(nodeid_to_block_.size()); 256 int length = static_cast<int>(nodeid_to_block_.size());
259 if (node->id() >= length) { 257 if (node->id() >= length) {
260 nodeid_to_block_.resize(node->id() + 1); 258 nodeid_to_block_.resize(node->id() + 1);
261 } 259 }
262 nodeid_to_block_[node->id()] = block; 260 nodeid_to_block_[node->id()] = block;
263 } 261 }
264 262
265 263
266 std::ostream& operator<<(std::ostream& os, const Schedule& s) { 264 std::ostream& operator<<(std::ostream& os, const Schedule& s) {
267 // TODO(svenpanne) Const-correct the RPO stuff/iterators. 265 for (BasicBlock* block : *s.rpo_order()) {
268 BasicBlockVector* rpo = const_cast<Schedule*>(&s)->rpo_order();
269 for (BasicBlockVectorIter i = rpo->begin(); i != rpo->end(); ++i) {
270 BasicBlock* block = *i;
271 os << "--- BLOCK B" << block->id(); 266 os << "--- BLOCK B" << block->id();
272 if (block->deferred()) os << " (deferred)"; 267 if (block->deferred()) os << " (deferred)";
273 if (block->PredecessorCount() != 0) os << " <- "; 268 if (block->PredecessorCount() != 0) os << " <- ";
274 bool comma = false; 269 bool comma = false;
275 for (BasicBlock::Predecessors::iterator j = block->predecessors_begin(); 270 for (BasicBlock const* predecessor : block->predecessors()) {
276 j != block->predecessors_end(); ++j) {
277 if (comma) os << ", "; 271 if (comma) os << ", ";
278 comma = true; 272 comma = true;
279 os << "B" << (*j)->id(); 273 os << "B" << predecessor->id();
280 } 274 }
281 os << " ---\n"; 275 os << " ---\n";
282 for (BasicBlock::const_iterator j = block->begin(); j != block->end(); 276 for (Node* node : *block) {
283 ++j) {
284 Node* node = *j;
285 os << " " << *node; 277 os << " " << *node;
286 if (NodeProperties::IsTyped(node)) { 278 if (NodeProperties::IsTyped(node)) {
287 Bounds bounds = NodeProperties::GetBounds(node); 279 Bounds bounds = NodeProperties::GetBounds(node);
288 os << " : "; 280 os << " : ";
289 bounds.lower->PrintTo(os); 281 bounds.lower->PrintTo(os);
290 if (!bounds.upper->Is(bounds.lower)) { 282 if (!bounds.upper->Is(bounds.lower)) {
291 os << ".."; 283 os << "..";
292 bounds.upper->PrintTo(os); 284 bounds.upper->PrintTo(os);
293 } 285 }
294 } 286 }
295 os << "\n"; 287 os << "\n";
296 } 288 }
297 BasicBlock::Control control = block->control(); 289 BasicBlock::Control control = block->control();
298 if (control != BasicBlock::kNone) { 290 if (control != BasicBlock::kNone) {
299 os << " "; 291 os << " ";
300 if (block->control_input() != NULL) { 292 if (block->control_input() != NULL) {
301 os << *block->control_input(); 293 os << *block->control_input();
302 } else { 294 } else {
303 os << "Goto"; 295 os << "Goto";
304 } 296 }
305 os << " -> "; 297 os << " -> ";
306 comma = false; 298 comma = false;
307 for (BasicBlock::Successors::iterator j = block->successors_begin(); 299 for (BasicBlock const* successor : block->successors()) {
308 j != block->successors_end(); ++j) {
309 if (comma) os << ", "; 300 if (comma) os << ", ";
310 comma = true; 301 comma = true;
311 os << "B" << (*j)->id(); 302 os << "B" << successor->id();
312 } 303 }
313 os << "\n"; 304 os << "\n";
314 } 305 }
315 } 306 }
316 return os; 307 return os;
317 } 308 }
318 309
319 } // namespace compiler 310 } // namespace compiler
320 } // namespace internal 311 } // namespace internal
321 } // namespace v8 312 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/schedule.h ('k') | src/compiler/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698