diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2022-04-11 20:55:55 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2022-04-28 07:56:13 +0300 |
commit | 6bd24204ea14a87046ad845ad34060f0f371b522 (patch) | |
tree | d5959bbbac0db314b3b4838029832ed3a77d09b7 /src | |
parent | 29c8411f992a74682fad4a6715452161b64a739b (diff) |
bootstrap: use the isolate snapshot in workers
PR-URL: https://github.com/nodejs/node/pull/42702
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_worker.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc index c9743fcf583..04cd60b2453 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -7,6 +7,7 @@ #include "node_buffer.h" #include "node_options-inl.h" #include "node_perf.h" +#include "node_snapshot_builder.h" #include "util-inl.h" #include "async_wrap-inl.h" @@ -146,6 +147,20 @@ class WorkerThreadData { SetIsolateCreateParamsForNode(¶ms); params.array_buffer_allocator_shared = allocator; + bool use_node_snapshot = true; + if (w_->per_isolate_opts_) { + use_node_snapshot = w_->per_isolate_opts_->node_snapshot; + } else { + // IsolateData is created after the Isolate is created so we'll + // inherit the option from the parent here. + use_node_snapshot = per_process::cli_options->per_isolate->node_snapshot; + } + const SnapshotData* snapshot_data = + use_node_snapshot ? SnapshotBuilder::GetEmbeddedSnapshotData() + : nullptr; + if (snapshot_data != nullptr) { + SnapshotBuilder::InitializeIsolateParams(snapshot_data, ¶ms); + } w->UpdateResourceConstraints(¶ms.constraints); Isolate* isolate = Isolate::Allocate(); |