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>2020-04-21 02:32:31 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2020-07-18 06:23:15 +0300
commit0b8ae5f2cd45a5fcbe46dc7fa7cdae93386e23f0 (patch)
tree21e15255c9f75ab5a872af17bc9897336e94499a /src
parent7ecb285842361de721a9d7c7d2a0535170b132dd (diff)
src: snapshot loaders
This runs `lib/internal/bootstrap/loaders.js` before creating the builtin snapshot and deserialize the loaders from the snapshot in deserialization mode. PR-URL: https://github.com/nodejs/node/pull/32984 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_binding.cc11
-rw-r--r--src/node_external_reference.h5
-rw-r--r--src/node_main_instance.cc9
-rw-r--r--src/node_native_module_env.cc14
-rw-r--r--src/node_native_module_env.h2
5 files changed, 38 insertions, 3 deletions
diff --git a/src/node_binding.cc b/src/node_binding.cc
index 80ab4e69e11..4dbf56b99a3 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -1,7 +1,8 @@
#include "node_binding.h"
-#include "node_errors.h"
#include <atomic>
#include "env-inl.h"
+#include "node_errors.h"
+#include "node_external_reference.h"
#include "node_native_module_env.h"
#include "util.h"
@@ -676,5 +677,13 @@ void RegisterBuiltinModules() {
#undef V
}
+void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
+ registry->Register(GetLinkedBinding);
+ registry->Register(GetInternalBinding);
+}
+
} // namespace binding
} // namespace node
+
+NODE_MODULE_EXTERNAL_REFERENCE(binding,
+ node::binding::RegisterExternalReferences)
diff --git a/src/node_external_reference.h b/src/node_external_reference.h
index 29dd4cb91ed..8c97eca2264 100644
--- a/src/node_external_reference.h
+++ b/src/node_external_reference.h
@@ -46,7 +46,10 @@ class ExternalReferenceRegistry {
std::vector<intptr_t> external_references_;
};
-#define EXTERNAL_REFERENCE_BINDING_LIST_BASE(V) V(process_object)
+#define EXTERNAL_REFERENCE_BINDING_LIST_BASE(V) \
+ V(binding) \
+ V(native_module) \
+ V(process_object)
#define EXTERNAL_REFERENCE_BINDING_LIST(V) \
EXTERNAL_REFERENCE_BINDING_LIST_BASE(V)
diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc
index 9fefc371d66..617a71e7cac 100644
--- a/src/node_main_instance.cc
+++ b/src/node_main_instance.cc
@@ -259,10 +259,17 @@ NodeMainInstance::CreateMainEnvironment(int* exit_code,
env->InitializeInspector({});
#endif
- if (env->RunBootstrapping().IsEmpty()) {
+ if (!deserialize_mode_ && env->RunBootstrapping().IsEmpty()) {
return nullptr;
}
+ if (deserialize_mode_ && env->BootstrapNode().IsEmpty()) {
+ return nullptr;
+ }
+
+ CHECK(env->req_wrap_queue()->IsEmpty());
+ CHECK(env->handle_wrap_queue()->IsEmpty());
+ env->set_has_run_bootstrapping_code(true);
return env;
}
diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc
index e38529eefae..b59ed7cb75c 100644
--- a/src/node_native_module_env.cc
+++ b/src/node_native_module_env.cc
@@ -1,5 +1,6 @@
#include "node_native_module_env.h"
#include "env-inl.h"
+#include "node_external_reference.h"
namespace node {
namespace native_module {
@@ -216,8 +217,21 @@ void NativeModuleEnv::Initialize(Local<Object> target,
target->SetIntegrityLevel(context, IntegrityLevel::kFrozen).FromJust();
}
+void NativeModuleEnv::RegisterExternalReferences(
+ ExternalReferenceRegistry* registry) {
+ registry->Register(ConfigStringGetter);
+ registry->Register(ModuleIdsGetter);
+ registry->Register(GetModuleCategories);
+ registry->Register(GetCacheUsage);
+ registry->Register(CompileFunction);
+ registry->Register(HasCachedBuiltins);
+}
+
} // namespace native_module
} // namespace node
NODE_MODULE_CONTEXT_AWARE_INTERNAL(
native_module, node::native_module::NativeModuleEnv::Initialize)
+NODE_MODULE_EXTERNAL_REFERENCE(
+ native_module,
+ node::native_module::NativeModuleEnv::RegisterExternalReferences)
diff --git a/src/node_native_module_env.h b/src/node_native_module_env.h
index bc36be75109..0a53771ff5d 100644
--- a/src/node_native_module_env.h
+++ b/src/node_native_module_env.h
@@ -7,6 +7,7 @@
namespace node {
class Environment;
+class ExternalReferenceRegistry;
namespace native_module {
@@ -14,6 +15,7 @@ extern const bool has_code_cache;
class NativeModuleEnv {
public:
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
static void Initialize(v8::Local<v8::Object> target,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,