| Index: src/compiler-dispatcher/compiler-dispatcher-job.cc
|
| diff --git a/src/compiler-dispatcher/compiler-dispatcher-job.cc b/src/compiler-dispatcher/compiler-dispatcher-job.cc
|
| index 2ca26011bb5646dbacef9b725ac015d2de52af5c..ed2c225069d75abdd3f50990613a4b3008d3533b 100644
|
| --- a/src/compiler-dispatcher/compiler-dispatcher-job.cc
|
| +++ b/src/compiler-dispatcher/compiler-dispatcher-job.cc
|
| @@ -26,7 +26,8 @@ CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
|
| CompilerDispatcherTracer* tracer,
|
| Handle<SharedFunctionInfo> shared,
|
| size_t max_stack_size)
|
| - : isolate_(isolate),
|
| + : status_(CompileJobStatus::kInitial),
|
| + isolate_(isolate),
|
| tracer_(tracer),
|
| shared_(Handle<SharedFunctionInfo>::cast(
|
| isolate_->global_handles()->Create(*shared))),
|
| @@ -42,7 +43,40 @@ CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
|
| if (trace_compiler_dispatcher_jobs_) {
|
| PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
|
| shared_->ShortPrint();
|
| - PrintF("\n");
|
| + PrintF(" in initial state.\n");
|
| + }
|
| +}
|
| +
|
| +CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
|
| + CompilerDispatcherTracer* tracer,
|
| + Handle<SharedFunctionInfo> shared,
|
| + FunctionLiteral* literal,
|
| + AstValueFactory* ast_value_factory,
|
| + size_t max_stack_size)
|
| + : status_(CompileJobStatus::kAnalyzed),
|
| + isolate_(isolate),
|
| + tracer_(tracer),
|
| + shared_(Handle<SharedFunctionInfo>::cast(
|
| + isolate_->global_handles()->Create(*shared))),
|
| + max_stack_size_(max_stack_size),
|
| + zone_(new Zone(isolate->allocator(), ZONE_NAME)),
|
| + parse_info_(new ParseInfo(
|
| + zone_.get(), Handle<Script>(Script::cast(shared->script())))),
|
| + compile_info_(
|
| + new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())),
|
| + can_parse_on_background_thread_(false),
|
| + can_compile_on_background_thread_(false),
|
| + trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
|
| + parse_info_->set_literal(literal);
|
| + parse_info_->set_shared_info(shared);
|
| + parse_info_->set_function_literal_id(shared->function_literal_id());
|
| + parse_info_->set_language_mode(literal->scope()->language_mode());
|
| + parse_info_->set_ast_value_factory(ast_value_factory);
|
| + parse_info_->set_ast_value_factory_owned(false);
|
| + if (trace_compiler_dispatcher_jobs_) {
|
| + PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
|
| + shared_->ShortPrint();
|
| + PrintF(" in Analyzed state.\n");
|
| }
|
| }
|
|
|
| @@ -161,7 +195,7 @@ bool CompilerDispatcherJob::FinalizeParsingOnMainThread() {
|
| if (parse_info_->literal() == nullptr) {
|
| status_ = CompileJobStatus::kFailed;
|
| } else {
|
| - status_ = CompileJobStatus::kReadyToAnalyse;
|
| + status_ = CompileJobStatus::kReadyToAnalyze;
|
| }
|
|
|
| DeferredHandleScope scope(isolate_);
|
| @@ -192,25 +226,38 @@ bool CompilerDispatcherJob::FinalizeParsingOnMainThread() {
|
| return status_ != CompileJobStatus::kFailed;
|
| }
|
|
|
| -bool CompilerDispatcherJob::PrepareToCompileOnMainThread() {
|
| +bool CompilerDispatcherJob::AnalyzeOnMainThread() {
|
| DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
|
| - DCHECK(status() == CompileJobStatus::kReadyToAnalyse);
|
| - COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToCompile);
|
| + DCHECK(status() == CompileJobStatus::kReadyToAnalyze);
|
| + COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kAnalyze);
|
| if (trace_compiler_dispatcher_jobs_) {
|
| - PrintF("CompilerDispatcherJob[%p]: Preparing to compile\n",
|
| - static_cast<void*>(this));
|
| + PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this));
|
| }
|
|
|
| compile_info_.reset(
|
| new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null()));
|
|
|
| DeferredHandleScope scope(isolate_);
|
| - if (Compiler::Analyze(parse_info_.get())) {
|
| - compile_job_.reset(
|
| - Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
|
| + {
|
| + if (Compiler::Analyze(parse_info_.get())) {
|
| + status_ = CompileJobStatus::kAnalyzed;
|
| + } else {
|
| + status_ = CompileJobStatus::kFailed;
|
| + if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
|
| + }
|
| }
|
| compile_info_->set_deferred_handles(scope.Detach());
|
|
|
| + return status_ != CompileJobStatus::kFailed;
|
| +}
|
| +
|
| +bool CompilerDispatcherJob::PrepareToCompileOnMainThread() {
|
| + DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
|
| + DCHECK(status() == CompileJobStatus::kAnalyzed);
|
| + COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToCompile);
|
| +
|
| + compile_job_.reset(
|
| + Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
|
| if (!compile_job_.get()) {
|
| if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
|
| status_ = CompileJobStatus::kFailed;
|
| @@ -309,7 +356,10 @@ double CompilerDispatcherJob::EstimateRuntimeOfNextStepInMs() const {
|
| case CompileJobStatus::kParsed:
|
| return tracer_->EstimateFinalizeParsingInMs();
|
|
|
| - case CompileJobStatus::kReadyToAnalyse:
|
| + case CompileJobStatus::kReadyToAnalyze:
|
| + return tracer_->EstimateAnalyzeInMs();
|
| +
|
| + case CompileJobStatus::kAnalyzed:
|
| return tracer_->EstimatePrepareToCompileInMs();
|
|
|
| case CompileJobStatus::kReadyToCompile:
|
|
|