Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-10-22 23:03:53 +0300
committerMyles Borins <mylesborins@google.com>2019-11-21 08:25:53 +0300
commit0d5de1a20ecde17394991a196586c74d611ef4d2 (patch)
tree82b8ebca283fe9531d0b2628bb618839ddd22813 /src/node_worker.cc
parent2952c5d72be362141e2ffbbb78a52fa19d35f1d0 (diff)
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 Backport-PR-URL: https://github.com/nodejs/node/pull/30513 PR-URL: https://github.com/nodejs/node/pull/30020 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_worker.cc')
-rw-r--r--src/node_worker.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc
index f1b2347d29c..3d3838d7969 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<ArrayBufferAllocator> Worker::array_buffer_allocator() {
- return array_buffer_allocator_;
-}
-
void Worker::UpdateResourceConstraints(ResourceConstraints* constraints) {
constraints->set_stack_limit(reinterpret_cast<uint32_t*>(stack_base_));
@@ -138,9 +133,11 @@ class WorkerThreadData {
: w_(w) {
CHECK_EQ(uv_loop_init(&loop_), 0);
+ std::shared_ptr<ArrayBufferAllocator> allocator =
+ ArrayBufferAllocator::Create();
Isolate::CreateParams params;
SetIsolateCreateParamsForNode(&params);
- params.array_buffer_allocator = w->array_buffer_allocator_.get();
+ params.array_buffer_allocator = allocator.get();
w->UpdateResourceConstraints(&params.constraints);
@@ -153,6 +150,7 @@ class WorkerThreadData {
w->platform_->RegisterIsolate(isolate, &loop_);
Isolate::Initialize(isolate, params);
SetIsolateUpForNode(isolate);
+ isolate->SetArrayBufferAllocatorShared(allocator);
isolate->AddNearHeapLimitCallback(Worker::NearHeapLimit, w);
@@ -164,7 +162,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_));