Skip to content

Commit

Permalink
bootstrap: support module_wrap binding in snapshot
Browse files Browse the repository at this point in the history
PR-URL: #45849
Backport-PR-URL: #46425
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed Nov 10, 2023
1 parent 6466acb commit c3f56a3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -808,8 +809,27 @@ void ModuleWrap::Initialize(Local<Object> 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)
2 changes: 2 additions & 0 deletions src/module_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace node {

class Environment;
class ExternalReferenceRegistry;

namespace contextify {
class ContextifyContext;
Expand Down Expand Up @@ -44,6 +45,7 @@ class ModuleWrap : public BaseObject {
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv);
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
static void HostInitializeImportMetaObjectCallback(
v8::Local<v8::Context> context,
v8::Local<v8::Module> module,
Expand Down
1 change: 1 addition & 0 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ExternalReferenceRegistry {
V(heap_utils) \
V(messaging) \
V(mksnapshot) \
V(module_wrap) \
V(options) \
V(os) \
V(performance) \
Expand Down

0 comments on commit c3f56a3

Please sign in to comment.