| 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" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 | 245 |
| 246 struct TurboCfgFile : public std::ofstream { | 246 struct TurboCfgFile : public std::ofstream { |
| 247 explicit TurboCfgFile(Isolate* isolate) | 247 explicit TurboCfgFile(Isolate* isolate) |
| 248 : std::ofstream(isolate->GetTurboCfgFileName().c_str(), | 248 : std::ofstream(isolate->GetTurboCfgFileName().c_str(), |
| 249 std::ios_base::app) {} | 249 std::ios_base::app) {} |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 | 252 |
| 253 static void TraceSchedule(Schedule* schedule) { | 253 static void TraceSchedule(Schedule* schedule) { |
| 254 if (!FLAG_trace_turbo) return; | 254 if (!FLAG_trace_turbo_graph && !FLAG_trace_turbo_scheduler) return; |
| 255 OFStream os(stdout); | 255 OFStream os(stdout); |
| 256 os << "-- Schedule --------------------------------------\n" << *schedule; | 256 os << "-- Schedule --------------------------------------\n" << *schedule; |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) { | 260 static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) { |
| 261 SmartArrayPointer<char> name; | 261 SmartArrayPointer<char> name; |
| 262 if (info->IsStub()) { | 262 if (info->IsStub()) { |
| 263 if (info->code_stub() != NULL) { | 263 if (info->code_stub() != NULL) { |
| 264 CodeStub::Major major_key = info->code_stub()->MajorKey(); | 264 CodeStub::Major major_key = info->code_stub()->MajorKey(); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 SNPrintF(filename, "turbo-none-%s", phase); | 639 SNPrintF(filename, "turbo-none-%s", phase); |
| 640 } | 640 } |
| 641 std::replace(filename.start(), filename.start() + filename.length(), ' ', | 641 std::replace(filename.start(), filename.start() + filename.length(), ' ', |
| 642 '_'); | 642 '_'); |
| 643 | 643 |
| 644 { // Print dot. | 644 { // Print dot. |
| 645 char dot_buffer[256]; | 645 char dot_buffer[256]; |
| 646 Vector<char> dot_filename(dot_buffer, sizeof(dot_buffer)); | 646 Vector<char> dot_filename(dot_buffer, sizeof(dot_buffer)); |
| 647 SNPrintF(dot_filename, "%s.dot", filename.start()); | 647 SNPrintF(dot_filename, "%s.dot", filename.start()); |
| 648 FILE* dot_file = base::OS::FOpen(dot_filename.start(), "w+"); | 648 FILE* dot_file = base::OS::FOpen(dot_filename.start(), "w+"); |
| 649 if (dot_file == nullptr) return; |
| 649 OFStream dot_of(dot_file); | 650 OFStream dot_of(dot_file); |
| 650 dot_of << AsDOT(*graph); | 651 dot_of << AsDOT(*graph); |
| 651 fclose(dot_file); | 652 fclose(dot_file); |
| 652 } | 653 } |
| 653 | 654 |
| 654 { // Print JSON. | 655 { // Print JSON. |
| 655 char json_buffer[256]; | 656 char json_buffer[256]; |
| 656 Vector<char> json_filename(json_buffer, sizeof(json_buffer)); | 657 Vector<char> json_filename(json_buffer, sizeof(json_buffer)); |
| 657 SNPrintF(json_filename, "%s.json", filename.start()); | 658 SNPrintF(json_filename, "%s.json", filename.start()); |
| 658 FILE* json_file = base::OS::FOpen(json_filename.start(), "w+"); | 659 FILE* json_file = base::OS::FOpen(json_filename.start(), "w+"); |
| 660 if (json_file == nullptr) return; |
| 659 OFStream json_of(json_file); | 661 OFStream json_of(json_file); |
| 660 json_of << AsJSON(*graph); | 662 json_of << AsJSON(*graph); |
| 661 fclose(json_file); | 663 fclose(json_file); |
| 662 } | 664 } |
| 663 | 665 |
| 664 OFStream os(stdout); | 666 OFStream os(stdout); |
| 665 if (FLAG_trace_turbo_graph) { // Simple textual RPO. | 667 if (FLAG_trace_turbo_graph) { // Simple textual RPO. |
| 666 os << "-- Graph after " << phase << " -- " << std::endl; | 668 os << "-- Graph after " << phase << " -- " << std::endl; |
| 667 os << AsRPO(*graph); | 669 os << AsRPO(*graph); |
| 668 } | 670 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 GenerateCode(&linkage); | 813 GenerateCode(&linkage); |
| 812 } | 814 } |
| 813 Handle<Code> code = data.code(); | 815 Handle<Code> code = data.code(); |
| 814 info()->SetCode(code); | 816 info()->SetCode(code); |
| 815 | 817 |
| 816 // Print optimized code. | 818 // Print optimized code. |
| 817 v8::internal::CodeGenerator::PrintCode(code, info()); | 819 v8::internal::CodeGenerator::PrintCode(code, info()); |
| 818 | 820 |
| 819 if (FLAG_trace_turbo) { | 821 if (FLAG_trace_turbo) { |
| 820 OFStream os(stdout); | 822 OFStream os(stdout); |
| 821 os << "--------------------------------------------------\n" | 823 os << "---------------------------------------------------\n" |
| 822 << "Finished compiling method " << GetDebugName(info()).get() | 824 << "Finished compiling method " << GetDebugName(info()).get() |
| 823 << " using Turbofan" << std::endl; | 825 << " using Turbofan" << std::endl; |
| 824 } | 826 } |
| 825 | 827 |
| 826 return code; | 828 return code; |
| 827 } | 829 } |
| 828 | 830 |
| 829 | 831 |
| 830 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 832 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| 831 Graph* graph, | 833 Graph* graph, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 debug_name = GetDebugName(data->info()); | 977 debug_name = GetDebugName(data->info()); |
| 976 #endif | 978 #endif |
| 977 | 979 |
| 978 ZonePool::Scope zone_scope(data->zone_pool()); | 980 ZonePool::Scope zone_scope(data->zone_pool()); |
| 979 data->InitializeRegisterAllocator(zone_scope.zone(), config, | 981 data->InitializeRegisterAllocator(zone_scope.zone(), config, |
| 980 debug_name.get()); | 982 debug_name.get()); |
| 981 | 983 |
| 982 Run<MeetRegisterConstraintsPhase>(); | 984 Run<MeetRegisterConstraintsPhase>(); |
| 983 Run<ResolvePhisPhase>(); | 985 Run<ResolvePhisPhase>(); |
| 984 Run<BuildLiveRangesPhase>(); | 986 Run<BuildLiveRangesPhase>(); |
| 985 if (FLAG_trace_turbo) { | 987 if (FLAG_trace_turbo_graph) { |
| 986 OFStream os(stdout); | 988 OFStream os(stdout); |
| 987 PrintableInstructionSequence printable = {config, data->sequence()}; | 989 PrintableInstructionSequence printable = {config, data->sequence()}; |
| 988 os << "----- Instruction sequence before register allocation -----\n" | 990 os << "----- Instruction sequence before register allocation -----\n" |
| 989 << printable; | 991 << printable; |
| 990 } | 992 } |
| 991 DCHECK(!data->register_allocator()->ExistsUseWithoutDefinition()); | 993 DCHECK(!data->register_allocator()->ExistsUseWithoutDefinition()); |
| 992 Run<AllocateGeneralRegistersPhase>(); | 994 Run<AllocateGeneralRegistersPhase>(); |
| 993 if (!data->register_allocator()->AllocationOk()) { | 995 if (!data->register_allocator()->AllocationOk()) { |
| 994 data->set_compilation_failed(); | 996 data->set_compilation_failed(); |
| 995 return; | 997 return; |
| 996 } | 998 } |
| 997 Run<AllocateDoubleRegistersPhase>(); | 999 Run<AllocateDoubleRegistersPhase>(); |
| 998 if (!data->register_allocator()->AllocationOk()) { | 1000 if (!data->register_allocator()->AllocationOk()) { |
| 999 data->set_compilation_failed(); | 1001 data->set_compilation_failed(); |
| 1000 return; | 1002 return; |
| 1001 } | 1003 } |
| 1002 if (FLAG_turbo_reuse_spill_slots) { | 1004 if (FLAG_turbo_reuse_spill_slots) { |
| 1003 Run<ReuseSpillSlotsPhase>(); | 1005 Run<ReuseSpillSlotsPhase>(); |
| 1004 } | 1006 } |
| 1005 Run<PopulatePointerMapsPhase>(); | 1007 Run<PopulatePointerMapsPhase>(); |
| 1006 Run<ConnectRangesPhase>(); | 1008 Run<ConnectRangesPhase>(); |
| 1007 Run<ResolveControlFlowPhase>(); | 1009 Run<ResolveControlFlowPhase>(); |
| 1008 Run<OptimizeMovesPhase>(); | 1010 Run<OptimizeMovesPhase>(); |
| 1009 | 1011 |
| 1010 if (FLAG_trace_turbo) { | 1012 if (FLAG_trace_turbo_graph) { |
| 1011 OFStream os(stdout); | 1013 OFStream os(stdout); |
| 1012 PrintableInstructionSequence printable = {config, data->sequence()}; | 1014 PrintableInstructionSequence printable = {config, data->sequence()}; |
| 1013 os << "----- Instruction sequence after register allocation -----\n" | 1015 os << "----- Instruction sequence after register allocation -----\n" |
| 1014 << printable; | 1016 << printable; |
| 1015 } | 1017 } |
| 1016 | 1018 |
| 1017 if (verifier != nullptr) { | 1019 if (verifier != nullptr) { |
| 1018 verifier->VerifyAssignment(); | 1020 verifier->VerifyAssignment(); |
| 1019 verifier->VerifyGapMoves(); | 1021 verifier->VerifyGapMoves(); |
| 1020 } | 1022 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1031 } | 1033 } |
| 1032 | 1034 |
| 1033 | 1035 |
| 1034 void Pipeline::TearDown() { | 1036 void Pipeline::TearDown() { |
| 1035 InstructionOperand::TearDownCaches(); | 1037 InstructionOperand::TearDownCaches(); |
| 1036 } | 1038 } |
| 1037 | 1039 |
| 1038 } // namespace compiler | 1040 } // namespace compiler |
| 1039 } // namespace internal | 1041 } // namespace internal |
| 1040 } // namespace v8 | 1042 } // namespace v8 |
| OLD | NEW |