Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: src/compiler-dispatcher/compiler-dispatcher-job.cc

Issue 2251713002: [Compiler] Add compile to CompilerDispatcherJob. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_compilerdispatcher
Patch Set: Address Jochen's comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 923793665aa3cd503ab554ada9fcf67f00b4e662..3ede6ca6f1a63fd395afb4ca5a0bc9da87b9b450 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"
@@ -131,7 +132,7 @@ bool CompilerDispatcherJob::FinalizeParsingOnMainThread() {
if (parse_info_->literal() == nullptr) {
status_ = CompileJobStatus::kFailed;
} else {
- status_ = CompileJobStatus::kReadyToCompile;
+ status_ = CompileJobStatus::kReadyToAnalyse;
}
DeferredHandleScope scope(isolate_);
@@ -146,6 +147,7 @@ bool CompilerDispatcherJob::FinalizeParsingOnMainThread() {
parse_info_->set_script(script);
parse_info_->set_context(handle(function_->context(), isolate_));
+ parse_info_->set_shared_info(handle(function_->shared(), isolate_));
// Do the parsing tasks which need to be done on the main thread. This will
// also handle parse errors.
@@ -163,6 +165,78 @@ bool CompilerDispatcherJob::FinalizeParsingOnMainThread() {
return status_ != CompileJobStatus::kFailed;
}
+bool CompilerDispatcherJob::PrepareToCompileOnMainThread() {
+ DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
+ DCHECK(status() == CompileJobStatus::kReadyToAnalyse);
+
+ compile_info_.reset(new CompilationInfo(parse_info_.get(), function_));
+
+ DeferredHandleScope scope(isolate_);
+ {
+ // 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())) {
+ compile_job_.reset(
+ Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
+ }
+ }
+ handles_from_analysing_.reset(scope.Detach());
jochen (gone - plz use gerrit) 2016/08/23 16:06:22 why not just compile_info_->set_deferred_handles(s
rmcilroy 2016/08/23 16:58:29 Works for me. Done.
+
+ if (!compile_job_.get()) {
+ if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
+ status_ = CompileJobStatus::kFailed;
+ return false;
+ }
+
+ status_ = CompileJobStatus::kReadyToCompile;
+ return true;
+}
+
+void CompilerDispatcherJob::Compile() {
+ 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);
+
+ CompilationJob::Status status = compile_job_->ExecuteJob();
+ USE(status);
+
+ // Always transition to kCompiled - errors will be reported by
+ // FinalizeCompilingOnMainThread.
+ status_ = CompileJobStatus::kCompiled;
+}
+
+bool CompilerDispatcherJob::FinalizeCompilingOnMainThread() {
+ DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
+ DCHECK(status() == CompileJobStatus::kCompiled);
+
+ if (compile_job_->state() == CompilationJob::State::kFailed ||
+ !Compiler::FinalizeCompilationJob(compile_job_.release())) {
+ if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
+ status_ = CompileJobStatus::kFailed;
+ return false;
+ }
+
+ zone_.reset();
+ parse_info_.reset();
+ compile_info_.reset();
+ compile_job_.reset();
+ handles_from_parsing_.reset();
+ handles_from_analysing_.reset();
+
+ status_ = CompileJobStatus::kDone;
+ return true;
+}
+
void CompilerDispatcherJob::ResetOnMainThread() {
DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
@@ -172,6 +246,9 @@ void CompilerDispatcherJob::ResetOnMainThread() {
parse_info_.reset();
zone_.reset();
handles_from_parsing_.reset();
+ compile_info_.reset();
+ compile_job_.reset();
+ handles_from_analysing_.reset();
if (!source_.is_null()) {
i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());

Powered by Google App Engine
This is Rietveld 408576698