OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/compiler/node.h" |
| 6 #include "src/compiler/node-properties.h" |
| 7 #include "src/compiler/node-properties-inl.h" |
| 8 #include "src/compiler/schedule.h" |
| 9 #include "src/ostreams.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 namespace compiler { |
| 14 |
| 15 OStream& operator<<(OStream& os, const BasicBlockData::Control& c) { |
| 16 switch (c) { |
| 17 case BasicBlockData::kNone: |
| 18 return os << "none"; |
| 19 case BasicBlockData::kGoto: |
| 20 return os << "goto"; |
| 21 case BasicBlockData::kBranch: |
| 22 return os << "branch"; |
| 23 case BasicBlockData::kReturn: |
| 24 return os << "return"; |
| 25 case BasicBlockData::kThrow: |
| 26 return os << "throw"; |
| 27 case BasicBlockData::kCall: |
| 28 return os << "call"; |
| 29 case BasicBlockData::kDeoptimize: |
| 30 return os << "deoptimize"; |
| 31 } |
| 32 UNREACHABLE(); |
| 33 return os; |
| 34 } |
| 35 |
| 36 |
| 37 OStream& operator<<(OStream& os, const Schedule& s) { |
| 38 // TODO(svenpanne) Const-correct the RPO stuff/iterators. |
| 39 BasicBlockVector* rpo = const_cast<Schedule*>(&s)->rpo_order(); |
| 40 for (BasicBlockVectorIter i = rpo->begin(); i != rpo->end(); ++i) { |
| 41 BasicBlock* block = *i; |
| 42 os << "--- BLOCK B" << block->id(); |
| 43 if (block->PredecessorCount() != 0) os << " <- "; |
| 44 BasicBlock::Predecessors predecessors = block->predecessors(); |
| 45 bool comma = false; |
| 46 for (BasicBlock::Predecessors::iterator j = predecessors.begin(); |
| 47 j != predecessors.end(); ++j) { |
| 48 if (comma) os << ", "; |
| 49 comma = true; |
| 50 os << "B" << (*j)->id(); |
| 51 } |
| 52 os << " ---\n"; |
| 53 for (BasicBlock::const_iterator j = block->begin(); j != block->end(); |
| 54 ++j) { |
| 55 Node* node = *j; |
| 56 os << " " << *node; |
| 57 if (!NodeProperties::IsControl(node)) { |
| 58 Bounds bounds = NodeProperties::GetBounds(node); |
| 59 os << " : "; |
| 60 bounds.lower->PrintTo(os); |
| 61 if (!bounds.upper->Is(bounds.lower)) { |
| 62 os << ".."; |
| 63 bounds.upper->PrintTo(os); |
| 64 } |
| 65 } |
| 66 os << "\n"; |
| 67 } |
| 68 BasicBlock::Control control = block->control_; |
| 69 if (control != BasicBlock::kNone) { |
| 70 os << " "; |
| 71 if (block->control_input_ != NULL) { |
| 72 os << *block->control_input_; |
| 73 } else { |
| 74 os << "Goto"; |
| 75 } |
| 76 os << " -> "; |
| 77 BasicBlock::Successors successors = block->successors(); |
| 78 comma = false; |
| 79 for (BasicBlock::Successors::iterator j = successors.begin(); |
| 80 j != successors.end(); ++j) { |
| 81 if (comma) os << ", "; |
| 82 comma = true; |
| 83 os << "B" << (*j)->id(); |
| 84 } |
| 85 os << "\n"; |
| 86 } |
| 87 } |
| 88 return os; |
| 89 } |
| 90 } // namespace compiler |
| 91 } // namespace internal |
| 92 } // namespace v8 |
OLD | NEW |