OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| 11 #include "src/compiler/node-matchers.h" |
11 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
12 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
13 #include "src/compiler/schedule.h" | 14 #include "src/compiler/schedule.h" |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 namespace compiler { | 18 namespace compiler { |
18 | 19 |
19 EffectControlLinearizer::EffectControlLinearizer(JSGraph* js_graph, | 20 EffectControlLinearizer::EffectControlLinearizer(JSGraph* js_graph, |
20 Schedule* schedule, | 21 Schedule* schedule, |
21 Zone* temp_zone) | 22 Zone* temp_zone) |
22 : js_graph_(js_graph), schedule_(schedule), temp_zone_(temp_zone) {} | 23 : js_graph_(js_graph), schedule_(schedule), temp_zone_(temp_zone) {} |
23 | 24 |
24 Graph* EffectControlLinearizer::graph() const { return js_graph_->graph(); } | 25 Graph* EffectControlLinearizer::graph() const { return js_graph_->graph(); } |
25 CommonOperatorBuilder* EffectControlLinearizer::common() const { | 26 CommonOperatorBuilder* EffectControlLinearizer::common() const { |
26 return js_graph_->common(); | 27 return js_graph_->common(); |
27 } | 28 } |
28 SimplifiedOperatorBuilder* EffectControlLinearizer::simplified() const { | 29 SimplifiedOperatorBuilder* EffectControlLinearizer::simplified() const { |
29 return js_graph_->simplified(); | 30 return js_graph_->simplified(); |
30 } | 31 } |
31 MachineOperatorBuilder* EffectControlLinearizer::machine() const { | 32 MachineOperatorBuilder* EffectControlLinearizer::machine() const { |
32 return js_graph_->machine(); | 33 return js_graph_->machine(); |
33 } | 34 } |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 struct BlockEffectControlData { | 38 struct BlockEffectControlData { |
38 Node* current_effect = nullptr; // New effect. | 39 Node* current_effect = nullptr; // New effect. |
39 Node* current_control = nullptr; // New control. | 40 Node* current_control = nullptr; // New control. |
40 Node* current_frame_state = nullptr; // New frame state. | 41 Node* current_frame_state = nullptr; // New frame state. |
41 }; | 42 }; |
42 | 43 |
| 44 class BlockEffectControlMap { |
| 45 public: |
| 46 explicit BlockEffectControlMap(Zone* temp_zone) : map_(temp_zone) {} |
| 47 |
| 48 BlockEffectControlData& For(BasicBlock* from, BasicBlock* to) { |
| 49 return map_[std::make_pair(from->rpo_number(), to->rpo_number())]; |
| 50 } |
| 51 |
| 52 const BlockEffectControlData& For(BasicBlock* from, BasicBlock* to) const { |
| 53 return map_.at(std::make_pair(from->rpo_number(), to->rpo_number())); |
| 54 } |
| 55 |
| 56 private: |
| 57 typedef std::pair<int32_t, int32_t> Key; |
| 58 typedef ZoneMap<Key, BlockEffectControlData> Map; |
| 59 |
| 60 Map map_; |
| 61 }; |
| 62 |
43 // Effect phis that need to be updated after the first pass. | 63 // Effect phis that need to be updated after the first pass. |
44 struct PendingEffectPhi { | 64 struct PendingEffectPhi { |
45 Node* effect_phi; | 65 Node* effect_phi; |
46 BasicBlock* block; | 66 BasicBlock* block; |
47 | 67 |
48 PendingEffectPhi(Node* effect_phi, BasicBlock* block) | 68 PendingEffectPhi(Node* effect_phi, BasicBlock* block) |
49 : effect_phi(effect_phi), block(block) {} | 69 : effect_phi(effect_phi), block(block) {} |
50 }; | 70 }; |
51 | 71 |
52 void UpdateEffectPhi(Node* node, BasicBlock* block, | 72 void UpdateEffectPhi(Node* node, BasicBlock* block, |
53 ZoneVector<BlockEffectControlData>* block_effects) { | 73 BlockEffectControlMap* block_effects) { |
54 // Update all inputs to an effect phi with the effects from the given | 74 // Update all inputs to an effect phi with the effects from the given |
55 // block->effect map. | 75 // block->effect map. |
56 DCHECK_EQ(IrOpcode::kEffectPhi, node->opcode()); | 76 DCHECK_EQ(IrOpcode::kEffectPhi, node->opcode()); |
57 DCHECK_EQ(node->op()->EffectInputCount(), block->PredecessorCount()); | 77 DCHECK_EQ(node->op()->EffectInputCount(), block->PredecessorCount()); |
58 for (int i = 0; i < node->op()->EffectInputCount(); i++) { | 78 for (int i = 0; i < node->op()->EffectInputCount(); i++) { |
59 Node* input = node->InputAt(i); | 79 Node* input = node->InputAt(i); |
60 BasicBlock* predecessor = block->PredecessorAt(static_cast<size_t>(i)); | 80 BasicBlock* predecessor = block->PredecessorAt(static_cast<size_t>(i)); |
61 Node* input_effect = | 81 const BlockEffectControlData& block_effect = |
62 (*block_effects)[predecessor->rpo_number()].current_effect; | 82 block_effects->For(predecessor, block); |
63 if (input != input_effect) { | 83 if (input != block_effect.current_effect) { |
64 node->ReplaceInput(i, input_effect); | 84 node->ReplaceInput(i, block_effect.current_effect); |
65 } | 85 } |
66 } | 86 } |
67 } | 87 } |
68 | 88 |
69 void UpdateBlockControl(BasicBlock* block, | 89 void UpdateBlockControl(BasicBlock* block, |
70 ZoneVector<BlockEffectControlData>* block_effects) { | 90 BlockEffectControlMap* block_effects) { |
71 Node* control = block->NodeAt(0); | 91 Node* control = block->NodeAt(0); |
72 DCHECK(NodeProperties::IsControl(control)); | 92 DCHECK(NodeProperties::IsControl(control)); |
73 | 93 |
74 // Do not rewire the end node. | 94 // Do not rewire the end node. |
75 if (control->opcode() == IrOpcode::kEnd) return; | 95 if (control->opcode() == IrOpcode::kEnd) return; |
76 | 96 |
77 // Update all inputs to the given control node with the correct control. | 97 // Update all inputs to the given control node with the correct control. |
78 DCHECK_EQ(control->op()->ControlInputCount(), block->PredecessorCount()); | 98 DCHECK(control->opcode() == IrOpcode::kMerge || |
| 99 control->op()->ControlInputCount() == block->PredecessorCount()); |
| 100 if (control->op()->ControlInputCount() != block->PredecessorCount()) { |
| 101 return; // We already re-wired the control inputs of this node. |
| 102 } |
79 for (int i = 0; i < control->op()->ControlInputCount(); i++) { | 103 for (int i = 0; i < control->op()->ControlInputCount(); i++) { |
80 Node* input = NodeProperties::GetControlInput(control, i); | 104 Node* input = NodeProperties::GetControlInput(control, i); |
81 BasicBlock* predecessor = block->PredecessorAt(static_cast<size_t>(i)); | 105 BasicBlock* predecessor = block->PredecessorAt(static_cast<size_t>(i)); |
82 Node* input_control = | 106 const BlockEffectControlData& block_effect = |
83 (*block_effects)[predecessor->rpo_number()].current_control; | 107 block_effects->For(predecessor, block); |
84 if (input != input_control) { | 108 if (input != block_effect.current_control) { |
85 NodeProperties::ReplaceControlInput(control, input_control, i); | 109 NodeProperties::ReplaceControlInput(control, block_effect.current_control, |
| 110 i); |
86 } | 111 } |
87 } | 112 } |
88 } | 113 } |
89 | 114 |
90 bool HasIncomingBackEdges(BasicBlock* block) { | 115 bool HasIncomingBackEdges(BasicBlock* block) { |
91 for (BasicBlock* pred : block->predecessors()) { | 116 for (BasicBlock* pred : block->predecessors()) { |
92 if (pred->rpo_number() >= block->rpo_number()) { | 117 if (pred->rpo_number() >= block->rpo_number()) { |
93 return true; | 118 return true; |
94 } | 119 } |
95 } | 120 } |
(...skipping 11 matching lines...) Expand all Loading... |
107 edge.UpdateTo(NodeProperties::GetEffectInput(node)); | 132 edge.UpdateTo(NodeProperties::GetEffectInput(node)); |
108 } else { | 133 } else { |
109 DCHECK(!NodeProperties::IsControlEdge(edge)); | 134 DCHECK(!NodeProperties::IsControlEdge(edge)); |
110 DCHECK(!NodeProperties::IsFrameStateEdge(edge)); | 135 DCHECK(!NodeProperties::IsFrameStateEdge(edge)); |
111 edge.UpdateTo(node->InputAt(0)); | 136 edge.UpdateTo(node->InputAt(0)); |
112 } | 137 } |
113 } | 138 } |
114 node->Kill(); | 139 node->Kill(); |
115 } | 140 } |
116 | 141 |
| 142 void TryCloneBranch(Node* node, BasicBlock* block, Graph* graph, |
| 143 CommonOperatorBuilder* common, |
| 144 BlockEffectControlMap* block_effects) { |
| 145 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); |
| 146 |
| 147 // This optimization is a special case of (super)block cloning. It takes an |
| 148 // input graph as shown below and clones the Branch node for every predecessor |
| 149 // to the Merge, essentially removing the Merge completely. This avoids |
| 150 // materializing the bit for the Phi and may offer potential for further |
| 151 // branch folding optimizations (i.e. because one or more inputs to the Phi is |
| 152 // a constant). Note that there may be more Phi nodes hanging off the Merge, |
| 153 // but we can only a certain subset of them currently (actually only Phi and |
| 154 // EffectPhi nodes whose uses have either the IfTrue or IfFalse as control |
| 155 // input). |
| 156 |
| 157 // Control1 ... ControlN |
| 158 // ^ ^ |
| 159 // | | Cond1 ... CondN |
| 160 // +----+ +----+ ^ ^ |
| 161 // | | | | |
| 162 // | | +----+ | |
| 163 // Merge<--+ | +------------+ |
| 164 // ^ \|/ |
| 165 // | Phi |
| 166 // | | |
| 167 // Branch----+ |
| 168 // ^ |
| 169 // | |
| 170 // +-----+-----+ |
| 171 // | | |
| 172 // IfTrue IfFalse |
| 173 // ^ ^ |
| 174 // | | |
| 175 |
| 176 // The resulting graph (modulo the Phi and EffectPhi nodes) looks like this: |
| 177 |
| 178 // Control1 Cond1 ... ControlN CondN |
| 179 // ^ ^ ^ ^ |
| 180 // \ / \ / |
| 181 // Branch ... Branch |
| 182 // ^ ^ |
| 183 // | | |
| 184 // +---+---+ +---+----+ |
| 185 // | | | | |
| 186 // IfTrue IfFalse ... IfTrue IfFalse |
| 187 // ^ ^ ^ ^ |
| 188 // | | | | |
| 189 // +--+ +-------------+ | |
| 190 // | | +--------------+ +--+ |
| 191 // | | | | |
| 192 // Merge Merge |
| 193 // ^ ^ |
| 194 // | | |
| 195 |
| 196 Node* branch = node; |
| 197 Node* cond = NodeProperties::GetValueInput(branch, 0); |
| 198 if (!cond->OwnedBy(branch) || cond->opcode() != IrOpcode::kPhi) return; |
| 199 Node* merge = NodeProperties::GetControlInput(branch); |
| 200 if (merge->opcode() != IrOpcode::kMerge || |
| 201 NodeProperties::GetControlInput(cond) != merge) { |
| 202 return; |
| 203 } |
| 204 // Grab the IfTrue/IfFalse projections of the Branch. |
| 205 BranchMatcher matcher(branch); |
| 206 // Check/collect other Phi/EffectPhi nodes hanging off the Merge. |
| 207 NodeVector phis(graph->zone()); |
| 208 for (Node* const use : merge->uses()) { |
| 209 if (use == branch || use == cond) continue; |
| 210 // We cannot currently deal with non-Phi/EffectPhi nodes hanging off the |
| 211 // Merge. Ideally, we would just clone the nodes (and everything that |
| 212 // depends on it to some distant join point), but that requires knowledge |
| 213 // about dominance/post-dominance. |
| 214 if (!NodeProperties::IsPhi(use)) return; |
| 215 for (Edge edge : use->use_edges()) { |
| 216 // Right now we can only handle Phi/EffectPhi nodes whose uses are |
| 217 // directly control-dependend on either the IfTrue or the IfFalse |
| 218 // successor, because we know exactly how to update those uses. |
| 219 if (edge.from()->op()->ControlInputCount() != 1) return; |
| 220 Node* control = NodeProperties::GetControlInput(edge.from()); |
| 221 if (NodeProperties::IsPhi(edge.from())) { |
| 222 control = NodeProperties::GetControlInput(control, edge.index()); |
| 223 } |
| 224 if (control != matcher.IfTrue() && control != matcher.IfFalse()) return; |
| 225 } |
| 226 phis.push_back(use); |
| 227 } |
| 228 BranchHint const hint = BranchHintOf(branch->op()); |
| 229 int const input_count = merge->op()->ControlInputCount(); |
| 230 DCHECK_LE(1, input_count); |
| 231 Node** const inputs = graph->zone()->NewArray<Node*>(2 * input_count); |
| 232 Node** const merge_true_inputs = &inputs[0]; |
| 233 Node** const merge_false_inputs = &inputs[input_count]; |
| 234 for (int index = 0; index < input_count; ++index) { |
| 235 Node* cond1 = NodeProperties::GetValueInput(cond, index); |
| 236 Node* control1 = NodeProperties::GetControlInput(merge, index); |
| 237 Node* branch1 = graph->NewNode(common->Branch(hint), cond1, control1); |
| 238 merge_true_inputs[index] = graph->NewNode(common->IfTrue(), branch1); |
| 239 merge_false_inputs[index] = graph->NewNode(common->IfFalse(), branch1); |
| 240 } |
| 241 Node* const merge_true = matcher.IfTrue(); |
| 242 Node* const merge_false = matcher.IfFalse(); |
| 243 merge_true->TrimInputCount(0); |
| 244 merge_false->TrimInputCount(0); |
| 245 for (int i = 0; i < input_count; ++i) { |
| 246 merge_true->AppendInput(graph->zone(), merge_true_inputs[i]); |
| 247 merge_false->AppendInput(graph->zone(), merge_false_inputs[i]); |
| 248 } |
| 249 DCHECK_EQ(2, block->SuccessorCount()); |
| 250 NodeProperties::ChangeOp(matcher.IfTrue(), common->Merge(input_count)); |
| 251 NodeProperties::ChangeOp(matcher.IfFalse(), common->Merge(input_count)); |
| 252 int const true_index = |
| 253 block->SuccessorAt(0)->NodeAt(0) == matcher.IfTrue() ? 0 : 1; |
| 254 BlockEffectControlData* true_block_data = |
| 255 &block_effects->For(block, block->SuccessorAt(true_index)); |
| 256 BlockEffectControlData* false_block_data = |
| 257 &block_effects->For(block, block->SuccessorAt(true_index ^ 1)); |
| 258 for (Node* const phi : phis) { |
| 259 for (int index = 0; index < input_count; ++index) { |
| 260 inputs[index] = phi->InputAt(index); |
| 261 } |
| 262 inputs[input_count] = merge_true; |
| 263 Node* phi_true = graph->NewNode(phi->op(), input_count + 1, inputs); |
| 264 inputs[input_count] = merge_false; |
| 265 Node* phi_false = graph->NewNode(phi->op(), input_count + 1, inputs); |
| 266 if (phi->UseCount() == 0) { |
| 267 DCHECK_EQ(phi->opcode(), IrOpcode::kEffectPhi); |
| 268 DCHECK_EQ(input_count, block->SuccessorCount()); |
| 269 } else { |
| 270 for (Edge edge : phi->use_edges()) { |
| 271 Node* control = NodeProperties::GetControlInput(edge.from()); |
| 272 if (NodeProperties::IsPhi(edge.from())) { |
| 273 control = NodeProperties::GetControlInput(control, edge.index()); |
| 274 } |
| 275 DCHECK(control == matcher.IfTrue() || control == matcher.IfFalse()); |
| 276 edge.UpdateTo((control == matcher.IfTrue()) ? phi_true : phi_false); |
| 277 } |
| 278 } |
| 279 true_block_data->current_effect = phi_true; |
| 280 false_block_data->current_effect = phi_false; |
| 281 phi->Kill(); |
| 282 } |
| 283 // Fix up IfTrue and IfFalse and kill all dead nodes. |
| 284 if (branch == block->control_input()) { |
| 285 true_block_data->current_control = merge_true; |
| 286 false_block_data->current_control = merge_false; |
| 287 } |
| 288 branch->Kill(); |
| 289 cond->Kill(); |
| 290 merge->Kill(); |
| 291 } |
117 } // namespace | 292 } // namespace |
118 | 293 |
119 void EffectControlLinearizer::Run() { | 294 void EffectControlLinearizer::Run() { |
120 ZoneVector<BlockEffectControlData> block_effects(temp_zone()); | 295 BlockEffectControlMap block_effects(temp_zone()); |
121 ZoneVector<PendingEffectPhi> pending_effect_phis(temp_zone()); | 296 ZoneVector<PendingEffectPhi> pending_effect_phis(temp_zone()); |
122 ZoneVector<BasicBlock*> pending_block_controls(temp_zone()); | 297 ZoneVector<BasicBlock*> pending_block_controls(temp_zone()); |
123 block_effects.resize(schedule()->RpoBlockCount()); | |
124 NodeVector inputs_buffer(temp_zone()); | 298 NodeVector inputs_buffer(temp_zone()); |
125 | 299 |
126 for (BasicBlock* block : *(schedule()->rpo_order())) { | 300 for (BasicBlock* block : *(schedule()->rpo_order())) { |
127 size_t instr = 0; | 301 size_t instr = 0; |
128 | 302 |
129 // The control node should be the first. | 303 // The control node should be the first. |
130 Node* control = block->NodeAt(instr); | 304 Node* control = block->NodeAt(instr); |
131 DCHECK(NodeProperties::IsControl(control)); | 305 DCHECK(NodeProperties::IsControl(control)); |
132 // Update the control inputs. | 306 // Update the control inputs. |
133 if (HasIncomingBackEdges(block)) { | 307 if (HasIncomingBackEdges(block)) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (block == schedule()->start()) { | 353 if (block == schedule()->start()) { |
180 // Start block => effect is start. | 354 // Start block => effect is start. |
181 DCHECK_EQ(graph()->start(), control); | 355 DCHECK_EQ(graph()->start(), control); |
182 effect = graph()->start(); | 356 effect = graph()->start(); |
183 } else if (control->opcode() == IrOpcode::kEnd) { | 357 } else if (control->opcode() == IrOpcode::kEnd) { |
184 // End block is just a dummy, no effect needed. | 358 // End block is just a dummy, no effect needed. |
185 DCHECK_EQ(BasicBlock::kNone, block->control()); | 359 DCHECK_EQ(BasicBlock::kNone, block->control()); |
186 DCHECK_EQ(1u, block->size()); | 360 DCHECK_EQ(1u, block->size()); |
187 effect = nullptr; | 361 effect = nullptr; |
188 } else { | 362 } else { |
189 // If all the predecessors have the same effect, we can use it | 363 // If all the predecessors have the same effect, we can use it as our |
190 // as our current effect. | 364 // current effect. |
191 int rpo_number = block->PredecessorAt(0)->rpo_number(); | 365 effect = |
192 effect = block_effects[rpo_number].current_effect; | 366 block_effects.For(block->PredecessorAt(0), block).current_effect; |
193 for (size_t i = 1; i < block->PredecessorCount(); i++) { | 367 for (size_t i = 1; i < block->PredecessorCount(); ++i) { |
194 int rpo_number = block->PredecessorAt(i)->rpo_number(); | 368 if (block_effects.For(block->PredecessorAt(i), block) |
195 if (block_effects[rpo_number].current_effect != effect) { | 369 .current_effect != effect) { |
196 effect = nullptr; | 370 effect = nullptr; |
197 break; | 371 break; |
198 } | 372 } |
199 } | 373 } |
200 if (effect == nullptr) { | 374 if (effect == nullptr) { |
201 DCHECK_NE(IrOpcode::kIfException, control->opcode()); | 375 DCHECK_NE(IrOpcode::kIfException, control->opcode()); |
202 // The input blocks do not have the same effect. We have | 376 // The input blocks do not have the same effect. We have |
203 // to create an effect phi node. | 377 // to create an effect phi node. |
204 inputs_buffer.clear(); | 378 inputs_buffer.clear(); |
205 inputs_buffer.resize(block->PredecessorCount(), graph()->start()); | 379 inputs_buffer.resize(block->PredecessorCount(), graph()->start()); |
(...skipping 19 matching lines...) Expand all Loading... |
225 | 399 |
226 // The frame state at block entry is determined by the frame states leaving | 400 // The frame state at block entry is determined by the frame states leaving |
227 // all predecessors. In case there is no frame state dominating this block, | 401 // all predecessors. In case there is no frame state dominating this block, |
228 // we can rely on a checkpoint being present before the next deoptimization. | 402 // we can rely on a checkpoint being present before the next deoptimization. |
229 // TODO(mstarzinger): Eventually we will need to go hunt for a frame state | 403 // TODO(mstarzinger): Eventually we will need to go hunt for a frame state |
230 // once deoptimizing nodes roam freely through the schedule. | 404 // once deoptimizing nodes roam freely through the schedule. |
231 Node* frame_state = nullptr; | 405 Node* frame_state = nullptr; |
232 if (block != schedule()->start()) { | 406 if (block != schedule()->start()) { |
233 // If all the predecessors have the same effect, we can use it | 407 // If all the predecessors have the same effect, we can use it |
234 // as our current effect. | 408 // as our current effect. |
235 int rpo_number = block->PredecessorAt(0)->rpo_number(); | 409 frame_state = |
236 frame_state = block_effects[rpo_number].current_frame_state; | 410 block_effects.For(block->PredecessorAt(0), block).current_frame_state; |
237 for (size_t i = 1; i < block->PredecessorCount(); i++) { | 411 for (size_t i = 1; i < block->PredecessorCount(); i++) { |
238 int rpo_number = block->PredecessorAt(i)->rpo_number(); | 412 if (block_effects.For(block->PredecessorAt(i), block) |
239 if (block_effects[rpo_number].current_frame_state != frame_state) { | 413 .current_frame_state != frame_state) { |
240 frame_state = nullptr; | 414 frame_state = nullptr; |
241 break; | 415 break; |
242 } | 416 } |
243 } | 417 } |
244 } | 418 } |
245 | 419 |
246 // Process the ordinary instructions. | 420 // Process the ordinary instructions. |
247 for (; instr < block->NodeCount(); instr++) { | 421 for (; instr < block->NodeCount(); instr++) { |
248 Node* node = block->NodeAt(instr); | 422 Node* node = block->NodeAt(instr); |
249 ProcessNode(node, &frame_state, &effect, &control); | 423 ProcessNode(node, &frame_state, &effect, &control); |
250 } | 424 } |
251 | 425 |
252 switch (block->control()) { | 426 switch (block->control()) { |
253 case BasicBlock::kGoto: | 427 case BasicBlock::kGoto: |
254 case BasicBlock::kNone: | 428 case BasicBlock::kNone: |
255 break; | 429 break; |
256 | 430 |
257 case BasicBlock::kCall: | 431 case BasicBlock::kCall: |
258 case BasicBlock::kTailCall: | 432 case BasicBlock::kTailCall: |
259 case BasicBlock::kBranch: | |
260 case BasicBlock::kSwitch: | 433 case BasicBlock::kSwitch: |
261 case BasicBlock::kReturn: | 434 case BasicBlock::kReturn: |
262 case BasicBlock::kDeoptimize: | 435 case BasicBlock::kDeoptimize: |
263 case BasicBlock::kThrow: | 436 case BasicBlock::kThrow: |
264 ProcessNode(block->control_input(), &frame_state, &effect, &control); | 437 ProcessNode(block->control_input(), &frame_state, &effect, &control); |
265 break; | 438 break; |
| 439 |
| 440 case BasicBlock::kBranch: |
| 441 ProcessNode(block->control_input(), &frame_state, &effect, &control); |
| 442 TryCloneBranch(block->control_input(), block, graph(), common(), |
| 443 &block_effects); |
| 444 break; |
266 } | 445 } |
267 | 446 |
268 // Store the effect for later use. | 447 // Store the effect, control and frame state for later use. |
269 block_effects[block->rpo_number()].current_effect = effect; | 448 for (BasicBlock* successor : block->successors()) { |
270 block_effects[block->rpo_number()].current_control = control; | 449 BlockEffectControlData* data = &block_effects.For(block, successor); |
271 block_effects[block->rpo_number()].current_frame_state = frame_state; | 450 if (data->current_effect == nullptr) { |
| 451 data->current_effect = effect; |
| 452 } |
| 453 if (data->current_control == nullptr) { |
| 454 data->current_control = control; |
| 455 } |
| 456 data->current_frame_state = frame_state; |
| 457 } |
272 } | 458 } |
273 | 459 |
274 // Update the incoming edges of the effect phis that could not be processed | 460 // Update the incoming edges of the effect phis that could not be processed |
275 // during the first pass (because they could have incoming back edges). | 461 // during the first pass (because they could have incoming back edges). |
276 for (const PendingEffectPhi& pending_effect_phi : pending_effect_phis) { | 462 for (const PendingEffectPhi& pending_effect_phi : pending_effect_phis) { |
277 UpdateEffectPhi(pending_effect_phi.effect_phi, pending_effect_phi.block, | 463 UpdateEffectPhi(pending_effect_phi.effect_phi, pending_effect_phi.block, |
278 &block_effects); | 464 &block_effects); |
279 } | 465 } |
280 for (BasicBlock* pending_block_control : pending_block_controls) { | 466 for (BasicBlock* pending_block_control : pending_block_controls) { |
281 UpdateBlockControl(pending_block_control, &block_effects); | 467 UpdateBlockControl(pending_block_control, &block_effects); |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 2054 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
1869 Operator::kNoThrow); | 2055 Operator::kNoThrow); |
1870 to_number_operator_.set(common()->Call(desc)); | 2056 to_number_operator_.set(common()->Call(desc)); |
1871 } | 2057 } |
1872 return to_number_operator_.get(); | 2058 return to_number_operator_.get(); |
1873 } | 2059 } |
1874 | 2060 |
1875 } // namespace compiler | 2061 } // namespace compiler |
1876 } // namespace internal | 2062 } // namespace internal |
1877 } // namespace v8 | 2063 } // namespace v8 |
OLD | NEW |