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

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

Issue 2428443002: [wasm] Trim graph before scheduling. (Closed)
Patch Set: Created 4 years, 2 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 | test/cctest/wasm/test-run-wasm.cc » ('j') | 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 <memory> 8 #include <memory>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 // Run the graph creation and initial optimization passes. 383 // Run the graph creation and initial optimization passes.
384 bool CreateGraph(); 384 bool CreateGraph();
385 385
386 // Run the concurrent optimization passes. 386 // Run the concurrent optimization passes.
387 bool OptimizeGraph(Linkage* linkage); 387 bool OptimizeGraph(Linkage* linkage);
388 388
389 // Perform the actual code generation and return handle to a code object. 389 // Perform the actual code generation and return handle to a code object.
390 Handle<Code> GenerateCode(Linkage* linkage); 390 Handle<Code> GenerateCode(Linkage* linkage);
391 391
392 bool ScheduleAndSelectInstructions(Linkage* linkage); 392 bool ScheduleAndSelectInstructions(Linkage* linkage, bool trim_graph);
393 void RunPrintAndVerify(const char* phase, bool untyped = false); 393 void RunPrintAndVerify(const char* phase, bool untyped = false);
394 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); 394 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor);
395 void AllocateRegisters(const RegisterConfiguration* config, 395 void AllocateRegisters(const RegisterConfiguration* config,
396 CallDescriptor* descriptor, bool run_verifier); 396 CallDescriptor* descriptor, bool run_verifier);
397 397
398 CompilationInfo* info() const; 398 CompilationInfo* info() const;
399 Isolate* isolate() const; 399 Isolate* isolate() const;
400 400
401 PipelineData* const data_; 401 PipelineData* const data_;
402 }; 402 };
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 PipelineWasmCompilationJob::Status 685 PipelineWasmCompilationJob::Status
686 PipelineWasmCompilationJob::ExecuteJobImpl() { 686 PipelineWasmCompilationJob::ExecuteJobImpl() {
687 if (FLAG_trace_turbo) { 687 if (FLAG_trace_turbo) {
688 TurboJsonFile json_of(info(), std::ios_base::trunc); 688 TurboJsonFile json_of(info(), std::ios_base::trunc);
689 json_of << "{\"function\":\"" << info()->GetDebugName().get() 689 json_of << "{\"function\":\"" << info()->GetDebugName().get()
690 << "\", \"source\":\"\",\n\"phases\":["; 690 << "\", \"source\":\"\",\n\"phases\":[";
691 } 691 }
692 692
693 pipeline_.RunPrintAndVerify("Machine", true); 693 pipeline_.RunPrintAndVerify("Machine", true);
694 694
695 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; 695 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_, true)) return FAILED;
696 return SUCCEEDED; 696 return SUCCEEDED;
697 } 697 }
698 698
699 PipelineWasmCompilationJob::Status 699 PipelineWasmCompilationJob::Status
700 PipelineWasmCompilationJob::FinalizeJobImpl() { 700 PipelineWasmCompilationJob::FinalizeJobImpl() {
701 pipeline_.GenerateCode(&linkage_); 701 pipeline_.GenerateCode(&linkage_);
702 return SUCCEEDED; 702 return SUCCEEDED;
703 } 703 }
704 704
705 template <typename Phase> 705 template <typename Phase>
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 trimmer.TrimGraph(roots.begin(), roots.end()); 1199 trimmer.TrimGraph(roots.begin(), roots.end());
1200 } 1200 }
1201 }; 1201 };
1202 1202
1203 1203
1204 struct LateGraphTrimmingPhase { 1204 struct LateGraphTrimmingPhase {
1205 static const char* phase_name() { return "late graph trimming"; } 1205 static const char* phase_name() { return "late graph trimming"; }
1206 void Run(PipelineData* data, Zone* temp_zone) { 1206 void Run(PipelineData* data, Zone* temp_zone) {
1207 GraphTrimmer trimmer(temp_zone, data->graph()); 1207 GraphTrimmer trimmer(temp_zone, data->graph());
1208 NodeVector roots(temp_zone); 1208 NodeVector roots(temp_zone);
1209 data->jsgraph()->GetCachedNodes(&roots); 1209 if (data->jsgraph()) {
1210 data->jsgraph()->GetCachedNodes(&roots);
1211 }
1210 trimmer.TrimGraph(roots.begin(), roots.end()); 1212 trimmer.TrimGraph(roots.begin(), roots.end());
1211 } 1213 }
1212 }; 1214 };
1213 1215
1214 1216
1215 struct StressLoopPeelingPhase { 1217 struct StressLoopPeelingPhase {
1216 static const char* phase_name() { return "stress loop peeling"; } 1218 static const char* phase_name() { return "stress loop peeling"; }
1217 1219
1218 void Run(PipelineData* data, Zone* temp_zone) { 1220 void Run(PipelineData* data, Zone* temp_zone) {
1219 // Peel the first outer loop for testing. 1221 // Peel the first outer loop for testing.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 // Optimize memory access and allocation operations. 1643 // Optimize memory access and allocation operations.
1642 Run<MemoryOptimizationPhase>(); 1644 Run<MemoryOptimizationPhase>();
1643 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 1645 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
1644 RunPrintAndVerify("Memory optimized", true); 1646 RunPrintAndVerify("Memory optimized", true);
1645 1647
1646 // Lower changes that have been inserted before. 1648 // Lower changes that have been inserted before.
1647 Run<LateOptimizationPhase>(); 1649 Run<LateOptimizationPhase>();
1648 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 1650 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
1649 RunPrintAndVerify("Late optimized", true); 1651 RunPrintAndVerify("Late optimized", true);
1650 1652
1651 Run<LateGraphTrimmingPhase>(); 1653 // Run<LateGraphTrimmingPhase>();
Benedikt Meurer 2016/10/17 07:18:46 Nit: Remove this dead code then.
ahaas 2016/10/17 07:23:57 Done
Benedikt Meurer 2016/10/17 08:38:14 Thx!
1652 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 1654 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
1653 RunPrintAndVerify("Late trimmed", true); 1655 // RunPrintAndVerify("Late trimmed", true);
1654 1656
1655 data->source_positions()->RemoveDecorator(); 1657 data->source_positions()->RemoveDecorator();
1656 1658
1657 return ScheduleAndSelectInstructions(linkage); 1659 return ScheduleAndSelectInstructions(linkage, true);
1658 } 1660 }
1659 1661
1660 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, 1662 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
1661 CallDescriptor* call_descriptor, 1663 CallDescriptor* call_descriptor,
1662 Graph* graph, Schedule* schedule, 1664 Graph* graph, Schedule* schedule,
1663 Code::Flags flags, 1665 Code::Flags flags,
1664 const char* debug_name) { 1666 const char* debug_name) {
1665 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); 1667 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags);
1666 if (isolate->serializer_enabled()) info.PrepareForSerializing(); 1668 if (isolate->serializer_enabled()) info.PrepareForSerializing();
1667 1669
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), 1762 CompilationInfo info(ArrayVector("testing"), sequence->isolate(),
1761 sequence->zone(), Code::ComputeFlags(Code::STUB)); 1763 sequence->zone(), Code::ComputeFlags(Code::STUB));
1762 ZoneStats zone_stats(sequence->isolate()->allocator()); 1764 ZoneStats zone_stats(sequence->isolate()->allocator());
1763 PipelineData data(&zone_stats, &info, sequence); 1765 PipelineData data(&zone_stats, &info, sequence);
1764 PipelineImpl pipeline(&data); 1766 PipelineImpl pipeline(&data);
1765 pipeline.data_->InitializeFrameData(nullptr); 1767 pipeline.data_->InitializeFrameData(nullptr);
1766 pipeline.AllocateRegisters(config, nullptr, run_verifier); 1768 pipeline.AllocateRegisters(config, nullptr, run_verifier);
1767 return !data.compilation_failed(); 1769 return !data.compilation_failed();
1768 } 1770 }
1769 1771
1770 bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage) { 1772 bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage,
1773 bool trim_graph) {
1771 CallDescriptor* call_descriptor = linkage->GetIncomingDescriptor(); 1774 CallDescriptor* call_descriptor = linkage->GetIncomingDescriptor();
1772 PipelineData* data = this->data_; 1775 PipelineData* data = this->data_;
1773 1776
1774 DCHECK_NOT_NULL(data->graph()); 1777 DCHECK_NOT_NULL(data->graph());
1775 1778
1779 if (trim_graph) {
1780 Run<LateGraphTrimmingPhase>();
1781 RunPrintAndVerify("Late trimmed", true);
1782 }
1776 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); 1783 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>();
1777 TraceSchedule(data->info(), data->schedule()); 1784 TraceSchedule(data->info(), data->schedule());
1778 1785
1779 if (FLAG_turbo_profiling) { 1786 if (FLAG_turbo_profiling) {
1780 data->set_profiler_data(BasicBlockInstrumentor::Instrument( 1787 data->set_profiler_data(BasicBlockInstrumentor::Instrument(
1781 info(), data->graph(), data->schedule())); 1788 info(), data->graph(), data->schedule()));
1782 } 1789 }
1783 1790
1784 if (FLAG_turbo_verify_machine_graph != nullptr && 1791 if (FLAG_turbo_verify_machine_graph != nullptr &&
1785 (!strcmp(FLAG_turbo_verify_machine_graph, "*") || 1792 (!strcmp(FLAG_turbo_verify_machine_graph, "*") ||
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 } 1895 }
1889 1896
1890 return code; 1897 return code;
1891 } 1898 }
1892 1899
1893 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( 1900 Handle<Code> PipelineImpl::ScheduleAndGenerateCode(
1894 CallDescriptor* call_descriptor) { 1901 CallDescriptor* call_descriptor) {
1895 Linkage linkage(call_descriptor); 1902 Linkage linkage(call_descriptor);
1896 1903
1897 // Schedule the graph, perform instruction selection and register allocation. 1904 // Schedule the graph, perform instruction selection and register allocation.
1898 if (!ScheduleAndSelectInstructions(&linkage)) return Handle<Code>(); 1905 if (!ScheduleAndSelectInstructions(&linkage, false)) return Handle<Code>();
1899 1906
1900 // Generate the final machine code. 1907 // Generate the final machine code.
1901 return GenerateCode(&linkage); 1908 return GenerateCode(&linkage);
1902 } 1909 }
1903 1910
1904 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, 1911 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
1905 CallDescriptor* descriptor, 1912 CallDescriptor* descriptor,
1906 bool run_verifier) { 1913 bool run_verifier) {
1907 PipelineData* data = this->data_; 1914 PipelineData* data = this->data_;
1908 // Don't track usage for this zone in compiler stats. 1915 // Don't track usage for this zone in compiler stats.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 data->DeleteRegisterAllocationZone(); 1995 data->DeleteRegisterAllocationZone();
1989 } 1996 }
1990 1997
1991 CompilationInfo* PipelineImpl::info() const { return data_->info(); } 1998 CompilationInfo* PipelineImpl::info() const { return data_->info(); }
1992 1999
1993 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } 2000 Isolate* PipelineImpl::isolate() const { return info()->isolate(); }
1994 2001
1995 } // namespace compiler 2002 } // namespace compiler
1996 } // namespace internal 2003 } // namespace internal
1997 } // namespace v8 2004 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698