Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Unified Diff: src/compiler/pipeline.cc

Issue 666223003: Simplify TurboFan's c1visualizer file handling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/pipeline.h ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index 438f10459524b33113a439c942e0434097f1fdc2..f050c9b4c0825b163eabf07b7a40adbdac399b4d 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"
@@ -97,19 +98,10 @@ static inline bool VerifyGraphs() {
}
-void Pipeline::PrintCompilationStart() {
- std::ofstream turbo_cfg_stream;
- OpenTurboCfgFile(&turbo_cfg_stream);
- turbo_cfg_stream << AsC1VCompilation(info());
-}
-
-
-void Pipeline::OpenTurboCfgFile(std::ofstream* stream) {
- char buffer[512];
- Vector<char> filename(buffer, sizeof(buffer));
- isolate()->GetTurboCfgFileName(filename);
- stream->open(filename.start(), std::fstream::out | std::fstream::app);
-}
+struct TurboCfgFile : public std::ofstream {
+ explicit TurboCfgFile(Isolate* isolate)
+ : std::ofstream(isolate->GetTurboCfgFileName(), std::ios_base::app) {}
+};
void Pipeline::VerifyAndPrintGraph(
@@ -158,24 +150,6 @@ void Pipeline::VerifyAndPrintGraph(
}
-void Pipeline::PrintScheduleAndInstructions(
- const char* phase, const Schedule* schedule,
- const SourcePositionTable* positions,
- const InstructionSequence* instructions) {
- std::ofstream turbo_cfg_stream;
- OpenTurboCfgFile(&turbo_cfg_stream);
- turbo_cfg_stream << AsC1V(phase, schedule, positions, instructions);
-}
-
-
-void Pipeline::PrintAllocator(const char* phase,
- const RegisterAllocator* allocator) {
- std::ofstream turbo_cfg_stream;
- OpenTurboCfgFile(&turbo_cfg_stream);
- turbo_cfg_stream << AsC1VAllocator(phase, allocator);
-}
-
-
class AstGraphBuilderWithPositions : public AstGraphBuilder {
public:
explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
@@ -234,7 +208,7 @@ Handle<Code> Pipeline::GenerateCode() {
<< "Begin compiling method "
<< info()->function()->debug_name()->ToCString().get()
<< " using Turbofan" << std::endl;
- PrintCompilationStart();
+ TurboCfgFile(isolate()) << AsC1VCompilation(info());
}
ZonePool zone_pool(isolate());
@@ -487,8 +461,8 @@ Handle<Code> Pipeline::GenerateCode(ZonePool* zone_pool, Linkage* linkage,
OFStream os(stdout);
os << "----- Instruction sequence before register allocation -----\n"
<< sequence;
- PrintScheduleAndInstructions("CodeGen", schedule, source_positions,
- &sequence);
+ TurboCfgFile(isolate())
+ << AsC1V("CodeGen", schedule, source_positions, &sequence);
}
// Allocate registers.
@@ -507,7 +481,7 @@ Handle<Code> Pipeline::GenerateCode(ZonePool* zone_pool, Linkage* linkage,
return Handle<Code>::null();
}
if (FLAG_trace_turbo) {
- PrintAllocator("CodeGen", &allocator);
+ TurboCfgFile(isolate()) << AsC1VAllocator("CodeGen", &allocator);
}
}
« no previous file with comments | « src/compiler/pipeline.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698