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 #include "src/compiler/node.h" | 5 #include "src/compiler/node.h" |
6 #include "src/compiler/node-properties.h" | 6 #include "src/compiler/node-properties.h" |
7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 BasicBlock::BasicBlock(Zone* zone, Id id) | 15 BasicBlock::BasicBlock(Zone* zone, Id id) |
16 : ao_number_(-1), | 16 : ao_number_(-1), |
17 rpo_number_(-1), | 17 rpo_number_(-1), |
18 deferred_(false), | 18 deferred_(false), |
| 19 dominator_depth_(-1), |
19 dominator_(NULL), | 20 dominator_(NULL), |
20 loop_header_(NULL), | 21 loop_header_(NULL), |
| 22 loop_end_(NULL), |
21 loop_depth_(0), | 23 loop_depth_(0), |
22 loop_end_(-1), | |
23 control_(kNone), | 24 control_(kNone), |
24 control_input_(NULL), | 25 control_input_(NULL), |
25 nodes_(zone), | 26 nodes_(zone), |
26 successors_(zone), | 27 successors_(zone), |
27 predecessors_(zone), | 28 predecessors_(zone), |
28 id_(id) {} | 29 id_(id) {} |
29 | 30 |
30 | 31 |
31 bool BasicBlock::LoopContains(BasicBlock* block) const { | 32 bool BasicBlock::LoopContains(BasicBlock* block) const { |
32 // RPO numbers must be initialized. | 33 // RPO numbers must be initialized. |
33 DCHECK(rpo_number_ >= 0); | 34 DCHECK(rpo_number_ >= 0); |
34 DCHECK(block->rpo_number_ >= 0); | 35 DCHECK(block->rpo_number_ >= 0); |
35 if (loop_end_ < 0) return false; // This is not a loop. | 36 if (loop_end_ == NULL) return false; // This is not a loop. |
36 return block->rpo_number_ >= rpo_number_ && block->rpo_number_ < loop_end_; | 37 return block->rpo_number_ >= rpo_number_ && |
| 38 block->rpo_number_ < loop_end_->rpo_number_; |
37 } | 39 } |
38 | 40 |
39 | 41 |
40 void BasicBlock::AddSuccessor(BasicBlock* successor) { | 42 void BasicBlock::AddSuccessor(BasicBlock* successor) { |
41 successors_.push_back(successor); | 43 successors_.push_back(successor); |
42 } | 44 } |
43 | 45 |
44 | 46 |
45 void BasicBlock::AddPredecessor(BasicBlock* predecessor) { | 47 void BasicBlock::AddPredecessor(BasicBlock* predecessor) { |
46 predecessors_.push_back(predecessor); | 48 predecessors_.push_back(predecessor); |
47 } | 49 } |
48 | 50 |
49 | 51 |
50 void BasicBlock::AddNode(Node* node) { nodes_.push_back(node); } | 52 void BasicBlock::AddNode(Node* node) { nodes_.push_back(node); } |
51 | 53 |
52 | 54 |
53 void BasicBlock::set_control(Control control) { | 55 void BasicBlock::set_control(Control control) { |
54 control_ = control; | 56 control_ = control; |
55 } | 57 } |
56 | 58 |
57 | 59 |
58 void BasicBlock::set_control_input(Node* control_input) { | 60 void BasicBlock::set_control_input(Node* control_input) { |
59 control_input_ = control_input; | 61 control_input_ = control_input; |
60 } | 62 } |
61 | 63 |
62 | 64 |
| 65 void BasicBlock::set_dominator_depth(int32_t dominator_depth) { |
| 66 dominator_depth_ = dominator_depth; |
| 67 } |
| 68 |
| 69 |
63 void BasicBlock::set_dominator(BasicBlock* dominator) { | 70 void BasicBlock::set_dominator(BasicBlock* dominator) { |
64 dominator_ = dominator; | 71 dominator_ = dominator; |
65 } | 72 } |
66 | 73 |
67 | 74 |
68 void BasicBlock::set_loop_depth(int32_t loop_depth) { | 75 void BasicBlock::set_loop_depth(int32_t loop_depth) { |
69 loop_depth_ = loop_depth; | 76 loop_depth_ = loop_depth; |
70 } | 77 } |
71 | 78 |
72 | 79 |
73 void BasicBlock::set_rpo_number(int32_t rpo_number) { | 80 void BasicBlock::set_rpo_number(int32_t rpo_number) { |
74 rpo_number_ = rpo_number; | 81 rpo_number_ = rpo_number; |
75 } | 82 } |
76 | 83 |
77 | 84 |
78 void BasicBlock::set_loop_end(int32_t loop_end) { loop_end_ = loop_end; } | 85 void BasicBlock::set_loop_end(BasicBlock* loop_end) { loop_end_ = loop_end; } |
79 | 86 |
80 | 87 |
81 void BasicBlock::set_loop_header(BasicBlock* loop_header) { | 88 void BasicBlock::set_loop_header(BasicBlock* loop_header) { |
82 loop_header_ = loop_header; | 89 loop_header_ = loop_header; |
83 } | 90 } |
84 | 91 |
85 | 92 |
86 std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) { | 93 std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) { |
87 switch (c) { | 94 switch (c) { |
88 case BasicBlock::kNone: | 95 case BasicBlock::kNone: |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 321 } |
315 os << "\n"; | 322 os << "\n"; |
316 } | 323 } |
317 } | 324 } |
318 return os; | 325 return os; |
319 } | 326 } |
320 | 327 |
321 } // namespace compiler | 328 } // namespace compiler |
322 } // namespace internal | 329 } // namespace internal |
323 } // namespace v8 | 330 } // namespace v8 |
OLD | NEW |