diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2022-04-11 19:38:57 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2022-04-28 07:56:12 +0300 |
commit | 29c8411f992a74682fad4a6715452161b64a739b (patch) | |
tree | a95e175680861e3b2e26b17a708102e7f5360ac5 /src/node_main_instance.cc | |
parent | 962d80b7a12c01b49033511989a1af89b9a3fa2f (diff) |
bootstrap: move embedded snapshot to SnapshotBuilder
So that the embedded snapshot can be reused by the worker.
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/node_main_instance.cc')
-rw-r--r-- | src/node_main_instance.cc | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 7167127c3db..e7218148ea0 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -7,6 +7,7 @@ #include "node_external_reference.h" #include "node_internals.h" #include "node_options-inl.h" +#include "node_snapshot_builder.h" #include "node_snapshotable.h" #include "node_v8_platform-inl.h" #include "util-inl.h" @@ -26,8 +27,6 @@ using v8::Isolate; using v8::Local; using v8::Locker; -std::unique_ptr<ExternalReferenceRegistry> NodeMainInstance::registry_ = - nullptr; NodeMainInstance::NodeMainInstance(Isolate* isolate, uv_loop_t* event_loop, MultiIsolatePlatform* platform, @@ -46,13 +45,6 @@ NodeMainInstance::NodeMainInstance(Isolate* isolate, SetIsolateMiscHandlers(isolate_, {}); } -const std::vector<intptr_t>& NodeMainInstance::CollectExternalReferences() { - // Cannot be called more than once. - CHECK_NULL(registry_); - registry_.reset(new ExternalReferenceRegistry()); - return registry_->external_references(); -} - std::unique_ptr<NodeMainInstance> NodeMainInstance::Create( Isolate* isolate, uv_loop_t* event_loop, @@ -78,13 +70,8 @@ NodeMainInstance::NodeMainInstance(const SnapshotData* snapshot_data, snapshot_data_(snapshot_data) { isolate_params_->array_buffer_allocator = array_buffer_allocator_.get(); if (snapshot_data != nullptr) { - // TODO(joyeecheung): collect external references and set it in - // params.external_references. - const std::vector<intptr_t>& external_references = - CollectExternalReferences(); - isolate_params_->external_references = external_references.data(); - isolate_params_->snapshot_blob = - const_cast<v8::StartupData*>(&(snapshot_data->blob)); + SnapshotBuilder::InitializeIsolateParams(snapshot_data, + isolate_params_.get()); } isolate_ = Isolate::Allocate(); |