| 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 <memory> | 8 #include <memory> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 std::stringstream schedule_stream; | 420 std::stringstream schedule_stream; |
| 421 schedule_stream << *schedule; | 421 schedule_stream << *schedule; |
| 422 std::string schedule_string(schedule_stream.str()); | 422 std::string schedule_string(schedule_stream.str()); |
| 423 for (const auto& c : schedule_string) { | 423 for (const auto& c : schedule_string) { |
| 424 json_of << AsEscapedUC16ForJSON(c); | 424 json_of << AsEscapedUC16ForJSON(c); |
| 425 } | 425 } |
| 426 json_of << "\"},\n"; | 426 json_of << "\"},\n"; |
| 427 } | 427 } |
| 428 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { | 428 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { |
| 429 AllowHandleDereference allow_deref; | 429 AllowHandleDereference allow_deref; |
| 430 OFStream os(stdout); | 430 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
| 431 OFStream os(tracing_scope.file()); |
| 431 os << "-- Schedule --------------------------------------\n" << *schedule; | 432 os << "-- Schedule --------------------------------------\n" << *schedule; |
| 432 } | 433 } |
| 433 } | 434 } |
| 434 | 435 |
| 435 | 436 |
| 436 class AstGraphBuilderWithPositions final : public AstGraphBuilder { | 437 class AstGraphBuilderWithPositions final : public AstGraphBuilder { |
| 437 public: | 438 public: |
| 438 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, | 439 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, |
| 439 JSGraph* jsgraph, | 440 JSGraph* jsgraph, |
| 440 LoopAssignmentAnalysis* loop_assignment, | 441 LoopAssignmentAnalysis* loop_assignment, |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 | 1428 |
| 1428 { // Print JSON. | 1429 { // Print JSON. |
| 1429 AllowHandleDereference allow_deref; | 1430 AllowHandleDereference allow_deref; |
| 1430 TurboJsonFile json_of(info, std::ios_base::app); | 1431 TurboJsonFile json_of(info, std::ios_base::app); |
| 1431 json_of << "{\"name\":\"" << phase << "\",\"type\":\"graph\",\"data\":" | 1432 json_of << "{\"name\":\"" << phase << "\",\"type\":\"graph\",\"data\":" |
| 1432 << AsJSON(*graph, data->source_positions()) << "},\n"; | 1433 << AsJSON(*graph, data->source_positions()) << "},\n"; |
| 1433 } | 1434 } |
| 1434 | 1435 |
| 1435 if (FLAG_trace_turbo_graph) { // Simple textual RPO. | 1436 if (FLAG_trace_turbo_graph) { // Simple textual RPO. |
| 1436 AllowHandleDereference allow_deref; | 1437 AllowHandleDereference allow_deref; |
| 1437 OFStream os(stdout); | 1438 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
| 1439 OFStream os(tracing_scope.file()); |
| 1438 os << "-- Graph after " << phase << " -- " << std::endl; | 1440 os << "-- Graph after " << phase << " -- " << std::endl; |
| 1439 os << AsRPO(*graph); | 1441 os << AsRPO(*graph); |
| 1440 } | 1442 } |
| 1441 } | 1443 } |
| 1442 }; | 1444 }; |
| 1443 | 1445 |
| 1444 | 1446 |
| 1445 struct VerifyGraphPhase { | 1447 struct VerifyGraphPhase { |
| 1446 static const char* phase_name() { return nullptr; } | 1448 static const char* phase_name() { return nullptr; } |
| 1447 | 1449 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1460 Run<VerifyGraphPhase>(untyped); | 1462 Run<VerifyGraphPhase>(untyped); |
| 1461 } | 1463 } |
| 1462 } | 1464 } |
| 1463 | 1465 |
| 1464 bool PipelineImpl::CreateGraph() { | 1466 bool PipelineImpl::CreateGraph() { |
| 1465 PipelineData* data = this->data_; | 1467 PipelineData* data = this->data_; |
| 1466 | 1468 |
| 1467 data->BeginPhaseKind("graph creation"); | 1469 data->BeginPhaseKind("graph creation"); |
| 1468 | 1470 |
| 1469 if (FLAG_trace_turbo) { | 1471 if (FLAG_trace_turbo) { |
| 1470 OFStream os(stdout); | 1472 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 1473 OFStream os(tracing_scope.file()); |
| 1471 os << "---------------------------------------------------\n" | 1474 os << "---------------------------------------------------\n" |
| 1472 << "Begin compiling method " << info()->GetDebugName().get() | 1475 << "Begin compiling method " << info()->GetDebugName().get() |
| 1473 << " using Turbofan" << std::endl; | 1476 << " using Turbofan" << std::endl; |
| 1474 TurboCfgFile tcf(isolate()); | 1477 TurboCfgFile tcf(isolate()); |
| 1475 tcf << AsC1VCompilation(info()); | 1478 tcf << AsC1VCompilation(info()); |
| 1476 } | 1479 } |
| 1477 | 1480 |
| 1478 data->source_positions()->AddDecorator(); | 1481 data->source_positions()->AddDecorator(); |
| 1479 | 1482 |
| 1480 if (FLAG_loop_assignment_analysis) { | 1483 if (FLAG_loop_assignment_analysis) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 std::string disassembly_string(disassembly_stream.str()); | 1829 std::string disassembly_string(disassembly_stream.str()); |
| 1827 for (const auto& c : disassembly_string) { | 1830 for (const auto& c : disassembly_string) { |
| 1828 json_of << AsEscapedUC16ForJSON(c); | 1831 json_of << AsEscapedUC16ForJSON(c); |
| 1829 } | 1832 } |
| 1830 #endif // ENABLE_DISASSEMBLER | 1833 #endif // ENABLE_DISASSEMBLER |
| 1831 json_of << "\"}\n],\n"; | 1834 json_of << "\"}\n],\n"; |
| 1832 json_of << "\"nodePositions\":"; | 1835 json_of << "\"nodePositions\":"; |
| 1833 json_of << data->source_position_output(); | 1836 json_of << data->source_position_output(); |
| 1834 json_of << "}"; | 1837 json_of << "}"; |
| 1835 | 1838 |
| 1836 OFStream os(stdout); | 1839 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 1840 OFStream os(tracing_scope.file()); |
| 1837 os << "---------------------------------------------------\n" | 1841 os << "---------------------------------------------------\n" |
| 1838 << "Finished compiling method " << info()->GetDebugName().get() | 1842 << "Finished compiling method " << info()->GetDebugName().get() |
| 1839 << " using Turbofan" << std::endl; | 1843 << " using Turbofan" << std::endl; |
| 1840 } | 1844 } |
| 1841 | 1845 |
| 1842 return code; | 1846 return code; |
| 1843 } | 1847 } |
| 1844 | 1848 |
| 1845 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( | 1849 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( |
| 1846 CallDescriptor* call_descriptor) { | 1850 CallDescriptor* call_descriptor) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1877 AllowHandleDereference allow_deref; | 1881 AllowHandleDereference allow_deref; |
| 1878 OsrHelper osr_helper(info()); | 1882 OsrHelper osr_helper(info()); |
| 1879 osr_helper.SetupFrame(data->frame()); | 1883 osr_helper.SetupFrame(data->frame()); |
| 1880 } | 1884 } |
| 1881 | 1885 |
| 1882 Run<MeetRegisterConstraintsPhase>(); | 1886 Run<MeetRegisterConstraintsPhase>(); |
| 1883 Run<ResolvePhisPhase>(); | 1887 Run<ResolvePhisPhase>(); |
| 1884 Run<BuildLiveRangesPhase>(); | 1888 Run<BuildLiveRangesPhase>(); |
| 1885 if (FLAG_trace_turbo_graph) { | 1889 if (FLAG_trace_turbo_graph) { |
| 1886 AllowHandleDereference allow_deref; | 1890 AllowHandleDereference allow_deref; |
| 1887 OFStream os(stdout); | 1891 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 1892 OFStream os(tracing_scope.file()); |
| 1888 os << "----- Instruction sequence before register allocation -----\n" | 1893 os << "----- Instruction sequence before register allocation -----\n" |
| 1889 << PrintableInstructionSequence({config, data->sequence()}); | 1894 << PrintableInstructionSequence({config, data->sequence()}); |
| 1890 } | 1895 } |
| 1891 if (verifier != nullptr) { | 1896 if (verifier != nullptr) { |
| 1892 CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition()); | 1897 CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition()); |
| 1893 CHECK(data->register_allocation_data() | 1898 CHECK(data->register_allocation_data() |
| 1894 ->RangesDefinedInDeferredStayInDeferred()); | 1899 ->RangesDefinedInDeferredStayInDeferred()); |
| 1895 } | 1900 } |
| 1896 | 1901 |
| 1897 if (FLAG_turbo_preprocess_ranges) { | 1902 if (FLAG_turbo_preprocess_ranges) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1912 Run<ConnectRangesPhase>(); | 1917 Run<ConnectRangesPhase>(); |
| 1913 Run<ResolveControlFlowPhase>(); | 1918 Run<ResolveControlFlowPhase>(); |
| 1914 if (FLAG_turbo_move_optimization) { | 1919 if (FLAG_turbo_move_optimization) { |
| 1915 Run<OptimizeMovesPhase>(); | 1920 Run<OptimizeMovesPhase>(); |
| 1916 } | 1921 } |
| 1917 | 1922 |
| 1918 Run<LocateSpillSlotsPhase>(); | 1923 Run<LocateSpillSlotsPhase>(); |
| 1919 | 1924 |
| 1920 if (FLAG_trace_turbo_graph) { | 1925 if (FLAG_trace_turbo_graph) { |
| 1921 AllowHandleDereference allow_deref; | 1926 AllowHandleDereference allow_deref; |
| 1922 OFStream os(stdout); | 1927 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 1928 OFStream os(tracing_scope.file()); |
| 1923 os << "----- Instruction sequence after register allocation -----\n" | 1929 os << "----- Instruction sequence after register allocation -----\n" |
| 1924 << PrintableInstructionSequence({config, data->sequence()}); | 1930 << PrintableInstructionSequence({config, data->sequence()}); |
| 1925 } | 1931 } |
| 1926 | 1932 |
| 1927 if (verifier != nullptr) { | 1933 if (verifier != nullptr) { |
| 1928 verifier->VerifyAssignment(); | 1934 verifier->VerifyAssignment(); |
| 1929 verifier->VerifyGapMoves(); | 1935 verifier->VerifyGapMoves(); |
| 1930 } | 1936 } |
| 1931 | 1937 |
| 1932 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { | 1938 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { |
| 1933 TurboCfgFile tcf(data->isolate()); | 1939 TurboCfgFile tcf(data->isolate()); |
| 1934 tcf << AsC1VRegisterAllocationData("CodeGen", | 1940 tcf << AsC1VRegisterAllocationData("CodeGen", |
| 1935 data->register_allocation_data()); | 1941 data->register_allocation_data()); |
| 1936 } | 1942 } |
| 1937 | 1943 |
| 1938 data->DeleteRegisterAllocationZone(); | 1944 data->DeleteRegisterAllocationZone(); |
| 1939 } | 1945 } |
| 1940 | 1946 |
| 1941 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1947 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
| 1942 | 1948 |
| 1943 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1949 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
| 1944 | 1950 |
| 1945 } // namespace compiler | 1951 } // namespace compiler |
| 1946 } // namespace internal | 1952 } // namespace internal |
| 1947 } // namespace v8 | 1953 } // namespace v8 |
| OLD | NEW |