Commit 83441dc2 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[d8] Fix job execution on the predictable platform

Jobs were still being posted on the underlying default platform, which
caused concurrent execution. By directly returning a
{NewDefaultJobHandle} with a pointer to the {PredictablePlatform}, we
force execution of all posted tasks via that platform.

R=ahaas@chromium.org, cbruni@chromium.org

Bug: v8:11848
Change-Id: Ie10519583341b427776ca428f85641e96f821367
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2944808Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75002}
parent febfbb21
......@@ -73,6 +73,9 @@ specific_include_rules = {
"+include/libplatform/v8-tracing.h",
"+perfetto/tracing.h"
],
"d8-platforms\.cc": [
"+include/libplatform/libplatform.h",
],
"builtins-trace\.cc": [
"+protos/perfetto",
],
......
......@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/d8/d8-platforms.h"
#include <memory>
#include <unordered_map>
#include "include/libplatform/libplatform.h"
#include "include/v8-platform.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
......@@ -12,7 +15,6 @@
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/utils/random-number-generator.h"
#include "src/d8/d8-platforms.h"
namespace v8 {
......@@ -43,7 +45,12 @@ class PredictablePlatform final : public Platform {
return platform_->GetForegroundTaskRunner(isolate);
}
int NumberOfWorkerThreads() override { return 0; }
int NumberOfWorkerThreads() override {
// The predictable platform executes everything on the main thread, but we
// still pretend to have the default number of worker threads to not
// unnecessarily change behaviour of the platform.
return platform_->NumberOfWorkerThreads();
}
void CallOnWorkerThread(std::unique_ptr<Task> task) override {
// We post worker tasks on the foreground task runner of the
......@@ -68,7 +75,10 @@ class PredictablePlatform final : public Platform {
std::unique_ptr<JobHandle> PostJob(
TaskPriority priority, std::unique_ptr<JobTask> job_task) override {
return platform_->PostJob(priority, std::move(job_task));
// Do not call {platform_->PostJob} here, as this would create a job that
// posts tasks directly to the underlying default platform.
return platform::NewDefaultJobHandle(this, priority, std::move(job_task),
NumberOfWorkerThreads());
}
double MonotonicallyIncreasingTime() override {
......
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