Commit ce8fab76 authored by ofrobots's avatar ofrobots Committed by Commit bot

trace-turbo should respect --redirect-code-traces

On larger workloads, lots of output on stdout becomes unwieldy.

R=bmeurer@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2293413004
Cr-Commit-Position: refs/heads/master@{#39111}
parent bcbbfa7d
......@@ -68,15 +68,17 @@ bool InstructionOperand::InterferesWith(const InstructionOperand& that) const {
return EqualsCanonicalized(that);
}
void InstructionOperand::Print(const RegisterConfiguration* config) const {
OFStream os(stdout);
void InstructionOperand::Print(std::ostream& os,
const RegisterConfiguration* config) const {
PrintableInstructionOperand wrapper;
wrapper.register_configuration_ = config;
wrapper.op_ = *this;
os << wrapper << std::endl;
}
void InstructionOperand::Print() const { Print(GetRegConfig()); }
void InstructionOperand::Print(std::ostream& os) const {
Print(os, GetRegConfig());
}
std::ostream& operator<<(std::ostream& os,
const PrintableInstructionOperand& printable) {
......@@ -199,8 +201,8 @@ std::ostream& operator<<(std::ostream& os,
return os;
}
void MoveOperands::Print(const RegisterConfiguration* config) const {
OFStream os(stdout);
void MoveOperands::Print(std::ostream& os,
const RegisterConfiguration* config) const {
PrintableInstructionOperand wrapper;
wrapper.register_configuration_ = config;
wrapper.op_ = destination();
......@@ -209,7 +211,7 @@ void MoveOperands::Print(const RegisterConfiguration* config) const {
os << wrapper << std::endl;
}
void MoveOperands::Print() const { Print(GetRegConfig()); }
void MoveOperands::Print(std::ostream& os) const { Print(os, GetRegConfig()); }
std::ostream& operator<<(std::ostream& os,
const PrintableMoveOperands& printable) {
......@@ -314,16 +316,15 @@ bool Instruction::AreMovesRedundant() const {
return true;
}
void Instruction::Print(const RegisterConfiguration* config) const {
OFStream os(stdout);
void Instruction::Print(std::ostream& os,
const RegisterConfiguration* config) const {
PrintableInstruction wrapper;
wrapper.instr_ = this;
wrapper.register_configuration_ = config;
os << wrapper << std::endl;
}
void Instruction::Print() const { Print(GetRegConfig()); }
void Instruction::Print(std::ostream& os) const { Print(os, GetRegConfig()); }
std::ostream& operator<<(std::ostream& os,
const PrintableParallelMove& printable) {
......@@ -874,20 +875,21 @@ void InstructionSequence::SetSourcePosition(const Instruction* instr,
source_positions_.insert(std::make_pair(instr, value));
}
void InstructionSequence::Print(const RegisterConfiguration* config) const {
OFStream os(stdout);
void InstructionSequence::Print(std::ostream& os,
const RegisterConfiguration* config) const {
PrintableInstructionSequence wrapper;
wrapper.register_configuration_ = config;
wrapper.sequence_ = this;
os << wrapper << std::endl;
}
void InstructionSequence::Print() const { Print(GetRegConfig()); }
void InstructionSequence::Print(std::ostream& os) const {
Print(os, GetRegConfig());
}
void InstructionSequence::PrintBlock(const RegisterConfiguration* config,
void InstructionSequence::PrintBlock(std::ostream& os,
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);
......@@ -936,8 +938,8 @@ void InstructionSequence::PrintBlock(const RegisterConfiguration* config,
os << "\n";
}
void InstructionSequence::PrintBlock(int block_id) const {
PrintBlock(GetRegConfig(), block_id);
void InstructionSequence::PrintBlock(std::ostream& os, int block_id) const {
PrintBlock(os, GetRegConfig(), block_id);
}
FrameStateDescriptor::FrameStateDescriptor(
......@@ -1021,7 +1023,7 @@ std::ostream& operator<<(std::ostream& os,
os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n";
}
for (int i = 0; i < code.InstructionBlockCount(); i++) {
printable.sequence_->PrintBlock(printable.register_configuration_, i);
printable.sequence_->PrintBlock(os, printable.register_configuration_, i);
}
return os;
}
......
......@@ -105,8 +105,8 @@ class InstructionOperand {
bool InterferesWith(const InstructionOperand& that) const;
void Print(const RegisterConfiguration* config) const;
void Print() const;
void Print(std::ostream& os, const RegisterConfiguration* config) const;
void Print(std::ostream& os) const;
protected:
explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {}
......@@ -672,8 +672,8 @@ class MoveOperands final : public ZoneObject {
return source_.IsInvalid();
}
void Print(const RegisterConfiguration* config) const;
void Print() const;
void Print(std::ostream& os, const RegisterConfiguration* config) const;
void Print(std::ostream& os) const;
private:
InstructionOperand source_;
......@@ -912,8 +912,8 @@ class Instruction final {
block_ = block;
}
void Print(const RegisterConfiguration* config) const;
void Print() const;
void Print(std::ostream& os, const RegisterConfiguration* config) const;
void Print(std::ostream& os) const;
private:
explicit Instruction(InstructionCode opcode);
......@@ -1441,11 +1441,12 @@ class InstructionSequence final : public ZoneObject {
}
return false;
}
void Print(const RegisterConfiguration* config) const;
void Print() const;
void Print(std::ostream& os, const RegisterConfiguration* config) const;
void Print(std::ostream& os) const;
void PrintBlock(const RegisterConfiguration* config, int block_id) const;
void PrintBlock(int block_id) const;
void PrintBlock(std::ostream& os, const RegisterConfiguration* config,
int block_id) const;
void PrintBlock(std::ostream& os, int block_id) const;
void ValidateEdgeSplitForm() const;
void ValidateDeferredBlockExitPaths() const;
......
......@@ -429,7 +429,8 @@ void TraceSchedule(CompilationInfo* info, Schedule* schedule) {
}
if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) {
AllowHandleDereference allow_deref;
OFStream os(stdout);
CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "-- Schedule --------------------------------------\n" << *schedule;
}
}
......@@ -1436,7 +1437,8 @@ struct PrintGraphPhase {
if (FLAG_trace_turbo_graph) { // Simple textual RPO.
AllowHandleDereference allow_deref;
OFStream os(stdout);
CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "-- Graph after " << phase << " -- " << std::endl;
os << AsRPO(*graph);
}
......@@ -1469,7 +1471,8 @@ bool PipelineImpl::CreateGraph() {
data->BeginPhaseKind("graph creation");
if (FLAG_trace_turbo) {
OFStream os(stdout);
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "---------------------------------------------------\n"
<< "Begin compiling method " << info()->GetDebugName().get()
<< " using Turbofan" << std::endl;
......@@ -1835,7 +1838,8 @@ Handle<Code> PipelineImpl::GenerateCode(Linkage* linkage) {
json_of << data->source_position_output();
json_of << "}";
OFStream os(stdout);
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "---------------------------------------------------\n"
<< "Finished compiling method " << info()->GetDebugName().get()
<< " using Turbofan" << std::endl;
......@@ -1886,7 +1890,8 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
Run<BuildLiveRangesPhase>();
if (FLAG_trace_turbo_graph) {
AllowHandleDereference allow_deref;
OFStream os(stdout);
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "----- Instruction sequence before register allocation -----\n"
<< PrintableInstructionSequence({config, data->sequence()});
}
......@@ -1921,7 +1926,8 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
if (FLAG_trace_turbo_graph) {
AllowHandleDereference allow_deref;
OFStream os(stdout);
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "----- Instruction sequence after register allocation -----\n"
<< PrintableInstructionSequence({config, data->sequence()});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment