From 5c86f223aec046d6dd37b5ff22907e30be7315ee Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 6 Apr 2023 02:24:48 +0200 Subject: [PATCH] src: use the internal field to determine if an object is a BaseObject Instead of storing the function template of BaseObject for checking if an object is BaseObject by calling HasInstance, simply checks the first internal field of the object, which is always set in the BaseObject constructor. This is simpler and faster (there is now no need to iterate over the inheritance for the check). PR-URL: https://github.com/nodejs/node/pull/47217 Reviewed-By: Chengzhong Wu --- src/async_wrap.cc | 1 - src/base_object-inl.h | 19 +++++++++++-------- src/base_object.cc | 13 ------------- src/base_object.h | 3 ++- src/crypto/crypto_cipher.cc | 4 +--- src/crypto/crypto_context.cc | 1 - src/crypto/crypto_dh.cc | 1 - src/crypto/crypto_ec.cc | 1 - src/crypto/crypto_hash.cc | 4 +--- src/crypto/crypto_hmac.cc | 4 +--- src/crypto/crypto_keys.cc | 2 -- src/crypto/crypto_sig.cc | 8 ++------ src/crypto/crypto_x509.cc | 1 - src/env.cc | 1 - src/env_properties.h | 1 - src/histogram.cc | 1 - src/module_wrap.cc | 1 - src/node_binding.cc | 1 - src/node_blob.cc | 2 -- src/node_i18n.cc | 1 - src/node_messaging.cc | 15 ++++++++------- src/node_serdes.cc | 2 -- src/node_snapshotable.cc | 13 +------------ src/node_sockaddr.cc | 2 -- src/node_trace_events.cc | 1 - src/node_util.cc | 1 - src/node_wasi.cc | 1 - src/node_wasm_web_api.cc | 1 - 28 files changed, 27 insertions(+), 79 deletions(-) diff --git a/src/async_wrap.cc b/src/async_wrap.cc index e70011f0b7ba4c..aac2f3c911b044 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -342,7 +342,6 @@ Local AsyncWrap::GetConstructorTemplate( tmpl = NewFunctionTemplate(isolate, nullptr); tmpl->SetClassName( FIXED_ONE_BYTE_STRING(isolate_data->isolate(), "AsyncWrap")); - tmpl->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); SetProtoMethod(isolate, tmpl, "getAsyncId", AsyncWrap::GetAsyncId); SetProtoMethod(isolate, tmpl, "asyncReset", AsyncWrap::AsyncReset); SetProtoMethod( diff --git a/src/base_object-inl.h b/src/base_object-inl.h index f003f1390b864f..feaeab306acefb 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -38,12 +38,6 @@ BaseObject::BaseObject(Environment* env, v8::Local object) // while allowing to create a BaseObject in a vm context. } -// static -v8::Local BaseObject::GetConstructorTemplate( - Environment* env) { - return BaseObject::GetConstructorTemplate(env->isolate_data()); -} - void BaseObject::Detach() { CHECK_GT(pointer_data()->strong_ptr_count, 0); pointer_data()->is_detached = true; @@ -76,14 +70,23 @@ Realm* BaseObject::realm() const { return realm_; } -void BaseObject::TagNodeObject(v8::Local object) { +bool BaseObject::IsBaseObject(v8::Local obj) { + if (obj->InternalFieldCount() < BaseObject::kInternalFieldCount) { + return false; + } + void* ptr = + obj->GetAlignedPointerFromInternalField(BaseObject::kEmbedderType); + return ptr == &kNodeEmbedderId; +} + +void BaseObject::TagBaseObject(v8::Local object) { DCHECK_GE(object->InternalFieldCount(), BaseObject::kInternalFieldCount); object->SetAlignedPointerInInternalField(BaseObject::kEmbedderType, &kNodeEmbedderId); } void BaseObject::SetInternalFields(v8::Local object, void* slot) { - TagNodeObject(object); + TagBaseObject(object); object->SetAlignedPointerInInternalField(BaseObject::kSlot, slot); } diff --git a/src/base_object.cc b/src/base_object.cc index d0444573c85ac7..ed0fafe74d43a9 100644 --- a/src/base_object.cc +++ b/src/base_object.cc @@ -89,7 +89,6 @@ Local BaseObject::MakeLazilyInitializedJSTemplate( IsolateData* isolate_data) { Local t = NewFunctionTemplate( isolate_data->isolate(), LazilyInitializedJSTemplateConstructor); - t->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); t->InstanceTemplate()->SetInternalFieldCount(BaseObject::kInternalFieldCount); return t; } @@ -145,18 +144,6 @@ bool BaseObject::IsRootNode() const { return !persistent_handle_.IsWeak(); } -Local BaseObject::GetConstructorTemplate( - IsolateData* isolate_data) { - Local tmpl = isolate_data->base_object_ctor_template(); - if (tmpl.IsEmpty()) { - tmpl = NewFunctionTemplate(isolate_data->isolate(), nullptr); - tmpl->SetClassName( - FIXED_ONE_BYTE_STRING(isolate_data->isolate(), "BaseObject")); - isolate_data->set_base_object_ctor_template(tmpl); - } - return tmpl; -} - bool BaseObject::IsNotIndicativeOfMemoryLeakAtExit() const { return IsWeakOrDetached(); } diff --git a/src/base_object.h b/src/base_object.h index 4ac644a034f4a6..96f661c41284dc 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -76,7 +76,8 @@ class BaseObject : public MemoryRetainer { // e.g. when the JS object used `MakeLazilyInitializedJSTemplate`. static inline void SetInternalFields(v8::Local object, void* slot); - static inline void TagNodeObject(v8::Local object); + static inline bool IsBaseObject(v8::Local object); + static inline void TagBaseObject(v8::Local object); static void LazilyInitializedJSTemplateConstructor( const v8::FunctionCallbackInfo& args); static inline BaseObject* FromJSObject(v8::Local object); diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc index 2685f5ea0bea99..2e6e02d229b67b 100644 --- a/src/crypto/crypto_cipher.cc +++ b/src/crypto/crypto_cipher.cc @@ -277,9 +277,7 @@ void CipherBase::Initialize(Environment* env, Local target) { Local t = NewFunctionTemplate(isolate, New); - t->InstanceTemplate()->SetInternalFieldCount( - CipherBase::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); + t->InstanceTemplate()->SetInternalFieldCount(CipherBase::kInternalFieldCount); SetProtoMethod(isolate, t, "init", Init); SetProtoMethod(isolate, t, "initiv", InitIv); diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index cb03cd7643909f..dafea2cf4af6c6 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -268,7 +268,6 @@ Local SecureContext::GetConstructorTemplate( tmpl = NewFunctionTemplate(isolate, New); tmpl->InstanceTemplate()->SetInternalFieldCount( SecureContext::kInternalFieldCount); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SecureContext")); SetProtoMethod(isolate, tmpl, "init", Init); diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc index dd69323b80076d..408d6be2a9cfdb 100644 --- a/src/crypto/crypto_dh.cc +++ b/src/crypto/crypto_dh.cc @@ -69,7 +69,6 @@ void DiffieHellman::Initialize(Environment* env, Local target) { t->InstanceTemplate()->SetInternalFieldCount( DiffieHellman::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, t, "generateKeys", GenerateKeys); SetProtoMethod(isolate, t, "computeSecret", ComputeSecret); diff --git a/src/crypto/crypto_ec.cc b/src/crypto/crypto_ec.cc index 3ccea99fb2bbe9..415464be04db6b 100644 --- a/src/crypto/crypto_ec.cc +++ b/src/crypto/crypto_ec.cc @@ -66,7 +66,6 @@ void ECDH::Initialize(Environment* env, Local target) { Local context = env->context(); Local t = NewFunctionTemplate(isolate, New); - t->Inherit(BaseObject::GetConstructorTemplate(env)); t->InstanceTemplate()->SetInternalFieldCount(ECDH::kInternalFieldCount); diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc index 200603a85ef33e..5627bac590f2b3 100644 --- a/src/crypto/crypto_hash.cc +++ b/src/crypto/crypto_hash.cc @@ -57,9 +57,7 @@ void Hash::Initialize(Environment* env, Local target) { Local context = env->context(); Local t = NewFunctionTemplate(isolate, New); - t->InstanceTemplate()->SetInternalFieldCount( - Hash::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); + t->InstanceTemplate()->SetInternalFieldCount(Hash::kInternalFieldCount); SetProtoMethod(isolate, t, "update", HashUpdate); SetProtoMethod(isolate, t, "digest", HashDigest); diff --git a/src/crypto/crypto_hmac.cc b/src/crypto/crypto_hmac.cc index ed78e21f118a18..41c83b31eb219d 100644 --- a/src/crypto/crypto_hmac.cc +++ b/src/crypto/crypto_hmac.cc @@ -41,9 +41,7 @@ void Hmac::Initialize(Environment* env, Local target) { Isolate* isolate = env->isolate(); Local t = NewFunctionTemplate(isolate, New); - t->InstanceTemplate()->SetInternalFieldCount( - Hmac::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); + t->InstanceTemplate()->SetInternalFieldCount(Hmac::kInternalFieldCount); SetProtoMethod(isolate, t, "init", HmacInit); SetProtoMethod(isolate, t, "update", HmacUpdate); diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc index 0be2283d6017a4..1b8e9b25a6991b 100644 --- a/src/crypto/crypto_keys.cc +++ b/src/crypto/crypto_keys.cc @@ -901,7 +901,6 @@ v8::Local KeyObjectHandle::Initialize(Environment* env) { templ = NewFunctionTemplate(isolate, New); templ->InstanceTemplate()->SetInternalFieldCount( KeyObjectHandle::kInternalFieldCount); - templ->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, templ, "init", Init); SetProtoMethodNoSideEffect( @@ -1342,7 +1341,6 @@ void NativeKeyObject::CreateNativeKeyObjectClass( NewFunctionTemplate(isolate, NativeKeyObject::New); t->InstanceTemplate()->SetInternalFieldCount( KeyObjectHandle::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); Local ctor; if (!t->GetFunction(env->context()).ToLocal(&ctor)) diff --git a/src/crypto/crypto_sig.cc b/src/crypto/crypto_sig.cc index 92188911b35a4d..8e8b5f0c61e219 100644 --- a/src/crypto/crypto_sig.cc +++ b/src/crypto/crypto_sig.cc @@ -329,9 +329,7 @@ void Sign::Initialize(Environment* env, Local target) { Isolate* isolate = env->isolate(); Local t = NewFunctionTemplate(isolate, New); - t->InstanceTemplate()->SetInternalFieldCount( - SignBase::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); + t->InstanceTemplate()->SetInternalFieldCount(SignBase::kInternalFieldCount); SetProtoMethod(isolate, t, "init", SignInit); SetProtoMethod(isolate, t, "update", SignUpdate); @@ -459,9 +457,7 @@ void Verify::Initialize(Environment* env, Local target) { Isolate* isolate = env->isolate(); Local t = NewFunctionTemplate(isolate, New); - t->InstanceTemplate()->SetInternalFieldCount( - SignBase::kInternalFieldCount); - t->Inherit(BaseObject::GetConstructorTemplate(env)); + t->InstanceTemplate()->SetInternalFieldCount(SignBase::kInternalFieldCount); SetProtoMethod(isolate, t, "init", VerifyInit); SetProtoMethod(isolate, t, "update", VerifyUpdate); diff --git a/src/crypto/crypto_x509.cc b/src/crypto/crypto_x509.cc index c2d4f44f285398..6897be680f62dc 100644 --- a/src/crypto/crypto_x509.cc +++ b/src/crypto/crypto_x509.cc @@ -59,7 +59,6 @@ Local X509Certificate::GetConstructorTemplate( tmpl = NewFunctionTemplate(isolate, nullptr); tmpl->InstanceTemplate()->SetInternalFieldCount( BaseObject::kInternalFieldCount); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); tmpl->SetClassName( FIXED_ONE_BYTE_STRING(env->isolate(), "X509Certificate")); SetProtoMethod(isolate, tmpl, "subject", Subject); diff --git a/src/env.cc b/src/env.cc index e37896ee0a6587..8ebbcfb2525239 100644 --- a/src/env.cc +++ b/src/env.cc @@ -480,7 +480,6 @@ void IsolateData::CreateProperties() { Local templ = FunctionTemplate::New(isolate()); templ->InstanceTemplate()->SetInternalFieldCount( BaseObject::kInternalFieldCount); - templ->Inherit(BaseObject::GetConstructorTemplate(this)); set_binding_data_ctor_template(templ); binding::CreateInternalBindingTemplates(this); diff --git a/src/env_properties.h b/src/env_properties.h index 05a4ac58380c35..095094714aa400 100644 --- a/src/env_properties.h +++ b/src/env_properties.h @@ -330,7 +330,6 @@ #define PER_ISOLATE_TEMPLATE_PROPERTIES(V) \ V(async_wrap_ctor_template, v8::FunctionTemplate) \ V(async_wrap_object_ctor_template, v8::FunctionTemplate) \ - V(base_object_ctor_template, v8::FunctionTemplate) \ V(binding_data_ctor_template, v8::FunctionTemplate) \ V(blob_constructor_template, v8::FunctionTemplate) \ V(blob_reader_constructor_template, v8::FunctionTemplate) \ diff --git a/src/histogram.cc b/src/histogram.cc index 112a8911cfb4af..5a2b1acf897647 100644 --- a/src/histogram.cc +++ b/src/histogram.cc @@ -288,7 +288,6 @@ Local HistogramBase::GetConstructorTemplate( tmpl = NewFunctionTemplate(isolate, New); Local classname = FIXED_ONE_BYTE_STRING(isolate, "Histogram"); tmpl->SetClassName(classname); - tmpl->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); tmpl->InstanceTemplate()->SetInternalFieldCount( HistogramBase::kInternalFieldCount); diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 9b2b0b8334d102..77ee0dc9109ebb 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -768,7 +768,6 @@ void ModuleWrap::Initialize(Local target, Local tpl = NewFunctionTemplate(isolate, New); tpl->InstanceTemplate()->SetInternalFieldCount( ModuleWrap::kInternalFieldCount); - tpl->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, tpl, "link", Link); SetProtoMethod(isolate, tpl, "instantiate", Instantiate); diff --git a/src/node_binding.cc b/src/node_binding.cc index bd6ca33fcaf91f..90855aada5dab9 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -565,7 +565,6 @@ void CreateInternalBindingTemplates(IsolateData* isolate_data) { FunctionTemplate::New(isolate_data->isolate()); \ templ->InstanceTemplate()->SetInternalFieldCount( \ BaseObject::kInternalFieldCount); \ - templ->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); \ _register_isolate_##modname(isolate_data, templ); \ isolate_data->set_##modname##_binding(templ); \ } while (0); diff --git a/src/node_blob.cc b/src/node_blob.cc index b2fc527b3b50aa..40112f5d06af0a 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -131,7 +131,6 @@ Local Blob::GetConstructorTemplate(Environment* env) { tmpl = NewFunctionTemplate(isolate, nullptr); tmpl->InstanceTemplate()->SetInternalFieldCount( BaseObject::kInternalFieldCount); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); tmpl->SetClassName( FIXED_ONE_BYTE_STRING(env->isolate(), "Blob")); SetProtoMethod(isolate, tmpl, "getReader", GetReader); @@ -281,7 +280,6 @@ Local Blob::Reader::GetConstructorTemplate(Environment* env) { tmpl = NewFunctionTemplate(isolate, nullptr); tmpl->InstanceTemplate()->SetInternalFieldCount( BaseObject::kInternalFieldCount); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "BlobReader")); SetProtoMethod(env->isolate(), tmpl, "pull", Pull); env->set_blob_reader_constructor_template(tmpl); diff --git a/src/node_i18n.cc b/src/node_i18n.cc index cdb264d6202eb3..e60b58b57185ff 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -875,7 +875,6 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data, // ConverterObject { Local t = NewFunctionTemplate(isolate, nullptr); - t->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); t->InstanceTemplate()->SetInternalFieldCount( ConverterObject::kInternalFieldCount); Local converter_string = diff --git a/src/node_messaging.cc b/src/node_messaging.cc index ae9720a3359ced..b40868a1ceeff4 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -301,7 +301,7 @@ class SerializerDelegate : public ValueSerializer::Delegate { } Maybe WriteHostObject(Isolate* isolate, Local object) override { - if (env_->base_object_ctor_template()->HasInstance(object)) { + if (BaseObject::IsBaseObject(object)) { return WriteHostObject( BaseObjectPtr { Unwrap(object) }); } @@ -490,7 +490,8 @@ Maybe Message::Serialize(Environment* env, array_buffers.push_back(ab); serializer.TransferArrayBuffer(id, ab); continue; - } else if (env->base_object_ctor_template()->HasInstance(entry)) { + } else if (entry->IsObject() && + BaseObject::IsBaseObject(entry.As())) { // Check if the source MessagePort is being transferred. if (!source_port.IsEmpty() && entry == source_port) { ThrowDataCloneException( @@ -1257,7 +1258,7 @@ JSTransferable::NestedTransferables() const { Local value; if (!list->Get(context, i).ToLocal(&value)) return Nothing(); - if (env()->base_object_ctor_template()->HasInstance(value)) + if (value->IsObject() && BaseObject::IsBaseObject(value.As())) ret.emplace_back(Unwrap(value)); } return Just(ret); @@ -1309,9 +1310,10 @@ BaseObjectPtr JSTransferable::Data::Deserialize( Local ret; CHECK(!env->messaging_deserialize_create_object().IsEmpty()); - if (!env->messaging_deserialize_create_object()->Call( - context, Null(env->isolate()), 1, &info).ToLocal(&ret) || - !env->base_object_ctor_template()->HasInstance(ret)) { + if (!env->messaging_deserialize_create_object() + ->Call(context, Null(env->isolate()), 1, &info) + .ToLocal(&ret) || + !ret->IsObject() || !BaseObject::IsBaseObject(ret.As())) { return {}; } @@ -1492,7 +1494,6 @@ static void InitMessaging(Local target, { Local t = NewFunctionTemplate(isolate, JSTransferable::New); - t->Inherit(BaseObject::GetConstructorTemplate(env)); t->InstanceTemplate()->SetInternalFieldCount( JSTransferable::kInternalFieldCount); SetConstructorFunction(context, target, "JSTransferable", t); diff --git a/src/node_serdes.cc b/src/node_serdes.cc index 6864f2d88b34ab..6698a1df81cb4e 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -462,7 +462,6 @@ void Initialize(Local target, ser->InstanceTemplate()->SetInternalFieldCount( SerializerContext::kInternalFieldCount); - ser->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, ser, "writeHeader", SerializerContext::WriteHeader); SetProtoMethod(isolate, ser, "writeValue", SerializerContext::WriteValue); @@ -490,7 +489,6 @@ void Initialize(Local target, des->InstanceTemplate()->SetInternalFieldCount( DeserializerContext::kInternalFieldCount); - des->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, des, "readHeader", DeserializerContext::ReadHeader); SetProtoMethod(isolate, des, "readValue", DeserializerContext::ReadValue); diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index 5af013ae90cf37..0c842a86315f37 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -1367,18 +1367,7 @@ StartupData SerializeNodeContextInternalFields(Local holder, // (most importantly, BaseObject::kSlot). // For Node.js this design is enough for all the native binding that are // serializable. - if (index != BaseObject::kEmbedderType) { - return StartupData{nullptr, 0}; - } - - void* type_ptr = holder->GetAlignedPointerFromInternalField(index); - if (type_ptr == nullptr) { - return StartupData{nullptr, 0}; - } - - uint16_t type = *(static_cast(type_ptr)); - per_process::Debug(DebugCategory::MKSNAPSHOT, "type = 0x%x\n", type); - if (type != kNodeEmbedderId) { + if (index != BaseObject::kEmbedderType || !BaseObject::IsBaseObject(holder)) { return StartupData{nullptr, 0}; } diff --git a/src/node_sockaddr.cc b/src/node_sockaddr.cc index 2fb768a284ce44..b54962b291100b 100644 --- a/src/node_sockaddr.cc +++ b/src/node_sockaddr.cc @@ -701,7 +701,6 @@ Local SocketAddressBlockListWrap::GetConstructorTemplate( Isolate* isolate = env->isolate(); tmpl = NewFunctionTemplate(isolate, SocketAddressBlockListWrap::New); tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "BlockList")); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); tmpl->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount); SetProtoMethod(isolate, tmpl, "addAddress", AddAddress); SetProtoMethod(isolate, tmpl, "addRange", AddRange); @@ -757,7 +756,6 @@ Local SocketAddressBase::GetConstructorTemplate( tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SocketAddress")); tmpl->InstanceTemplate()->SetInternalFieldCount( SocketAddressBase::kInternalFieldCount); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, tmpl, "detail", Detail); SetProtoMethod(isolate, tmpl, "legacyDetail", LegacyDetail); SetProtoMethodNoSideEffect(isolate, tmpl, "flowlabel", GetFlowLabel); diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index c84651dc832a33..bd2eefafb68cbc 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -137,7 +137,6 @@ void NodeCategorySet::Initialize(Local target, NewFunctionTemplate(isolate, NodeCategorySet::New); category_set->InstanceTemplate()->SetInternalFieldCount( NodeCategorySet::kInternalFieldCount); - category_set->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, category_set, "enable", NodeCategorySet::Enable); SetProtoMethod(isolate, category_set, "disable", NodeCategorySet::Disable); diff --git a/src/node_util.cc b/src/node_util.cc index 8bb647877a9f2e..c434f201e592a4 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -464,7 +464,6 @@ void Initialize(Local target, NewFunctionTemplate(isolate, WeakReference::New); weak_ref->InstanceTemplate()->SetInternalFieldCount( WeakReference::kInternalFieldCount); - weak_ref->Inherit(BaseObject::GetConstructorTemplate(env)); SetProtoMethod(isolate, weak_ref, "get", WeakReference::Get); SetProtoMethod(isolate, weak_ref, "incRef", WeakReference::IncRef); SetProtoMethod(isolate, weak_ref, "decRef", WeakReference::DecRef); diff --git a/src/node_wasi.cc b/src/node_wasi.cc index 061de8e8b21281..e1a16c4e4b7d47 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -1271,7 +1271,6 @@ static void InitializePreview1(Local target, Local tmpl = NewFunctionTemplate(isolate, WASI::New); tmpl->InstanceTemplate()->SetInternalFieldCount(WASI::kInternalFieldCount); - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); #define V(F, name) \ SetFunction(WASI::F, env, name, tmpl); diff --git a/src/node_wasm_web_api.cc b/src/node_wasm_web_api.cc index 0f79f20fccb2e0..824ff66664a57c 100644 --- a/src/node_wasm_web_api.cc +++ b/src/node_wasm_web_api.cc @@ -28,7 +28,6 @@ Local WasmStreamingObject::Initialize(Environment* env) { Isolate* isolate = env->isolate(); Local t = NewFunctionTemplate(isolate, New); - t->Inherit(BaseObject::GetConstructorTemplate(env)); t->InstanceTemplate()->SetInternalFieldCount( WasmStreamingObject::kInternalFieldCount);