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

Side by Side Diff: src/compiler.h

Issue 1872483002: [compiler] Make OptimizedCompileJob agnostic from backend. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Prevent endless recompile. Created 4 years, 8 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/bailout-reason.h ('k') | src/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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_COMPILER_H_ 5 #ifndef V8_COMPILER_H_
6 #define V8_COMPILER_H_ 6 #define V8_COMPILER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 int osr_expr_stack_height_; 561 int osr_expr_stack_height_;
562 562
563 // The current OSR frame for specialization or {nullptr}. 563 // The current OSR frame for specialization or {nullptr}.
564 JavaScriptFrame* osr_frame_ = nullptr; 564 JavaScriptFrame* osr_frame_ = nullptr;
565 565
566 const char* debug_name_; 566 const char* debug_name_;
567 567
568 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 568 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
569 }; 569 };
570 570
571 571 // A base class for compilation jobs intended to run concurrent to the main
572 class HGraph; 572 // thread. The job is split into three phases which are called in sequence on
573 class LChunk; 573 // different threads and with different limitations:
574 574 // 1) CreateGraph: Runs on main thread. No major limitations.
575 // A helper class that calls the three compilation phases in 575 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs.
576 // Crankshaft and keeps track of its state. The three phases 576 // 3) GenerateCode: Runs on main thread. No dependency changes.
577 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either 577 //
578 // fail, bail-out to the full code generator or succeed. Apart from 578 // Each of the three phases can either fail, bail-out to full code generator or
579 // their return value, the status of the phase last run can be checked 579 // succeed. Apart from their return value, the status of the phase last run can
580 // using last_status(). 580 // be checked using {last_status()} as well.
581 class OptimizedCompileJob: public ZoneObject { 581 class OptimizedCompileJob: public ZoneObject {
582 public: 582 public:
583 explicit OptimizedCompileJob(CompilationInfo* info) 583 explicit OptimizedCompileJob(CompilationInfo* info)
584 : info_(info), graph_(NULL), chunk_(NULL), last_status_(FAILED) {} 584 : info_(info), last_status_(SUCCEEDED) {}
585 virtual ~OptimizedCompileJob() {}
585 586
586 enum Status { 587 enum Status {
587 FAILED, BAILED_OUT, SUCCEEDED 588 FAILED, BAILED_OUT, SUCCEEDED
588 }; 589 };
589 590
590 MUST_USE_RESULT Status CreateGraph(); 591 MUST_USE_RESULT Status CreateGraph();
591 MUST_USE_RESULT Status OptimizeGraph(); 592 MUST_USE_RESULT Status OptimizeGraph();
592 MUST_USE_RESULT Status GenerateCode(); 593 MUST_USE_RESULT Status GenerateCode();
593 594
594 Status last_status() const { return last_status_; } 595 Status last_status() const { return last_status_; }
595 CompilationInfo* info() const { return info_; } 596 CompilationInfo* info() const { return info_; }
596 Isolate* isolate() const { return info()->isolate(); } 597 Isolate* isolate() const { return info()->isolate(); }
597 598
598 Status RetryOptimization(BailoutReason reason) { 599 Status RetryOptimization(BailoutReason reason) {
599 info_->RetryOptimization(reason); 600 info_->RetryOptimization(reason);
600 return SetLastStatus(BAILED_OUT); 601 return SetLastStatus(BAILED_OUT);
601 } 602 }
602 603
603 Status AbortOptimization(BailoutReason reason) { 604 Status AbortOptimization(BailoutReason reason) {
604 info_->AbortOptimization(reason); 605 info_->AbortOptimization(reason);
605 return SetLastStatus(BAILED_OUT); 606 return SetLastStatus(BAILED_OUT);
606 } 607 }
607 608
609 void RecordOptimizationStats();
610
611 protected:
612 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
613
614 // Overridden by the actual implementation.
615 virtual Status CreateGraphImpl() = 0;
616 virtual Status OptimizeGraphImpl() = 0;
617 virtual Status GenerateCodeImpl() = 0;
618
608 private: 619 private:
609 CompilationInfo* info_; 620 CompilationInfo* info_;
610 HGraph* graph_;
611 LChunk* chunk_;
612 base::TimeDelta time_taken_to_create_graph_; 621 base::TimeDelta time_taken_to_create_graph_;
613 base::TimeDelta time_taken_to_optimize_; 622 base::TimeDelta time_taken_to_optimize_;
614 base::TimeDelta time_taken_to_codegen_; 623 base::TimeDelta time_taken_to_codegen_;
615 Status last_status_; 624 Status last_status_;
616 625
617 MUST_USE_RESULT Status SetLastStatus(Status status) { 626 MUST_USE_RESULT Status SetLastStatus(Status status) {
618 last_status_ = status; 627 last_status_ = status;
619 return last_status_; 628 return last_status_;
620 } 629 }
621 void RecordOptimizationStats();
622
623 struct Timer {
624 Timer(OptimizedCompileJob* job, base::TimeDelta* location)
625 : job_(job), location_(location) {
626 DCHECK(location_ != NULL);
627 timer_.Start();
628 }
629
630 ~Timer() {
631 *location_ += timer_.Elapsed();
632 }
633
634 OptimizedCompileJob* job_;
635 base::ElapsedTimer timer_;
636 base::TimeDelta* location_;
637 };
638 }; 630 };
639 631
640 } // namespace internal 632 } // namespace internal
641 } // namespace v8 633 } // namespace v8
642 634
643 #endif // V8_COMPILER_H_ 635 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/bailout-reason.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698