Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a2c1c3e

Browse filesBrowse files
joyeecheungBethGriggs
authored andcommitted
src: register external references of BaseObject for snapshot
PR-URL: #39961 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent 6fdf025 commit a2c1c3e
Copy full SHA for a2c1c3e

File tree

Expand file treeCollapse file tree

3 files changed

+14
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-7
lines changed
Open diff view settings
Collapse file

‎src/base_object-inl.h‎

Copy file name to clipboardExpand all lines: src/base_object-inl.h
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,17 @@ bool BaseObject::IsWeakOrDetached() const {
148148
return pd->wants_weak_jsobj || pd->is_detached;
149149
}
150150

151+
void BaseObject::LazilyInitializedJSTemplateConstructor(
152+
const v8::FunctionCallbackInfo<v8::Value>& args) {
153+
DCHECK(args.IsConstructCall());
154+
DCHECK_GT(args.This()->InternalFieldCount(), 0);
155+
args.This()->SetAlignedPointerInInternalField(BaseObject::kSlot, nullptr);
156+
}
157+
151158
v8::Local<v8::FunctionTemplate>
152159
BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
153-
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
154-
DCHECK(args.IsConstructCall());
155-
DCHECK_GT(args.This()->InternalFieldCount(), 0);
156-
args.This()->SetAlignedPointerInInternalField(BaseObject::kSlot, nullptr);
157-
};
158-
159-
v8::Local<v8::FunctionTemplate> t = env->NewFunctionTemplate(constructor);
160+
v8::Local<v8::FunctionTemplate> t =
161+
env->NewFunctionTemplate(LazilyInitializedJSTemplateConstructor);
160162
t->Inherit(BaseObject::GetConstructorTemplate(env));
161163
t->InstanceTemplate()->SetInternalFieldCount(
162164
BaseObject::kInternalFieldCount);
Collapse file

‎src/base_object.h‎

Copy file name to clipboardExpand all lines: src/base_object.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class BaseObject : public MemoryRetainer {
6565
// was also passed to the `BaseObject()` constructor initially.
6666
// This may return `nullptr` if the C++ object has not been constructed yet,
6767
// e.g. when the JS object used `MakeLazilyInitializedJSTemplate`.
68+
static inline void LazilyInitializedJSTemplateConstructor(
69+
const v8::FunctionCallbackInfo<v8::Value>& args);
6870
static inline BaseObject* FromJSObject(v8::Local<v8::Value> object);
6971
template <typename T>
7072
static inline T* FromJSObject(v8::Local<v8::Value> object);
Collapse file

‎src/node_external_reference.cc‎

Copy file name to clipboardExpand all lines: src/node_external_reference.cc
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "node_external_reference.h"
22
#include <cinttypes>
33
#include <vector>
4+
#include "base_object-inl.h"
45
#include "util.h"
56

67
namespace node {
@@ -13,6 +14,8 @@ const std::vector<intptr_t>& ExternalReferenceRegistry::external_references() {
1314
}
1415

1516
ExternalReferenceRegistry::ExternalReferenceRegistry() {
17+
this->Register(BaseObject::LazilyInitializedJSTemplateConstructor);
18+
1619
#define V(modname) _register_external_reference_##modname(this);
1720
EXTERNAL_REFERENCE_BINDING_LIST(V)
1821
#undef V

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.