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
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2022-04-11 20:55:55 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2022-04-19 21:21:26 +0300
commit2baf025545f436f50ff3c283aceca9926bb43d16 (patch)
tree20626709db40a440b1baf6a48f542f5f1aa45113 /src
parent43d2e247c7c198fcbbded3e13fa3996687848660 (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.cc15
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(&params);
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, &params);
+ }
w->UpdateResourceConstraints(&params.constraints);
Isolate* isolate = Isolate::Allocate();