diff options
Diffstat (limited to 'deps/v8/src/compiler/instruction.cc')
-rw-r--r-- | deps/v8/src/compiler/instruction.cc | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/deps/v8/src/compiler/instruction.cc b/deps/v8/src/compiler/instruction.cc index 2ea3736b90..83ed28fb53 100644 --- a/deps/v8/src/compiler/instruction.cc +++ b/deps/v8/src/compiler/instruction.cc @@ -4,6 +4,8 @@ #include "src/compiler/instruction.h" +#include <iomanip> + #include "src/compiler/common-operator.h" #include "src/compiler/graph.h" #include "src/compiler/schedule.h" @@ -117,11 +119,10 @@ bool LocationOperand::IsCompatible(LocationOperand* op) { } void InstructionOperand::Print(const RegisterConfiguration* config) const { - OFStream os(stdout); PrintableInstructionOperand wrapper; wrapper.register_configuration_ = config; wrapper.op_ = *this; - os << wrapper << std::endl; + StdoutStream{} << wrapper << std::endl; } void InstructionOperand::Print() const { Print(GetRegConfig()); } @@ -183,7 +184,8 @@ std::ostream& operator<<(std::ostream& os, os << "[fp_stack:" << allocated.index(); } else if (op.IsRegister()) { os << "[" - << GetRegConfig()->GetGeneralRegisterName(allocated.register_code()) + << GetRegConfig()->GetGeneralOrSpecialRegisterName( + allocated.register_code()) << "|R"; } else if (op.IsDoubleRegister()) { os << "[" @@ -249,7 +251,7 @@ std::ostream& operator<<(std::ostream& os, } void MoveOperands::Print(const RegisterConfiguration* config) const { - OFStream os(stdout); + StdoutStream os; PrintableInstructionOperand wrapper; wrapper.register_configuration_ = config; wrapper.op_ = destination(); @@ -367,11 +369,10 @@ bool Instruction::AreMovesRedundant() const { } void Instruction::Print(const RegisterConfiguration* config) const { - OFStream os(stdout); PrintableInstruction wrapper; wrapper.instr_ = this; wrapper.register_configuration_ = config; - os << wrapper << std::endl; + StdoutStream{} << wrapper << std::endl; } void Instruction::Print() const { Print(GetRegConfig()); } @@ -691,7 +692,7 @@ static InstructionBlock* InstructionBlockFor(Zone* zone, } std::ostream& operator<<(std::ostream& os, - PrintableInstructionBlock& printable_block) { + const PrintableInstructionBlock& printable_block) { const InstructionBlock* block = printable_block.block_; const RegisterConfiguration* config = printable_block.register_configuration_; const InstructionSequence* code = printable_block.code_; @@ -724,17 +725,15 @@ std::ostream& operator<<(std::ostream& os, os << std::endl; } - ScopedVector<char> buf(32); PrintableInstruction printable_instr; printable_instr.register_configuration_ = config; for (int j = block->first_instruction_index(); j <= block->last_instruction_index(); j++) { - // TODO(svenpanne) Add some basic formatting to our streams. - SNPrintF(buf, "%5d", j); printable_instr.instr_ = code->InstructionAt(j); - os << " " << buf.start() << ": " << printable_instr << std::endl; + os << " " << std::setw(5) << j << ": " << printable_instr << std::endl; } + os << " successors:"; for (RpoNumber succ : block->successors()) { os << " B" << succ.ToInt(); } @@ -869,12 +868,8 @@ void InstructionSequence::StartBlock(RpoNumber rpo) { void InstructionSequence::EndBlock(RpoNumber rpo) { int end = static_cast<int>(instructions_.size()); DCHECK_EQ(current_block_->rpo_number(), rpo); - if (current_block_->code_start() == end) { // Empty block. Insert a nop. - AddInstruction(Instruction::New(zone(), kArchNop)); - end = static_cast<int>(instructions_.size()); - } - DCHECK(current_block_->code_start() >= 0 && - current_block_->code_start() < end); + CHECK(current_block_->code_start() >= 0 && + current_block_->code_start() < end); current_block_->set_code_end(end); current_block_ = nullptr; } @@ -990,23 +985,21 @@ void InstructionSequence::SetSourcePosition(const Instruction* instr, } void InstructionSequence::Print(const RegisterConfiguration* config) const { - OFStream os(stdout); PrintableInstructionSequence wrapper; wrapper.register_configuration_ = config; wrapper.sequence_ = this; - os << wrapper << std::endl; + StdoutStream{} << wrapper << std::endl; } void InstructionSequence::Print() const { Print(GetRegConfig()); } void InstructionSequence::PrintBlock(const RegisterConfiguration* config, int block_id) const { - OFStream os(stdout); RpoNumber rpo = RpoNumber::FromInt(block_id); const InstructionBlock* block = InstructionBlockAt(rpo); CHECK(block->rpo_number() == rpo); PrintableInstructionBlock printable_block = {config, block, this}; - os << printable_block << std::endl; + StdoutStream{} << printable_block << std::endl; } void InstructionSequence::PrintBlock(int block_id) const { |