Revert "Simplify TurboFan's c1visualizer file handling."

This reverts r24819, it broke the build on Mac due to header incompatibilities.

TBR=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/672873002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24821 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2014-10-23 07:36:39 +00:00
parent 6d5f6914f7
commit ea3a205af2
4 changed files with 57 additions and 17 deletions

View File

@ -4,7 +4,6 @@
#include "src/compiler/pipeline.h" #include "src/compiler/pipeline.h"
#include <fstream> // NOLINT(readability/streams)
#include <sstream> #include <sstream>
#include "src/base/platform/elapsed-timer.h" #include "src/base/platform/elapsed-timer.h"
@ -98,10 +97,19 @@ static inline bool VerifyGraphs() {
} }
struct TurboCfgFile : public std::ofstream { void Pipeline::PrintCompilationStart() {
explicit TurboCfgFile(Isolate* isolate) std::ofstream turbo_cfg_stream;
: std::ofstream(isolate->GetTurboCfgFileName(), std::ios_base::app) {} 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);
}
void Pipeline::VerifyAndPrintGraph( void Pipeline::VerifyAndPrintGraph(
@ -150,6 +158,24 @@ 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 { class AstGraphBuilderWithPositions : public AstGraphBuilder {
public: public:
explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
@ -208,7 +234,7 @@ Handle<Code> Pipeline::GenerateCode() {
<< "Begin compiling method " << "Begin compiling method "
<< info()->function()->debug_name()->ToCString().get() << info()->function()->debug_name()->ToCString().get()
<< " using Turbofan" << std::endl; << " using Turbofan" << std::endl;
TurboCfgFile(isolate()) << AsC1VCompilation(info()); PrintCompilationStart();
} }
ZonePool zone_pool(isolate()); ZonePool zone_pool(isolate());
@ -461,8 +487,8 @@ Handle<Code> Pipeline::GenerateCode(ZonePool* zone_pool, Linkage* linkage,
OFStream os(stdout); OFStream os(stdout);
os << "----- Instruction sequence before register allocation -----\n" os << "----- Instruction sequence before register allocation -----\n"
<< sequence; << sequence;
TurboCfgFile(isolate()) PrintScheduleAndInstructions("CodeGen", schedule, source_positions,
<< AsC1V("CodeGen", schedule, source_positions, &sequence); &sequence);
} }
// Allocate registers. // Allocate registers.
@ -481,7 +507,7 @@ Handle<Code> Pipeline::GenerateCode(ZonePool* zone_pool, Linkage* linkage,
return Handle<Code>::null(); return Handle<Code>::null();
} }
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
TurboCfgFile(isolate()) << AsC1VAllocator("CodeGen", &allocator); PrintAllocator("CodeGen", &allocator);
} }
} }

View File

@ -5,6 +5,8 @@
#ifndef V8_COMPILER_PIPELINE_H_ #ifndef V8_COMPILER_PIPELINE_H_
#define V8_COMPILER_PIPELINE_H_ #define V8_COMPILER_PIPELINE_H_
#include <fstream> // NOLINT(readability/streams)
#include "src/v8.h" #include "src/v8.h"
#include "src/compiler.h" #include "src/compiler.h"
@ -51,6 +53,12 @@ class Pipeline {
Zone* zone() { return info_->zone(); } Zone* zone() { return info_->zone(); }
Schedule* ComputeSchedule(ZonePool* zone_pool, Graph* graph); Schedule* ComputeSchedule(ZonePool* zone_pool, Graph* graph);
void OpenTurboCfgFile(std::ofstream* stream);
void PrintCompilationStart();
void PrintScheduleAndInstructions(const char* phase, const Schedule* schedule,
const SourcePositionTable* positions,
const InstructionSequence* instructions);
void PrintAllocator(const char* phase, const RegisterAllocator* allocator);
void VerifyAndPrintGraph(Graph* graph, const char* phase, void VerifyAndPrintGraph(Graph* graph, const char* phase,
bool untyped = false); bool untyped = false);
Handle<Code> GenerateCode(ZonePool* zone_pool, Linkage* linkage, Graph* graph, Handle<Code> GenerateCode(ZonePool* zone_pool, Linkage* linkage, Graph* graph,

View File

@ -1951,8 +1951,12 @@ bool Isolate::Init(Deserializer* des) {
if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value());
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
// Create an empty file. // Erase the file.
std::ofstream(GetTurboCfgFileName(), std::ios_base::trunc); char buffer[512];
Vector<char> filename(buffer, sizeof(buffer));
GetTurboCfgFileName(filename);
std::ofstream turbo_cfg_stream(filename.start(),
std::fstream::out | std::fstream::trunc);
} }
// If we are deserializing, log non-function code objects and compiled // If we are deserializing, log non-function code objects and compiled
@ -2368,11 +2372,13 @@ BasicBlockProfiler* Isolate::GetOrCreateBasicBlockProfiler() {
} }
std::string Isolate::GetTurboCfgFileName() { void Isolate::GetTurboCfgFileName(Vector<char> filename) {
return FLAG_trace_turbo_cfg_file == NULL if (FLAG_trace_turbo_cfg_file == NULL) {
? "turbo-" + std::to_string(base::OS::GetCurrentProcessId()) + SNPrintF(filename, "turbo-%d-%d.cfg", base::OS::GetCurrentProcessId(),
"-" + std::to_string(id()) + ".cfg" id());
: FLAG_trace_turbo_cfg_file; } else {
StrNCpy(filename, FLAG_trace_turbo_cfg_file, filename.length());
}
} }

View File

@ -1098,7 +1098,7 @@ class Isolate {
static Isolate* NewForTesting() { return new Isolate(false); } static Isolate* NewForTesting() { return new Isolate(false); }
std::string GetTurboCfgFileName(); void GetTurboCfgFileName(Vector<char> buffer);
private: private:
explicit Isolate(bool enable_serializer); explicit Isolate(bool enable_serializer);