Commit 51a289b1 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Fix --trace-trubo to generate complete JSON files.

R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/1946523002
Cr-Commit-Position: refs/heads/master@{#35975}
parent 98c23129
......@@ -471,31 +471,35 @@ class PipelineRunScope {
PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info,
ZonePool* zone_pool) {
if (!FLAG_turbo_stats) return nullptr;
PipelineStatistics* pipeline_statistics =
new PipelineStatistics(info, zone_pool);
pipeline_statistics->BeginPhaseKind("initializing");
FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "w+");
if (json_file != nullptr) {
OFStream json_of(json_file);
Handle<Script> script = info->script();
base::SmartArrayPointer<char> function_name = info->GetDebugName();
int pos = info->shared_info()->start_position();
json_of << "{\"function\":\"" << function_name.get()
<< "\", \"sourcePosition\":" << pos << ", \"source\":\"";
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
DisallowHeapAllocation no_allocation;
int start = info->shared_info()->start_position();
int len = info->shared_info()->end_position() - start;
String::SubStringRange source(String::cast(script->source()), start, len);
for (const auto& c : source) {
json_of << AsEscapedUC16ForJSON(c);
PipelineStatistics* pipeline_statistics = nullptr;
if (FLAG_turbo_stats) {
pipeline_statistics = new PipelineStatistics(info, zone_pool);
pipeline_statistics->BeginPhaseKind("initializing");
}
if (FLAG_trace_turbo) {
FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "w+");
if (json_file != nullptr) {
OFStream json_of(json_file);
Handle<Script> script = info->script();
base::SmartArrayPointer<char> function_name = info->GetDebugName();
int pos = info->shared_info()->start_position();
json_of << "{\"function\":\"" << function_name.get()
<< "\", \"sourcePosition\":" << pos << ", \"source\":\"";
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
DisallowHeapAllocation no_allocation;
int start = info->shared_info()->start_position();
int len = info->shared_info()->end_position() - start;
String::SubStringRange source(String::cast(script->source()), start,
len);
for (const auto& c : source) {
json_of << AsEscapedUC16ForJSON(c);
}
}
json_of << "\",\n\"phases\":[";
fclose(json_file);
}
json_of << "\",\n\"phases\":[";
fclose(json_file);
}
return pipeline_statistics;
......
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