From 87fb6b91698ba57cce4a8ca7aa5e5c66aadf0ec1 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 01:45:50 +0200 Subject: [PATCH] bootstrap: support module_wrap binding in snapshot PR-URL: https://github.com/nodejs/node/pull/45849 Backport-PR-URL: https://github.com/nodejs/node/pull/46425 Reviewed-By: Geoffrey Booth Reviewed-By: Chengzhong Wu --- graal-nodejs/src/module_wrap.cc | 20 ++++++++++++++++++++ graal-nodejs/src/module_wrap.h | 2 ++ graal-nodejs/src/node_external_reference.h | 1 + 3 files changed, 23 insertions(+) diff --git a/graal-nodejs/src/module_wrap.cc b/graal-nodejs/src/module_wrap.cc index 0645b3ddf50..9b2b0b8334d 100644 --- a/graal-nodejs/src/module_wrap.cc +++ b/graal-nodejs/src/module_wrap.cc @@ -4,6 +4,7 @@ #include "memory_tracker-inl.h" #include "node_contextify.h" #include "node_errors.h" +#include "node_external_reference.h" #include "node_internals.h" #include "node_process-inl.h" #include "node_watchdog.h" @@ -808,8 +809,27 @@ void ModuleWrap::Initialize(Local target, #undef V } +void ModuleWrap::RegisterExternalReferences( + ExternalReferenceRegistry* registry) { + registry->Register(New); + + registry->Register(Link); + registry->Register(Instantiate); + registry->Register(Evaluate); + registry->Register(SetSyntheticExport); + registry->Register(CreateCachedData); + registry->Register(GetNamespace); + registry->Register(GetStatus); + registry->Register(GetError); + registry->Register(GetStaticDependencySpecifiers); + + registry->Register(SetImportModuleDynamicallyCallback); + registry->Register(SetInitializeImportMetaObjectCallback); +} } // namespace loader } // namespace node NODE_BINDING_CONTEXT_AWARE_INTERNAL(module_wrap, node::loader::ModuleWrap::Initialize) +NODE_BINDING_EXTERNAL_REFERENCE( + module_wrap, node::loader::ModuleWrap::RegisterExternalReferences) diff --git a/graal-nodejs/src/module_wrap.h b/graal-nodejs/src/module_wrap.h index 58b233d0365..c609ba5509d 100644 --- a/graal-nodejs/src/module_wrap.h +++ b/graal-nodejs/src/module_wrap.h @@ -11,6 +11,7 @@ namespace node { class Environment; +class ExternalReferenceRegistry; namespace contextify { class ContextifyContext; @@ -44,6 +45,7 @@ class ModuleWrap : public BaseObject { v8::Local unused, v8::Local context, void* priv); + static void RegisterExternalReferences(ExternalReferenceRegistry* registry); static void HostInitializeImportMetaObjectCallback( v8::Local context, v8::Local module, diff --git a/graal-nodejs/src/node_external_reference.h b/graal-nodejs/src/node_external_reference.h index 954bb233e94..0b594967732 100644 --- a/graal-nodejs/src/node_external_reference.h +++ b/graal-nodejs/src/node_external_reference.h @@ -74,6 +74,7 @@ class ExternalReferenceRegistry { V(heap_utils) \ V(messaging) \ V(mksnapshot) \ + V(module_wrap) \ V(options) \ V(os) \ V(performance) \