diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-18 22:09:28 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-23 11:26:04 +0800 |
commit | bf5dadeef07250763948765e9902edd2ecee5448 (patch) | |
tree | ac7b81a4217ecd6d4f767c981db6ad4def233469 /src | |
parent | d7016679509cd7f2d50612369509e8797d8157b0 (diff) | |
download | android-node-v8-bf5dadeef07250763948765e9902edd2ecee5448.tar.gz android-node-v8-bf5dadeef07250763948765e9902edd2ecee5448.tar.bz2 android-node-v8-bf5dadeef07250763948765e9902edd2ecee5448.zip |
src: enable snapshot with per-isolate data
Enable serializing the isolate from an isolate snapshot generated
by node_mksnapshot with per-isolate data.
PR-URL: https://github.com/nodejs/node/pull/27321
Refs: https://github.com/nodejs/node/issues/17058
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 15 | ||||
-rw-r--r-- | src/node_main_instance.cc | 1 | ||||
-rw-r--r-- | src/node_main_instance.h | 5 | ||||
-rw-r--r-- | src/node_snapshot_stub.cc | 13 |
4 files changed, 33 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc index 9e969d33dc..66e6db7472 100644 --- a/src/node.cc +++ b/src/node.cc @@ -887,11 +887,24 @@ int Start(int argc, char** argv) { { Isolate::CreateParams params; + // TODO(joyeecheung): collect external references and set it in + // params.external_references. + std::vector<intptr_t> external_references = { + reinterpret_cast<intptr_t>(nullptr)}; + v8::StartupData* blob = NodeMainInstance::GetEmbeddedSnapshotBlob(); + const NodeMainInstance::IndexArray* indexes = + NodeMainInstance::GetIsolateDataIndexes(); + if (blob != nullptr) { + params.external_references = external_references.data(); + params.snapshot_blob = blob; + } + NodeMainInstance main_instance(¶ms, uv_default_loop(), per_process::v8_platform.Platform(), result.args, - result.exec_args); + result.exec_args, + indexes); result.exit_code = main_instance.Run(); } diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 11dfadabb9..419fd76772 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -175,6 +175,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment( if (deserialize_mode_) { SetIsolateUpForNode(isolate_, IsolateSettingCategories::kErrorHandlers); } + CHECK(!context.IsEmpty()); Context::Scope context_scope(context); diff --git a/src/node_main_instance.h b/src/node_main_instance.h index 615fda1f49..98c17cc8f0 100644 --- a/src/node_main_instance.h +++ b/src/node_main_instance.h @@ -70,6 +70,11 @@ class NodeMainInstance { // and the environment creation routine in workers somehow. std::unique_ptr<Environment> CreateMainEnvironment(int* exit_code); + // If nullptr is returned, the binary is not built with embedded + // snapshot. + static const IndexArray* GetIsolateDataIndexes(); + static v8::StartupData* GetEmbeddedSnapshotBlob(); + private: NodeMainInstance(const NodeMainInstance&) = delete; NodeMainInstance& operator=(const NodeMainInstance&) = delete; diff --git a/src/node_snapshot_stub.cc b/src/node_snapshot_stub.cc new file mode 100644 index 0000000000..c0604237d5 --- /dev/null +++ b/src/node_snapshot_stub.cc @@ -0,0 +1,13 @@ +#include "node_main_instance.h" + +namespace node { + +v8::StartupData* NodeMainInstance::GetEmbeddedSnapshotBlob() { + return nullptr; +} + +const NodeMainInstance::IndexArray* NodeMainInstance::GetIsolateDataIndexes() { + return nullptr; +} + +} // namespace node |