Commit 9136841f authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Eliminate nondeterminism if requested

If --wasm-num-compilation-tasks is set to 0, we spawn all background
tasks as foreground tasks. Semantically, they are still treated like
background tasks, but they will execute interleaved with the foreground
tasks. This should not deadlong since all foreground tasks eventually
return to the event loop.

R=ahaas@chromium.org

Bug: chromium:829681
Change-Id: Id57cbb10157c085acd57a3d30a0a43c824a64591
Reviewed-on: https://chromium-review.googlesource.com/999594Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52445}
parent 87f9c148
......@@ -2599,8 +2599,12 @@ void AsyncCompileJob::DoSync(Args&&... args) {
}
void AsyncCompileJob::StartBackgroundTask() {
background_task_runner_->PostTask(
base::make_unique<CompileTask>(this, false));
// If --wasm-num-compilation-tasks=0 is passed, do only spawn foreground
// tasks. This is used to make timing deterministic.
v8::TaskRunner* task_runner = FLAG_wasm_num_compilation_tasks > 0
? background_task_runner_.get()
: foreground_task_runner_.get();
task_runner->PostTask(base::make_unique<CompileTask>(this, false));
}
template <typename Step, typename... Args>
......@@ -3221,7 +3225,12 @@ void CompilationState::RestartBackgroundTasks() {
// TODO(wasm): Do not start more background tasks than the number of available
// units in {compilation_units_}.
for (; stopped_compilation_tasks_ > 0; --stopped_compilation_tasks_) {
background_task_runner_->PostTask(base::make_unique<BackgroundCompileTask>(
// If --wasm-num-compilation-tasks=0 is passed, do only spawn foreground
// tasks. This is used to make timing deterministic.
v8::TaskRunner* task_runner = FLAG_wasm_num_compilation_tasks > 0
? background_task_runner_.get()
: foreground_task_runner_.get();
task_runner->PostTask(base::make_unique<BackgroundCompileTask>(
this, &background_task_manager_));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment