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 <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
11 #include "src/compiler/ast-graph-builder.h" | 11 #include "src/compiler/ast-graph-builder.h" |
12 #include "src/compiler/basic-block-instrumentor.h" | 12 #include "src/compiler/basic-block-instrumentor.h" |
13 #include "src/compiler/change-lowering.h" | 13 #include "src/compiler/change-lowering.h" |
14 #include "src/compiler/code-generator.h" | 14 #include "src/compiler/code-generator.h" |
15 #include "src/compiler/control-reducer.h" | 15 #include "src/compiler/control-reducer.h" |
16 #include "src/compiler/graph-replay.h" | 16 #include "src/compiler/graph-replay.h" |
17 #include "src/compiler/graph-visualizer.h" | 17 #include "src/compiler/graph-visualizer.h" |
18 #include "src/compiler/instruction.h" | 18 #include "src/compiler/instruction.h" |
19 #include "src/compiler/instruction-selector.h" | 19 #include "src/compiler/instruction-selector.h" |
20 #include "src/compiler/js-context-specialization.h" | 20 #include "src/compiler/js-context-specialization.h" |
21 #include "src/compiler/js-generic-lowering.h" | 21 #include "src/compiler/js-generic-lowering.h" |
22 #include "src/compiler/js-inlining.h" | 22 #include "src/compiler/js-inlining.h" |
23 #include "src/compiler/js-typed-lowering.h" | 23 #include "src/compiler/js-typed-lowering.h" |
24 #include "src/compiler/machine-operator-reducer.h" | 24 #include "src/compiler/machine-operator-reducer.h" |
25 #include "src/compiler/pipeline-statistics.h" | 25 #include "src/compiler/pipeline-statistics.h" |
26 #include "src/compiler/register-allocator.h" | 26 #include "src/compiler/register-allocator.h" |
| 27 #include "src/compiler/register-allocator-verifier.h" |
27 #include "src/compiler/schedule.h" | 28 #include "src/compiler/schedule.h" |
28 #include "src/compiler/scheduler.h" | 29 #include "src/compiler/scheduler.h" |
29 #include "src/compiler/select-lowering.h" | 30 #include "src/compiler/select-lowering.h" |
30 #include "src/compiler/simplified-lowering.h" | 31 #include "src/compiler/simplified-lowering.h" |
31 #include "src/compiler/simplified-operator-reducer.h" | 32 #include "src/compiler/simplified-operator-reducer.h" |
32 #include "src/compiler/typer.h" | 33 #include "src/compiler/typer.h" |
33 #include "src/compiler/value-numbering-reducer.h" | 34 #include "src/compiler/value-numbering-reducer.h" |
34 #include "src/compiler/verifier.h" | 35 #include "src/compiler/verifier.h" |
35 #include "src/compiler/zone-pool.h" | 36 #include "src/compiler/zone-pool.h" |
36 #include "src/ostreams.h" | 37 #include "src/ostreams.h" |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), | 569 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), |
569 &sequence); | 570 &sequence); |
570 } | 571 } |
571 | 572 |
572 data->DeleteGraphZone(); | 573 data->DeleteGraphZone(); |
573 | 574 |
574 if (data->pipeline_statistics() != NULL) { | 575 if (data->pipeline_statistics() != NULL) { |
575 data->pipeline_statistics()->BeginPhaseKind("register allocation"); | 576 data->pipeline_statistics()->BeginPhaseKind("register allocation"); |
576 } | 577 } |
577 | 578 |
| 579 #ifdef DEBUG |
| 580 // Don't track usage for this zone in compiler stats. |
| 581 Zone verifier_zone(info()->isolate()); |
| 582 RegisterAllocatorVerifier verifier( |
| 583 &verifier_zone, RegisterConfiguration::ArchDefault(), &sequence); |
| 584 #endif |
| 585 |
578 // Allocate registers. | 586 // Allocate registers. |
579 Frame frame; | 587 Frame frame; |
580 { | 588 { |
581 int node_count = sequence.VirtualRegisterCount(); | 589 int node_count = sequence.VirtualRegisterCount(); |
582 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { | 590 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { |
583 info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); | 591 info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); |
584 return Handle<Code>::null(); | 592 return Handle<Code>::null(); |
585 } | 593 } |
586 ZonePool::Scope zone_scope(data->zone_pool()); | 594 ZonePool::Scope zone_scope(data->zone_pool()); |
587 | 595 |
588 SmartArrayPointer<char> debug_name; | 596 SmartArrayPointer<char> debug_name; |
589 RegisterAllocator::VerificationType verification_type = | |
590 RegisterAllocator::kNoVerify; | |
591 #ifdef DEBUG | 597 #ifdef DEBUG |
592 debug_name = GetDebugName(info()); | 598 debug_name = GetDebugName(info()); |
593 verification_type = RegisterAllocator::kVerifyAssignment; | |
594 #endif | 599 #endif |
595 | 600 |
596 RegisterAllocator allocator(RegisterConfiguration::ArchDefault(), | 601 RegisterAllocator allocator(RegisterConfiguration::ArchDefault(), |
597 zone_scope.zone(), &frame, &sequence, | 602 zone_scope.zone(), &frame, &sequence, |
598 debug_name.get()); | 603 debug_name.get()); |
599 if (!allocator.Allocate(data->pipeline_statistics(), verification_type)) { | 604 if (!allocator.Allocate(data->pipeline_statistics())) { |
600 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 605 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
601 return Handle<Code>::null(); | 606 return Handle<Code>::null(); |
602 } | 607 } |
603 if (FLAG_trace_turbo) { | 608 if (FLAG_trace_turbo) { |
604 TurboCfgFile tcf(isolate()); | 609 TurboCfgFile tcf(isolate()); |
605 tcf << AsC1VAllocator("CodeGen", &allocator); | 610 tcf << AsC1VAllocator("CodeGen", &allocator); |
606 } | 611 } |
607 } | 612 } |
608 | 613 |
609 if (FLAG_trace_turbo) { | 614 if (FLAG_trace_turbo) { |
610 OFStream os(stdout); | 615 OFStream os(stdout); |
611 PrintableInstructionSequence printable = { | 616 PrintableInstructionSequence printable = { |
612 RegisterConfiguration::ArchDefault(), &sequence}; | 617 RegisterConfiguration::ArchDefault(), &sequence}; |
613 os << "----- Instruction sequence after register allocation -----\n" | 618 os << "----- Instruction sequence after register allocation -----\n" |
614 << printable; | 619 << printable; |
615 } | 620 } |
616 | 621 |
| 622 #ifdef DEBUG |
| 623 verifier.VerifyAssignment(); |
| 624 verifier.VerifyGapMoves(); |
| 625 #endif |
| 626 |
617 if (data->pipeline_statistics() != NULL) { | 627 if (data->pipeline_statistics() != NULL) { |
618 data->pipeline_statistics()->BeginPhaseKind("code generation"); | 628 data->pipeline_statistics()->BeginPhaseKind("code generation"); |
619 } | 629 } |
620 | 630 |
621 // Generate native sequence. | 631 // Generate native sequence. |
622 Handle<Code> code; | 632 Handle<Code> code; |
623 { | 633 { |
624 PhaseScope phase_scope(data->pipeline_statistics(), "generate code"); | 634 PhaseScope phase_scope(data->pipeline_statistics(), "generate code"); |
625 CodeGenerator generator(&frame, linkage, &sequence, info()); | 635 CodeGenerator generator(&frame, linkage, &sequence, info()); |
626 code = generator.GenerateCode(); | 636 code = generator.GenerateCode(); |
(...skipping 14 matching lines...) Expand all Loading... |
641 } | 651 } |
642 | 652 |
643 | 653 |
644 void Pipeline::TearDown() { | 654 void Pipeline::TearDown() { |
645 InstructionOperand::TearDownCaches(); | 655 InstructionOperand::TearDownCaches(); |
646 } | 656 } |
647 | 657 |
648 } // namespace compiler | 658 } // namespace compiler |
649 } // namespace internal | 659 } // namespace internal |
650 } // namespace v8 | 660 } // namespace v8 |
OLD | NEW |