From be2d7edf73241924ff305fed7027e82d8297cbba Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 6 May 2023 18:07:19 +0200 Subject: [PATCH] src: avoid prototype access in binding templates This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template. Previously the initialization was similar to: ``` function Binding() {} Binding.prototype.property = ...; module.exports = new Binding; ``` Now it's similar to: ``` module.exports = { property: ... }; ``` --- src/async_wrap.cc | 3 +- src/async_wrap.h | 4 +-- src/encoding_binding.cc | 4 +-- src/encoding_binding.h | 2 +- src/env-inl.h | 2 +- src/env.cc | 13 ++++---- src/env.h | 4 +-- src/env_properties.h | 2 +- src/node_binding.cc | 26 +++++++--------- src/node_binding.h | 2 +- src/node_blob.cc | 3 +- src/node_blob.h | 2 +- src/node_builtins.cc | 62 ++++++++++++++++++------------------- src/node_builtins.h | 4 +-- src/node_contextify.cc | 4 +-- src/node_file.cc | 5 ++- src/node_i18n.cc | 19 ++++++------ src/node_perf.cc | 26 +++++++--------- src/node_process_methods.cc | 4 +-- src/node_stat_watcher.cc | 3 +- src/node_stat_watcher.h | 2 +- src/node_url.cc | 4 +-- src/node_url.h | 2 +- src/node_worker.cc | 7 ++--- src/timers.cc | 4 +-- src/timers.h | 2 +- 26 files changed, 97 insertions(+), 118 deletions(-) diff --git a/src/async_wrap.cc b/src/async_wrap.cc index ad150ff7b0ca13..42cddc52aed285 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -353,9 +353,8 @@ Local AsyncWrap::GetConstructorTemplate( } void AsyncWrap::CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); SetMethod(isolate, target, "setupHooks", SetupHooks); SetMethod(isolate, target, "setCallbackTrampoline", SetCallbackTrampoline); diff --git a/src/async_wrap.h b/src/async_wrap.h index 1c6e62846d915c..c91896295a6cf9 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -151,8 +151,8 @@ class AsyncWrap : public BaseObject { v8::Local unused, v8::Local context, void* priv); - static void CreatePerIsolateProperties( - IsolateData* isolate_data, v8::Local target); + static void CreatePerIsolateProperties(IsolateData* isolate_data, + v8::Local target); static void GetAsyncId(const v8::FunctionCallbackInfo& args); static void PushAsyncContext(const v8::FunctionCallbackInfo& args); diff --git a/src/encoding_binding.cc b/src/encoding_binding.cc index 38cb63d8a75643..0cf588295405ac 100644 --- a/src/encoding_binding.cc +++ b/src/encoding_binding.cc @@ -16,7 +16,6 @@ using v8::ArrayBuffer; using v8::BackingStore; using v8::Context; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::Isolate; using v8::Local; using v8::MaybeLocal; @@ -219,9 +218,8 @@ void BindingData::ToUnicode(const v8::FunctionCallbackInfo& args) { } void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); SetMethod(isolate, target, "encodeInto", EncodeInto); SetMethodNoSideEffect(isolate, target, "encodeUtf8String", EncodeUtf8String); SetMethodNoSideEffect(isolate, target, "decodeUTF8", DecodeUTF8); diff --git a/src/encoding_binding.h b/src/encoding_binding.h index 437aa9c5587918..2690cb74f8a05b 100644 --- a/src/encoding_binding.h +++ b/src/encoding_binding.h @@ -36,7 +36,7 @@ class BindingData : public SnapshotableObject { static void ToUnicode(const v8::FunctionCallbackInfo& args); static void CreatePerIsolateProperties(IsolateData* isolate_data, - v8::Local ctor); + v8::Local target); static void CreatePerContextProperties(v8::Local target, v8::Local unused, v8::Local context, diff --git a/src/env-inl.h b/src/env-inl.h index 7b135c7b83293a..43fc11217133c2 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -807,7 +807,7 @@ void Environment::set_process_exit_handler( #undef VY #undef VP -#define VM(PropertyName) V(PropertyName##_binding, v8::FunctionTemplate) +#define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate) #define V(PropertyName, TypeName) \ inline v8::Local IsolateData::PropertyName() const { \ return PropertyName##_.Get(isolate_); \ diff --git a/src/env.cc b/src/env.cc index ff8d3952cf20a3..61e334bb984a57 100644 --- a/src/env.cc +++ b/src/env.cc @@ -38,7 +38,6 @@ using v8::Context; using v8::EmbedderGraph; using v8::EscapableHandleScope; using v8::Function; -using v8::FunctionTemplate; using v8::HandleScope; using v8::HeapProfiler; using v8::HeapSpaceStatistics; @@ -49,6 +48,7 @@ using v8::MaybeLocal; using v8::NewStringType; using v8::Number; using v8::Object; +using v8::ObjectTemplate; using v8::Private; using v8::Script; using v8::SnapshotCreator; @@ -326,7 +326,7 @@ IsolateDataSerializeInfo IsolateData::Serialize(SnapshotCreator* creator) { info.primitive_values.push_back(creator->AddData(async_wrap_provider(i))); uint32_t id = 0; -#define VM(PropertyName) V(PropertyName##_binding, FunctionTemplate) +#define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate) #define V(PropertyName, TypeName) \ do { \ Local field = PropertyName(); \ @@ -390,7 +390,7 @@ void IsolateData::DeserializeProperties(const IsolateDataSerializeInfo* info) { const std::vector& values = info->template_values; i = 0; // index to the array uint32_t id = 0; -#define VM(PropertyName) V(PropertyName##_binding, FunctionTemplate) +#define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate) #define V(PropertyName, TypeName) \ do { \ if (values.size() > i && id == values[i].id) { \ @@ -491,10 +491,9 @@ void IsolateData::CreateProperties() { NODE_ASYNC_PROVIDER_TYPES(V) #undef V - Local templ = FunctionTemplate::New(isolate()); - templ->InstanceTemplate()->SetInternalFieldCount( - BaseObject::kInternalFieldCount); - set_binding_data_ctor_template(templ); + Local templ = ObjectTemplate::New(isolate()); + templ->SetInternalFieldCount(BaseObject::kInternalFieldCount); + set_binding_data_default_template(templ); binding::CreateInternalBindingTemplates(this); contextify::ContextifyContext::InitializeGlobalTemplates(this); diff --git a/src/env.h b/src/env.h index 5359436be31e76..bf28592c5bb3ee 100644 --- a/src/env.h +++ b/src/env.h @@ -163,7 +163,7 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer { #undef VS #undef VP -#define VM(PropertyName) V(PropertyName##_binding, v8::FunctionTemplate) +#define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate) #define V(PropertyName, TypeName) \ inline v8::Local PropertyName() const; \ inline void set_##PropertyName(v8::Local value); @@ -191,7 +191,7 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer { #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) #define VS(PropertyName, StringValue) V(v8::String, PropertyName) #define VR(PropertyName, TypeName) V(v8::Private, per_realm_##PropertyName) -#define VM(PropertyName) V(v8::FunctionTemplate, PropertyName##_binding) +#define VM(PropertyName) V(v8::ObjectTemplate, PropertyName##_binding_template) #define VT(PropertyName, TypeName) V(TypeName, PropertyName) #define V(TypeName, PropertyName) \ v8::Eternal PropertyName ## _; diff --git a/src/env_properties.h b/src/env_properties.h index 3ef589397dbdcc..77b143dbf78931 100644 --- a/src/env_properties.h +++ b/src/env_properties.h @@ -333,7 +333,7 @@ #define PER_ISOLATE_TEMPLATE_PROPERTIES(V) \ V(async_wrap_ctor_template, v8::FunctionTemplate) \ V(async_wrap_object_ctor_template, v8::FunctionTemplate) \ - V(binding_data_ctor_template, v8::FunctionTemplate) \ + V(binding_data_default_template, v8::ObjectTemplate) \ V(blob_constructor_template, v8::FunctionTemplate) \ V(blob_reader_constructor_template, v8::FunctionTemplate) \ V(blocklist_constructor_template, v8::FunctionTemplate) \ diff --git a/src/node_binding.cc b/src/node_binding.cc index cb27a497a3b6d1..e365bf1dbac5b4 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -101,7 +101,7 @@ NODE_BUILTIN_BINDINGS(V) #define V(modname) \ void _register_isolate_##modname(node::IsolateData* isolate_data, \ - v8::Local target); + v8::Local target); NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V) #undef V @@ -235,11 +235,11 @@ using v8::Context; using v8::EscapableHandleScope; using v8::Exception; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::Object; +using v8::ObjectTemplate; using v8::String; using v8::Value; @@ -572,12 +572,11 @@ inline struct node_module* FindModule(struct node_module* list, void CreateInternalBindingTemplates(IsolateData* isolate_data) { #define V(modname) \ do { \ - Local templ = \ - FunctionTemplate::New(isolate_data->isolate()); \ - templ->InstanceTemplate()->SetInternalFieldCount( \ - BaseObject::kInternalFieldCount); \ + Local templ = \ + ObjectTemplate::New(isolate_data->isolate()); \ + templ->SetInternalFieldCount(BaseObject::kInternalFieldCount); \ _register_isolate_##modname(isolate_data, templ); \ - isolate_data->set_##modname##_binding(templ); \ + isolate_data->set_##modname##_binding_template(templ); \ } while (0); NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V) #undef V @@ -586,21 +585,20 @@ void CreateInternalBindingTemplates(IsolateData* isolate_data) { static Local GetInternalBindingExportObject(IsolateData* isolate_data, const char* mod_name, Local context) { - Local ctor; + Local templ; + #define V(name) \ if (strcmp(mod_name, #name) == 0) { \ - ctor = isolate_data->name##_binding(); \ + templ = isolate_data->name##_binding_template(); \ } else // NOLINT(readability/braces) NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V) #undef V { - ctor = isolate_data->binding_data_ctor_template(); + // Default template. + templ = isolate_data->binding_data_default_template(); } - Local obj = ctor->GetFunction(context) - .ToLocalChecked() - ->NewInstance(context) - .ToLocalChecked(); + Local obj = templ->NewInstance(context).ToLocalChecked(); return obj; } diff --git a/src/node_binding.h b/src/node_binding.h index f04be60c3890f0..c2febb84ff3e58 100644 --- a/src/node_binding.h +++ b/src/node_binding.h @@ -83,7 +83,7 @@ namespace node { // list. #define NODE_BINDING_PER_ISOLATE_INIT(modname, per_isolate_func) \ void _register_isolate_##modname(node::IsolateData* isolate_data, \ - v8::Local target) { \ + v8::Local target) { \ per_isolate_func(isolate_data, target); \ } diff --git a/src/node_blob.cc b/src/node_blob.cc index a7b83f088f0777..6130360cacc537 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -109,9 +109,8 @@ void BlobFromFilePath(const FunctionCallbackInfo& args) { } // namespace void Blob::CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); SetMethod(isolate, target, "createBlob", New); SetMethod(isolate, target, "storeDataObject", StoreDataObject); diff --git a/src/node_blob.h b/src/node_blob.h index 96468534916e22..c601015d9af47b 100644 --- a/src/node_blob.h +++ b/src/node_blob.h @@ -27,7 +27,7 @@ class Blob : public BaseObject { ExternalReferenceRegistry* registry); static void CreatePerIsolateProperties(IsolateData* isolate_data, - v8::Local ctor); + v8::Local target); static void CreatePerContextProperties(v8::Local target, v8::Local unused, v8::Local context, diff --git a/src/node_builtins.cc b/src/node_builtins.cc index fb4d53e0ce3ddb..8673142d1e5dfd 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -15,7 +15,6 @@ using v8::DEFAULT; using v8::EscapableHandleScope; using v8::Function; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::IntegrityLevel; using v8::Isolate; using v8::Local; @@ -663,38 +662,37 @@ void BuiltinLoader::CopySourceAndCodeCacheReferenceFrom( } void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data, - Local target) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local proto = target->PrototypeTemplate(); - - proto->SetAccessor(isolate_data->config_string(), - ConfigStringGetter, - nullptr, - Local(), - DEFAULT, - None, - SideEffectType::kHasNoSideEffect); - - proto->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"), - BuiltinIdsGetter, - nullptr, - Local(), - DEFAULT, - None, - SideEffectType::kHasNoSideEffect); - - proto->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"), - GetBuiltinCategories, - nullptr, - Local(), - DEFAULT, - None, - SideEffectType::kHasNoSideEffect); - - SetMethod(isolate, proto, "getCacheUsage", BuiltinLoader::GetCacheUsage); - SetMethod(isolate, proto, "compileFunction", BuiltinLoader::CompileFunction); - SetMethod(isolate, proto, "hasCachedBuiltins", HasCachedBuiltins); - SetMethod(isolate, proto, "setInternalLoaders", SetInternalLoaders); + + target->SetAccessor(isolate_data->config_string(), + ConfigStringGetter, + nullptr, + Local(), + DEFAULT, + None, + SideEffectType::kHasNoSideEffect); + + target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"), + BuiltinIdsGetter, + nullptr, + Local(), + DEFAULT, + None, + SideEffectType::kHasNoSideEffect); + + target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"), + GetBuiltinCategories, + nullptr, + Local(), + DEFAULT, + None, + SideEffectType::kHasNoSideEffect); + + SetMethod(isolate, target, "getCacheUsage", BuiltinLoader::GetCacheUsage); + SetMethod(isolate, target, "compileFunction", BuiltinLoader::CompileFunction); + SetMethod(isolate, target, "hasCachedBuiltins", HasCachedBuiltins); + SetMethod(isolate, target, "setInternalLoaders", SetInternalLoaders); } void BuiltinLoader::CreatePerContextProperties(Local target, diff --git a/src/node_builtins.h b/src/node_builtins.h index 11af941780be90..3cfdf552a31b9a 100644 --- a/src/node_builtins.h +++ b/src/node_builtins.h @@ -84,8 +84,8 @@ class NODE_EXTERN_PRIVATE BuiltinLoader { BuiltinLoader& operator=(const BuiltinLoader&) = delete; static void RegisterExternalReferences(ExternalReferenceRegistry* registry); - static void CreatePerIsolateProperties( - IsolateData* isolate_data, v8::Local target); + static void CreatePerIsolateProperties(IsolateData* isolate_data, + v8::Local target); static void CreatePerContextProperties(v8::Local target, v8::Local unused, v8::Local context, diff --git a/src/node_contextify.cc b/src/node_contextify.cc index eb84d35985f769..75cb88fce8e8d3 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1393,9 +1393,9 @@ void MicrotaskQueueWrap::RegisterExternalReferences( } void CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); + ContextifyContext::CreatePerIsolateProperties(isolate_data, target); ContextifyScript::CreatePerIsolateProperties(isolate_data, target); MicrotaskQueueWrap::CreatePerIsolateProperties(isolate_data, target); diff --git a/src/node_file.cc b/src/node_file.cc index 9c69cdfc7ed821..5a92432019dbb1 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2827,9 +2827,8 @@ InternalFieldInfoBase* BindingData::Serialize(int index) { } static void CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); SetMethod(isolate, target, "access", Access); SetMethod(isolate, target, "close", Close); @@ -2873,7 +2872,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data, SetMethod(isolate, target, "mkdtemp", Mkdtemp); - StatWatcher::CreatePerIsolateProperties(isolate_data, ctor); + StatWatcher::CreatePerIsolateProperties(isolate_data, target); target->Set( FIXED_ONE_BYTE_STRING(isolate, "kFsStatsFieldsNumber"), diff --git a/src/node_i18n.cc b/src/node_i18n.cc index e60b58b57185ff..372df8d029fc4f 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -860,17 +860,16 @@ static void GetStringWidth(const FunctionCallbackInfo& args) { } static void CreatePerIsolateProperties(IsolateData* isolate_data, - Local target) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local proto = target->PrototypeTemplate(); - SetMethod(isolate, proto, "toUnicode", ToUnicode); - SetMethod(isolate, proto, "toASCII", ToASCII); - SetMethod(isolate, proto, "getStringWidth", GetStringWidth); + SetMethod(isolate, target, "toUnicode", ToUnicode); + SetMethod(isolate, target, "toASCII", ToASCII); + SetMethod(isolate, target, "getStringWidth", GetStringWidth); // One-shot converters - SetMethod(isolate, proto, "icuErrName", ICUErrorName); - SetMethod(isolate, proto, "transcode", Transcode); + SetMethod(isolate, target, "icuErrName", ICUErrorName); + SetMethod(isolate, target, "transcode", Transcode); // ConverterObject { @@ -883,9 +882,9 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data, isolate_data->set_i18n_converter_template(t->InstanceTemplate()); } - SetMethod(isolate, proto, "getConverter", ConverterObject::Create); - SetMethod(isolate, proto, "decode", ConverterObject::Decode); - SetMethod(isolate, proto, "hasConverter", ConverterObject::Has); + SetMethod(isolate, target, "getConverter", ConverterObject::Create); + SetMethod(isolate, target, "decode", ConverterObject::Decode); + SetMethod(isolate, target, "hasConverter", ConverterObject::Has); } void CreatePerContextProperties(Local target, diff --git a/src/node_perf.cc b/src/node_perf.cc index 94773fa9e9fed6..555a90b0a76091 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -18,7 +18,6 @@ using v8::Context; using v8::DontDelete; using v8::Function; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::GCCallbackFlags; using v8::GCType; using v8::Int32; @@ -296,28 +295,27 @@ void MarkBootstrapComplete(const FunctionCallbackInfo& args) { } static void CreatePerIsolateProperties(IsolateData* isolate_data, - Local target) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local proto = target->PrototypeTemplate(); - HistogramBase::Initialize(isolate_data, proto); + HistogramBase::Initialize(isolate_data, target); - SetMethod(isolate, proto, "markMilestone", MarkMilestone); - SetMethod(isolate, proto, "setupObservers", SetupPerformanceObservers); + SetMethod(isolate, target, "markMilestone", MarkMilestone); + SetMethod(isolate, target, "setupObservers", SetupPerformanceObservers); SetMethod(isolate, - proto, + target, "installGarbageCollectionTracking", InstallGarbageCollectionTracking); SetMethod(isolate, - proto, + target, "removeGarbageCollectionTracking", RemoveGarbageCollectionTracking); - SetMethod(isolate, proto, "notify", Notify); - SetMethod(isolate, proto, "loopIdleTime", LoopIdleTime); - SetMethod(isolate, proto, "getTimeOrigin", GetTimeOrigin); - SetMethod(isolate, proto, "getTimeOriginTimestamp", GetTimeOriginTimeStamp); - SetMethod(isolate, proto, "createELDHistogram", CreateELDHistogram); - SetMethod(isolate, proto, "markBootstrapComplete", MarkBootstrapComplete); + SetMethod(isolate, target, "notify", Notify); + SetMethod(isolate, target, "loopIdleTime", LoopIdleTime); + SetMethod(isolate, target, "getTimeOrigin", GetTimeOrigin); + SetMethod(isolate, target, "getTimeOriginTimestamp", GetTimeOriginTimeStamp); + SetMethod(isolate, target, "createELDHistogram", CreateELDHistogram); + SetMethod(isolate, target, "markBootstrapComplete", MarkBootstrapComplete); } void CreatePerContextProperties(Local target, diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index bd0ba33d7d8dd9..eca0b343baef3a 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -41,7 +41,6 @@ using v8::CFunction; using v8::Context; using v8::Float64Array; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::HeapStatistics; using v8::Integer; using v8::Isolate; @@ -572,9 +571,8 @@ void BindingData::Deserialize(Local context, } static void CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); BindingData::AddMethods(isolate, target); // define various internal methods diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index 39a22eb2e1fca5..79a0b7ed9965a7 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -45,9 +45,8 @@ using v8::Uint32; using v8::Value; void StatWatcher::CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); Local t = NewFunctionTemplate(isolate, StatWatcher::New); t->InstanceTemplate()->SetInternalFieldCount( diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h index cc76975ddb5653..b4341cd872439a 100644 --- a/src/node_stat_watcher.h +++ b/src/node_stat_watcher.h @@ -40,7 +40,7 @@ class ExternalReferenceRegistry; class StatWatcher : public HandleWrap { public: static void CreatePerIsolateProperties(IsolateData* isolate_data, - v8::Local ctor); + v8::Local ctor); static void RegisterExternalReferences(ExternalReferenceRegistry* registry); protected: diff --git a/src/node_url.cc b/src/node_url.cc index c5e1be2131fd23..ef845c612ef464 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -19,7 +19,6 @@ using v8::CFunction; using v8::Context; using v8::FastOneByteString; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::HandleScope; using v8::Isolate; using v8::Local; @@ -318,9 +317,8 @@ void BindingData::UpdateComponents(const ada::url_components& components, } void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); SetMethodNoSideEffect(isolate, target, "domainToASCII", DomainToASCII); SetMethodNoSideEffect(isolate, target, "domainToUnicode", DomainToUnicode); SetMethodNoSideEffect(isolate, target, "format", Format); diff --git a/src/node_url.h b/src/node_url.h index 04a57a9e2c413a..dffe4b63ef11ad 100644 --- a/src/node_url.h +++ b/src/node_url.h @@ -57,7 +57,7 @@ class BindingData : public SnapshotableObject { static void Update(const v8::FunctionCallbackInfo& args); static void CreatePerIsolateProperties(IsolateData* isolate_data, - v8::Local ctor); + v8::Local ctor); static void CreatePerContextProperties(v8::Local target, v8::Local unused, v8::Local context, diff --git a/src/node_worker.cc b/src/node_worker.cc index 2bb5bdf569ebef..284df890494e05 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -900,9 +900,8 @@ void GetEnvMessagePort(const FunctionCallbackInfo& args) { } void CreateWorkerPerIsolateProperties(IsolateData* isolate_data, - Local target) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local proto = target->PrototypeTemplate(); { Local w = NewFunctionTemplate(isolate, Worker::New); @@ -921,7 +920,7 @@ void CreateWorkerPerIsolateProperties(IsolateData* isolate_data, SetProtoMethod(isolate, w, "loopIdleTime", Worker::LoopIdleTime); SetProtoMethod(isolate, w, "loopStartTime", Worker::LoopStartTime); - SetConstructorFunction(isolate, proto, "Worker", w); + SetConstructorFunction(isolate, target, "Worker", w); } { @@ -938,7 +937,7 @@ void CreateWorkerPerIsolateProperties(IsolateData* isolate_data, wst->InstanceTemplate()); } - SetMethod(isolate, proto, "getEnvMessagePort", GetEnvMessagePort); + SetMethod(isolate, target, "getEnvMessagePort", GetEnvMessagePort); } void CreateWorkerPerContextProperties(Local target, diff --git a/src/timers.cc b/src/timers.cc index 8318894e33cb54..59b4770fa219e8 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -12,7 +12,6 @@ namespace timers { using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; -using v8::FunctionTemplate; using v8::Isolate; using v8::Local; using v8::Number; @@ -123,9 +122,8 @@ v8::CFunction BindingData::fast_toggle_immediate_ref_( v8::CFunction::Make(FastToggleImmediateRef)); void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, - Local ctor) { + Local target) { Isolate* isolate = isolate_data->isolate(); - Local target = ctor->InstanceTemplate(); SetMethod(isolate, target, "setupTimers", SetupTimers); SetFastMethod( diff --git a/src/timers.h b/src/timers.h index 61cc5d6bf8ed43..d514a70fc25990 100644 --- a/src/timers.h +++ b/src/timers.h @@ -46,7 +46,7 @@ class BindingData : public SnapshotableObject { static void ToggleImmediateRefImpl(BindingData* data, bool ref); static void CreatePerIsolateProperties(IsolateData* isolate_data, - v8::Local ctor); + v8::Local target); static void CreatePerContextProperties(v8::Local target, v8::Local unused, v8::Local context,