| Index: src/compiler.h
|
| diff --git a/src/compiler.h b/src/compiler.h
|
| index 55215733c11c66a8b9160a0adebc927e1c564ad0..fa12679675ba63d100de5a555bfba64e876e068a 100644
|
| --- a/src/compiler.h
|
| +++ b/src/compiler.h
|
| @@ -57,8 +57,12 @@ class Compiler : public AllStatic {
|
| static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
|
| static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script);
|
|
|
| + // Prepare a compilation job for unoptimized code. Requires ParseAndAnalyse.
|
| + static CompilationJob* PrepareUnoptimizedCompilationJob(
|
| + CompilationInfo* info);
|
| +
|
| // Generate and install code from previously queued compilation job.
|
| - static void FinalizeCompilationJob(CompilationJob* job);
|
| + static bool FinalizeCompilationJob(CompilationJob* job);
|
|
|
| // Give the compiler a chance to perform low-latency initialization tasks of
|
| // the given {function} on its instantiation. Note that only the runtime will
|
| @@ -557,20 +561,35 @@ class CompilationJob {
|
| kFailed,
|
| };
|
|
|
| - explicit CompilationJob(CompilationInfo* info, const char* compiler_name,
|
| + explicit CompilationJob(Isolate* isolate, CompilationInfo* info,
|
| + const char* compiler_name,
|
| State initial_state = State::kReadyToPrepare)
|
| - : info_(info), compiler_name_(compiler_name), state_(initial_state) {}
|
| + : info_(info),
|
| + compiler_name_(compiler_name),
|
| + state_(initial_state),
|
| + stack_limit_(isolate->stack_guard()->real_climit()) {}
|
| 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.
|
| + // Executes the compile job. Can be called on a background thread if
|
| + // can_execute_on_background_thread() returns true.
|
| MUST_USE_RESULT Status ExecuteJob();
|
|
|
| // Finalizes the compile job. Must be called on the main thread.
|
| MUST_USE_RESULT Status FinalizeJob();
|
|
|
| + // Record compilation stats once job has finished.
|
| + void RecordCompilationStats() const {
|
| + DCHECK(state() == State::kSucceeded);
|
| + if (info_->IsOptimizing()) {
|
| + RecordOptimizedCompilationStats();
|
| + } else {
|
| + RecordUnoptimizedCompilationStats();
|
| + }
|
| + }
|
| +
|
| // Report a transient failure, try again next time. Should only be called on
|
| // optimization compilation jobs.
|
| Status RetryOptimization(BailoutReason reason) {
|
| @@ -589,7 +608,10 @@ class CompilationJob {
|
| return FAILED;
|
| }
|
|
|
| - void RecordOptimizationStats();
|
| + virtual bool can_execute_on_background_thread() const { return true; }
|
| +
|
| + void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
|
| + uintptr_t stack_limit() const { return stack_limit_; }
|
|
|
| State state() const { return state_; }
|
| CompilationInfo* info() const { return info_; }
|
| @@ -606,12 +628,16 @@ class CompilationJob {
|
| void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
|
|
| private:
|
| + void RecordOptimizedCompilationStats() const;
|
| + void RecordUnoptimizedCompilationStats() const;
|
| +
|
| CompilationInfo* info_;
|
| base::TimeDelta time_taken_to_prepare_;
|
| base::TimeDelta time_taken_to_execute_;
|
| base::TimeDelta time_taken_to_finalize_;
|
| const char* compiler_name_;
|
| State state_;
|
| + uintptr_t stack_limit_;
|
|
|
| MUST_USE_RESULT Status UpdateState(Status status, State next_state) {
|
| if (status == SUCCEEDED) {
|
|
|