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 << "gap "; | 290 os << (instr.IsBlockStart() ? " block-start" : "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 GapInstruction* InstructionSequence::GetBlockStart( | 446 BlockStartInstruction* 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 GapInstruction::cast(InstructionAt(block->code_start())); | 449 return BlockStartInstruction::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); |
459 } | 461 } |
460 | 462 |
461 | 463 |
462 void InstructionSequence::EndBlock(BasicBlock::RpoNumber rpo) { | 464 void InstructionSequence::EndBlock(BasicBlock::RpoNumber rpo) { |
463 int end = static_cast<int>(instructions_.size()); | 465 int end = static_cast<int>(instructions_.size()); |
464 InstructionBlock* block = InstructionBlockAt(rpo); | 466 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 } | |
469 DCHECK(block->code_start() >= 0 && block->code_start() < end); | 467 DCHECK(block->code_start() >= 0 && block->code_start() < end); |
470 block->set_code_end(end); | 468 block->set_code_end(end); |
471 } | 469 } |
472 | 470 |
473 | 471 |
474 int InstructionSequence::AddInstruction(Instruction* instr) { | 472 int InstructionSequence::AddInstruction(Instruction* instr) { |
| 473 // TODO(titzer): the order of these gaps is a holdover from Lithium. |
475 GapInstruction* gap = GapInstruction::New(zone()); | 474 GapInstruction* gap = GapInstruction::New(zone()); |
476 instructions_.push_back(gap); | 475 if (instr->IsControl()) instructions_.push_back(gap); |
477 int index = static_cast<int>(instructions_.size()); | 476 int index = static_cast<int>(instructions_.size()); |
478 instructions_.push_back(instr); | 477 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 |