Index: src/compiler/pipeline.cc |
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc |
index 7da2fb543c9d32c77bad75e558ac262d942b20ce..36c9339bb18043b03480c6bec5737aeba8e42c4c 100644 |
--- a/src/compiler/pipeline.cc |
+++ b/src/compiler/pipeline.cc |
@@ -4,6 +4,7 @@ |
#include "src/compiler/pipeline.h" |
+#include <fstream> // NOLINT(readability/streams) |
#include <sstream> |
#include "src/base/platform/elapsed-timer.h" |
@@ -90,13 +91,20 @@ static inline bool VerifyGraphs() { |
} |
+void Pipeline::PrintCompilationStart() { |
+ std::ofstream turbo_cfg_stream("turbo.cfg", |
Vyacheslav Egorov (Google)
2014/10/13 07:42:10
consider mangling the name with PID so it works fr
|
+ std::fstream::out | std::fstream::app); |
+ turbo_cfg_stream << AsC1VCompilation(info()); |
+} |
+ |
+ |
void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) { |
if (FLAG_trace_turbo) { |
char buffer[256]; |
Vector<char> filename(buffer, sizeof(buffer)); |
+ SmartArrayPointer<char> functionname; |
if (!info_->shared_info().is_null()) { |
- SmartArrayPointer<char> functionname = |
- info_->shared_info()->DebugName()->ToCString(); |
+ functionname = info_->shared_info()->DebugName()->ToCString(); |
if (strlen(functionname.get()) > 0) { |
SNPrintF(filename, "turbo-%s-%s", functionname.get(), phase); |
} else { |
@@ -132,6 +140,23 @@ void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) { |
} |
+void Pipeline::PrintScheduleAndInstructions( |
+ const char* phase, const Schedule* schedule, |
+ const InstructionSequence* instructions) { |
+ std::ofstream turbo_cfg_stream("turbo.cfg", |
+ std::fstream::out | std::fstream::app); |
+ turbo_cfg_stream << AsC1V(phase, schedule, instructions); |
+} |
+ |
+ |
+void Pipeline::PrintAllocator(const char* phase, |
+ const RegisterAllocator* allocator) { |
+ std::ofstream turbo_cfg_stream("turbo.cfg", |
+ std::fstream::out | std::fstream::app); |
+ turbo_cfg_stream << AsC1VAllocator(phase, allocator); |
+} |
+ |
+ |
class AstGraphBuilderWithPositions : public AstGraphBuilder { |
public: |
explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, |
@@ -188,6 +213,7 @@ Handle<Code> Pipeline::GenerateCode() { |
<< "Begin compiling method " |
<< info()->function()->debug_name()->ToCString().get() |
<< " using Turbofan" << std::endl; |
+ PrintCompilationStart(); |
} |
// Build the graph. |
@@ -405,6 +431,7 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, |
OFStream os(stdout); |
os << "----- Instruction sequence before register allocation -----\n" |
<< sequence; |
+ PrintScheduleAndInstructions("CodeGen", schedule, &sequence); |
} |
// Allocate registers. |
@@ -419,6 +446,9 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, |
linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
return Handle<Code>::null(); |
} |
+ if (FLAG_trace_turbo) { |
+ PrintAllocator("CodeGen", &allocator); |
+ } |
} |
if (FLAG_trace_turbo) { |