Commit 4cc41fbb authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] JSToWasm Wrapper compilation respects --single-threaded

When --single-threaded is set, and therefore
--wasm-num-compilation-tasks=0, the compilation job for JSToWasm
wrapper compilation is executed directly instead of first posted and
then joined on the main thread.

R=clemensb@chromium.org

Bug: v8:11279
Change-Id: Idba150cf9d32a6a6b12b322f46c0ba36fd220c5b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2595441
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71953}
parent ec7e9a8d
...@@ -3341,17 +3341,16 @@ class CompileJSToWasmWrapperJob final : public JobTask { ...@@ -3341,17 +3341,16 @@ class CompileJSToWasmWrapperJob final : public JobTask {
JSToWasmWrapperCompilationUnit* unit = (*compilation_units_)[*key].get(); JSToWasmWrapperCompilationUnit* unit = (*compilation_units_)[*key].get();
unit->Execute(); unit->Execute();
outstanding_units_.fetch_sub(1, std::memory_order_relaxed); outstanding_units_.fetch_sub(1, std::memory_order_relaxed);
if (delegate->ShouldYield()) return; if (delegate && delegate->ShouldYield()) return;
} }
} }
size_t GetMaxConcurrency(size_t /* worker_count */) const override { size_t GetMaxConcurrency(size_t /* worker_count */) const override {
DCHECK_GE(FLAG_wasm_num_compilation_tasks, 1);
// {outstanding_units_} includes the units that other workers are currently // {outstanding_units_} includes the units that other workers are currently
// working on, so we can safely ignore the {worker_count} and just return // working on, so we can safely ignore the {worker_count} and just return
// the current number of outstanding units. // the current number of outstanding units.
size_t flag_limit = return std::min(static_cast<size_t>(FLAG_wasm_num_compilation_tasks),
static_cast<size_t>(std::max(1, FLAG_wasm_num_compilation_tasks));
return std::min(flag_limit,
outstanding_units_.load(std::memory_order_relaxed)); outstanding_units_.load(std::memory_order_relaxed));
} }
...@@ -3387,11 +3386,15 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module, ...@@ -3387,11 +3386,15 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
auto job = auto job =
std::make_unique<CompileJSToWasmWrapperJob>(&queue, &compilation_units); std::make_unique<CompileJSToWasmWrapperJob>(&queue, &compilation_units);
auto job_handle = V8::GetCurrentPlatform()->PostJob( if (FLAG_wasm_num_compilation_tasks > 0) {
TaskPriority::kUserVisible, std::move(job)); auto job_handle = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserVisible, std::move(job));
// Wait for completion, while contributing to the work. // Wait for completion, while contributing to the work.
job_handle->Join(); job_handle->Join();
} else {
job->Run(nullptr);
}
// Finalize compilation jobs in the main thread. // Finalize compilation jobs in the main thread.
// TODO(6792): Wrappers below are allocated with {Factory::NewCode}. As an // TODO(6792): Wrappers below are allocated with {Factory::NewCode}. As an
......
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