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

Side by Side Diff: src/compiler.h

Issue 2260583002: Revert of [Interpreter] Introduce InterpreterCompilationJob (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_peekhole
Patch Set: 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 | « no previous file | 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 <memory> 8 #include <memory>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 JavaScriptFrame* osr_frame_ = nullptr; 533 JavaScriptFrame* osr_frame_ = nullptr;
534 534
535 Vector<const char> debug_name_; 535 Vector<const char> debug_name_;
536 536
537 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 537 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
538 }; 538 };
539 539
540 // A base class for compilation jobs intended to run concurrent to the main 540 // A base class for compilation jobs intended to run concurrent to the main
541 // thread. The job is split into three phases which are called in sequence on 541 // thread. The job is split into three phases which are called in sequence on
542 // different threads and with different limitations: 542 // different threads and with different limitations:
543 // 1) PrepareJob: Runs on main thread. No major limitations. 543 // 1) CreateGraph: Runs on main thread. No major limitations.
544 // 2) ExecuteJob: Runs concurrently. No heap allocation or handle derefs. 544 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs.
545 // 3) FinalizeJob: Runs on main thread. No dependency changes. 545 // 3) GenerateCode: Runs on main thread. No dependency changes.
546 // 546 //
547 // Each of the three phases can either fail or succeed. The current state of 547 // Each of the three phases can either fail or succeed. Apart from their return
548 // the job can be checked using {state()}. 548 // value, the status of the phase last run can be checked using {last_status()}
549 // as well. When failing we distinguish between the following levels:
550 // a) AbortOptimization: Persistent failure, disable future optimization.
551 // b) RetryOptimzation: Transient failure, try again next time.
549 class CompilationJob { 552 class CompilationJob {
550 public: 553 public:
551 enum Status { SUCCEEDED, FAILED }; 554 explicit CompilationJob(CompilationInfo* info, const char* compiler_name)
552 enum class State { 555 : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {}
553 kReadyToPrepare,
554 kReadyToExecute,
555 kReadyToFinalize,
556 kSucceeded,
557 kFailed,
558 };
559
560 explicit CompilationJob(CompilationInfo* info, const char* compiler_name,
561 State initial_state = State::kReadyToPrepare)
562 : info_(info), compiler_name_(compiler_name), state_(initial_state) {}
563 virtual ~CompilationJob() {} 556 virtual ~CompilationJob() {}
564 557
565 // Prepare the compile job. Must be called on the main thread. 558 enum Status { FAILED, SUCCEEDED };
566 MUST_USE_RESULT Status PrepareJob();
567 559
568 // Executes the compile job. Can be called off the main thread. 560 MUST_USE_RESULT Status CreateGraph();
569 MUST_USE_RESULT Status ExecuteJob(); 561 MUST_USE_RESULT Status OptimizeGraph();
562 MUST_USE_RESULT Status GenerateCode();
570 563
571 // Finalizes the compile job. Must be called on the main thread. 564 Status last_status() const { return last_status_; }
572 MUST_USE_RESULT Status FinalizeJob(); 565 CompilationInfo* info() const { return info_; }
566 Isolate* isolate() const { return info()->isolate(); }
573 567
574 // Report a transient failure, try again next time. Should only be called on
575 // optimization compilation jobs.
576 Status RetryOptimization(BailoutReason reason) { 568 Status RetryOptimization(BailoutReason reason) {
577 DCHECK(info_->IsOptimizing());
578 info_->RetryOptimization(reason); 569 info_->RetryOptimization(reason);
579 state_ = State::kFailed; 570 return SetLastStatus(FAILED);
580 return FAILED;
581 } 571 }
582 572
583 // Report a persistent failure, disable future optimization on the function.
584 // Should only be called on optimization compilation jobs.
585 Status AbortOptimization(BailoutReason reason) { 573 Status AbortOptimization(BailoutReason reason) {
586 DCHECK(info_->IsOptimizing());
587 info_->AbortOptimization(reason); 574 info_->AbortOptimization(reason);
588 state_ = State::kFailed; 575 return SetLastStatus(FAILED);
589 return FAILED;
590 } 576 }
591 577
592 void RecordOptimizationStats(); 578 void RecordOptimizationStats();
593 579
594 State state() const { return state_; } 580 protected:
595 CompilationInfo* info() const { return info_; } 581 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
596 Isolate* isolate() const { return info()->isolate(); }
597 582
598 protected:
599 // Overridden by the actual implementation. 583 // Overridden by the actual implementation.
600 virtual Status PrepareJobImpl() = 0; 584 virtual Status CreateGraphImpl() = 0;
601 virtual Status ExecuteJobImpl() = 0; 585 virtual Status OptimizeGraphImpl() = 0;
602 virtual Status FinalizeJobImpl() = 0; 586 virtual Status GenerateCodeImpl() = 0;
603
604 // Registers weak object to optimized code dependencies.
605 // TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
606 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
607 587
608 private: 588 private:
609 CompilationInfo* info_; 589 CompilationInfo* info_;
610 base::TimeDelta time_taken_to_prepare_; 590 base::TimeDelta time_taken_to_create_graph_;
611 base::TimeDelta time_taken_to_execute_; 591 base::TimeDelta time_taken_to_optimize_;
612 base::TimeDelta time_taken_to_finalize_; 592 base::TimeDelta time_taken_to_codegen_;
613 const char* compiler_name_; 593 const char* compiler_name_;
614 State state_; 594 Status last_status_;
615 595
616 MUST_USE_RESULT Status UpdateState(Status status, State next_state) { 596 MUST_USE_RESULT Status SetLastStatus(Status status) {
617 if (status == SUCCEEDED) { 597 last_status_ = status;
618 state_ = next_state; 598 return last_status_;
619 } else {
620 state_ = State::kFailed;
621 }
622 return status;
623 } 599 }
624 }; 600 };
625 601
626 } // namespace internal 602 } // namespace internal
627 } // namespace v8 603 } // namespace v8
628 604
629 #endif // V8_COMPILER_H_ 605 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698