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 <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/base/platform/elapsed-timer.h" | 9 #include "src/base/platform/elapsed-timer.h" |
10 #include "src/compiler/ast-graph-builder.h" | 10 #include "src/compiler/ast-graph-builder.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 DCHECK_NOT_NULL(linkage); | 447 DCHECK_NOT_NULL(linkage); |
448 DCHECK_NOT_NULL(schedule); | 448 DCHECK_NOT_NULL(schedule); |
449 CHECK(SupportedBackend()); | 449 CHECK(SupportedBackend()); |
450 | 450 |
451 BasicBlockProfiler::Data* profiler_data = NULL; | 451 BasicBlockProfiler::Data* profiler_data = NULL; |
452 if (FLAG_turbo_profiling) { | 452 if (FLAG_turbo_profiling) { |
453 profiler_data = BasicBlockInstrumentor::Instrument(info_, graph, schedule); | 453 profiler_data = BasicBlockInstrumentor::Instrument(info_, graph, schedule); |
454 } | 454 } |
455 | 455 |
456 Zone* instruction_zone = schedule->zone(); | 456 Zone* instruction_zone = schedule->zone(); |
457 InstructionSequence sequence(instruction_zone, linkage, graph, schedule); | 457 InstructionSequence sequence(instruction_zone, graph, schedule); |
458 | 458 |
459 // Select and schedule instructions covering the scheduled graph. | 459 // Select and schedule instructions covering the scheduled graph. |
460 { | 460 { |
461 InstructionSelector selector(&sequence, schedule, source_positions); | 461 InstructionSelector selector(linkage, &sequence, schedule, |
| 462 source_positions); |
462 selector.SelectInstructions(); | 463 selector.SelectInstructions(); |
463 } | 464 } |
464 | 465 |
465 if (FLAG_trace_turbo) { | 466 if (FLAG_trace_turbo) { |
466 OFStream os(stdout); | 467 OFStream os(stdout); |
467 os << "----- Instruction sequence before register allocation -----\n" | 468 os << "----- Instruction sequence before register allocation -----\n" |
468 << sequence; | 469 << sequence; |
469 PrintScheduleAndInstructions("CodeGen", schedule, source_positions, | 470 PrintScheduleAndInstructions("CodeGen", schedule, source_positions, |
470 &sequence); | 471 &sequence); |
471 } | 472 } |
472 | 473 |
473 // Allocate registers. | 474 // Allocate registers. |
| 475 Frame frame; |
474 { | 476 { |
475 int node_count = graph->NodeCount(); | 477 int node_count = graph->NodeCount(); |
476 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { | 478 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { |
477 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); | 479 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); |
478 return Handle<Code>::null(); | 480 return Handle<Code>::null(); |
479 } | 481 } |
480 RegisterAllocator allocator(&sequence); | 482 RegisterAllocator allocator(&frame, linkage->info(), &sequence); |
481 if (!allocator.Allocate()) { | 483 if (!allocator.Allocate()) { |
482 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 484 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
483 return Handle<Code>::null(); | 485 return Handle<Code>::null(); |
484 } | 486 } |
485 if (FLAG_trace_turbo) { | 487 if (FLAG_trace_turbo) { |
486 PrintAllocator("CodeGen", &allocator); | 488 PrintAllocator("CodeGen", &allocator); |
487 } | 489 } |
488 } | 490 } |
489 | 491 |
490 if (FLAG_trace_turbo) { | 492 if (FLAG_trace_turbo) { |
491 OFStream os(stdout); | 493 OFStream os(stdout); |
492 os << "----- Instruction sequence after register allocation -----\n" | 494 os << "----- Instruction sequence after register allocation -----\n" |
493 << sequence; | 495 << sequence; |
494 } | 496 } |
495 | 497 |
496 // Generate native sequence. | 498 // Generate native sequence. |
497 CodeGenerator generator(&sequence); | 499 CodeGenerator generator(&frame, linkage, &sequence); |
498 Handle<Code> code = generator.GenerateCode(); | 500 Handle<Code> code = generator.GenerateCode(); |
499 if (profiler_data != NULL) { | 501 if (profiler_data != NULL) { |
500 #if ENABLE_DISASSEMBLER | 502 #if ENABLE_DISASSEMBLER |
501 std::ostringstream os; | 503 std::ostringstream os; |
502 code->Disassemble(NULL, os); | 504 code->Disassemble(NULL, os); |
503 profiler_data->SetCode(&os); | 505 profiler_data->SetCode(&os); |
504 #endif | 506 #endif |
505 } | 507 } |
506 return code; | 508 return code; |
507 } | 509 } |
508 | 510 |
509 | 511 |
510 void Pipeline::SetUp() { | 512 void Pipeline::SetUp() { |
511 InstructionOperand::SetUpCaches(); | 513 InstructionOperand::SetUpCaches(); |
512 } | 514 } |
513 | 515 |
514 | 516 |
515 void Pipeline::TearDown() { | 517 void Pipeline::TearDown() { |
516 InstructionOperand::TearDownCaches(); | 518 InstructionOperand::TearDownCaches(); |
517 } | 519 } |
518 | 520 |
519 } // namespace compiler | 521 } // namespace compiler |
520 } // namespace internal | 522 } // namespace internal |
521 } // namespace v8 | 523 } // namespace v8 |
OLD | NEW |