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

Side by Side Diff: src/compiler/pipeline.cc

Issue 1946523002: [turbofan] Fix --trace-trubo to generate complete JSON files. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/pipeline.h" 5 #include "src/compiler/pipeline.h"
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/base/adapters.h" 10 #include "src/base/adapters.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 464
465 Zone* zone() { return zone_scope_.zone(); } 465 Zone* zone() { return zone_scope_.zone(); }
466 466
467 private: 467 private:
468 PhaseScope phase_scope_; 468 PhaseScope phase_scope_;
469 ZonePool::Scope zone_scope_; 469 ZonePool::Scope zone_scope_;
470 }; 470 };
471 471
472 PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, 472 PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info,
473 ZonePool* zone_pool) { 473 ZonePool* zone_pool) {
474 if (!FLAG_turbo_stats) return nullptr; 474 PipelineStatistics* pipeline_statistics = nullptr;
475 475
476 PipelineStatistics* pipeline_statistics = 476 if (FLAG_turbo_stats) {
477 new PipelineStatistics(info, zone_pool); 477 pipeline_statistics = new PipelineStatistics(info, zone_pool);
478 pipeline_statistics->BeginPhaseKind("initializing"); 478 pipeline_statistics->BeginPhaseKind("initializing");
479 }
479 480
480 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "w+"); 481 if (FLAG_trace_turbo) {
481 if (json_file != nullptr) { 482 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "w+");
482 OFStream json_of(json_file); 483 if (json_file != nullptr) {
483 Handle<Script> script = info->script(); 484 OFStream json_of(json_file);
484 base::SmartArrayPointer<char> function_name = info->GetDebugName(); 485 Handle<Script> script = info->script();
485 int pos = info->shared_info()->start_position(); 486 base::SmartArrayPointer<char> function_name = info->GetDebugName();
486 json_of << "{\"function\":\"" << function_name.get() 487 int pos = info->shared_info()->start_position();
487 << "\", \"sourcePosition\":" << pos << ", \"source\":\""; 488 json_of << "{\"function\":\"" << function_name.get()
488 if (!script->IsUndefined() && !script->source()->IsUndefined()) { 489 << "\", \"sourcePosition\":" << pos << ", \"source\":\"";
489 DisallowHeapAllocation no_allocation; 490 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
490 int start = info->shared_info()->start_position(); 491 DisallowHeapAllocation no_allocation;
491 int len = info->shared_info()->end_position() - start; 492 int start = info->shared_info()->start_position();
492 String::SubStringRange source(String::cast(script->source()), start, len); 493 int len = info->shared_info()->end_position() - start;
493 for (const auto& c : source) { 494 String::SubStringRange source(String::cast(script->source()), start,
494 json_of << AsEscapedUC16ForJSON(c); 495 len);
496 for (const auto& c : source) {
497 json_of << AsEscapedUC16ForJSON(c);
498 }
495 } 499 }
500 json_of << "\",\n\"phases\":[";
501 fclose(json_file);
496 } 502 }
497 json_of << "\",\n\"phases\":[";
498 fclose(json_file);
499 } 503 }
500 504
501 return pipeline_statistics; 505 return pipeline_statistics;
502 } 506 }
503 507
504 class PipelineCompilationJob final : public CompilationJob { 508 class PipelineCompilationJob final : public CompilationJob {
505 public: 509 public:
506 PipelineCompilationJob(Isolate* isolate, Handle<JSFunction> function) 510 PipelineCompilationJob(Isolate* isolate, Handle<JSFunction> function)
507 // Note that the CompilationInfo is not initialized at the time we pass it 511 // Note that the CompilationInfo is not initialized at the time we pass it
508 // to the CompilationJob constructor, but it is not dereferenced there. 512 // to the CompilationJob constructor, but it is not dereferenced there.
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 data->DeleteRegisterAllocationZone(); 1775 data->DeleteRegisterAllocationZone();
1772 } 1776 }
1773 1777
1774 CompilationInfo* Pipeline::info() const { return data_->info(); } 1778 CompilationInfo* Pipeline::info() const { return data_->info(); }
1775 1779
1776 Isolate* Pipeline::isolate() const { return info()->isolate(); } 1780 Isolate* Pipeline::isolate() const { return info()->isolate(); }
1777 1781
1778 } // namespace compiler 1782 } // namespace compiler
1779 } // namespace internal 1783 } // namespace internal
1780 } // namespace v8 1784 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698