summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--node.gyp29
-rw-r--r--src/node.cc15
-rw-r--r--src/node_main_instance.cc1
-rw-r--r--src/node_main_instance.h5
-rw-r--r--src/node_snapshot_stub.cc13
5 files changed, 62 insertions, 1 deletions
diff --git a/node.gyp b/node.gyp
index 8019a16599..82efba25d6 100644
--- a/node.gyp
+++ b/node.gyp
@@ -223,6 +223,7 @@
'deps/acorn/acorn/dist/acorn.js',
'deps/acorn/acorn-walk/dist/walk.js',
],
+ 'node_mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_mksnapshot<(EXECUTABLE_SUFFIX)',
'mkcodecache_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkcodecache<(EXECUTABLE_SUFFIX)',
'conditions': [
[ 'node_shared=="true"', {
@@ -430,6 +431,31 @@
'src/node_code_cache_stub.cc'
],
}],
+ ['want_separate_host_toolset==0', {
+ 'dependencies': [
+ 'node_mksnapshot',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'node_mksnapshot',
+ 'process_outputs_as_sources': 1,
+ 'inputs': [
+ '<(node_mksnapshot_exec)',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
+ ],
+ 'action': [
+ '<@(_inputs)',
+ '<@(_outputs)',
+ ],
+ },
+ ],
+ }, {
+ 'sources': [
+ 'src/node_snapshot_stub.cc'
+ ],
+ }],
],
}, # node_core_target_name
{
@@ -1038,6 +1064,7 @@
'defines': [ 'NODE_WANT_INTERNALS=1' ],
'sources': [
+ 'src/node_snapshot_stub.cc',
'src/node_code_cache_stub.cc',
'test/cctest/gtest/gtest-all.cc',
'test/cctest/gtest/gtest_main.cc',
@@ -1131,6 +1158,7 @@
'NODE_WANT_INTERNALS=1'
],
'sources': [
+ 'src/node_snapshot_stub.cc',
'src/node_code_cache_stub.cc',
'tools/code_cache/mkcodecache.cc',
'tools/code_cache/cache_builder.cc',
@@ -1180,6 +1208,7 @@
'defines': [ 'NODE_WANT_INTERNALS=1' ],
'sources': [
+ 'src/node_snapshot_stub.cc',
'src/node_code_cache_stub.cc',
'tools/snapshot/node_mksnapshot.cc',
'tools/snapshot/snapshot_builder.cc',
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(&params,
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