| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 case Constant::kHeapObject: | 330 case Constant::kHeapObject: |
| 331 return os << Brief(*constant.ToHeapObject()); | 331 return os << Brief(*constant.ToHeapObject()); |
| 332 case Constant::kRpoNumber: | 332 case Constant::kRpoNumber: |
| 333 return os << "RPO" << constant.ToRpoNumber().ToInt(); | 333 return os << "RPO" << constant.ToRpoNumber().ToInt(); |
| 334 } | 334 } |
| 335 UNREACHABLE(); | 335 UNREACHABLE(); |
| 336 return os; | 336 return os; |
| 337 } | 337 } |
| 338 | 338 |
| 339 | 339 |
| 340 PhiInstruction::PhiInstruction(Zone* zone, int virtual_register, |
| 341 size_t input_count) |
| 342 : virtual_register_(virtual_register), |
| 343 output_(UnallocatedOperand(UnallocatedOperand::NONE, virtual_register)), |
| 344 operands_(input_count, zone), |
| 345 inputs_(input_count, zone) {} |
| 346 |
| 347 |
| 348 void PhiInstruction::SetInput(size_t offset, int virtual_register) { |
| 349 DCHECK(inputs_[offset].IsInvalid()); |
| 350 auto input = UnallocatedOperand(UnallocatedOperand::ANY, virtual_register); |
| 351 inputs_[offset] = input; |
| 352 operands_[offset] = virtual_register; |
| 353 } |
| 354 |
| 355 |
| 340 InstructionBlock::InstructionBlock(Zone* zone, BasicBlock::Id id, | 356 InstructionBlock::InstructionBlock(Zone* zone, BasicBlock::Id id, |
| 341 BasicBlock::RpoNumber rpo_number, | 357 BasicBlock::RpoNumber rpo_number, |
| 342 BasicBlock::RpoNumber loop_header, | 358 BasicBlock::RpoNumber loop_header, |
| 343 BasicBlock::RpoNumber loop_end, | 359 BasicBlock::RpoNumber loop_end, |
| 344 bool deferred) | 360 bool deferred) |
| 345 : successors_(zone), | 361 : successors_(zone), |
| 346 predecessors_(zone), | 362 predecessors_(zone), |
| 347 phis_(zone), | 363 phis_(zone), |
| 348 id_(id), | 364 id_(id), |
| 349 ao_number_(rpo_number), | 365 ao_number_(rpo_number), |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 << block->code_end() << ")\n predecessors:"; | 675 << block->code_end() << ")\n predecessors:"; |
| 660 | 676 |
| 661 for (auto pred : block->predecessors()) { | 677 for (auto pred : block->predecessors()) { |
| 662 const InstructionBlock* pred_block = code.InstructionBlockAt(pred); | 678 const InstructionBlock* pred_block = code.InstructionBlockAt(pred); |
| 663 os << " B" << pred_block->id(); | 679 os << " B" << pred_block->id(); |
| 664 } | 680 } |
| 665 os << "\n"; | 681 os << "\n"; |
| 666 | 682 |
| 667 for (auto phi : block->phis()) { | 683 for (auto phi : block->phis()) { |
| 668 PrintableInstructionOperand printable_op = { | 684 PrintableInstructionOperand printable_op = { |
| 669 printable.register_configuration_, phi->output()}; | 685 printable.register_configuration_, &phi->output()}; |
| 670 os << " phi: " << printable_op << " ="; | 686 os << " phi: " << printable_op << " ="; |
| 671 for (auto input : phi->inputs()) { | 687 for (auto input : phi->inputs()) { |
| 672 printable_op.op_ = input; | 688 printable_op.op_ = &input; |
| 673 os << " " << printable_op; | 689 os << " " << printable_op; |
| 674 } | 690 } |
| 675 os << "\n"; | 691 os << "\n"; |
| 676 } | 692 } |
| 677 | 693 |
| 678 ScopedVector<char> buf(32); | 694 ScopedVector<char> buf(32); |
| 679 PrintableInstruction printable_instr; | 695 PrintableInstruction printable_instr; |
| 680 printable_instr.register_configuration_ = printable.register_configuration_; | 696 printable_instr.register_configuration_ = printable.register_configuration_; |
| 681 for (int j = block->first_instruction_index(); | 697 for (int j = block->first_instruction_index(); |
| 682 j <= block->last_instruction_index(); j++) { | 698 j <= block->last_instruction_index(); j++) { |
| 683 // TODO(svenpanne) Add some basic formatting to our streams. | 699 // TODO(svenpanne) Add some basic formatting to our streams. |
| 684 SNPrintF(buf, "%5d", j); | 700 SNPrintF(buf, "%5d", j); |
| 685 printable_instr.instr_ = code.InstructionAt(j); | 701 printable_instr.instr_ = code.InstructionAt(j); |
| 686 os << " " << buf.start() << ": " << printable_instr << "\n"; | 702 os << " " << buf.start() << ": " << printable_instr << "\n"; |
| 687 } | 703 } |
| 688 | 704 |
| 689 for (auto succ : block->successors()) { | 705 for (auto succ : block->successors()) { |
| 690 const InstructionBlock* succ_block = code.InstructionBlockAt(succ); | 706 const InstructionBlock* succ_block = code.InstructionBlockAt(succ); |
| 691 os << " B" << succ_block->id(); | 707 os << " B" << succ_block->id(); |
| 692 } | 708 } |
| 693 os << "\n"; | 709 os << "\n"; |
| 694 } | 710 } |
| 695 return os; | 711 return os; |
| 696 } | 712 } |
| 697 | 713 |
| 698 } // namespace compiler | 714 } // namespace compiler |
| 699 } // namespace internal | 715 } // namespace internal |
| 700 } // namespace v8 | 716 } // namespace v8 |
| OLD | NEW |