[platform] Require the foreground taskrunner to support non-nestable tasks for weak refs
Bug: v8:8179 Change-Id: I2e7024412216decc06e814e88eecd5b4eb5ae8cb Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2013696 Reviewed-by: Ben Smith <binji@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#65966}
This commit is contained in:
parent
1dc3ac9693
commit
1920e6c92f
@ -326,7 +326,8 @@ class Platform {
|
||||
|
||||
/**
|
||||
* Returns a TaskRunner which can be used to post a task on the foreground.
|
||||
* This function should only be called from a foreground thread.
|
||||
* The TaskRunner's NonNestableTasksEnabled() must be true. This function
|
||||
* should only be called from a foreground thread.
|
||||
*/
|
||||
virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
|
||||
Isolate* isolate) = 0;
|
||||
|
@ -8269,6 +8269,14 @@ void Isolate::Initialize(Isolate* isolate,
|
||||
}
|
||||
i_isolate->set_only_terminate_in_safe_scope(
|
||||
params.only_terminate_in_safe_scope);
|
||||
|
||||
if (!i::V8::GetCurrentPlatform()
|
||||
->GetForegroundTaskRunner(isolate)
|
||||
->NonNestableTasksEnabled()) {
|
||||
FATAL(
|
||||
"The current platform's foreground task runner does not have "
|
||||
"non-nestable tasks enabled. The embedder must provide one.");
|
||||
}
|
||||
}
|
||||
|
||||
Isolate* Isolate::New(const Isolate::CreateParams& params) {
|
||||
|
@ -175,6 +175,11 @@ class DelayedTasksPlatform : public Platform {
|
||||
task_runner_->PostTask(platform_->MakeDelayedTask(std::move(task)));
|
||||
}
|
||||
|
||||
void PostNonNestableTask(std::unique_ptr<Task> task) final {
|
||||
task_runner_->PostNonNestableTask(
|
||||
platform_->MakeDelayedTask(std::move(task)));
|
||||
}
|
||||
|
||||
void PostDelayedTask(std::unique_ptr<Task> task,
|
||||
double delay_in_seconds) final {
|
||||
task_runner_->PostDelayedTask(platform_->MakeDelayedTask(std::move(task)),
|
||||
@ -188,6 +193,10 @@ class DelayedTasksPlatform : public Platform {
|
||||
|
||||
bool IdleTasksEnabled() final { return task_runner_->IdleTasksEnabled(); }
|
||||
|
||||
bool NonNestableTasksEnabled() const final {
|
||||
return task_runner_->NonNestableTasksEnabled();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class DelayedTaskRunnerDeleter;
|
||||
std::shared_ptr<TaskRunner> task_runner_;
|
||||
|
@ -272,6 +272,11 @@ class MockPlatform : public v8::Platform {
|
||||
platform_->foreground_tasks_.push_back(std::move(task));
|
||||
}
|
||||
|
||||
void PostNonNestableTask(std::unique_ptr<v8::Task> task) override {
|
||||
// The mock platform does not nest tasks.
|
||||
PostTask(std::move(task));
|
||||
}
|
||||
|
||||
void PostDelayedTask(std::unique_ptr<Task> task,
|
||||
double delay_in_seconds) override {
|
||||
UNREACHABLE();
|
||||
@ -286,6 +291,8 @@ class MockPlatform : public v8::Platform {
|
||||
|
||||
bool IdleTasksEnabled() override { return true; }
|
||||
|
||||
bool NonNestableTasksEnabled() const override { return false; }
|
||||
|
||||
private:
|
||||
MockPlatform* platform_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user