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 "src/base/platform/elapsed-timer.h" | 7 #include "src/base/platform/elapsed-timer.h" |
8 #include "src/compiler/ast-graph-builder.h" | 8 #include "src/compiler/ast-graph-builder.h" |
| 9 #include "src/compiler/basic-block-profiler.h" |
9 #include "src/compiler/change-lowering.h" | 10 #include "src/compiler/change-lowering.h" |
10 #include "src/compiler/code-generator.h" | 11 #include "src/compiler/code-generator.h" |
11 #include "src/compiler/graph-replay.h" | 12 #include "src/compiler/graph-replay.h" |
12 #include "src/compiler/graph-visualizer.h" | 13 #include "src/compiler/graph-visualizer.h" |
13 #include "src/compiler/instruction.h" | 14 #include "src/compiler/instruction.h" |
14 #include "src/compiler/instruction-selector.h" | 15 #include "src/compiler/instruction-selector.h" |
15 #include "src/compiler/js-context-specialization.h" | 16 #include "src/compiler/js-context-specialization.h" |
16 #include "src/compiler/js-generic-lowering.h" | 17 #include "src/compiler/js-generic-lowering.h" |
17 #include "src/compiler/js-inlining.h" | 18 #include "src/compiler/js-inlining.h" |
18 #include "src/compiler/js-typed-lowering.h" | 19 #include "src/compiler/js-typed-lowering.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 SourcePositionTable::Scope pos(&source_positions, | 296 SourcePositionTable::Scope pos(&source_positions, |
296 SourcePosition::Unknown()); | 297 SourcePosition::Unknown()); |
297 JSGenericLowering lowering(info(), &jsgraph); | 298 JSGenericLowering lowering(info(), &jsgraph); |
298 GraphReducer graph_reducer(&graph); | 299 GraphReducer graph_reducer(&graph); |
299 graph_reducer.AddReducer(&lowering); | 300 graph_reducer.AddReducer(&lowering); |
300 graph_reducer.ReduceGraph(); | 301 graph_reducer.ReduceGraph(); |
301 | 302 |
302 VerifyAndPrintGraph(&graph, "Lowered generic"); | 303 VerifyAndPrintGraph(&graph, "Lowered generic"); |
303 } | 304 } |
304 | 305 |
| 306 source_positions.RemoveDecorator(); |
| 307 |
305 { | 308 { |
306 // Compute a schedule. | 309 // Compute a schedule. |
307 Schedule* schedule = ComputeSchedule(&graph); | 310 Schedule* schedule = ComputeSchedule(&graph); |
308 // Generate optimized code. | 311 // Generate optimized code. |
309 PhaseStats codegen_stats(info(), PhaseStats::CODEGEN, "codegen"); | 312 PhaseStats codegen_stats(info(), PhaseStats::CODEGEN, "codegen"); |
310 Linkage linkage(info()); | 313 Linkage linkage(info()); |
311 code = GenerateCode(&linkage, &graph, schedule, &source_positions); | 314 code = GenerateCode(&linkage, &graph, schedule, &source_positions); |
312 info()->SetCode(code); | 315 info()->SetCode(code); |
313 } | 316 } |
314 | 317 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 364 |
362 | 365 |
363 Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, | 366 Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, |
364 Schedule* schedule, | 367 Schedule* schedule, |
365 SourcePositionTable* source_positions) { | 368 SourcePositionTable* source_positions) { |
366 DCHECK_NOT_NULL(graph); | 369 DCHECK_NOT_NULL(graph); |
367 DCHECK_NOT_NULL(linkage); | 370 DCHECK_NOT_NULL(linkage); |
368 DCHECK_NOT_NULL(schedule); | 371 DCHECK_NOT_NULL(schedule); |
369 CHECK(SupportedBackend()); | 372 CHECK(SupportedBackend()); |
370 | 373 |
| 374 BasicBlockProfiler::Data* profiler_data = NULL; |
| 375 if (FLAG_turbo_profiling) { |
| 376 profiler_data = info_->isolate()->GetBasicBlockProfiler()->Profile( |
| 377 info_, graph, schedule); |
| 378 } |
| 379 |
371 InstructionSequence sequence(linkage, graph, schedule); | 380 InstructionSequence sequence(linkage, graph, schedule); |
372 | 381 |
373 // Select and schedule instructions covering the scheduled graph. | 382 // Select and schedule instructions covering the scheduled graph. |
374 { | 383 { |
375 InstructionSelector selector(&sequence, source_positions); | 384 InstructionSelector selector(&sequence, source_positions); |
376 selector.SelectInstructions(); | 385 selector.SelectInstructions(); |
377 } | 386 } |
378 | 387 |
379 if (FLAG_trace_turbo) { | 388 if (FLAG_trace_turbo) { |
380 OFStream os(stdout); | 389 OFStream os(stdout); |
(...skipping 16 matching lines...) Expand all Loading... |
397 } | 406 } |
398 | 407 |
399 if (FLAG_trace_turbo) { | 408 if (FLAG_trace_turbo) { |
400 OFStream os(stdout); | 409 OFStream os(stdout); |
401 os << "----- Instruction sequence after register allocation -----\n" | 410 os << "----- Instruction sequence after register allocation -----\n" |
402 << sequence; | 411 << sequence; |
403 } | 412 } |
404 | 413 |
405 // Generate native sequence. | 414 // Generate native sequence. |
406 CodeGenerator generator(&sequence); | 415 CodeGenerator generator(&sequence); |
407 return generator.GenerateCode(); | 416 Handle<Code> code = generator.GenerateCode(); |
| 417 if (profiler_data != NULL) { |
| 418 profiler_data->SetCode(code); |
| 419 } |
| 420 return code; |
408 } | 421 } |
409 | 422 |
410 | 423 |
411 void Pipeline::SetUp() { | 424 void Pipeline::SetUp() { |
412 InstructionOperand::SetUpCaches(); | 425 InstructionOperand::SetUpCaches(); |
413 } | 426 } |
414 | 427 |
415 | 428 |
416 void Pipeline::TearDown() { | 429 void Pipeline::TearDown() { |
417 InstructionOperand::TearDownCaches(); | 430 InstructionOperand::TearDownCaches(); |
418 } | 431 } |
419 | 432 |
420 } // namespace compiler | 433 } // namespace compiler |
421 } // namespace internal | 434 } // namespace internal |
422 } // namespace v8 | 435 } // namespace v8 |
OLD | NEW |