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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/instruction.h" | 7 #include "src/compiler/instruction.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (i > 0) os << ", "; | 280 if (i > 0) os << ", "; |
281 printable_op.op_ = instr.OutputAt(i); | 281 printable_op.op_ = instr.OutputAt(i); |
282 os << printable_op; | 282 os << printable_op; |
283 } | 283 } |
284 | 284 |
285 if (instr.OutputCount() > 1) os << ") = "; | 285 if (instr.OutputCount() > 1) os << ") = "; |
286 if (instr.OutputCount() == 1) os << " = "; | 286 if (instr.OutputCount() == 1) os << " = "; |
287 | 287 |
288 if (instr.IsGapMoves()) { | 288 if (instr.IsGapMoves()) { |
289 const GapInstruction* gap = GapInstruction::cast(&instr); | 289 const GapInstruction* gap = GapInstruction::cast(&instr); |
290 os << (instr.IsBlockStart() ? " block-start" : "gap "); | 290 os << "gap "; |
291 for (int i = GapInstruction::FIRST_INNER_POSITION; | 291 for (int i = GapInstruction::FIRST_INNER_POSITION; |
292 i <= GapInstruction::LAST_INNER_POSITION; i++) { | 292 i <= GapInstruction::LAST_INNER_POSITION; i++) { |
293 os << "("; | 293 os << "("; |
294 if (gap->parallel_moves_[i] != NULL) { | 294 if (gap->parallel_moves_[i] != NULL) { |
295 PrintableParallelMove ppm = {printable.register_configuration_, | 295 PrintableParallelMove ppm = {printable.register_configuration_, |
296 gap->parallel_moves_[i]}; | 296 gap->parallel_moves_[i]}; |
297 os << ppm; | 297 os << ppm; |
298 } | 298 } |
299 os << ") "; | 299 os << ") "; |
300 } | 300 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 instructions_(zone()), | 436 instructions_(zone()), |
437 next_virtual_register_(0), | 437 next_virtual_register_(0), |
438 pointer_maps_(zone()), | 438 pointer_maps_(zone()), |
439 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), | 439 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), |
440 references_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), | 440 references_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), |
441 deoptimization_entries_(zone()) { | 441 deoptimization_entries_(zone()) { |
442 block_starts_.reserve(instruction_blocks_->size()); | 442 block_starts_.reserve(instruction_blocks_->size()); |
443 } | 443 } |
444 | 444 |
445 | 445 |
446 BlockStartInstruction* InstructionSequence::GetBlockStart( | 446 GapInstruction* InstructionSequence::GetBlockStart( |
447 BasicBlock::RpoNumber rpo) const { | 447 BasicBlock::RpoNumber rpo) const { |
448 const InstructionBlock* block = InstructionBlockAt(rpo); | 448 const InstructionBlock* block = InstructionBlockAt(rpo); |
449 return BlockStartInstruction::cast(InstructionAt(block->code_start())); | 449 return GapInstruction::cast(InstructionAt(block->code_start())); |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 void InstructionSequence::StartBlock(BasicBlock::RpoNumber rpo) { | 453 void InstructionSequence::StartBlock(BasicBlock::RpoNumber rpo) { |
454 DCHECK(block_starts_.size() == rpo.ToSize()); | 454 DCHECK(block_starts_.size() == rpo.ToSize()); |
455 InstructionBlock* block = InstructionBlockAt(rpo); | 455 InstructionBlock* block = InstructionBlockAt(rpo); |
456 int code_start = static_cast<int>(instructions_.size()); | 456 int code_start = static_cast<int>(instructions_.size()); |
457 block->set_code_start(code_start); | 457 block->set_code_start(code_start); |
458 block_starts_.push_back(code_start); | 458 block_starts_.push_back(code_start); |
459 BlockStartInstruction* block_start = BlockStartInstruction::New(zone()); | |
460 AddInstruction(block_start); | |
461 } | 459 } |
462 | 460 |
463 | 461 |
464 void InstructionSequence::EndBlock(BasicBlock::RpoNumber rpo) { | 462 void InstructionSequence::EndBlock(BasicBlock::RpoNumber rpo) { |
465 int end = static_cast<int>(instructions_.size()); | 463 int end = static_cast<int>(instructions_.size()); |
466 InstructionBlock* block = InstructionBlockAt(rpo); | 464 InstructionBlock* block = InstructionBlockAt(rpo); |
| 465 if (block->code_start() == end) { // Empty block. Insert a nop. |
| 466 AddInstruction(Instruction::New(zone(), kArchNop)); |
| 467 end = static_cast<int>(instructions_.size()); |
| 468 } |
467 DCHECK(block->code_start() >= 0 && block->code_start() < end); | 469 DCHECK(block->code_start() >= 0 && block->code_start() < end); |
468 block->set_code_end(end); | 470 block->set_code_end(end); |
469 } | 471 } |
470 | 472 |
471 | 473 |
472 int InstructionSequence::AddInstruction(Instruction* instr) { | 474 int InstructionSequence::AddInstruction(Instruction* instr) { |
473 // TODO(titzer): the order of these gaps is a holdover from Lithium. | |
474 GapInstruction* gap = GapInstruction::New(zone()); | 475 GapInstruction* gap = GapInstruction::New(zone()); |
475 if (instr->IsControl()) instructions_.push_back(gap); | 476 instructions_.push_back(gap); |
476 int index = static_cast<int>(instructions_.size()); | 477 int index = static_cast<int>(instructions_.size()); |
477 instructions_.push_back(instr); | 478 instructions_.push_back(instr); |
478 if (!instr->IsControl()) instructions_.push_back(gap); | |
479 if (instr->NeedsPointerMap()) { | 479 if (instr->NeedsPointerMap()) { |
480 DCHECK(instr->pointer_map() == NULL); | 480 DCHECK(instr->pointer_map() == NULL); |
481 PointerMap* pointer_map = new (zone()) PointerMap(zone()); | 481 PointerMap* pointer_map = new (zone()) PointerMap(zone()); |
482 pointer_map->set_instruction_position(index); | 482 pointer_map->set_instruction_position(index); |
483 instr->set_pointer_map(pointer_map); | 483 instr->set_pointer_map(pointer_map); |
484 pointer_maps_.push_back(pointer_map); | 484 pointer_maps_.push_back(pointer_map); |
485 } | 485 } |
486 return index; | 486 return index; |
487 } | 487 } |
488 | 488 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 os << " B" << succ_block->id(); | 679 os << " B" << succ_block->id(); |
680 } | 680 } |
681 os << "\n"; | 681 os << "\n"; |
682 } | 682 } |
683 return os; | 683 return os; |
684 } | 684 } |
685 | 685 |
686 } // namespace compiler | 686 } // namespace compiler |
687 } // namespace internal | 687 } // namespace internal |
688 } // namespace v8 | 688 } // namespace v8 |
OLD | NEW |