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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), | 568 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), |
568 &sequence); | 569 &sequence); |
569 } | 570 } |
570 | 571 |
571 data->DeleteGraphZone(); | 572 data->DeleteGraphZone(); |
572 | 573 |
573 if (data->pipeline_statistics() != NULL) { | 574 if (data->pipeline_statistics() != NULL) { |
574 data->pipeline_statistics()->BeginPhaseKind("register allocation"); | 575 data->pipeline_statistics()->BeginPhaseKind("register allocation"); |
575 } | 576 } |
576 | 577 |
578 SmartPointer<Zone> verifier_zone; | |
579 RegisterAllocatorVerifier* verifier = NULL; | |
Jarin
2014/11/12 08:13:35
I think it would be better if we could avoid the p
dcarney
2014/11/12 08:53:31
Done.
| |
577 // Allocate registers. | 580 // Allocate registers. |
578 Frame frame; | 581 Frame frame; |
579 { | 582 { |
580 int node_count = sequence.VirtualRegisterCount(); | 583 int node_count = sequence.VirtualRegisterCount(); |
581 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { | 584 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { |
582 info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); | 585 info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); |
583 return Handle<Code>::null(); | 586 return Handle<Code>::null(); |
584 } | 587 } |
585 ZonePool::Scope zone_scope(data->zone_pool()); | 588 ZonePool::Scope zone_scope(data->zone_pool()); |
586 | 589 |
587 SmartArrayPointer<char> debug_name; | 590 SmartArrayPointer<char> debug_name; |
588 RegisterAllocator::VerificationType verification_type = | |
589 RegisterAllocator::kNoVerify; | |
590 #ifdef DEBUG | 591 #ifdef DEBUG |
591 debug_name = GetDebugName(info()); | 592 debug_name = GetDebugName(info()); |
592 verification_type = RegisterAllocator::kVerifyAssignment; | 593 // Don't track usage for this zone in compiler stats. |
594 verifier_zone.Reset(new Zone(info()->isolate())); | |
595 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( | |
596 verifier_zone.get(), RegisterConfiguration::ArchDefault(), &sequence); | |
593 #endif | 597 #endif |
594 | 598 |
595 RegisterAllocator allocator(RegisterConfiguration::ArchDefault(), | 599 RegisterAllocator allocator(RegisterConfiguration::ArchDefault(), |
596 zone_scope.zone(), &frame, &sequence, | 600 zone_scope.zone(), &frame, &sequence, |
597 debug_name.get()); | 601 debug_name.get()); |
598 if (!allocator.Allocate(data->pipeline_statistics(), verification_type)) { | 602 if (!allocator.Allocate(data->pipeline_statistics())) { |
599 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 603 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
600 return Handle<Code>::null(); | 604 return Handle<Code>::null(); |
601 } | 605 } |
602 if (FLAG_trace_turbo) { | 606 if (FLAG_trace_turbo) { |
603 TurboCfgFile tcf(isolate()); | 607 TurboCfgFile tcf(isolate()); |
604 tcf << AsC1VAllocator("CodeGen", &allocator); | 608 tcf << AsC1VAllocator("CodeGen", &allocator); |
605 } | 609 } |
606 } | 610 } |
607 | 611 |
608 if (FLAG_trace_turbo) { | 612 if (FLAG_trace_turbo) { |
609 OFStream os(stdout); | 613 OFStream os(stdout); |
610 PrintableInstructionSequence printable = { | 614 PrintableInstructionSequence printable = { |
611 RegisterConfiguration::ArchDefault(), &sequence}; | 615 RegisterConfiguration::ArchDefault(), &sequence}; |
612 os << "----- Instruction sequence after register allocation -----\n" | 616 os << "----- Instruction sequence after register allocation -----\n" |
613 << printable; | 617 << printable; |
614 } | 618 } |
615 | 619 |
620 if (verifier != NULL) { | |
621 verifier->VerifyAssignment(); | |
622 verifier->VerifyGapMoves(); | |
623 verifier_zone.Reset(nullptr); | |
624 } | |
625 | |
616 if (data->pipeline_statistics() != NULL) { | 626 if (data->pipeline_statistics() != NULL) { |
617 data->pipeline_statistics()->BeginPhaseKind("code generation"); | 627 data->pipeline_statistics()->BeginPhaseKind("code generation"); |
618 } | 628 } |
619 | 629 |
620 // Generate native sequence. | 630 // Generate native sequence. |
621 Handle<Code> code; | 631 Handle<Code> code; |
622 { | 632 { |
623 PhaseScope phase_scope(data->pipeline_statistics(), "generate code"); | 633 PhaseScope phase_scope(data->pipeline_statistics(), "generate code"); |
624 CodeGenerator generator(&frame, linkage, &sequence, info()); | 634 CodeGenerator generator(&frame, linkage, &sequence, info()); |
625 code = generator.GenerateCode(); | 635 code = generator.GenerateCode(); |
(...skipping 14 matching lines...) Expand all Loading... | |
640 } | 650 } |
641 | 651 |
642 | 652 |
643 void Pipeline::TearDown() { | 653 void Pipeline::TearDown() { |
644 InstructionOperand::TearDownCaches(); | 654 InstructionOperand::TearDownCaches(); |
645 } | 655 } |
646 | 656 |
647 } // namespace compiler | 657 } // namespace compiler |
648 } // namespace internal | 658 } // namespace internal |
649 } // namespace v8 | 659 } // namespace v8 |
OLD | NEW |