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

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

Issue 666223003: Simplify TurboFan's c1visualizer file handling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/pipeline.h ('k') | src/isolate.h » ('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 <sstream> 8 #include <sstream>
8 9
9 #include "src/base/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
10 #include "src/compiler/ast-graph-builder.h" 11 #include "src/compiler/ast-graph-builder.h"
11 #include "src/compiler/basic-block-instrumentor.h" 12 #include "src/compiler/basic-block-instrumentor.h"
12 #include "src/compiler/change-lowering.h" 13 #include "src/compiler/change-lowering.h"
13 #include "src/compiler/code-generator.h" 14 #include "src/compiler/code-generator.h"
14 #include "src/compiler/control-reducer.h" 15 #include "src/compiler/control-reducer.h"
15 #include "src/compiler/graph-replay.h" 16 #include "src/compiler/graph-replay.h"
16 #include "src/compiler/graph-visualizer.h" 17 #include "src/compiler/graph-visualizer.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 static inline bool VerifyGraphs() { 92 static inline bool VerifyGraphs() {
92 #ifdef DEBUG 93 #ifdef DEBUG
93 return true; 94 return true;
94 #else 95 #else
95 return FLAG_turbo_verify; 96 return FLAG_turbo_verify;
96 #endif 97 #endif
97 } 98 }
98 99
99 100
100 void Pipeline::PrintCompilationStart() { 101 struct TurboCfgFile : public std::ofstream {
101 std::ofstream turbo_cfg_stream; 102 explicit TurboCfgFile(Isolate* isolate)
102 OpenTurboCfgFile(&turbo_cfg_stream); 103 : std::ofstream(isolate->GetTurboCfgFileName(), std::ios_base::app) {}
103 turbo_cfg_stream << AsC1VCompilation(info()); 104 };
104 }
105
106
107 void Pipeline::OpenTurboCfgFile(std::ofstream* stream) {
108 char buffer[512];
109 Vector<char> filename(buffer, sizeof(buffer));
110 isolate()->GetTurboCfgFileName(filename);
111 stream->open(filename.start(), std::fstream::out | std::fstream::app);
112 }
113 105
114 106
115 void Pipeline::VerifyAndPrintGraph( 107 void Pipeline::VerifyAndPrintGraph(
116 Graph* graph, const char* phase, bool untyped) { 108 Graph* graph, const char* phase, bool untyped) {
117 if (FLAG_trace_turbo) { 109 if (FLAG_trace_turbo) {
118 char buffer[256]; 110 char buffer[256];
119 Vector<char> filename(buffer, sizeof(buffer)); 111 Vector<char> filename(buffer, sizeof(buffer));
120 SmartArrayPointer<char> functionname; 112 SmartArrayPointer<char> functionname;
121 if (!info_->shared_info().is_null()) { 113 if (!info_->shared_info().is_null()) {
122 functionname = info_->shared_info()->DebugName()->ToCString(); 114 functionname = info_->shared_info()->DebugName()->ToCString();
(...skipping 28 matching lines...) Expand all
151 os << "-- " << phase << " graph printed to file " << filename.start() 143 os << "-- " << phase << " graph printed to file " << filename.start()
152 << "\n"; 144 << "\n";
153 } 145 }
154 if (VerifyGraphs()) { 146 if (VerifyGraphs()) {
155 Verifier::Run(graph, 147 Verifier::Run(graph,
156 FLAG_turbo_types && !untyped ? Verifier::TYPED : Verifier::UNTYPED); 148 FLAG_turbo_types && !untyped ? Verifier::TYPED : Verifier::UNTYPED);
157 } 149 }
158 } 150 }
159 151
160 152
161 void Pipeline::PrintScheduleAndInstructions(
162 const char* phase, const Schedule* schedule,
163 const SourcePositionTable* positions,
164 const InstructionSequence* instructions) {
165 std::ofstream turbo_cfg_stream;
166 OpenTurboCfgFile(&turbo_cfg_stream);
167 turbo_cfg_stream << AsC1V(phase, schedule, positions, instructions);
168 }
169
170
171 void Pipeline::PrintAllocator(const char* phase,
172 const RegisterAllocator* allocator) {
173 std::ofstream turbo_cfg_stream;
174 OpenTurboCfgFile(&turbo_cfg_stream);
175 turbo_cfg_stream << AsC1VAllocator(phase, allocator);
176 }
177
178
179 class AstGraphBuilderWithPositions : public AstGraphBuilder { 153 class AstGraphBuilderWithPositions : public AstGraphBuilder {
180 public: 154 public:
181 explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, 155 explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
182 JSGraph* jsgraph, 156 JSGraph* jsgraph,
183 SourcePositionTable* source_positions) 157 SourcePositionTable* source_positions)
184 : AstGraphBuilder(local_zone, info, jsgraph), 158 : AstGraphBuilder(local_zone, info, jsgraph),
185 source_positions_(source_positions) {} 159 source_positions_(source_positions) {}
186 160
187 bool CreateGraph() { 161 bool CreateGraph() {
188 SourcePositionTable::Scope pos(source_positions_, 162 SourcePositionTable::Scope pos(source_positions_,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 201 }
228 202
229 if (FLAG_turbo_stats) isolate()->GetTStatistics()->Initialize(info_); 203 if (FLAG_turbo_stats) isolate()->GetTStatistics()->Initialize(info_);
230 204
231 if (FLAG_trace_turbo) { 205 if (FLAG_trace_turbo) {
232 OFStream os(stdout); 206 OFStream os(stdout);
233 os << "---------------------------------------------------\n" 207 os << "---------------------------------------------------\n"
234 << "Begin compiling method " 208 << "Begin compiling method "
235 << info()->function()->debug_name()->ToCString().get() 209 << info()->function()->debug_name()->ToCString().get()
236 << " using Turbofan" << std::endl; 210 << " using Turbofan" << std::endl;
237 PrintCompilationStart(); 211 TurboCfgFile(isolate()) << AsC1VCompilation(info());
238 } 212 }
239 213
240 ZonePool zone_pool(isolate()); 214 ZonePool zone_pool(isolate());
241 215
242 // Build the graph. 216 // Build the graph.
243 Graph graph(zone()); 217 Graph graph(zone());
244 SourcePositionTable source_positions(&graph); 218 SourcePositionTable source_positions(&graph);
245 source_positions.AddDecorator(); 219 source_positions.AddDecorator();
246 // TODO(turbofan): there is no need to type anything during initial graph 220 // TODO(turbofan): there is no need to type anything during initial graph
247 // construction. This is currently only needed for the node cache, which the 221 // construction. This is currently only needed for the node cache, which the
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 ZonePool::Scope zone_scope(zone_pool); 454 ZonePool::Scope zone_scope(zone_pool);
481 InstructionSelector selector(zone_scope.zone(), linkage, &sequence, 455 InstructionSelector selector(zone_scope.zone(), linkage, &sequence,
482 schedule, source_positions); 456 schedule, source_positions);
483 selector.SelectInstructions(); 457 selector.SelectInstructions();
484 } 458 }
485 459
486 if (FLAG_trace_turbo) { 460 if (FLAG_trace_turbo) {
487 OFStream os(stdout); 461 OFStream os(stdout);
488 os << "----- Instruction sequence before register allocation -----\n" 462 os << "----- Instruction sequence before register allocation -----\n"
489 << sequence; 463 << sequence;
490 PrintScheduleAndInstructions("CodeGen", schedule, source_positions, 464 TurboCfgFile(isolate())
491 &sequence); 465 << AsC1V("CodeGen", schedule, source_positions, &sequence);
492 } 466 }
493 467
494 // Allocate registers. 468 // Allocate registers.
495 Frame frame; 469 Frame frame;
496 { 470 {
497 int node_count = graph->NodeCount(); 471 int node_count = graph->NodeCount();
498 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { 472 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) {
499 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); 473 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues);
500 return Handle<Code>::null(); 474 return Handle<Code>::null();
501 } 475 }
502 ZonePool::Scope zone_scope(zone_pool); 476 ZonePool::Scope zone_scope(zone_pool);
503 RegisterAllocator allocator(zone_scope.zone(), &frame, linkage->info(), 477 RegisterAllocator allocator(zone_scope.zone(), &frame, linkage->info(),
504 &sequence); 478 &sequence);
505 if (!allocator.Allocate(zone_pool)) { 479 if (!allocator.Allocate(zone_pool)) {
506 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); 480 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
507 return Handle<Code>::null(); 481 return Handle<Code>::null();
508 } 482 }
509 if (FLAG_trace_turbo) { 483 if (FLAG_trace_turbo) {
510 PrintAllocator("CodeGen", &allocator); 484 TurboCfgFile(isolate()) << AsC1VAllocator("CodeGen", &allocator);
511 } 485 }
512 } 486 }
513 487
514 if (FLAG_trace_turbo) { 488 if (FLAG_trace_turbo) {
515 OFStream os(stdout); 489 OFStream os(stdout);
516 os << "----- Instruction sequence after register allocation -----\n" 490 os << "----- Instruction sequence after register allocation -----\n"
517 << sequence; 491 << sequence;
518 } 492 }
519 493
520 // Generate native sequence. 494 // Generate native sequence.
(...skipping 15 matching lines...) Expand all
536 } 510 }
537 511
538 512
539 void Pipeline::TearDown() { 513 void Pipeline::TearDown() {
540 InstructionOperand::TearDownCaches(); 514 InstructionOperand::TearDownCaches();
541 } 515 }
542 516
543 } // namespace compiler 517 } // namespace compiler
544 } // namespace internal 518 } // namespace internal
545 } // namespace v8 519 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/pipeline.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698