| OLD | NEW |
| 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/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| 11 #include "src/bootstrapper.h" // TODO(mstarzinger): Only temporary. | 11 #include "src/bootstrapper.h" // TODO(mstarzinger): Only temporary. |
| 12 #include "src/compiler/ast-graph-builder.h" | 12 #include "src/compiler/ast-graph-builder.h" |
| 13 #include "src/compiler/ast-loop-assignment-analyzer.h" | 13 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 14 #include "src/compiler/basic-block-instrumentor.h" | 14 #include "src/compiler/basic-block-instrumentor.h" |
| 15 #include "src/compiler/change-lowering.h" | 15 #include "src/compiler/change-lowering.h" |
| 16 #include "src/compiler/code-generator.h" | 16 #include "src/compiler/code-generator.h" |
| 17 #include "src/compiler/common-operator-reducer.h" | 17 #include "src/compiler/common-operator-reducer.h" |
| 18 #include "src/compiler/control-flow-optimizer.h" | 18 #include "src/compiler/control-flow-optimizer.h" |
| 19 #include "src/compiler/control-reducer.h" | 19 #include "src/compiler/control-reducer.h" |
| 20 #include "src/compiler/graph-replay.h" | 20 #include "src/compiler/graph-replay.h" |
| 21 #include "src/compiler/graph-visualizer.h" | |
| 22 #include "src/compiler/instruction.h" | 21 #include "src/compiler/instruction.h" |
| 23 #include "src/compiler/instruction-selector.h" | 22 #include "src/compiler/instruction-selector.h" |
| 24 #include "src/compiler/js-builtin-reducer.h" | 23 #include "src/compiler/js-builtin-reducer.h" |
| 25 #include "src/compiler/js-context-specialization.h" | 24 #include "src/compiler/js-context-specialization.h" |
| 26 #include "src/compiler/js-generic-lowering.h" | 25 #include "src/compiler/js-generic-lowering.h" |
| 27 #include "src/compiler/js-inlining.h" | 26 #include "src/compiler/js-inlining.h" |
| 28 #include "src/compiler/js-intrinsic-lowering.h" | 27 #include "src/compiler/js-intrinsic-lowering.h" |
| 29 #include "src/compiler/js-typed-lowering.h" | 28 #include "src/compiler/js-typed-lowering.h" |
| 30 #include "src/compiler/jump-threading.h" | 29 #include "src/compiler/jump-threading.h" |
| 31 #include "src/compiler/load-elimination.h" | 30 #include "src/compiler/load-elimination.h" |
| 32 #include "src/compiler/loop-analysis.h" | 31 #include "src/compiler/loop-analysis.h" |
| 33 #include "src/compiler/loop-peeling.h" | 32 #include "src/compiler/loop-peeling.h" |
| 34 #include "src/compiler/machine-operator-reducer.h" | 33 #include "src/compiler/machine-operator-reducer.h" |
| 35 #include "src/compiler/move-optimizer.h" | 34 #include "src/compiler/move-optimizer.h" |
| 36 #include "src/compiler/osr.h" | 35 #include "src/compiler/osr.h" |
| 37 #include "src/compiler/pipeline-statistics.h" | 36 #include "src/compiler/pipeline-statistics.h" |
| 38 #include "src/compiler/register-allocator.h" | 37 #include "src/compiler/register-allocator.h" |
| 39 #include "src/compiler/register-allocator-verifier.h" | 38 #include "src/compiler/register-allocator-verifier.h" |
| 40 #include "src/compiler/schedule.h" | 39 #include "src/compiler/schedule.h" |
| 41 #include "src/compiler/scheduler.h" | 40 #include "src/compiler/scheduler.h" |
| 42 #include "src/compiler/select-lowering.h" | 41 #include "src/compiler/select-lowering.h" |
| 43 #include "src/compiler/simplified-lowering.h" | 42 #include "src/compiler/simplified-lowering.h" |
| 44 #include "src/compiler/simplified-operator-reducer.h" | 43 #include "src/compiler/simplified-operator-reducer.h" |
| 45 #include "src/compiler/typer.h" | 44 #include "src/compiler/typer.h" |
| 46 #include "src/compiler/value-numbering-reducer.h" | 45 #include "src/compiler/value-numbering-reducer.h" |
| 47 #include "src/compiler/verifier.h" | 46 #include "src/compiler/verifier.h" |
| 47 #include "src/compiler/visualizer.h" |
| 48 #include "src/compiler/zone-pool.h" | 48 #include "src/compiler/zone-pool.h" |
| 49 #include "src/ostreams.h" | 49 #include "src/ostreams.h" |
| 50 #include "src/utils.h" | 50 #include "src/utils.h" |
| 51 | 51 |
| 52 namespace v8 { | 52 namespace v8 { |
| 53 namespace internal { | 53 namespace internal { |
| 54 namespace compiler { | 54 namespace compiler { |
| 55 | 55 |
| 56 class PipelineData { | 56 class PipelineData { |
| 57 public: | 57 public: |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 | 279 |
| 280 struct TurboCfgFile : public std::ofstream { | 280 struct TurboCfgFile : public std::ofstream { |
| 281 explicit TurboCfgFile(Isolate* isolate) | 281 explicit TurboCfgFile(Isolate* isolate) |
| 282 : std::ofstream(isolate->GetTurboCfgFileName().c_str(), | 282 : std::ofstream(isolate->GetTurboCfgFileName().c_str(), |
| 283 std::ios_base::app) {} | 283 std::ios_base::app) {} |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 | 286 |
| 287 static void TraceSchedule(Schedule* schedule) { | 287 static void TraceSchedule(CompilationInfo* info, |
| 288 SourcePositionTable* source_positions, |
| 289 Schedule* schedule) { |
| 290 if (FLAG_trace_turbo) { |
| 291 FILE* json_file = OpenVisualizerLogFile(info, NULL, "json", "a+"); |
| 292 if (json_file != nullptr) { |
| 293 OFStream json_of(json_file); |
| 294 json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; |
| 295 std::stringstream schedule_stream; |
| 296 schedule_stream << ScheduleAsJSON(*schedule, source_positions); |
| 297 std::string schedule_string(schedule_stream.str()); |
| 298 for (const auto& c : schedule_string) { |
| 299 json_of << AsEscapedUC16ForJSON(c); |
| 300 } |
| 301 json_of << "\"},\n"; |
| 302 fclose(json_file); |
| 303 } |
| 304 } |
| 288 if (!FLAG_trace_turbo_graph && !FLAG_trace_turbo_scheduler) return; | 305 if (!FLAG_trace_turbo_graph && !FLAG_trace_turbo_scheduler) return; |
| 289 OFStream os(stdout); | 306 OFStream os(stdout); |
| 290 os << "-- Schedule --------------------------------------\n" << *schedule; | 307 os << "-- Schedule --------------------------------------\n" |
| 308 << ScheduleAsJSON(*schedule); |
| 291 } | 309 } |
| 292 | 310 |
| 293 | 311 |
| 294 static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) { | 312 static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) { |
| 295 SmartArrayPointer<char> name; | 313 SmartArrayPointer<char> name; |
| 296 if (info->IsStub()) { | 314 if (info->IsStub()) { |
| 297 if (info->code_stub() != NULL) { | 315 if (info->code_stub() != NULL) { |
| 298 CodeStub::Major major_key = info->code_stub()->MajorKey(); | 316 CodeStub::Major major_key = info->code_stub()->MajorKey(); |
| 299 const char* major_name = CodeStub::MajorName(major_key, false); | 317 const char* major_name = CodeStub::MajorName(major_key, false); |
| 300 size_t len = strlen(major_name); | 318 size_t len = strlen(major_name); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 OFStream dot_of(dot_file); | 796 OFStream dot_of(dot_file); |
| 779 dot_of << AsDOT(*graph); | 797 dot_of << AsDOT(*graph); |
| 780 fclose(dot_file); | 798 fclose(dot_file); |
| 781 } | 799 } |
| 782 | 800 |
| 783 { // Print JSON. | 801 { // Print JSON. |
| 784 FILE* json_file = OpenVisualizerLogFile(info, NULL, "json", "a+"); | 802 FILE* json_file = OpenVisualizerLogFile(info, NULL, "json", "a+"); |
| 785 if (json_file == nullptr) return; | 803 if (json_file == nullptr) return; |
| 786 OFStream json_of(json_file); | 804 OFStream json_of(json_file); |
| 787 json_of << "{\"name\":\"" << phase << "\",\"type\":\"graph\",\"data\":" | 805 json_of << "{\"name\":\"" << phase << "\",\"type\":\"graph\",\"data\":" |
| 788 << AsJSON(*graph, data->source_positions()) << "},\n"; | 806 << GraphAsJSON(*graph, data->source_positions()) << "},\n"; |
| 789 fclose(json_file); | 807 fclose(json_file); |
| 790 } | 808 } |
| 791 | 809 |
| 792 if (FLAG_trace_turbo_graph) { // Simple textual RPO. | 810 if (FLAG_trace_turbo_graph) { // Simple textual RPO. |
| 793 OFStream os(stdout); | 811 OFStream os(stdout); |
| 794 os << "-- Graph after " << phase << " -- " << std::endl; | 812 os << "-- Graph after " << phase << " -- " << std::endl; |
| 795 os << AsRPO(*graph); | 813 os << AsRPO(*graph); |
| 796 } | 814 } |
| 797 } | 815 } |
| 798 }; | 816 }; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 | 1063 |
| 1046 | 1064 |
| 1047 Handle<Code> Pipeline::ScheduleAndGenerateCode( | 1065 Handle<Code> Pipeline::ScheduleAndGenerateCode( |
| 1048 CallDescriptor* call_descriptor) { | 1066 CallDescriptor* call_descriptor) { |
| 1049 PipelineData* data = this->data_; | 1067 PipelineData* data = this->data_; |
| 1050 | 1068 |
| 1051 DCHECK_NOT_NULL(data->graph()); | 1069 DCHECK_NOT_NULL(data->graph()); |
| 1052 CHECK(SupportedBackend()); | 1070 CHECK(SupportedBackend()); |
| 1053 | 1071 |
| 1054 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); | 1072 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); |
| 1055 TraceSchedule(data->schedule()); | 1073 TraceSchedule(data->info(), data->source_positions(), data->schedule()); |
| 1056 | 1074 |
| 1057 BasicBlockProfiler::Data* profiler_data = NULL; | 1075 BasicBlockProfiler::Data* profiler_data = NULL; |
| 1058 if (FLAG_turbo_profiling) { | 1076 if (FLAG_turbo_profiling) { |
| 1059 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(), | 1077 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(), |
| 1060 data->schedule()); | 1078 data->schedule()); |
| 1061 } | 1079 } |
| 1062 | 1080 |
| 1063 data->InitializeInstructionSequence(); | 1081 data->InitializeInstructionSequence(); |
| 1064 | 1082 |
| 1065 // Select and schedule instructions covering the scheduled graph. | 1083 // Select and schedule instructions covering the scheduled graph. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 | 1215 |
| 1198 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { | 1216 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { |
| 1199 TurboCfgFile tcf(data->isolate()); | 1217 TurboCfgFile tcf(data->isolate()); |
| 1200 tcf << AsC1VAllocator("CodeGen", data->register_allocator()); | 1218 tcf << AsC1VAllocator("CodeGen", data->register_allocator()); |
| 1201 } | 1219 } |
| 1202 } | 1220 } |
| 1203 | 1221 |
| 1204 } // namespace compiler | 1222 } // namespace compiler |
| 1205 } // namespace internal | 1223 } // namespace internal |
| 1206 } // namespace v8 | 1224 } // namespace v8 |
| OLD | NEW |