diff --git a/src/node_binding.cc b/src/node_binding.cc index 80ab4e69e110d0..4dbf56b99a3ddb 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -1,7 +1,8 @@ #include "node_binding.h" -#include "node_errors.h" #include #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 29dd4cb91ed663..8c97eca2264a60 100644 --- a/src/node_external_reference.h +++ b/src/node_external_reference.h @@ -46,7 +46,10 @@ class ExternalReferenceRegistry { std::vector 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 9fefc371d66ab4..617a71e7cac60d 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 e38529eefae9c4..b59ed7cb75cf67 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 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 bc36be75109639..0a53771ff5d1ca 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 target, v8::Local unused, v8::Local context, diff --git a/tools/snapshot/snapshot_builder.cc b/tools/snapshot/snapshot_builder.cc index 7086a98a6c80c8..364202711105a4 100644 --- a/tools/snapshot/snapshot_builder.cc +++ b/tools/snapshot/snapshot_builder.cc @@ -130,6 +130,7 @@ std::string SnapshotBuilder::Generate( nullptr, node::EnvironmentFlags::kDefaultFlags, {}); + env->BootstrapInternalLoaders().ToLocalChecked(); if (per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) { env->PrintAllBaseObjects(); printf("Environment = %p\n", env);