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