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 8134e4fec0b975f232505d015a67b329c361f0b7..ff5ce605cc43b4e44019d2d6621942045b740c3c 100644 |
--- a/src/compiler-dispatcher/compiler-dispatcher-job.cc |
+++ b/src/compiler-dispatcher/compiler-dispatcher-job.cc |
@@ -5,6 +5,7 @@ |
#include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
#include "src/assert-scope.h" |
+#include "src/compiler.h" |
#include "src/global-handles.h" |
#include "src/isolate.h" |
#include "src/objects-inl.h" |
@@ -68,6 +69,7 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() { |
} |
parse_info_.reset(new ParseInfo(zone_.get())); |
parse_info_->set_isolate(isolate_); |
+ parse_info_->set_shared_info(shared); |
parse_info_->set_character_stream(character_stream_.get()); |
parse_info_->set_lazy(); |
parse_info_->set_hash_seed(isolate_->heap()->HashSeed()); |
@@ -135,9 +137,66 @@ void CompilerDispatcherJob::FinalizeParsingOnMainThread() { |
InternalizeParsingResult(); |
+ status_ = CompileJobStatus::kReadyToAnalyse; |
+} |
+ |
+void CompilerDispatcherJob::PrepareToCompileOnMainThread() { |
jochen (gone - plz use gerrit)
2016/08/23 12:04:26
can you make this return a bool that's false if yo
rmcilroy
2016/08/23 15:55:10
Done.
|
+ DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); |
+ DCHECK(status() == CompileJobStatus::kReadyToAnalyse); |
+ |
+ compile_info_.reset(new CompilationInfo(parse_info_.get(), function_)); |
jochen (gone - plz use gerrit)
2016/08/23 12:04:26
mind putting a DeferredHandleScope here and later
rmcilroy
2016/08/23 15:55:10
Done.
|
+ |
+ // Create a canonical handle scope before ast numbering if compiling bytecode. |
+ // This is required for off-thread bytecode generation. |
+ std::unique_ptr<CanonicalHandleScope> canonical; |
+ if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate_)); |
+ |
+ if (!Compiler::Analyze(parse_info_.get())) { |
+ status_ = CompileJobStatus::kFailed; |
+ return; |
+ } |
+ compile_job_.reset( |
+ Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get())); |
+ if (!compile_job_.get()) { |
+ status_ = CompileJobStatus::kFailed; |
+ return; |
+ } |
+ |
status_ = CompileJobStatus::kReadyToCompile; |
} |
+void CompilerDispatcherJob::Compile() { |
jochen (gone - plz use gerrit)
2016/08/23 12:04:26
same here
rmcilroy
2016/08/23 15:55:10
Change this phase to never fail, and always report
|
+ DCHECK(status() == CompileJobStatus::kReadyToCompile); |
+ DCHECK(compile_job_->can_execute_on_background_thread() || |
+ ThreadId::Current().Equals(isolate_->thread_id())); |
+ |
+ // Disallowing of handle dereference and heap access dealt with in |
+ // CompilationJob::ExecuteJob. |
+ |
+ uintptr_t stack_limit = |
+ reinterpret_cast<uintptr_t>(&stack_limit) - max_stack_size_ * KB; |
+ compile_job_->set_stack_limit(stack_limit); |
+ |
+ if (compile_job_->ExecuteJob() != CompilationJob::SUCCEEDED) { |
+ status_ = CompileJobStatus::kFailed; |
+ return; |
+ } |
+ |
+ status_ = CompileJobStatus::kCompiled; |
+} |
+ |
+void CompilerDispatcherJob::FinalizeCompilingOnMainThread() { |
+ DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); |
+ DCHECK(status() == CompileJobStatus::kCompiled); |
+ |
+ if (!Compiler::FinalizeCompilationJob(compile_job_.release())) { |
+ status_ = CompileJobStatus::kFailed; |
+ return; |
+ } |
+ |
+ status_ = CompileJobStatus::kDone; |
+} |
+ |
void CompilerDispatcherJob::ReportErrorsOnMainThread() { |
DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); |
DCHECK(status() == CompileJobStatus::kFailed); |
@@ -155,6 +214,7 @@ void CompilerDispatcherJob::ResetOnMainThread() { |
unicode_cache_.reset(); |
character_stream_.reset(); |
parse_info_.reset(); |
+ compile_info_.reset(); |
jochen (gone - plz use gerrit)
2016/08/23 12:04:26
why not also reset the compile_job_?
rmcilroy
2016/08/23 15:55:10
Opps, done (also for new DeferredHandleScope).
|
zone_.reset(); |
if (!source_.is_null()) { |
@@ -170,8 +230,6 @@ void CompilerDispatcherJob::InternalizeParsingResult() { |
DCHECK(status() == CompileJobStatus::kParsed || |
status() == CompileJobStatus::kFailed); |
- HandleScope scope(isolate_); |
- |
// Create a canonical handle scope before internalizing parsed values if |
// compiling bytecode. This is required for off-thread bytecode generation. |
std::unique_ptr<CanonicalHandleScope> canonical; |