| 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-instrumentor.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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 SourcePositionTable::Scope pos(&source_positions, | 309 SourcePositionTable::Scope pos(&source_positions, |
| 309 SourcePosition::Unknown()); | 310 SourcePosition::Unknown()); |
| 310 JSGenericLowering lowering(info(), &jsgraph); | 311 JSGenericLowering lowering(info(), &jsgraph); |
| 311 GraphReducer graph_reducer(&graph); | 312 GraphReducer graph_reducer(&graph); |
| 312 graph_reducer.AddReducer(&lowering); | 313 graph_reducer.AddReducer(&lowering); |
| 313 graph_reducer.ReduceGraph(); | 314 graph_reducer.ReduceGraph(); |
| 314 | 315 |
| 315 VerifyAndPrintGraph(&graph, "Lowered generic"); | 316 VerifyAndPrintGraph(&graph, "Lowered generic"); |
| 316 } | 317 } |
| 317 | 318 |
| 319 source_positions.RemoveDecorator(); |
| 320 |
| 318 Handle<Code> code = Handle<Code>::null(); | 321 Handle<Code> code = Handle<Code>::null(); |
| 319 { | 322 { |
| 320 // Compute a schedule. | 323 // Compute a schedule. |
| 321 Schedule* schedule = ComputeSchedule(&graph); | 324 Schedule* schedule = ComputeSchedule(&graph); |
| 322 // Generate optimized code. | 325 // Generate optimized code. |
| 323 PhaseStats codegen_stats(info(), PhaseStats::CODEGEN, "codegen"); | 326 PhaseStats codegen_stats(info(), PhaseStats::CODEGEN, "codegen"); |
| 324 Linkage linkage(info()); | 327 Linkage linkage(info()); |
| 325 code = GenerateCode(&linkage, &graph, schedule, &source_positions); | 328 code = GenerateCode(&linkage, &graph, schedule, &source_positions); |
| 326 info()->SetCode(code); | 329 info()->SetCode(code); |
| 327 } | 330 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 377 |
| 375 | 378 |
| 376 Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, | 379 Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, |
| 377 Schedule* schedule, | 380 Schedule* schedule, |
| 378 SourcePositionTable* source_positions) { | 381 SourcePositionTable* source_positions) { |
| 379 DCHECK_NOT_NULL(graph); | 382 DCHECK_NOT_NULL(graph); |
| 380 DCHECK_NOT_NULL(linkage); | 383 DCHECK_NOT_NULL(linkage); |
| 381 DCHECK_NOT_NULL(schedule); | 384 DCHECK_NOT_NULL(schedule); |
| 382 CHECK(SupportedBackend()); | 385 CHECK(SupportedBackend()); |
| 383 | 386 |
| 387 BasicBlockProfiler::Data* profiler_data = NULL; |
| 388 if (FLAG_turbo_profiling) { |
| 389 profiler_data = BasicBlockInstrumentor::Instrument(info_, graph, schedule); |
| 390 } |
| 391 |
| 384 InstructionSequence sequence(linkage, graph, schedule); | 392 InstructionSequence sequence(linkage, graph, schedule); |
| 385 | 393 |
| 386 // Select and schedule instructions covering the scheduled graph. | 394 // Select and schedule instructions covering the scheduled graph. |
| 387 { | 395 { |
| 388 InstructionSelector selector(&sequence, source_positions); | 396 InstructionSelector selector(&sequence, source_positions); |
| 389 selector.SelectInstructions(); | 397 selector.SelectInstructions(); |
| 390 } | 398 } |
| 391 | 399 |
| 392 if (FLAG_trace_turbo) { | 400 if (FLAG_trace_turbo) { |
| 393 OFStream os(stdout); | 401 OFStream os(stdout); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 410 } | 418 } |
| 411 | 419 |
| 412 if (FLAG_trace_turbo) { | 420 if (FLAG_trace_turbo) { |
| 413 OFStream os(stdout); | 421 OFStream os(stdout); |
| 414 os << "----- Instruction sequence after register allocation -----\n" | 422 os << "----- Instruction sequence after register allocation -----\n" |
| 415 << sequence; | 423 << sequence; |
| 416 } | 424 } |
| 417 | 425 |
| 418 // Generate native sequence. | 426 // Generate native sequence. |
| 419 CodeGenerator generator(&sequence); | 427 CodeGenerator generator(&sequence); |
| 420 return generator.GenerateCode(); | 428 Handle<Code> code = generator.GenerateCode(); |
| 429 if (profiler_data != NULL) { |
| 430 #if ENABLE_DISASSEMBLER |
| 431 OStringStream os; |
| 432 code->Disassemble(NULL, os); |
| 433 profiler_data->SetCode(&os); |
| 434 #endif |
| 435 } |
| 436 return code; |
| 421 } | 437 } |
| 422 | 438 |
| 423 | 439 |
| 424 void Pipeline::SetUp() { | 440 void Pipeline::SetUp() { |
| 425 InstructionOperand::SetUpCaches(); | 441 InstructionOperand::SetUpCaches(); |
| 426 } | 442 } |
| 427 | 443 |
| 428 | 444 |
| 429 void Pipeline::TearDown() { | 445 void Pipeline::TearDown() { |
| 430 InstructionOperand::TearDownCaches(); | 446 InstructionOperand::TearDownCaches(); |
| 431 } | 447 } |
| 432 | 448 |
| 433 } // namespace compiler | 449 } // namespace compiler |
| 434 } // namespace internal | 450 } // namespace internal |
| 435 } // namespace v8 | 451 } // namespace v8 |
| OLD | NEW |