| Index: src/compiler.h
|
| diff --git a/src/compiler.h b/src/compiler.h
|
| index 55215733c11c66a8b9160a0adebc927e1c564ad0..bd9c0dc0ca67ce4d6d08742928797ca9d5fb594a 100644
|
| --- a/src/compiler.h
|
| +++ b/src/compiler.h
|
| @@ -540,86 +540,62 @@
|
| // A base class for compilation jobs intended to run concurrent to the main
|
| // thread. The job is split into three phases which are called in sequence on
|
| // different threads and with different limitations:
|
| -// 1) PrepareJob: Runs on main thread. No major limitations.
|
| -// 2) ExecuteJob: Runs concurrently. No heap allocation or handle derefs.
|
| -// 3) FinalizeJob: Runs on main thread. No dependency changes.
|
| +// 1) CreateGraph: Runs on main thread. No major limitations.
|
| +// 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs.
|
| +// 3) GenerateCode: Runs on main thread. No dependency changes.
|
| //
|
| -// Each of the three phases can either fail or succeed. The current state of
|
| -// the job can be checked using {state()}.
|
| +// Each of the three phases can either fail or succeed. Apart from their return
|
| +// value, the status of the phase last run can be checked using {last_status()}
|
| +// as well. When failing we distinguish between the following levels:
|
| +// a) AbortOptimization: Persistent failure, disable future optimization.
|
| +// b) RetryOptimzation: Transient failure, try again next time.
|
| class CompilationJob {
|
| public:
|
| - enum Status { SUCCEEDED, FAILED };
|
| - enum class State {
|
| - kReadyToPrepare,
|
| - kReadyToExecute,
|
| - kReadyToFinalize,
|
| - kSucceeded,
|
| - kFailed,
|
| - };
|
| -
|
| - explicit CompilationJob(CompilationInfo* info, const char* compiler_name,
|
| - State initial_state = State::kReadyToPrepare)
|
| - : info_(info), compiler_name_(compiler_name), state_(initial_state) {}
|
| + explicit CompilationJob(CompilationInfo* info, const char* compiler_name)
|
| + : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {}
|
| virtual ~CompilationJob() {}
|
|
|
| - // Prepare the compile job. Must be called on the main thread.
|
| - MUST_USE_RESULT Status PrepareJob();
|
| -
|
| - // Executes the compile job. Can be called off the main thread.
|
| - MUST_USE_RESULT Status ExecuteJob();
|
| -
|
| - // Finalizes the compile job. Must be called on the main thread.
|
| - MUST_USE_RESULT Status FinalizeJob();
|
| -
|
| - // Report a transient failure, try again next time. Should only be called on
|
| - // optimization compilation jobs.
|
| - Status RetryOptimization(BailoutReason reason) {
|
| - DCHECK(info_->IsOptimizing());
|
| - info_->RetryOptimization(reason);
|
| - state_ = State::kFailed;
|
| - return FAILED;
|
| - }
|
| -
|
| - // Report a persistent failure, disable future optimization on the function.
|
| - // Should only be called on optimization compilation jobs.
|
| - Status AbortOptimization(BailoutReason reason) {
|
| - DCHECK(info_->IsOptimizing());
|
| - info_->AbortOptimization(reason);
|
| - state_ = State::kFailed;
|
| - return FAILED;
|
| - }
|
| -
|
| - void RecordOptimizationStats();
|
| -
|
| - State state() const { return state_; }
|
| + enum Status { FAILED, SUCCEEDED };
|
| +
|
| + MUST_USE_RESULT Status CreateGraph();
|
| + MUST_USE_RESULT Status OptimizeGraph();
|
| + MUST_USE_RESULT Status GenerateCode();
|
| +
|
| + Status last_status() const { return last_status_; }
|
| CompilationInfo* info() const { return info_; }
|
| Isolate* isolate() const { return info()->isolate(); }
|
|
|
| + Status RetryOptimization(BailoutReason reason) {
|
| + info_->RetryOptimization(reason);
|
| + return SetLastStatus(FAILED);
|
| + }
|
| +
|
| + Status AbortOptimization(BailoutReason reason) {
|
| + info_->AbortOptimization(reason);
|
| + return SetLastStatus(FAILED);
|
| + }
|
| +
|
| + void RecordOptimizationStats();
|
| +
|
| protected:
|
| + void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
| +
|
| // Overridden by the actual implementation.
|
| - virtual Status PrepareJobImpl() = 0;
|
| - virtual Status ExecuteJobImpl() = 0;
|
| - virtual Status FinalizeJobImpl() = 0;
|
| -
|
| - // Registers weak object to optimized code dependencies.
|
| - // TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
|
| - void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
| + virtual Status CreateGraphImpl() = 0;
|
| + virtual Status OptimizeGraphImpl() = 0;
|
| + virtual Status GenerateCodeImpl() = 0;
|
|
|
| private:
|
| CompilationInfo* info_;
|
| - base::TimeDelta time_taken_to_prepare_;
|
| - base::TimeDelta time_taken_to_execute_;
|
| - base::TimeDelta time_taken_to_finalize_;
|
| + base::TimeDelta time_taken_to_create_graph_;
|
| + base::TimeDelta time_taken_to_optimize_;
|
| + base::TimeDelta time_taken_to_codegen_;
|
| const char* compiler_name_;
|
| - State state_;
|
| -
|
| - MUST_USE_RESULT Status UpdateState(Status status, State next_state) {
|
| - if (status == SUCCEEDED) {
|
| - state_ = next_state;
|
| - } else {
|
| - state_ = State::kFailed;
|
| - }
|
| - return status;
|
| + Status last_status_;
|
| +
|
| + MUST_USE_RESULT Status SetLastStatus(Status status) {
|
| + last_status_ = status;
|
| + return last_status_;
|
| }
|
| };
|
|
|
|
|