From 2bdeb88c27b4d8de3a8f6b7a438cf0bcb88fa927 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 22 Oct 2019 22:03:53 +0200 Subject: src: remove custom tracking for SharedArrayBuffers Remove custom tracking for `SharedArrayBuffer`s and their allocators and instead let V8 do the tracking of both. This is required starting in V8 7.9, because lifetime management for `ArrayBuffer::Allocator`s differs from what was performed previously (i.e. it is no longer easily possible for one Isolate to release an `ArrayBuffer` and another to accept it into its own allocator), and the alternative would have been adapting the `SharedArrayBuffer` tracking logic to also apply to regular `ArrayBuffer` instances. Refs: https://github.com/nodejs/node/pull/30044 PR-URL: https://github.com/nodejs/node/pull/30020 Reviewed-By: Colin Ihrig Reviewed-By: Jiawen Geng Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina --- src/node_worker.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/node_worker.cc') diff --git a/src/node_worker.cc b/src/node_worker.cc index 9f2da4c9de..3c604ec2ec 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -51,7 +51,6 @@ Worker::Worker(Environment* env, per_isolate_opts_(per_isolate_opts), exec_argv_(exec_argv), platform_(env->isolate_data()->platform()), - array_buffer_allocator_(ArrayBufferAllocator::Create()), start_profiler_idle_notifier_(env->profiler_idle_notifier_started()), thread_id_(Environment::AllocateThreadId()), env_vars_(env->env_vars()) { @@ -95,10 +94,6 @@ bool Worker::is_stopped() const { return stopped_; } -std::shared_ptr Worker::array_buffer_allocator() { - return array_buffer_allocator_; -} - void Worker::UpdateResourceConstraints(ResourceConstraints* constraints) { constraints->set_stack_limit(reinterpret_cast(stack_base_)); @@ -138,9 +133,11 @@ class WorkerThreadData { : w_(w) { CHECK_EQ(uv_loop_init(&loop_), 0); + std::shared_ptr allocator = + ArrayBufferAllocator::Create(); Isolate::CreateParams params; SetIsolateCreateParamsForNode(¶ms); - params.array_buffer_allocator = w->array_buffer_allocator_.get(); + params.array_buffer_allocator_shared = allocator; w->UpdateResourceConstraints(¶ms.constraints); @@ -164,7 +161,7 @@ class WorkerThreadData { isolate_data_.reset(CreateIsolateData(isolate, &loop_, w_->platform_, - w->array_buffer_allocator_.get())); + allocator.get())); CHECK(isolate_data_); if (w_->per_isolate_opts_) isolate_data_->set_options(std::move(w_->per_isolate_opts_)); -- cgit v1.2.3