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>2021-05-13 19:58:19 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2021-05-19 20:16:00 +0300
commit527da94a3e39c95c3acbc599772d45d57ce3b1fd (patch)
treed0cfced15d9abbd12815de46d6ac527cf6e17c7b /src
parent5d7b6c249740824035aa779bceb20b738ae587fd (diff)
bootstrap: include vm and contextify binding into the snapshot
In addition, defer the patching of the vm module based on the value of --experimental-vm-modules to runtime. PR-URL: https://github.com/nodejs/node/pull/38677 Refs: https://github.com/nodejs/node/issues/35711 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_contextify.cc39
-rw-r--r--src/node_contextify.h5
-rw-r--r--src/node_external_reference.h1
3 files changed, 41 insertions, 4 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 23895382b33..6e2b167da58 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -21,13 +21,14 @@
#include "node_contextify.h"
-#include "memory_tracker-inl.h"
-#include "node_internals.h"
-#include "node_watchdog.h"
#include "base_object-inl.h"
+#include "memory_tracker-inl.h"
+#include "module_wrap.h"
#include "node_context_data.h"
#include "node_errors.h"
-#include "module_wrap.h"
+#include "node_external_reference.h"
+#include "node_internals.h"
+#include "node_watchdog.h"
#include "util-inl.h"
namespace node {
@@ -255,6 +256,12 @@ void ContextifyContext::Init(Environment* env, Local<Object> target) {
env->SetMethod(target, "compileFunction", CompileFunction);
}
+void ContextifyContext::RegisterExternalReferences(
+ ExternalReferenceRegistry* registry) {
+ registry->Register(MakeContext);
+ registry->Register(IsContext);
+ registry->Register(CompileFunction);
+}
// makeContext(sandbox, name, origin, strings, wasm);
void ContextifyContext::MakeContext(const FunctionCallbackInfo<Value>& args) {
@@ -665,6 +672,14 @@ void ContextifyScript::Init(Environment* env, Local<Object> target) {
env->set_script_context_constructor_template(script_tmpl);
}
+void ContextifyScript::RegisterExternalReferences(
+ ExternalReferenceRegistry* registry) {
+ registry->Register(New);
+ registry->Register(CreateCachedData);
+ registry->Register(RunInContext);
+ registry->Register(RunInThisContext);
+}
+
void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
@@ -1293,6 +1308,10 @@ void MicrotaskQueueWrap::Init(Environment* env, Local<Object> target) {
env->SetConstructorFunction(target, "MicrotaskQueue", tmpl);
}
+void MicrotaskQueueWrap::RegisterExternalReferences(
+ ExternalReferenceRegistry* registry) {
+ registry->Register(New);
+}
void Initialize(Local<Object> target,
Local<Value> unused,
@@ -1347,7 +1366,19 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "measureMemory", MeasureMemory);
}
+void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
+ ContextifyContext::RegisterExternalReferences(registry);
+ ContextifyScript::RegisterExternalReferences(registry);
+ MicrotaskQueueWrap::RegisterExternalReferences(registry);
+
+ registry->Register(StartSigintWatchdog);
+ registry->Register(StopSigintWatchdog);
+ registry->Register(WatchdogHasPendingSigint);
+ registry->Register(MeasureMemory);
+}
} // namespace contextify
} // namespace node
NODE_MODULE_CONTEXT_AWARE_INTERNAL(contextify, node::contextify::Initialize)
+NODE_MODULE_EXTERNAL_REFERENCE(contextify,
+ node::contextify::RegisterExternalReferences)
diff --git a/src/node_contextify.h b/src/node_contextify.h
index 357029d8e18..08ee97df777 100644
--- a/src/node_contextify.h
+++ b/src/node_contextify.h
@@ -8,6 +8,8 @@
#include "node_errors.h"
namespace node {
+class ExternalReferenceRegistry;
+
namespace contextify {
class MicrotaskQueueWrap : public BaseObject {
@@ -17,6 +19,7 @@ class MicrotaskQueueWrap : public BaseObject {
const std::shared_ptr<v8::MicrotaskQueue>& microtask_queue() const;
static void Init(Environment* env, v8::Local<v8::Object> target);
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
// This could have methods for running the microtask queue, if we ever decide
@@ -52,6 +55,7 @@ class ContextifyContext {
v8::Local<v8::Object> sandbox_obj,
const ContextOptions& options);
static void Init(Environment* env, v8::Local<v8::Object> target);
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
static ContextifyContext* ContextFromContextifiedSandbox(
Environment* env,
@@ -141,6 +145,7 @@ class ContextifyScript : public BaseObject {
~ContextifyScript() override;
static void Init(Environment* env, v8::Local<v8::Object> target);
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static bool InstanceOf(Environment* env, const v8::Local<v8::Value>& args);
static void CreateCachedData(
diff --git a/src/node_external_reference.h b/src/node_external_reference.h
index 316d1d7b865..5f64870178f 100644
--- a/src/node_external_reference.h
+++ b/src/node_external_reference.h
@@ -50,6 +50,7 @@ class ExternalReferenceRegistry {
V(async_wrap) \
V(binding) \
V(buffer) \
+ V(contextify) \
V(credentials) \
V(env_var) \
V(errors) \