summaryrefslogtreecommitdiff
path: root/src/node_main_instance.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-18 16:25:32 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-23 11:25:59 +0800
commitffcc949f1cb72c19e4c7db6704ae02d0f7dac232 (patch)
tree42d51f4026457404bf815b79f97792528dedb852 /src/node_main_instance.h
parent70d887e95717a6b89135bf5cfd7b6394f451abe7 (diff)
downloadandroid-node-v8-ffcc949f1cb72c19e4c7db6704ae02d0f7dac232.tar.gz
android-node-v8-ffcc949f1cb72c19e4c7db6704ae02d0f7dac232.tar.bz2
android-node-v8-ffcc949f1cb72c19e4c7db6704ae02d0f7dac232.zip
src: implement IsolateData serialization and deserialization
This patch allows serializing per-isolate data into an isolate snapshot and deserializing them from an isolate snapthot. 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/node_main_instance.h')
-rw-r--r--src/node_main_instance.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/node_main_instance.h b/src/node_main_instance.h
index 0a8be137a0..615fda1f49 100644
--- a/src/node_main_instance.h
+++ b/src/node_main_instance.h
@@ -15,6 +15,18 @@ namespace node {
// We may be able to create an abstract class to reuse some of the routines.
class NodeMainInstance {
public:
+ // An array of indexes that can be used to deserialize data from a V8
+ // snapshot.
+ struct IndexArray {
+ const size_t* data;
+ size_t length;
+
+ size_t Get(size_t index) const {
+ DCHECK_LT(index, length);
+ return data[index];
+ }
+ };
+
// To create a main instance that does not own the isoalte,
// The caller needs to do:
//
@@ -45,12 +57,15 @@ class NodeMainInstance {
uv_loop_t* event_loop,
MultiIsolatePlatform* platform,
const std::vector<std::string>& args,
- const std::vector<std::string>& exec_args);
+ const std::vector<std::string>& exec_args,
+ const IndexArray* per_isolate_data_indexes = nullptr);
~NodeMainInstance();
// Start running the Node.js instances, return the exit code when finished.
int Run();
+ IsolateData* isolate_data() { return isolate_data_.get(); }
+
// TODO(joyeecheung): align this with the CreateEnvironment exposed in node.h
// and the environment creation routine in workers somehow.
std::unique_ptr<Environment> CreateMainEnvironment(int* exit_code);
@@ -66,6 +81,7 @@ class NodeMainInstance {
MultiIsolatePlatform* platform,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args);
+
std::vector<std::string> args_;
std::vector<std::string> exec_args_;
std::unique_ptr<ArrayBufferAllocator> array_buffer_allocator_;
@@ -73,6 +89,7 @@ class NodeMainInstance {
MultiIsolatePlatform* platform_;
std::unique_ptr<IsolateData> isolate_data_;
bool owns_isolate_ = false;
+ bool deserialize_mode_ = false;
};
} // namespace node