Chromium Code Reviews| Index: src/compiler.h |
| diff --git a/src/compiler.h b/src/compiler.h |
| index b8b3a0bfb4f3c6f58ef26e1e16b7dfb77a3b35ed..f7d89cd56493125ce0db7680661601b41d512be5 100644 |
| --- a/src/compiler.h |
| +++ b/src/compiler.h |
| @@ -120,6 +120,9 @@ class Compiler : public AllStatic { |
| static Handle<SharedFunctionInfo> GetSharedFunctionInfoForNative( |
| v8::Extension* extension, Handle<String> name); |
| + // Registers weak object to optimized code dependencies. |
| + static void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); |
|
Michael Starzinger
2016/08/16 08:46:40
IMHO this doesn't belong into the "Compiler" inter
rmcilroy
2016/08/16 11:10:44
Done.
|
| + |
| // =========================================================================== |
| // The following family of methods provides support for OSR. Code generated |
| // for entry via OSR might not be suitable for normal entry, hence will be |
| @@ -537,62 +540,81 @@ class CompilationInfo final { |
| // 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) 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. |
| +// 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. |
| // |
| -// 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. |
| +// Each of the three phases can either fail or succeed. The current state of |
| +// the job can be checked using {state()}. |
| class CompilationJob { |
| public: |
| - explicit CompilationJob(CompilationInfo* info, const char* compiler_name) |
| - : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {} |
| + 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) {} |
| virtual ~CompilationJob() {} |
| - enum Status { FAILED, SUCCEEDED }; |
| + // Prepare the compile job. Must be called on the main thread. |
| + MUST_USE_RESULT Status PrepareJob(); |
| - MUST_USE_RESULT Status CreateGraph(); |
| - MUST_USE_RESULT Status OptimizeGraph(); |
| - MUST_USE_RESULT Status GenerateCode(); |
| + // Executes the compile job. Can called off the main thread. |
|
Michael Starzinger
2016/08/16 08:46:40
nit: s/Can called/Can be called/
rmcilroy
2016/08/16 11:10:44
Done.
|
| + MUST_USE_RESULT Status ExecuteJob(); |
| - Status last_status() const { return last_status_; } |
| - CompilationInfo* info() const { return info_; } |
| - Isolate* isolate() const { return info()->isolate(); } |
| + // 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); |
| - return SetLastStatus(FAILED); |
| + 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); |
| - return SetLastStatus(FAILED); |
| + state_ = State::kFailed; |
| + return FAILED; |
| } |
| void RecordOptimizationStats(); |
| - protected: |
| - void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); |
| + State state() const { return state_; } |
| + CompilationInfo* info() const { return info_; } |
| + Isolate* isolate() const { return info()->isolate(); } |
| + protected: |
| // Overridden by the actual implementation. |
| - virtual Status CreateGraphImpl() = 0; |
| - virtual Status OptimizeGraphImpl() = 0; |
| - virtual Status GenerateCodeImpl() = 0; |
| + virtual Status PrepareJobImpl() = 0; |
| + virtual Status ExecuteJobImpl() = 0; |
| + virtual Status FinalizeJobImpl() = 0; |
| private: |
| CompilationInfo* info_; |
| - base::TimeDelta time_taken_to_create_graph_; |
| - base::TimeDelta time_taken_to_optimize_; |
| - base::TimeDelta time_taken_to_codegen_; |
| + base::TimeDelta time_taken_to_prepare_; |
| + base::TimeDelta time_taken_to_execute_; |
| + base::TimeDelta time_taken_to_finalize_; |
| const char* compiler_name_; |
| - Status last_status_; |
| - |
| - MUST_USE_RESULT Status SetLastStatus(Status status) { |
| - last_status_ = status; |
| - return last_status_; |
| + State state_; |
| + |
| + MUST_USE_RESULT Status UpdateState(Status status, State next_state) { |
| + if (status == SUCCEEDED) |
|
Michael Starzinger
2016/08/16 08:46:40
nit: Curly braces around bodies of multi-line if s
rmcilroy
2016/08/16 11:10:44
Done.
|
| + state_ = next_state; |
| + else |
| + state_ = State::kFailed; |
| + return status; |
| } |
| }; |