OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/instruction.h" | 5 #include "src/compiler/instruction.h" |
6 #include "src/compiler/register-allocator-verifier.h" | 6 #include "src/compiler/register-allocator-verifier.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 LocationMap::allocator_type(zone)), | 235 LocationMap::allocator_type(zone)), |
236 predecessor_intersection_(LocationMap::key_compare(), | 236 predecessor_intersection_(LocationMap::key_compare(), |
237 LocationMap::allocator_type(zone)) {} | 237 LocationMap::allocator_type(zone)) {} |
238 | 238 |
239 LocationMap* locations() { return &locations_; } | 239 LocationMap* locations() { return &locations_; } |
240 | 240 |
241 void RunPhis(const InstructionSequence* sequence, | 241 void RunPhis(const InstructionSequence* sequence, |
242 const InstructionBlock* block, size_t phi_index) { | 242 const InstructionBlock* block, size_t phi_index) { |
243 // This operation is only valid in edge split form. | 243 // This operation is only valid in edge split form. |
244 size_t predecessor_index = block->predecessors()[phi_index].ToSize(); | 244 size_t predecessor_index = block->predecessors()[phi_index].ToSize(); |
245 CHECK(sequence->instruction_blocks()[predecessor_index]->SuccessorCount() == | 245 for (const auto* phi : block->phis()) { |
| 246 CHECK( |
| 247 sequence->instruction_blocks()[predecessor_index]->SuccessorCount() == |
246 1); | 248 1); |
247 for (const auto* phi : block->phis()) { | |
248 auto input = phi->inputs()[phi_index]; | 249 auto input = phi->inputs()[phi_index]; |
249 CHECK(locations()->find(input) != locations()->end()); | 250 CHECK(locations()->find(input) != locations()->end()); |
250 auto it = locations()->find(phi->output()); | 251 auto it = locations()->find(phi->output()); |
251 CHECK(it != locations()->end()); | 252 CHECK(it != locations()->end()); |
252 if (input->IsConstant()) { | 253 if (input->IsConstant()) { |
253 CHECK_EQ(it->second, input->index()); | 254 CHECK_EQ(it->second, input->index()); |
254 } else { | 255 } else { |
255 CHECK_EQ(it->second, phi->operands()[phi_index]); | 256 CHECK_EQ(it->second, phi->operands()[phi_index]); |
256 } | 257 } |
257 it->second = phi->virtual_register(); | 258 it->second = phi->virtual_register(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 311 } |
311 } | 312 } |
312 | 313 |
313 void InitializeFromFirstPredecessor(const InstructionSequence* sequence, | 314 void InitializeFromFirstPredecessor(const InstructionSequence* sequence, |
314 const OutgoingMappings* outgoing_mappings, | 315 const OutgoingMappings* outgoing_mappings, |
315 const InstructionBlock* block) { | 316 const InstructionBlock* block) { |
316 if (block->predecessors().empty()) return; | 317 if (block->predecessors().empty()) return; |
317 size_t predecessor_index = block->predecessors()[0].ToSize(); | 318 size_t predecessor_index = block->predecessors()[0].ToSize(); |
318 CHECK(predecessor_index < block->rpo_number().ToSize()); | 319 CHECK(predecessor_index < block->rpo_number().ToSize()); |
319 auto* incoming = outgoing_mappings->at(predecessor_index); | 320 auto* incoming = outgoing_mappings->at(predecessor_index); |
320 if (block->PredecessorCount() > 1) { | 321 if (block->PredecessorCount() >= 1) { |
321 // Update incoming map with phis. The remaining phis will be checked later | 322 // Update incoming map with phis. The remaining phis will be checked later |
322 // as their mappings are not guaranteed to exist yet. | 323 // as their mappings are not guaranteed to exist yet. |
323 incoming->RunPhis(sequence, block, 0); | 324 incoming->RunPhis(sequence, block, 0); |
324 } | 325 } |
325 // Now initialize outgoing mapping for this block with incoming mapping. | 326 // Now initialize outgoing mapping for this block with incoming mapping. |
326 CHECK(locations_.empty()); | 327 CHECK(locations_.empty()); |
327 locations_ = incoming->locations_; | 328 locations_ = incoming->locations_; |
328 } | 329 } |
329 | 330 |
330 void InitializeFromIntersection() { locations_ = predecessor_intersection_; } | 331 void InitializeFromIntersection() { locations_ = predecessor_intersection_; } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 const auto* gap = GapInstruction::cast(instr); | 452 const auto* gap = GapInstruction::cast(instr); |
452 current->RunGapInstruction(zone(), gap); | 453 current->RunGapInstruction(zone(), gap); |
453 } | 454 } |
454 } | 455 } |
455 } | 456 } |
456 } | 457 } |
457 | 458 |
458 } // namespace compiler | 459 } // namespace compiler |
459 } // namespace internal | 460 } // namespace internal |
460 } // namespace v8 | 461 } // namespace v8 |
OLD | NEW |