From 716ce620bfb0ccca21f782f3179c90a23943bda7 Mon Sep 17 00:00:00 2001 From: Etienne Pierre-Doray Date: Mon, 11 Dec 2023 04:13:38 -0500 Subject: [PATCH] v8: update default platform to override functions with location (#173) Co-authored-by: Etienne Pierre-Doray --- src/node_platform.cc | 19 +++++++++++++------ src/node_platform.h | 16 +++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/node_platform.cc b/src/node_platform.cc index 927fdddb8d9a1a..291e386ccae0d2 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -496,17 +496,22 @@ bool PerIsolatePlatformData::FlushForegroundTasksInternal() { return did_work; } -void NodePlatform::CallOnWorkerThread(std::unique_ptr task) { +void NodePlatform::PostTaskOnWorkerThreadImpl( + v8::TaskPriority priority, + std::unique_ptr task, + const v8::SourceLocation& location) { worker_thread_task_runner_->PostTask(std::move(task)); } -void NodePlatform::CallDelayedOnWorkerThread(std::unique_ptr task, - double delay_in_seconds) { +void NodePlatform::PostDelayedTaskOnWorkerThreadImpl( + v8::TaskPriority priority, + std::unique_ptr task, + double delay_in_seconds, + const v8::SourceLocation& location) { worker_thread_task_runner_->PostDelayedTask(std::move(task), delay_in_seconds); } - IsolatePlatformDelegate* NodePlatform::ForIsolate(Isolate* isolate) { Mutex::ScopedLock lock(per_isolate_mutex_); auto data = per_isolate_[isolate]; @@ -528,8 +533,10 @@ bool NodePlatform::FlushForegroundTasks(Isolate* isolate) { return per_isolate->FlushForegroundTasksInternal(); } -std::unique_ptr NodePlatform::CreateJob( - v8::TaskPriority priority, std::unique_ptr job_task) { +std::unique_ptr NodePlatform::CreateJobImpl( + v8::TaskPriority priority, + std::unique_ptr job_task, + const v8::SourceLocation& location) { return v8::platform::NewDefaultJobHandle( this, priority, std::move(job_task), NumberOfWorkerThreads()); } diff --git a/src/node_platform.h b/src/node_platform.h index 1062f3b1b9c386..77cb5e6e4f891c 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -147,17 +147,23 @@ class NodePlatform : public MultiIsolatePlatform { // v8::Platform implementation. int NumberOfWorkerThreads() override; - void CallOnWorkerThread(std::unique_ptr task) override; - void CallDelayedOnWorkerThread(std::unique_ptr task, - double delay_in_seconds) override; + void PostTaskOnWorkerThreadImpl(v8::TaskPriority priority, + std::unique_ptr task, + const v8::SourceLocation& location) override; + void PostDelayedTaskOnWorkerThreadImpl( + v8::TaskPriority priority, + std::unique_ptr task, + double delay_in_seconds, + const v8::SourceLocation& location) override; bool IdleTasksEnabled(v8::Isolate* isolate) override; double MonotonicallyIncreasingTime() override; double CurrentClockTimeMillis() override; v8::TracingController* GetTracingController() override; bool FlushForegroundTasks(v8::Isolate* isolate) override; - std::unique_ptr CreateJob( + std::unique_ptr CreateJobImpl( v8::TaskPriority priority, - std::unique_ptr job_task) override; + std::unique_ptr job_task, + const v8::SourceLocation& location) override; void RegisterIsolate(v8::Isolate* isolate, uv_loop_t* loop) override; void RegisterIsolate(v8::Isolate* isolate,