Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/pipeline.cc

Issue 2240463002: [Interpreter] Introduce InterpreterCompilationJob (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_peekhole
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler-dispatcher/optimizing-compile-dispatcher.cc ('k') | src/compiler/wasm-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 zone_(isolate->allocator()), 566 zone_(isolate->allocator()),
567 zone_pool_(isolate->allocator()), 567 zone_pool_(isolate->allocator()),
568 parse_info_(&zone_, function), 568 parse_info_(&zone_, function),
569 info_(&parse_info_, function), 569 info_(&parse_info_, function),
570 pipeline_statistics_(CreatePipelineStatistics(info(), &zone_pool_)), 570 pipeline_statistics_(CreatePipelineStatistics(info(), &zone_pool_)),
571 data_(&zone_pool_, info(), pipeline_statistics_.get()), 571 data_(&zone_pool_, info(), pipeline_statistics_.get()),
572 pipeline_(&data_), 572 pipeline_(&data_),
573 linkage_(nullptr) {} 573 linkage_(nullptr) {}
574 574
575 protected: 575 protected:
576 Status CreateGraphImpl() final; 576 Status PrepareJobImpl() final;
577 Status OptimizeGraphImpl() final; 577 Status ExecuteJobImpl() final;
578 Status GenerateCodeImpl() final; 578 Status FinalizeJobImpl() final;
579 579
580 private: 580 private:
581 Zone zone_; 581 Zone zone_;
582 ZonePool zone_pool_; 582 ZonePool zone_pool_;
583 ParseInfo parse_info_; 583 ParseInfo parse_info_;
584 CompilationInfo info_; 584 CompilationInfo info_;
585 std::unique_ptr<PipelineStatistics> pipeline_statistics_; 585 std::unique_ptr<PipelineStatistics> pipeline_statistics_;
586 PipelineData data_; 586 PipelineData data_;
587 PipelineImpl pipeline_; 587 PipelineImpl pipeline_;
588 Linkage* linkage_; 588 Linkage* linkage_;
589 589
590 DISALLOW_COPY_AND_ASSIGN(PipelineCompilationJob); 590 DISALLOW_COPY_AND_ASSIGN(PipelineCompilationJob);
591 }; 591 };
592 592
593 PipelineCompilationJob::Status PipelineCompilationJob::CreateGraphImpl() { 593 PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl() {
594 if (info()->shared_info()->asm_function()) { 594 if (info()->shared_info()->asm_function()) {
595 if (info()->osr_frame()) info()->MarkAsFrameSpecializing(); 595 if (info()->osr_frame()) info()->MarkAsFrameSpecializing();
596 info()->MarkAsFunctionContextSpecializing(); 596 info()->MarkAsFunctionContextSpecializing();
597 } else { 597 } else {
598 if (!FLAG_always_opt) { 598 if (!FLAG_always_opt) {
599 info()->MarkAsBailoutOnUninitialized(); 599 info()->MarkAsBailoutOnUninitialized();
600 } 600 }
601 if (FLAG_native_context_specialization) { 601 if (FLAG_native_context_specialization) {
602 info()->MarkAsNativeContextSpecializing(); 602 info()->MarkAsNativeContextSpecializing();
603 } 603 }
(...skipping 22 matching lines...) Expand all
626 linkage_ = new (&zone_) Linkage(Linkage::ComputeIncoming(&zone_, info())); 626 linkage_ = new (&zone_) Linkage(Linkage::ComputeIncoming(&zone_, info()));
627 627
628 if (!pipeline_.CreateGraph()) { 628 if (!pipeline_.CreateGraph()) {
629 if (isolate()->has_pending_exception()) return FAILED; // Stack overflowed. 629 if (isolate()->has_pending_exception()) return FAILED; // Stack overflowed.
630 return AbortOptimization(kGraphBuildingFailed); 630 return AbortOptimization(kGraphBuildingFailed);
631 } 631 }
632 632
633 return SUCCEEDED; 633 return SUCCEEDED;
634 } 634 }
635 635
636 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() { 636 PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl() {
637 if (!pipeline_.OptimizeGraph(linkage_)) return FAILED; 637 if (!pipeline_.OptimizeGraph(linkage_)) return FAILED;
638 return SUCCEEDED; 638 return SUCCEEDED;
639 } 639 }
640 640
641 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() { 641 PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl() {
642 Handle<Code> code = pipeline_.GenerateCode(linkage_); 642 Handle<Code> code = pipeline_.GenerateCode(linkage_);
643 if (code.is_null()) { 643 if (code.is_null()) {
644 if (info()->bailout_reason() == kNoReason) { 644 if (info()->bailout_reason() == kNoReason) {
645 return AbortOptimization(kCodeGenerationFailed); 645 return AbortOptimization(kCodeGenerationFailed);
646 } 646 }
647 return FAILED; 647 return FAILED;
648 } 648 }
649 info()->dependencies()->Commit(code); 649 info()->dependencies()->Commit(code);
650 info()->SetCode(code); 650 info()->SetCode(code);
651 if (info()->is_deoptimization_enabled()) { 651 if (info()->is_deoptimization_enabled()) {
652 info()->context()->native_context()->AddOptimizedCode(*code); 652 info()->context()->native_context()->AddOptimizedCode(*code);
653 RegisterWeakObjectsInOptimizedCode(code); 653 RegisterWeakObjectsInOptimizedCode(code);
654 } 654 }
655 return SUCCEEDED; 655 return SUCCEEDED;
656 } 656 }
657 657
658 class PipelineWasmCompilationJob final : public CompilationJob { 658 class PipelineWasmCompilationJob final : public CompilationJob {
659 public: 659 public:
660 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, 660 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph,
661 CallDescriptor* descriptor, 661 CallDescriptor* descriptor,
662 SourcePositionTable* source_positions) 662 SourcePositionTable* source_positions)
663 : CompilationJob(info, "TurboFan"), 663 : CompilationJob(info, "TurboFan", State::kReadyToExecute),
664 zone_pool_(info->isolate()->allocator()), 664 zone_pool_(info->isolate()->allocator()),
665 data_(&zone_pool_, info, graph, source_positions), 665 data_(&zone_pool_, info, graph, source_positions),
666 pipeline_(&data_), 666 pipeline_(&data_),
667 linkage_(descriptor) {} 667 linkage_(descriptor) {}
668 668
669 protected: 669 protected:
670 Status CreateGraphImpl() final; 670 Status PrepareJobImpl() final;
671 Status OptimizeGraphImpl() final; 671 Status ExecuteJobImpl() final;
672 Status GenerateCodeImpl() final; 672 Status FinalizeJobImpl() final;
673 673
674 private: 674 private:
675 ZonePool zone_pool_; 675 ZonePool zone_pool_;
676 PipelineData data_; 676 PipelineData data_;
677 PipelineImpl pipeline_; 677 PipelineImpl pipeline_;
678 Linkage linkage_; 678 Linkage linkage_;
679 }; 679 };
680 680
681 PipelineWasmCompilationJob::Status 681 PipelineWasmCompilationJob::Status
682 PipelineWasmCompilationJob::CreateGraphImpl() { 682 PipelineWasmCompilationJob::PrepareJobImpl() {
683 UNREACHABLE(); // Prepare should always be skipped for WasmCompilationJob.
683 return SUCCEEDED; 684 return SUCCEEDED;
684 } 685 }
685 686
686 PipelineWasmCompilationJob::Status 687 PipelineWasmCompilationJob::Status
687 PipelineWasmCompilationJob::OptimizeGraphImpl() { 688 PipelineWasmCompilationJob::ExecuteJobImpl() {
688 if (FLAG_trace_turbo) { 689 if (FLAG_trace_turbo) {
689 TurboJsonFile json_of(info(), std::ios_base::trunc); 690 TurboJsonFile json_of(info(), std::ios_base::trunc);
690 json_of << "{\"function\":\"" << info()->GetDebugName().get() 691 json_of << "{\"function\":\"" << info()->GetDebugName().get()
691 << "\", \"source\":\"\",\n\"phases\":["; 692 << "\", \"source\":\"\",\n\"phases\":[";
692 } 693 }
693 694
694 pipeline_.RunPrintAndVerify("Machine", true); 695 pipeline_.RunPrintAndVerify("Machine", true);
695 696
696 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; 697 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED;
697 return SUCCEEDED; 698 return SUCCEEDED;
698 } 699 }
699 700
700 PipelineWasmCompilationJob::Status 701 PipelineWasmCompilationJob::Status
701 PipelineWasmCompilationJob::GenerateCodeImpl() { 702 PipelineWasmCompilationJob::FinalizeJobImpl() {
702 pipeline_.GenerateCode(&linkage_); 703 pipeline_.GenerateCode(&linkage_);
703 return SUCCEEDED; 704 return SUCCEEDED;
704 } 705 }
705 706
706 template <typename Phase> 707 template <typename Phase>
707 void PipelineImpl::Run() { 708 void PipelineImpl::Run() {
708 PipelineRunScope scope(this->data_, Phase::phase_name()); 709 PipelineRunScope scope(this->data_, Phase::phase_name());
709 Phase phase; 710 Phase phase;
710 phase.Run(this->data_, scope.zone()); 711 phase.Run(this->data_, scope.zone());
711 } 712 }
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 data->DeleteRegisterAllocationZone(); 1930 data->DeleteRegisterAllocationZone();
1930 } 1931 }
1931 1932
1932 CompilationInfo* PipelineImpl::info() const { return data_->info(); } 1933 CompilationInfo* PipelineImpl::info() const { return data_->info(); }
1933 1934
1934 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } 1935 Isolate* PipelineImpl::isolate() const { return info()->isolate(); }
1935 1936
1936 } // namespace compiler 1937 } // namespace compiler
1937 } // namespace internal 1938 } // namespace internal
1938 } // namespace v8 1939 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/optimizing-compile-dispatcher.cc ('k') | src/compiler/wasm-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698