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

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

Issue 1976123002: [turbofan] Fix --trace-turbo handle dereferences. (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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 struct TurboCfgFile : public std::ofstream { 397 struct TurboCfgFile : public std::ofstream {
398 explicit TurboCfgFile(Isolate* isolate) 398 explicit TurboCfgFile(Isolate* isolate)
399 : std::ofstream(isolate->GetTurboCfgFileName().c_str(), 399 : std::ofstream(isolate->GetTurboCfgFileName().c_str(),
400 std::ios_base::app) {} 400 std::ios_base::app) {}
401 }; 401 };
402 402
403 403
404 void TraceSchedule(CompilationInfo* info, Schedule* schedule) { 404 void TraceSchedule(CompilationInfo* info, Schedule* schedule) {
405 if (FLAG_trace_turbo) { 405 if (FLAG_trace_turbo) {
406 AllowHandleDereference allow_deref;
406 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+"); 407 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+");
407 if (json_file != nullptr) { 408 if (json_file != nullptr) {
408 OFStream json_of(json_file); 409 OFStream json_of(json_file);
409 json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; 410 json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\"";
410 std::stringstream schedule_stream; 411 std::stringstream schedule_stream;
411 schedule_stream << *schedule; 412 schedule_stream << *schedule;
412 std::string schedule_string(schedule_stream.str()); 413 std::string schedule_string(schedule_stream.str());
413 for (const auto& c : schedule_string) { 414 for (const auto& c : schedule_string) {
414 json_of << AsEscapedUC16ForJSON(c); 415 json_of << AsEscapedUC16ForJSON(c);
415 } 416 }
416 json_of << "\"},\n"; 417 json_of << "\"},\n";
417 fclose(json_file); 418 fclose(json_file);
418 } 419 }
419 } 420 }
420 if (!FLAG_trace_turbo_graph && !FLAG_trace_turbo_scheduler) return; 421 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) {
421 OFStream os(stdout); 422 AllowHandleDereference allow_deref;
422 os << "-- Schedule --------------------------------------\n" << *schedule; 423 OFStream os(stdout);
424 os << "-- Schedule --------------------------------------\n" << *schedule;
425 }
423 } 426 }
424 427
425 428
426 class AstGraphBuilderWithPositions final : public AstGraphBuilder { 429 class AstGraphBuilderWithPositions final : public AstGraphBuilder {
427 public: 430 public:
428 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, 431 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
429 JSGraph* jsgraph, 432 JSGraph* jsgraph,
430 LoopAssignmentAnalysis* loop_assignment, 433 LoopAssignmentAnalysis* loop_assignment,
431 TypeHintAnalysis* type_hint_analysis, 434 TypeHintAnalysis* type_hint_analysis,
432 SourcePositionTable* source_positions) 435 SourcePositionTable* source_positions)
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1301
1299 1302
1300 struct PrintGraphPhase { 1303 struct PrintGraphPhase {
1301 static const char* phase_name() { return nullptr; } 1304 static const char* phase_name() { return nullptr; }
1302 1305
1303 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { 1306 void Run(PipelineData* data, Zone* temp_zone, const char* phase) {
1304 CompilationInfo* info = data->info(); 1307 CompilationInfo* info = data->info();
1305 Graph* graph = data->graph(); 1308 Graph* graph = data->graph();
1306 1309
1307 { // Print JSON. 1310 { // Print JSON.
1311 AllowHandleDereference allow_deref;
1308 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+"); 1312 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+");
1309 if (json_file == nullptr) return; 1313 if (json_file == nullptr) return;
1310 OFStream json_of(json_file); 1314 OFStream json_of(json_file);
1311 json_of << "{\"name\":\"" << phase << "\",\"type\":\"graph\",\"data\":" 1315 json_of << "{\"name\":\"" << phase << "\",\"type\":\"graph\",\"data\":"
1312 << AsJSON(*graph, data->source_positions()) << "},\n"; 1316 << AsJSON(*graph, data->source_positions()) << "},\n";
1313 fclose(json_file); 1317 fclose(json_file);
1314 } 1318 }
1315 1319
1316 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 1320 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
1321 AllowHandleDereference allow_deref;
1317 OFStream os(stdout); 1322 OFStream os(stdout);
1318 os << "-- Graph after " << phase << " -- " << std::endl; 1323 os << "-- Graph after " << phase << " -- " << std::endl;
1319 os << AsRPO(*graph); 1324 os << AsRPO(*graph);
1320 } 1325 }
1321 } 1326 }
1322 }; 1327 };
1323 1328
1324 1329
1325 struct VerifyGraphPhase { 1330 struct VerifyGraphPhase {
1326 static const char* phase_name() { return nullptr; } 1331 static const char* phase_name() { return nullptr; }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 info(), data->graph(), data->schedule())); 1618 info(), data->graph(), data->schedule()));
1614 } 1619 }
1615 1620
1616 data->InitializeInstructionSequence(call_descriptor); 1621 data->InitializeInstructionSequence(call_descriptor);
1617 1622
1618 data->InitializeFrameData(call_descriptor); 1623 data->InitializeFrameData(call_descriptor);
1619 // Select and schedule instructions covering the scheduled graph. 1624 // Select and schedule instructions covering the scheduled graph.
1620 Run<InstructionSelectionPhase>(linkage); 1625 Run<InstructionSelectionPhase>(linkage);
1621 1626
1622 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { 1627 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) {
1628 AllowHandleDereference allow_deref;
1623 TurboCfgFile tcf(isolate()); 1629 TurboCfgFile tcf(isolate());
1624 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), 1630 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(),
1625 data->sequence()); 1631 data->sequence());
1626 } 1632 }
1627 1633
1628 if (FLAG_trace_turbo) { 1634 if (FLAG_trace_turbo) {
1629 std::ostringstream source_position_output; 1635 std::ostringstream source_position_output;
1630 // Output source position information before the graph is deleted. 1636 // Output source position information before the graph is deleted.
1631 data_->source_positions()->Print(source_position_output); 1637 data_->source_positions()->Print(source_position_output);
1632 data_->set_source_position_output(source_position_output.str()); 1638 data_->set_source_position_output(source_position_output.str());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 data->InitializeRegisterAllocationData(config, descriptor); 1750 data->InitializeRegisterAllocationData(config, descriptor);
1745 if (info()->is_osr()) { 1751 if (info()->is_osr()) {
1746 OsrHelper osr_helper(info()); 1752 OsrHelper osr_helper(info());
1747 osr_helper.SetupFrame(data->frame()); 1753 osr_helper.SetupFrame(data->frame());
1748 } 1754 }
1749 1755
1750 Run<MeetRegisterConstraintsPhase>(); 1756 Run<MeetRegisterConstraintsPhase>();
1751 Run<ResolvePhisPhase>(); 1757 Run<ResolvePhisPhase>();
1752 Run<BuildLiveRangesPhase>(); 1758 Run<BuildLiveRangesPhase>();
1753 if (FLAG_trace_turbo_graph) { 1759 if (FLAG_trace_turbo_graph) {
1760 AllowHandleDereference allow_deref;
1754 OFStream os(stdout); 1761 OFStream os(stdout);
1755 PrintableInstructionSequence printable = {config, data->sequence()};
1756 os << "----- Instruction sequence before register allocation -----\n" 1762 os << "----- Instruction sequence before register allocation -----\n"
1757 << printable; 1763 << PrintableInstructionSequence({config, data->sequence()});
1758 } 1764 }
1759 if (verifier != nullptr) { 1765 if (verifier != nullptr) {
1760 CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition()); 1766 CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition());
1761 CHECK(data->register_allocation_data() 1767 CHECK(data->register_allocation_data()
1762 ->RangesDefinedInDeferredStayInDeferred()); 1768 ->RangesDefinedInDeferredStayInDeferred());
1763 } 1769 }
1764 1770
1765 if (FLAG_turbo_preprocess_ranges) { 1771 if (FLAG_turbo_preprocess_ranges) {
1766 Run<SplinterLiveRangesPhase>(); 1772 Run<SplinterLiveRangesPhase>();
1767 } 1773 }
(...skipping 16 matching lines...) Expand all
1784 Run<PopulateReferenceMapsPhase>(); 1790 Run<PopulateReferenceMapsPhase>();
1785 Run<ConnectRangesPhase>(); 1791 Run<ConnectRangesPhase>();
1786 Run<ResolveControlFlowPhase>(); 1792 Run<ResolveControlFlowPhase>();
1787 if (FLAG_turbo_move_optimization) { 1793 if (FLAG_turbo_move_optimization) {
1788 Run<OptimizeMovesPhase>(); 1794 Run<OptimizeMovesPhase>();
1789 } 1795 }
1790 1796
1791 Run<LocateSpillSlotsPhase>(); 1797 Run<LocateSpillSlotsPhase>();
1792 1798
1793 if (FLAG_trace_turbo_graph) { 1799 if (FLAG_trace_turbo_graph) {
1800 AllowHandleDereference allow_deref;
1794 OFStream os(stdout); 1801 OFStream os(stdout);
1795 PrintableInstructionSequence printable = {config, data->sequence()};
1796 os << "----- Instruction sequence after register allocation -----\n" 1802 os << "----- Instruction sequence after register allocation -----\n"
1797 << printable; 1803 << PrintableInstructionSequence({config, data->sequence()});
1798 } 1804 }
1799 1805
1800 if (verifier != nullptr) { 1806 if (verifier != nullptr) {
1801 verifier->VerifyAssignment(); 1807 verifier->VerifyAssignment();
1802 verifier->VerifyGapMoves(); 1808 verifier->VerifyGapMoves();
1803 } 1809 }
1804 1810
1805 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { 1811 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) {
1806 TurboCfgFile tcf(data->isolate()); 1812 TurboCfgFile tcf(data->isolate());
1807 tcf << AsC1VRegisterAllocationData("CodeGen", 1813 tcf << AsC1VRegisterAllocationData("CodeGen",
1808 data->register_allocation_data()); 1814 data->register_allocation_data());
1809 } 1815 }
1810 1816
1811 data->DeleteRegisterAllocationZone(); 1817 data->DeleteRegisterAllocationZone();
1812 } 1818 }
1813 1819
1814 CompilationInfo* PipelineImpl::info() const { return data_->info(); } 1820 CompilationInfo* PipelineImpl::info() const { return data_->info(); }
1815 1821
1816 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } 1822 Isolate* PipelineImpl::isolate() const { return info()->isolate(); }
1817 1823
1818 } // namespace compiler 1824 } // namespace compiler
1819 } // namespace internal 1825 } // namespace internal
1820 } // namespace v8 1826 } // 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