mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
src: make AsyncWrap subclass internal field counts explicit
This helps ensure that we already set the correct number of internal fields when creating objects, even if the number of internal fields of e.g. AsyncWrap changes over time. PR-URL: https://github.com/nodejs/node/pull/62103 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
1 parent
9e6dfe6435
commit
fbfbc83809
32 files changed
+129
-55
No files matched your search
@@ -89,6 +89,15 @@ inline v8::Local<v8::FunctionTemplate> AsyncWrap::GetConstructorTemplate(
|
||||
return GetConstructorTemplate(env->isolate_data());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::FunctionTemplate> AsyncWrap::MakeLazilyInitializedJSTemplate(
|
||||
Environment* env, int internal_field_count) {
|
||||
v8::Local<v8::FunctionTemplate> t =
|
||||
BaseObject::MakeLazilyInitializedJSTemplate(env, internal_field_count);
|
||||
t->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
return t;
|
||||
}
|
||||
|
||||
} // namespace node
|
||||
|
||||
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
||||
|
||||
@@ -115,6 +115,10 @@ class ExternalReferenceRegistry;
|
||||
|
||||
class AsyncWrap : public BaseObject {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = BaseObject::kInternalFieldCount,
|
||||
};
|
||||
|
||||
enum ProviderType {
|
||||
#define V(PROVIDER) \
|
||||
PROVIDER_ ## PROVIDER,
|
||||
@@ -228,6 +232,9 @@ class AsyncWrap : public BaseObject {
|
||||
|
||||
bool IsDoneInitializing() const override;
|
||||
|
||||
static inline v8::Local<v8::FunctionTemplate> MakeLazilyInitializedJSTemplate(
|
||||
Environment* env, int internal_field_count = kInternalFieldCount);
|
||||
|
||||
private:
|
||||
ProviderType provider_type_ = PROVIDER_NONE;
|
||||
bool init_hook_ran_ = false;
|
||||
|
||||
+5
-4
@@ -81,15 +81,16 @@ void BaseObject::LazilyInitializedJSTemplateConstructor(
|
||||
}
|
||||
|
||||
Local<FunctionTemplate> BaseObject::MakeLazilyInitializedJSTemplate(
|
||||
Environment* env) {
|
||||
return MakeLazilyInitializedJSTemplate(env->isolate_data());
|
||||
Environment* env, int internal_field_count) {
|
||||
return MakeLazilyInitializedJSTemplate(env->isolate_data(),
|
||||
internal_field_count);
|
||||
}
|
||||
|
||||
Local<FunctionTemplate> BaseObject::MakeLazilyInitializedJSTemplate(
|
||||
IsolateData* isolate_data) {
|
||||
IsolateData* isolate_data, int internal_field_count) {
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(
|
||||
isolate_data->isolate(), LazilyInitializedJSTemplateConstructor);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(BaseObject::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(internal_field_count);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -106,9 +106,9 @@ class BaseObject : public MemoryRetainer {
|
||||
// the `BaseObject*` pointer) and a constructor that initializes that field
|
||||
// to `nullptr`.
|
||||
static v8::Local<v8::FunctionTemplate> MakeLazilyInitializedJSTemplate(
|
||||
IsolateData* isolate);
|
||||
IsolateData* isolate, int internal_field_count = kInternalFieldCount);
|
||||
static v8::Local<v8::FunctionTemplate> MakeLazilyInitializedJSTemplate(
|
||||
Environment* env);
|
||||
Environment* env, int internal_field_count = kInternalFieldCount);
|
||||
|
||||
// Setter/Getter pair for internal fields that can be passed to SetAccessor.
|
||||
template <int Field>
|
||||
|
||||
+3
-9
@@ -2219,19 +2219,13 @@ void Initialize(Local<Object> target,
|
||||
NODE_DEFINE_CONSTANT(target, DNS_ORDER_IPV4_FIRST);
|
||||
NODE_DEFINE_CONSTANT(target, DNS_ORDER_IPV6_FIRST);
|
||||
|
||||
Local<FunctionTemplate> aiw =
|
||||
BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
aiw->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<FunctionTemplate> aiw = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
SetConstructorFunction(context, target, "GetAddrInfoReqWrap", aiw);
|
||||
|
||||
Local<FunctionTemplate> niw =
|
||||
BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
niw->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<FunctionTemplate> niw = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
SetConstructorFunction(context, target, "GetNameInfoReqWrap", niw);
|
||||
|
||||
Local<FunctionTemplate> qrw =
|
||||
BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
qrw->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<FunctionTemplate> qrw = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
SetConstructorFunction(context, target, "QueryReqWrap", qrw);
|
||||
|
||||
Local<FunctionTemplate> channel_wrap =
|
||||
|
||||
@@ -1081,7 +1081,7 @@ void NativeKeyObject::CreateNativeKeyObjectClass(
|
||||
Local<FunctionTemplate> t =
|
||||
NewFunctionTemplate(isolate, NativeKeyObject::New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(
|
||||
KeyObjectHandle::kInternalFieldCount);
|
||||
NativeKeyObject::kInternalFieldCount);
|
||||
|
||||
Local<Value> ctor;
|
||||
if (!t->GetFunction(env->context()).ToLocal(&ctor))
|
||||
|
||||
@@ -323,7 +323,7 @@ void Sign::Initialize(Environment* env, Local<Object> target) {
|
||||
Isolate* isolate = env->isolate();
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
|
||||
t->InstanceTemplate()->SetInternalFieldCount(SignBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(Sign::kInternalFieldCount);
|
||||
|
||||
SetProtoMethod(isolate, t, "init", SignInit);
|
||||
SetProtoMethod(isolate, t, "update", SignUpdate);
|
||||
@@ -458,7 +458,7 @@ void Verify::Initialize(Environment* env, Local<Object> target) {
|
||||
Isolate* isolate = env->isolate();
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
|
||||
t->InstanceTemplate()->SetInternalFieldCount(SignBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(Verify::kInternalFieldCount);
|
||||
|
||||
SetProtoMethod(isolate, t, "init", VerifyInit);
|
||||
SetProtoMethod(isolate, t, "update", VerifyUpdate);
|
||||
|
||||
@@ -2186,11 +2186,11 @@ void TLSWrap::Initialize(
|
||||
|
||||
NODE_DEFINE_CONSTANT(target, HAVE_SSL_TRACE);
|
||||
|
||||
Local<FunctionTemplate> t = BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
Local<FunctionTemplate> t = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
Local<String> tlsWrapString =
|
||||
FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap");
|
||||
t->SetClassName(tlsWrapString);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(TLSWrap::kInternalFieldCount);
|
||||
|
||||
Local<FunctionTemplate> get_write_queue_size =
|
||||
FunctionTemplate::New(env->isolate(),
|
||||
|
||||
@@ -43,6 +43,11 @@ class TLSWrap : public AsyncWrap,
|
||||
public StreamBase,
|
||||
public StreamListener {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(AsyncWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
enum class Kind {
|
||||
kClient,
|
||||
kServer
|
||||
|
||||
@@ -405,7 +405,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
|
||||
v8::Local<v8::FunctionTemplate> job = NewFunctionTemplate(isolate, new_fn);
|
||||
job->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
job->InstanceTemplate()->SetInternalFieldCount(
|
||||
AsyncWrap::kInternalFieldCount);
|
||||
CryptoJob::kInternalFieldCount);
|
||||
SetProtoMethod(isolate, job, "run", Run);
|
||||
SetConstructorFunction(context, target, CryptoJobTraits::JobName, job);
|
||||
}
|
||||
|
||||
@@ -843,7 +843,7 @@ Local<FunctionTemplate> X509Certificate::GetConstructorTemplate(
|
||||
Isolate* isolate = env->isolate();
|
||||
tmpl = NewFunctionTemplate(isolate, nullptr);
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
BaseObject::kInternalFieldCount);
|
||||
X509Certificate::kInternalFieldCount);
|
||||
tmpl->SetClassName(
|
||||
FIXED_ONE_BYTE_STRING(env->isolate(), "X509Certificate"));
|
||||
SetProtoMethodNoSideEffect(isolate, tmpl, "subject", Subject);
|
||||
|
||||
+6
-1
@@ -269,6 +269,11 @@ class HeapSnapshotStream : public AsyncWrap,
|
||||
public StreamBase,
|
||||
public v8::OutputStream {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(AsyncWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
HeapSnapshotStream(
|
||||
Environment* env,
|
||||
HeapSnapshotPointer&& snapshot,
|
||||
@@ -403,7 +408,7 @@ BaseObjectPtr<AsyncWrap> CreateHeapSnapshotStream(
|
||||
Local<FunctionTemplate> os = FunctionTemplate::New(env->isolate());
|
||||
os->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<ObjectTemplate> ost = os->InstanceTemplate();
|
||||
ost->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
ost->SetInternalFieldCount(HeapSnapshotStream::kInternalFieldCount);
|
||||
os->SetClassName(
|
||||
FIXED_ONE_BYTE_STRING(env->isolate(), "HeapSnapshotStream"));
|
||||
StreamBase::AddMethods(env, os);
|
||||
|
||||
+2
-2
@@ -270,7 +270,7 @@ Local<FunctionTemplate> HistogramBase::GetConstructorTemplate(
|
||||
Local<String> classname = FIXED_ONE_BYTE_STRING(isolate, "Histogram");
|
||||
tmpl->SetClassName(classname);
|
||||
auto instance = tmpl->InstanceTemplate();
|
||||
instance->SetInternalFieldCount(HistogramImpl::kInternalFieldCount);
|
||||
instance->SetInternalFieldCount(HistogramBase::kInternalFieldCount);
|
||||
SetFastMethod(isolate, instance, "record", Record, &fast_record_);
|
||||
SetFastMethod(
|
||||
isolate, instance, "recordDelta", RecordDelta, &fast_record_delta_);
|
||||
@@ -326,7 +326,7 @@ Local<FunctionTemplate> IntervalHistogram::GetConstructorTemplate(
|
||||
tmpl->Inherit(HandleWrap::GetConstructorTemplate(env));
|
||||
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "Histogram"));
|
||||
auto instance = tmpl->InstanceTemplate();
|
||||
instance->SetInternalFieldCount(HistogramImpl::kInternalFieldCount);
|
||||
instance->SetInternalFieldCount(IntervalHistogram::kInternalFieldCount);
|
||||
HistogramImpl::AddMethods(isolate, tmpl);
|
||||
SetFastMethod(isolate, instance, "start", Start, &fast_start_);
|
||||
SetFastMethod(isolate, instance, "stop", Stop, &fast_stop_);
|
||||
|
||||
+11
-1
@@ -71,7 +71,7 @@ class HistogramImpl {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kSlot = BaseObject::kSlot,
|
||||
kImplField = BaseObject::kInternalFieldCount,
|
||||
kImplField = HandleWrap::kInternalFieldCount,
|
||||
kInternalFieldCount
|
||||
};
|
||||
|
||||
@@ -133,6 +133,11 @@ class HistogramImpl {
|
||||
|
||||
class HistogramBase final : public BaseObject, public HistogramImpl {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(
|
||||
BaseObject::kInternalFieldCount, HistogramImpl::kInternalFieldCount),
|
||||
};
|
||||
|
||||
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
|
||||
IsolateData* isolate_data);
|
||||
static void Initialize(IsolateData* isolate_data,
|
||||
@@ -203,6 +208,11 @@ class HistogramBase final : public BaseObject, public HistogramImpl {
|
||||
|
||||
class IntervalHistogram final : public HandleWrap, public HistogramImpl {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(
|
||||
HandleWrap::kInternalFieldCount, HistogramImpl::kInternalFieldCount),
|
||||
};
|
||||
|
||||
enum class StartFlags {
|
||||
NONE,
|
||||
RESET
|
||||
|
||||
+1
-2
@@ -210,8 +210,7 @@ void JSStream::Initialize(Local<Object> target,
|
||||
Isolate* isolate = env->isolate();
|
||||
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
t->InstanceTemplate()
|
||||
->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(JSStream::kInternalFieldCount);
|
||||
t->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
|
||||
SetProtoMethod(isolate, t, "finishWrite", Finish<WriteWrap>);
|
||||
|
||||
@@ -12,6 +12,11 @@ class Environment;
|
||||
|
||||
class JSStream : public AsyncWrap, public StreamBase {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(AsyncWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
static void Initialize(v8::Local<v8::Object> target,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
|
||||
+2
-3
@@ -146,8 +146,7 @@ Local<FunctionTemplate> Blob::GetConstructorTemplate(Environment* env) {
|
||||
if (tmpl.IsEmpty()) {
|
||||
Isolate* isolate = env->isolate();
|
||||
tmpl = NewFunctionTemplate(isolate, nullptr);
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
BaseObject::kInternalFieldCount);
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(Blob::kInternalFieldCount);
|
||||
tmpl->SetClassName(
|
||||
FIXED_ONE_BYTE_STRING(env->isolate(), "Blob"));
|
||||
SetProtoMethod(isolate, tmpl, "getReader", GetReader);
|
||||
@@ -309,7 +308,7 @@ Local<FunctionTemplate> Blob::Reader::GetConstructorTemplate(Environment* env) {
|
||||
Isolate* isolate = env->isolate();
|
||||
tmpl = NewFunctionTemplate(isolate, nullptr);
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
BaseObject::kInternalFieldCount);
|
||||
Blob::Reader::kInternalFieldCount);
|
||||
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "BlobReader"));
|
||||
SetProtoMethod(env->isolate(), tmpl, "pull", Pull);
|
||||
env->set_blob_reader_constructor_template(tmpl);
|
||||
|
||||
+2
-1
@@ -321,7 +321,8 @@ class FileHandleReadWrap final : public ReqWrap<uv_fs_t> {
|
||||
class FileHandle final : public AsyncWrap, public StreamBase {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kFileHandleBaseField = StreamBase::kInternalFieldCount,
|
||||
kFileHandleBaseField = std::max<uint32_t>(AsyncWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
kClosingPromiseSlot,
|
||||
kInternalFieldCount
|
||||
};
|
||||
|
||||
+2
-2
@@ -3508,7 +3508,7 @@ void Initialize(Local<Object> target,
|
||||
Local<FunctionTemplate> setting = FunctionTemplate::New(env->isolate());
|
||||
setting->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<ObjectTemplate> settingt = setting->InstanceTemplate();
|
||||
settingt->SetInternalFieldCount(AsyncWrap::kInternalFieldCount);
|
||||
settingt->SetInternalFieldCount(Http2Settings::kInternalFieldCount);
|
||||
env->set_http2settings_constructor_template(settingt);
|
||||
|
||||
Local<FunctionTemplate> stream = FunctionTemplate::New(env->isolate());
|
||||
@@ -3524,7 +3524,7 @@ void Initialize(Local<Object> target,
|
||||
stream->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
StreamBase::AddMethods(env, stream);
|
||||
Local<ObjectTemplate> streamt = stream->InstanceTemplate();
|
||||
streamt->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
streamt->SetInternalFieldCount(Http2Stream::kInternalFieldCount);
|
||||
env->set_http2stream_constructor_template(streamt);
|
||||
SetConstructorFunction(context, target, "Http2Stream", stream);
|
||||
|
||||
|
||||
@@ -270,6 +270,11 @@ using Http2Header = NgHeader<Http2HeaderTraits>;
|
||||
class Http2Stream : public AsyncWrap,
|
||||
public StreamBase {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(AsyncWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
static Http2Stream* New(
|
||||
Http2Session* session,
|
||||
int32_t id,
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
extern "C" {
|
||||
int nodedbg_const_ContextEmbedderIndex__kEnvironment__int;
|
||||
int nodedbg_const_BaseObject__kInternalFieldCount__int;
|
||||
int nodedbg_const_HandleWrap__kInternalFieldCount__int;
|
||||
int nodedbg_const_ReqWrap__kInternalFieldCount__int;
|
||||
uintptr_t nodedbg_offset_ExternalString__data__uintptr_t;
|
||||
uintptr_t nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue;
|
||||
|
||||
@@ -54,6 +56,10 @@ int GenDebugSymbols() {
|
||||
ContextEmbedderIndex::kEnvironment;
|
||||
nodedbg_const_BaseObject__kInternalFieldCount__int =
|
||||
BaseObject::kInternalFieldCount;
|
||||
nodedbg_const_HandleWrap__kInternalFieldCount__int =
|
||||
HandleWrap::kInternalFieldCount;
|
||||
nodedbg_const_ReqWrap__kInternalFieldCount__int =
|
||||
ReqWrap<uv_req_t>::kInternalFieldCount;
|
||||
|
||||
nodedbg_offset_ExternalString__data__uintptr_t = NODE_OFF_EXTSTR_DATA;
|
||||
nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue =
|
||||
|
||||
+1
-1
@@ -2503,7 +2503,7 @@ Local<FunctionTemplate> StatementSyncIterator::GetConstructorTemplate(
|
||||
tmpl = NewFunctionTemplate(isolate, IllegalConstructor);
|
||||
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "StatementSyncIterator"));
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
StatementSync::kInternalFieldCount);
|
||||
StatementSyncIterator::kInternalFieldCount);
|
||||
SetProtoMethod(isolate, tmpl, "next", StatementSyncIterator::Next);
|
||||
SetProtoMethod(isolate, tmpl, "return", StatementSyncIterator::Return);
|
||||
env->set_sqlite_statement_sync_iterator_constructor_template(tmpl);
|
||||
|
||||
+1
-1
@@ -684,7 +684,7 @@ void Initialize(Local<Object> target,
|
||||
// GCProfiler
|
||||
Local<FunctionTemplate> t =
|
||||
NewFunctionTemplate(env->isolate(), GCProfiler::New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(BaseObject::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(GCProfiler::kInternalFieldCount);
|
||||
SetProtoMethod(env->isolate(), t, "start", GCProfiler::Start);
|
||||
SetProtoMethod(env->isolate(), t, "stop", GCProfiler::Stop);
|
||||
SetConstructorFunction(context, target, "GCProfiler", t);
|
||||
|
||||
+2
-3
@@ -72,7 +72,7 @@ void PipeWrap::Initialize(Local<Object> target,
|
||||
Isolate* isolate = env->isolate();
|
||||
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(PipeWrap::kInternalFieldCount);
|
||||
|
||||
t->Inherit(LibuvStreamWrap::GetConstructorTemplate(env));
|
||||
|
||||
@@ -91,8 +91,7 @@ void PipeWrap::Initialize(Local<Object> target,
|
||||
env->set_pipe_constructor_template(t);
|
||||
|
||||
// Create FunctionTemplate for PipeConnectWrap.
|
||||
auto cwt = BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
cwt->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
auto cwt = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
SetConstructorFunction(context, target, "PipeConnectWrap", cwt);
|
||||
|
||||
// Define constants
|
||||
|
||||
@@ -17,6 +17,10 @@ class LogStream : public AsyncWrap, public StreamBase {
|
||||
public:
|
||||
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
|
||||
Environment* env);
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(AsyncWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
static BaseObjectPtr<LogStream> Create(Environment* env);
|
||||
|
||||
|
||||
+12
-2
@@ -37,7 +37,7 @@ class StreamReq {
|
||||
// BaseObject, and the slots are used for the identical purpose.
|
||||
enum InternalFields {
|
||||
kSlot = BaseObject::kSlot,
|
||||
kStreamReqField = BaseObject::kInternalFieldCount,
|
||||
kStreamReqField = AsyncWrap::kInternalFieldCount,
|
||||
kInternalFieldCount
|
||||
};
|
||||
|
||||
@@ -310,7 +310,7 @@ class StreamBase : public StreamResource {
|
||||
// BaseObject (it's possible for it not to, however).
|
||||
enum InternalFields {
|
||||
kSlot = BaseObject::kSlot,
|
||||
kStreamBaseField = BaseObject::kInternalFieldCount,
|
||||
kStreamBaseField = AsyncWrap::kInternalFieldCount,
|
||||
kOnReadFunctionField,
|
||||
kInternalFieldCount
|
||||
};
|
||||
@@ -440,6 +440,11 @@ class StreamBase : public StreamResource {
|
||||
template <typename OtherBase>
|
||||
class SimpleShutdownWrap : public ShutdownWrap, public OtherBase {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(ShutdownWrap::kInternalFieldCount,
|
||||
OtherBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
SimpleShutdownWrap(StreamBase* stream,
|
||||
v8::Local<v8::Object> req_wrap_obj);
|
||||
|
||||
@@ -457,6 +462,11 @@ class SimpleShutdownWrap : public ShutdownWrap, public OtherBase {
|
||||
template <typename OtherBase>
|
||||
class SimpleWriteWrap : public WriteWrap, public OtherBase {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(WriteWrap::kInternalFieldCount,
|
||||
OtherBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
SimpleWriteWrap(StreamBase* stream,
|
||||
v8::Local<v8::Object> req_wrap_obj);
|
||||
|
||||
|
||||
+4
-4
@@ -72,7 +72,8 @@ void LibuvStreamWrap::Initialize(Local<Object> target,
|
||||
|
||||
Local<FunctionTemplate> sw =
|
||||
NewFunctionTemplate(isolate, IsConstructCallCallback);
|
||||
sw->InstanceTemplate()->SetInternalFieldCount(StreamReq::kInternalFieldCount);
|
||||
sw->InstanceTemplate()->SetInternalFieldCount(
|
||||
ShutdownWrap::kInternalFieldCount);
|
||||
|
||||
// we need to set handle and callback to null,
|
||||
// so that those fields are created and functions
|
||||
@@ -93,8 +94,7 @@ void LibuvStreamWrap::Initialize(Local<Object> target,
|
||||
|
||||
Local<FunctionTemplate> ww =
|
||||
FunctionTemplate::New(isolate, IsConstructCallCallback);
|
||||
ww->InstanceTemplate()->SetInternalFieldCount(
|
||||
StreamReq::kInternalFieldCount);
|
||||
ww->InstanceTemplate()->SetInternalFieldCount(WriteWrap::kInternalFieldCount);
|
||||
ww->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
SetConstructorFunction(context, target, "WriteWrap", ww);
|
||||
env->set_write_wrap_template(ww->InstanceTemplate());
|
||||
@@ -141,7 +141,7 @@ Local<FunctionTemplate> LibuvStreamWrap::GetConstructorTemplate(
|
||||
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "LibuvStreamWrap"));
|
||||
tmpl->Inherit(HandleWrap::GetConstructorTemplate(env));
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
StreamBase::kInternalFieldCount);
|
||||
LibuvStreamWrap::kInternalFieldCount);
|
||||
Local<FunctionTemplate> get_write_queue_size =
|
||||
FunctionTemplate::New(isolate,
|
||||
GetWriteQueueSize,
|
||||
|
||||
@@ -35,6 +35,11 @@ class ExternalReferenceRegistry;
|
||||
|
||||
class LibuvStreamWrap : public HandleWrap, public StreamBase {
|
||||
public:
|
||||
enum InternalFields {
|
||||
kInternalFieldCount = std::max<uint32_t>(HandleWrap::kInternalFieldCount,
|
||||
StreamBase::kInternalFieldCount),
|
||||
};
|
||||
|
||||
static void Initialize(v8::Local<v8::Object> target,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
|
||||
+2
-4
@@ -79,7 +79,7 @@ void TCPWrap::Initialize(Local<Object> target,
|
||||
Isolate* isolate = env->isolate();
|
||||
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(TCPWrap::kInternalFieldCount);
|
||||
|
||||
// Init properties
|
||||
t->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "reading"),
|
||||
@@ -115,9 +115,7 @@ void TCPWrap::Initialize(Local<Object> target,
|
||||
env->set_tcp_constructor_template(t);
|
||||
|
||||
// Create FunctionTemplate for TCPConnectWrap.
|
||||
Local<FunctionTemplate> cwt =
|
||||
BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
cwt->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<FunctionTemplate> cwt = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
SetConstructorFunction(context, target, "TCPConnectWrap", cwt);
|
||||
|
||||
// Define constants
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ void TTYWrap::Initialize(Local<Object> target,
|
||||
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
t->SetClassName(ttyString);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(StreamBase::kInternalFieldCount);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(TTYWrap::kInternalFieldCount);
|
||||
t->Inherit(LibuvStreamWrap::GetConstructorTemplate(env));
|
||||
|
||||
SetProtoMethodNoSideEffect(
|
||||
|
||||
+1
-3
@@ -223,9 +223,7 @@ void UDPWrap::Initialize(Local<Object> target,
|
||||
env->set_udp_constructor_function(t->GetFunction(context).ToLocalChecked());
|
||||
|
||||
// Create FunctionTemplate for SendWrap
|
||||
Local<FunctionTemplate> swt =
|
||||
BaseObject::MakeLazilyInitializedJSTemplate(env);
|
||||
swt->Inherit(AsyncWrap::GetConstructorTemplate(env));
|
||||
Local<FunctionTemplate> swt = AsyncWrap::MakeLazilyInitializedJSTemplate(env);
|
||||
SetConstructorFunction(context, target, "SendWrap", swt);
|
||||
|
||||
Local<Object> constants = Object::New(isolate);
|
||||
|
||||
@@ -16,6 +16,8 @@ extern uintptr_t
|
||||
extern int debug_symbols_generated;
|
||||
extern int nodedbg_const_ContextEmbedderIndex__kEnvironment__int;
|
||||
extern int nodedbg_const_BaseObject__kInternalFieldCount__int;
|
||||
extern int nodedbg_const_HandleWrap__kInternalFieldCount__int;
|
||||
extern int nodedbg_const_ReqWrap__kInternalFieldCount__int;
|
||||
extern uintptr_t
|
||||
nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap;
|
||||
extern uintptr_t
|
||||
@@ -76,6 +78,18 @@ TEST_F(DebugSymbolsTest, BaseObjectkInternalFieldCount) {
|
||||
kInternalFieldCount);
|
||||
}
|
||||
|
||||
TEST_F(DebugSymbolsTest, HandleWrapInternalFieldCount) {
|
||||
int kInternalFieldCount = node::HandleWrap::kInternalFieldCount;
|
||||
EXPECT_EQ(nodedbg_const_HandleWrap__kInternalFieldCount__int,
|
||||
kInternalFieldCount);
|
||||
}
|
||||
|
||||
TEST_F(DebugSymbolsTest, ReqWrapInternalFieldCount) {
|
||||
int kInternalFieldCount = node::ReqWrap<uv_req_t>::kInternalFieldCount;
|
||||
EXPECT_EQ(nodedbg_const_ReqWrap__kInternalFieldCount__int,
|
||||
kInternalFieldCount);
|
||||
}
|
||||
|
||||
TEST_F(DebugSymbolsTest, ExternalStringDataOffset) {
|
||||
EXPECT_EQ(nodedbg_offset_ExternalString__data__uintptr_t,
|
||||
NODE_OFF_EXTSTR_DATA);
|
||||
@@ -149,7 +163,7 @@ TEST_F(DebugSymbolsTest, HandleWrapList) {
|
||||
|
||||
auto obj_template = v8::FunctionTemplate::New(isolate_);
|
||||
obj_template->InstanceTemplate()->SetInternalFieldCount(
|
||||
nodedbg_const_BaseObject__kInternalFieldCount__int);
|
||||
nodedbg_const_HandleWrap__kInternalFieldCount__int);
|
||||
|
||||
v8::Local<v8::Object> object = obj_template->GetFunction(env.context())
|
||||
.ToLocalChecked()
|
||||
@@ -182,7 +196,7 @@ TEST_F(DebugSymbolsTest, ReqWrapList) {
|
||||
|
||||
auto obj_template = v8::FunctionTemplate::New(isolate_);
|
||||
obj_template->InstanceTemplate()->SetInternalFieldCount(
|
||||
nodedbg_const_BaseObject__kInternalFieldCount__int);
|
||||
nodedbg_const_ReqWrap__kInternalFieldCount__int);
|
||||
|
||||
v8::Local<v8::Object> object = obj_template->GetFunction(env.context())
|
||||
.ToLocalChecked()
|
||||
|
||||
Reference in new issue
Block a user