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: ... }; ``` PR-URL: https://github.com/nodejs/node/pull/47913 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
21153a8c22
commit
c0365fd52a
@ -353,9 +353,8 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AsyncWrap::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void AsyncWrap::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
|
|
||||||
SetMethod(isolate, target, "setupHooks", SetupHooks);
|
SetMethod(isolate, target, "setupHooks", SetupHooks);
|
||||||
SetMethod(isolate, target, "setCallbackTrampoline", SetCallbackTrampoline);
|
SetMethod(isolate, target, "setCallbackTrampoline", SetCallbackTrampoline);
|
||||||
|
@ -151,8 +151,8 @@ class AsyncWrap : public BaseObject {
|
|||||||
v8::Local<v8::Value> unused,
|
v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
void* priv);
|
void* priv);
|
||||||
static void CreatePerIsolateProperties(
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
IsolateData* isolate_data, v8::Local<v8::FunctionTemplate> target);
|
v8::Local<v8::ObjectTemplate> target);
|
||||||
|
|
||||||
static void GetAsyncId(const v8::FunctionCallbackInfo<v8::Value>& args);
|
static void GetAsyncId(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||||
static void PushAsyncContext(const v8::FunctionCallbackInfo<v8::Value>& args);
|
static void PushAsyncContext(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||||
|
@ -16,7 +16,6 @@ using v8::ArrayBuffer;
|
|||||||
using v8::BackingStore;
|
using v8::BackingStore;
|
||||||
using v8::Context;
|
using v8::Context;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
using v8::MaybeLocal;
|
using v8::MaybeLocal;
|
||||||
@ -219,9 +218,8 @@ void BindingData::ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
SetMethod(isolate, target, "encodeInto", EncodeInto);
|
SetMethod(isolate, target, "encodeInto", EncodeInto);
|
||||||
SetMethodNoSideEffect(isolate, target, "encodeUtf8String", EncodeUtf8String);
|
SetMethodNoSideEffect(isolate, target, "encodeUtf8String", EncodeUtf8String);
|
||||||
SetMethodNoSideEffect(isolate, target, "decodeUTF8", DecodeUTF8);
|
SetMethodNoSideEffect(isolate, target, "decodeUTF8", DecodeUTF8);
|
||||||
|
@ -36,7 +36,7 @@ class BindingData : public SnapshotableObject {
|
|||||||
static void ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
|
static void ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
v8::Local<v8::FunctionTemplate> ctor);
|
v8::Local<v8::ObjectTemplate> target);
|
||||||
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
||||||
v8::Local<v8::Value> unused,
|
v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
|
@ -807,7 +807,7 @@ void Environment::set_process_exit_handler(
|
|||||||
#undef VY
|
#undef VY
|
||||||
#undef VP
|
#undef VP
|
||||||
|
|
||||||
#define VM(PropertyName) V(PropertyName##_binding, v8::FunctionTemplate)
|
#define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate)
|
||||||
#define V(PropertyName, TypeName) \
|
#define V(PropertyName, TypeName) \
|
||||||
inline v8::Local<TypeName> IsolateData::PropertyName() const { \
|
inline v8::Local<TypeName> IsolateData::PropertyName() const { \
|
||||||
return PropertyName##_.Get(isolate_); \
|
return PropertyName##_.Get(isolate_); \
|
||||||
|
13
src/env.cc
13
src/env.cc
@ -38,7 +38,6 @@ using v8::Context;
|
|||||||
using v8::EmbedderGraph;
|
using v8::EmbedderGraph;
|
||||||
using v8::EscapableHandleScope;
|
using v8::EscapableHandleScope;
|
||||||
using v8::Function;
|
using v8::Function;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::HandleScope;
|
using v8::HandleScope;
|
||||||
using v8::HeapProfiler;
|
using v8::HeapProfiler;
|
||||||
using v8::HeapSpaceStatistics;
|
using v8::HeapSpaceStatistics;
|
||||||
@ -49,6 +48,7 @@ using v8::MaybeLocal;
|
|||||||
using v8::NewStringType;
|
using v8::NewStringType;
|
||||||
using v8::Number;
|
using v8::Number;
|
||||||
using v8::Object;
|
using v8::Object;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
using v8::Private;
|
using v8::Private;
|
||||||
using v8::Script;
|
using v8::Script;
|
||||||
using v8::SnapshotCreator;
|
using v8::SnapshotCreator;
|
||||||
@ -326,7 +326,7 @@ IsolateDataSerializeInfo IsolateData::Serialize(SnapshotCreator* creator) {
|
|||||||
info.primitive_values.push_back(creator->AddData(async_wrap_provider(i)));
|
info.primitive_values.push_back(creator->AddData(async_wrap_provider(i)));
|
||||||
|
|
||||||
uint32_t id = 0;
|
uint32_t id = 0;
|
||||||
#define VM(PropertyName) V(PropertyName##_binding, FunctionTemplate)
|
#define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate)
|
||||||
#define V(PropertyName, TypeName) \
|
#define V(PropertyName, TypeName) \
|
||||||
do { \
|
do { \
|
||||||
Local<TypeName> field = PropertyName(); \
|
Local<TypeName> field = PropertyName(); \
|
||||||
@ -390,7 +390,7 @@ void IsolateData::DeserializeProperties(const IsolateDataSerializeInfo* info) {
|
|||||||
const std::vector<PropInfo>& values = info->template_values;
|
const std::vector<PropInfo>& values = info->template_values;
|
||||||
i = 0; // index to the array
|
i = 0; // index to the array
|
||||||
uint32_t id = 0;
|
uint32_t id = 0;
|
||||||
#define VM(PropertyName) V(PropertyName##_binding, FunctionTemplate)
|
#define VM(PropertyName) V(PropertyName##_binding_template, ObjectTemplate)
|
||||||
#define V(PropertyName, TypeName) \
|
#define V(PropertyName, TypeName) \
|
||||||
do { \
|
do { \
|
||||||
if (values.size() > i && id == values[i].id) { \
|
if (values.size() > i && id == values[i].id) { \
|
||||||
@ -491,10 +491,9 @@ void IsolateData::CreateProperties() {
|
|||||||
NODE_ASYNC_PROVIDER_TYPES(V)
|
NODE_ASYNC_PROVIDER_TYPES(V)
|
||||||
#undef V
|
#undef V
|
||||||
|
|
||||||
Local<FunctionTemplate> templ = FunctionTemplate::New(isolate());
|
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate());
|
||||||
templ->InstanceTemplate()->SetInternalFieldCount(
|
templ->SetInternalFieldCount(BaseObject::kInternalFieldCount);
|
||||||
BaseObject::kInternalFieldCount);
|
set_binding_data_default_template(templ);
|
||||||
set_binding_data_ctor_template(templ);
|
|
||||||
binding::CreateInternalBindingTemplates(this);
|
binding::CreateInternalBindingTemplates(this);
|
||||||
|
|
||||||
contextify::ContextifyContext::InitializeGlobalTemplates(this);
|
contextify::ContextifyContext::InitializeGlobalTemplates(this);
|
||||||
|
@ -166,7 +166,7 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
|
|||||||
#undef VS
|
#undef VS
|
||||||
#undef VP
|
#undef VP
|
||||||
|
|
||||||
#define VM(PropertyName) V(PropertyName##_binding, v8::FunctionTemplate)
|
#define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate)
|
||||||
#define V(PropertyName, TypeName) \
|
#define V(PropertyName, TypeName) \
|
||||||
inline v8::Local<TypeName> PropertyName() const; \
|
inline v8::Local<TypeName> PropertyName() const; \
|
||||||
inline void set_##PropertyName(v8::Local<TypeName> value);
|
inline void set_##PropertyName(v8::Local<TypeName> value);
|
||||||
@ -194,7 +194,7 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
|
|||||||
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
|
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
|
||||||
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
|
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
|
||||||
#define VR(PropertyName, TypeName) V(v8::Private, per_realm_##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 VT(PropertyName, TypeName) V(TypeName, PropertyName)
|
||||||
#define V(TypeName, PropertyName) \
|
#define V(TypeName, PropertyName) \
|
||||||
v8::Eternal<TypeName> PropertyName ## _;
|
v8::Eternal<TypeName> PropertyName ## _;
|
||||||
|
@ -333,7 +333,7 @@
|
|||||||
#define PER_ISOLATE_TEMPLATE_PROPERTIES(V) \
|
#define PER_ISOLATE_TEMPLATE_PROPERTIES(V) \
|
||||||
V(async_wrap_ctor_template, v8::FunctionTemplate) \
|
V(async_wrap_ctor_template, v8::FunctionTemplate) \
|
||||||
V(async_wrap_object_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_constructor_template, v8::FunctionTemplate) \
|
||||||
V(blob_reader_constructor_template, v8::FunctionTemplate) \
|
V(blob_reader_constructor_template, v8::FunctionTemplate) \
|
||||||
V(blocklist_constructor_template, v8::FunctionTemplate) \
|
V(blocklist_constructor_template, v8::FunctionTemplate) \
|
||||||
|
@ -101,7 +101,7 @@ NODE_BUILTIN_BINDINGS(V)
|
|||||||
|
|
||||||
#define V(modname) \
|
#define V(modname) \
|
||||||
void _register_isolate_##modname(node::IsolateData* isolate_data, \
|
void _register_isolate_##modname(node::IsolateData* isolate_data, \
|
||||||
v8::Local<v8::FunctionTemplate> target);
|
v8::Local<v8::ObjectTemplate> target);
|
||||||
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
|
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
|
||||||
#undef V
|
#undef V
|
||||||
|
|
||||||
@ -235,11 +235,11 @@ using v8::Context;
|
|||||||
using v8::EscapableHandleScope;
|
using v8::EscapableHandleScope;
|
||||||
using v8::Exception;
|
using v8::Exception;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::HandleScope;
|
using v8::HandleScope;
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
using v8::Object;
|
using v8::Object;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
using v8::String;
|
using v8::String;
|
||||||
using v8::Value;
|
using v8::Value;
|
||||||
|
|
||||||
@ -572,12 +572,11 @@ inline struct node_module* FindModule(struct node_module* list,
|
|||||||
void CreateInternalBindingTemplates(IsolateData* isolate_data) {
|
void CreateInternalBindingTemplates(IsolateData* isolate_data) {
|
||||||
#define V(modname) \
|
#define V(modname) \
|
||||||
do { \
|
do { \
|
||||||
Local<FunctionTemplate> templ = \
|
Local<ObjectTemplate> templ = \
|
||||||
FunctionTemplate::New(isolate_data->isolate()); \
|
ObjectTemplate::New(isolate_data->isolate()); \
|
||||||
templ->InstanceTemplate()->SetInternalFieldCount( \
|
templ->SetInternalFieldCount(BaseObject::kInternalFieldCount); \
|
||||||
BaseObject::kInternalFieldCount); \
|
|
||||||
_register_isolate_##modname(isolate_data, templ); \
|
_register_isolate_##modname(isolate_data, templ); \
|
||||||
isolate_data->set_##modname##_binding(templ); \
|
isolate_data->set_##modname##_binding_template(templ); \
|
||||||
} while (0);
|
} while (0);
|
||||||
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
|
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
|
||||||
#undef V
|
#undef V
|
||||||
@ -586,21 +585,20 @@ void CreateInternalBindingTemplates(IsolateData* isolate_data) {
|
|||||||
static Local<Object> GetInternalBindingExportObject(IsolateData* isolate_data,
|
static Local<Object> GetInternalBindingExportObject(IsolateData* isolate_data,
|
||||||
const char* mod_name,
|
const char* mod_name,
|
||||||
Local<Context> context) {
|
Local<Context> context) {
|
||||||
Local<FunctionTemplate> ctor;
|
Local<ObjectTemplate> templ;
|
||||||
|
|
||||||
#define V(name) \
|
#define V(name) \
|
||||||
if (strcmp(mod_name, #name) == 0) { \
|
if (strcmp(mod_name, #name) == 0) { \
|
||||||
ctor = isolate_data->name##_binding(); \
|
templ = isolate_data->name##_binding_template(); \
|
||||||
} else // NOLINT(readability/braces)
|
} else // NOLINT(readability/braces)
|
||||||
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
|
NODE_BINDINGS_WITH_PER_ISOLATE_INIT(V)
|
||||||
#undef V
|
#undef V
|
||||||
{
|
{
|
||||||
ctor = isolate_data->binding_data_ctor_template();
|
// Default template.
|
||||||
|
templ = isolate_data->binding_data_default_template();
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Object> obj = ctor->GetFunction(context)
|
Local<Object> obj = templ->NewInstance(context).ToLocalChecked();
|
||||||
.ToLocalChecked()
|
|
||||||
->NewInstance(context)
|
|
||||||
.ToLocalChecked();
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace node {
|
|||||||
// list.
|
// list.
|
||||||
#define NODE_BINDING_PER_ISOLATE_INIT(modname, per_isolate_func) \
|
#define NODE_BINDING_PER_ISOLATE_INIT(modname, per_isolate_func) \
|
||||||
void _register_isolate_##modname(node::IsolateData* isolate_data, \
|
void _register_isolate_##modname(node::IsolateData* isolate_data, \
|
||||||
v8::Local<v8::FunctionTemplate> target) { \
|
v8::Local<v8::ObjectTemplate> target) { \
|
||||||
per_isolate_func(isolate_data, target); \
|
per_isolate_func(isolate_data, target); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,9 +109,8 @@ void BlobFromFilePath(const FunctionCallbackInfo<Value>& args) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Blob::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void Blob::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
|
|
||||||
SetMethod(isolate, target, "createBlob", New);
|
SetMethod(isolate, target, "createBlob", New);
|
||||||
SetMethod(isolate, target, "storeDataObject", StoreDataObject);
|
SetMethod(isolate, target, "storeDataObject", StoreDataObject);
|
||||||
|
@ -27,7 +27,7 @@ class Blob : public BaseObject {
|
|||||||
ExternalReferenceRegistry* registry);
|
ExternalReferenceRegistry* registry);
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
v8::Local<v8::FunctionTemplate> ctor);
|
v8::Local<v8::ObjectTemplate> target);
|
||||||
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
||||||
v8::Local<v8::Value> unused,
|
v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
|
@ -15,7 +15,6 @@ using v8::DEFAULT;
|
|||||||
using v8::EscapableHandleScope;
|
using v8::EscapableHandleScope;
|
||||||
using v8::Function;
|
using v8::Function;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::IntegrityLevel;
|
using v8::IntegrityLevel;
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
@ -663,11 +662,10 @@ void BuiltinLoader::CopySourceAndCodeCacheReferenceFrom(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> target) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> proto = target->PrototypeTemplate();
|
|
||||||
|
|
||||||
proto->SetAccessor(isolate_data->config_string(),
|
target->SetAccessor(isolate_data->config_string(),
|
||||||
ConfigStringGetter,
|
ConfigStringGetter,
|
||||||
nullptr,
|
nullptr,
|
||||||
Local<Value>(),
|
Local<Value>(),
|
||||||
@ -675,7 +673,7 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
|
|||||||
None,
|
None,
|
||||||
SideEffectType::kHasNoSideEffect);
|
SideEffectType::kHasNoSideEffect);
|
||||||
|
|
||||||
proto->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
|
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
|
||||||
BuiltinIdsGetter,
|
BuiltinIdsGetter,
|
||||||
nullptr,
|
nullptr,
|
||||||
Local<Value>(),
|
Local<Value>(),
|
||||||
@ -683,7 +681,7 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
|
|||||||
None,
|
None,
|
||||||
SideEffectType::kHasNoSideEffect);
|
SideEffectType::kHasNoSideEffect);
|
||||||
|
|
||||||
proto->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"),
|
target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"),
|
||||||
GetBuiltinCategories,
|
GetBuiltinCategories,
|
||||||
nullptr,
|
nullptr,
|
||||||
Local<Value>(),
|
Local<Value>(),
|
||||||
@ -691,10 +689,10 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
|
|||||||
None,
|
None,
|
||||||
SideEffectType::kHasNoSideEffect);
|
SideEffectType::kHasNoSideEffect);
|
||||||
|
|
||||||
SetMethod(isolate, proto, "getCacheUsage", BuiltinLoader::GetCacheUsage);
|
SetMethod(isolate, target, "getCacheUsage", BuiltinLoader::GetCacheUsage);
|
||||||
SetMethod(isolate, proto, "compileFunction", BuiltinLoader::CompileFunction);
|
SetMethod(isolate, target, "compileFunction", BuiltinLoader::CompileFunction);
|
||||||
SetMethod(isolate, proto, "hasCachedBuiltins", HasCachedBuiltins);
|
SetMethod(isolate, target, "hasCachedBuiltins", HasCachedBuiltins);
|
||||||
SetMethod(isolate, proto, "setInternalLoaders", SetInternalLoaders);
|
SetMethod(isolate, target, "setInternalLoaders", SetInternalLoaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltinLoader::CreatePerContextProperties(Local<Object> target,
|
void BuiltinLoader::CreatePerContextProperties(Local<Object> target,
|
||||||
|
@ -84,8 +84,8 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
|
|||||||
BuiltinLoader& operator=(const BuiltinLoader&) = delete;
|
BuiltinLoader& operator=(const BuiltinLoader&) = delete;
|
||||||
|
|
||||||
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
||||||
static void CreatePerIsolateProperties(
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
IsolateData* isolate_data, v8::Local<v8::FunctionTemplate> target);
|
v8::Local<v8::ObjectTemplate> target);
|
||||||
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
||||||
v8::Local<v8::Value> unused,
|
v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
|
@ -1393,9 +1393,9 @@ void MicrotaskQueueWrap::RegisterExternalReferences(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CreatePerIsolateProperties(IsolateData* isolate_data,
|
void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
ContextifyContext::CreatePerIsolateProperties(isolate_data, target);
|
ContextifyContext::CreatePerIsolateProperties(isolate_data, target);
|
||||||
ContextifyScript::CreatePerIsolateProperties(isolate_data, target);
|
ContextifyScript::CreatePerIsolateProperties(isolate_data, target);
|
||||||
MicrotaskQueueWrap::CreatePerIsolateProperties(isolate_data, target);
|
MicrotaskQueueWrap::CreatePerIsolateProperties(isolate_data, target);
|
||||||
|
@ -2827,9 +2827,8 @@ InternalFieldInfoBase* BindingData::Serialize(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
|
|
||||||
SetMethod(isolate, target, "access", Access);
|
SetMethod(isolate, target, "access", Access);
|
||||||
SetMethod(isolate, target, "close", Close);
|
SetMethod(isolate, target, "close", Close);
|
||||||
@ -2873,7 +2872,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|||||||
|
|
||||||
SetMethod(isolate, target, "mkdtemp", Mkdtemp);
|
SetMethod(isolate, target, "mkdtemp", Mkdtemp);
|
||||||
|
|
||||||
StatWatcher::CreatePerIsolateProperties(isolate_data, ctor);
|
StatWatcher::CreatePerIsolateProperties(isolate_data, target);
|
||||||
|
|
||||||
target->Set(
|
target->Set(
|
||||||
FIXED_ONE_BYTE_STRING(isolate, "kFsStatsFieldsNumber"),
|
FIXED_ONE_BYTE_STRING(isolate, "kFsStatsFieldsNumber"),
|
||||||
|
@ -860,17 +860,16 @@ static void GetStringWidth(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> target) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> proto = target->PrototypeTemplate();
|
|
||||||
|
|
||||||
SetMethod(isolate, proto, "toUnicode", ToUnicode);
|
SetMethod(isolate, target, "toUnicode", ToUnicode);
|
||||||
SetMethod(isolate, proto, "toASCII", ToASCII);
|
SetMethod(isolate, target, "toASCII", ToASCII);
|
||||||
SetMethod(isolate, proto, "getStringWidth", GetStringWidth);
|
SetMethod(isolate, target, "getStringWidth", GetStringWidth);
|
||||||
|
|
||||||
// One-shot converters
|
// One-shot converters
|
||||||
SetMethod(isolate, proto, "icuErrName", ICUErrorName);
|
SetMethod(isolate, target, "icuErrName", ICUErrorName);
|
||||||
SetMethod(isolate, proto, "transcode", Transcode);
|
SetMethod(isolate, target, "transcode", Transcode);
|
||||||
|
|
||||||
// ConverterObject
|
// ConverterObject
|
||||||
{
|
{
|
||||||
@ -883,9 +882,9 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|||||||
isolate_data->set_i18n_converter_template(t->InstanceTemplate());
|
isolate_data->set_i18n_converter_template(t->InstanceTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMethod(isolate, proto, "getConverter", ConverterObject::Create);
|
SetMethod(isolate, target, "getConverter", ConverterObject::Create);
|
||||||
SetMethod(isolate, proto, "decode", ConverterObject::Decode);
|
SetMethod(isolate, target, "decode", ConverterObject::Decode);
|
||||||
SetMethod(isolate, proto, "hasConverter", ConverterObject::Has);
|
SetMethod(isolate, target, "hasConverter", ConverterObject::Has);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatePerContextProperties(Local<Object> target,
|
void CreatePerContextProperties(Local<Object> target,
|
||||||
|
@ -18,7 +18,6 @@ using v8::Context;
|
|||||||
using v8::DontDelete;
|
using v8::DontDelete;
|
||||||
using v8::Function;
|
using v8::Function;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::GCCallbackFlags;
|
using v8::GCCallbackFlags;
|
||||||
using v8::GCType;
|
using v8::GCType;
|
||||||
using v8::Int32;
|
using v8::Int32;
|
||||||
@ -296,28 +295,27 @@ void MarkBootstrapComplete(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> target) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> proto = target->PrototypeTemplate();
|
|
||||||
|
|
||||||
HistogramBase::Initialize(isolate_data, proto);
|
HistogramBase::Initialize(isolate_data, target);
|
||||||
|
|
||||||
SetMethod(isolate, proto, "markMilestone", MarkMilestone);
|
SetMethod(isolate, target, "markMilestone", MarkMilestone);
|
||||||
SetMethod(isolate, proto, "setupObservers", SetupPerformanceObservers);
|
SetMethod(isolate, target, "setupObservers", SetupPerformanceObservers);
|
||||||
SetMethod(isolate,
|
SetMethod(isolate,
|
||||||
proto,
|
target,
|
||||||
"installGarbageCollectionTracking",
|
"installGarbageCollectionTracking",
|
||||||
InstallGarbageCollectionTracking);
|
InstallGarbageCollectionTracking);
|
||||||
SetMethod(isolate,
|
SetMethod(isolate,
|
||||||
proto,
|
target,
|
||||||
"removeGarbageCollectionTracking",
|
"removeGarbageCollectionTracking",
|
||||||
RemoveGarbageCollectionTracking);
|
RemoveGarbageCollectionTracking);
|
||||||
SetMethod(isolate, proto, "notify", Notify);
|
SetMethod(isolate, target, "notify", Notify);
|
||||||
SetMethod(isolate, proto, "loopIdleTime", LoopIdleTime);
|
SetMethod(isolate, target, "loopIdleTime", LoopIdleTime);
|
||||||
SetMethod(isolate, proto, "getTimeOrigin", GetTimeOrigin);
|
SetMethod(isolate, target, "getTimeOrigin", GetTimeOrigin);
|
||||||
SetMethod(isolate, proto, "getTimeOriginTimestamp", GetTimeOriginTimeStamp);
|
SetMethod(isolate, target, "getTimeOriginTimestamp", GetTimeOriginTimeStamp);
|
||||||
SetMethod(isolate, proto, "createELDHistogram", CreateELDHistogram);
|
SetMethod(isolate, target, "createELDHistogram", CreateELDHistogram);
|
||||||
SetMethod(isolate, proto, "markBootstrapComplete", MarkBootstrapComplete);
|
SetMethod(isolate, target, "markBootstrapComplete", MarkBootstrapComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatePerContextProperties(Local<Object> target,
|
void CreatePerContextProperties(Local<Object> target,
|
||||||
|
@ -41,7 +41,6 @@ using v8::CFunction;
|
|||||||
using v8::Context;
|
using v8::Context;
|
||||||
using v8::Float64Array;
|
using v8::Float64Array;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::HeapStatistics;
|
using v8::HeapStatistics;
|
||||||
using v8::Integer;
|
using v8::Integer;
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
@ -572,9 +571,8 @@ void BindingData::Deserialize(Local<Context> context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
|
|
||||||
BindingData::AddMethods(isolate, target);
|
BindingData::AddMethods(isolate, target);
|
||||||
// define various internal methods
|
// define various internal methods
|
||||||
|
@ -35,7 +35,6 @@ namespace node {
|
|||||||
using v8::Context;
|
using v8::Context;
|
||||||
using v8::Function;
|
using v8::Function;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::HandleScope;
|
using v8::HandleScope;
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
@ -1325,9 +1324,8 @@ void CreatePerContextProperties(Local<Object> target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CreatePerIsolateProperties(IsolateData* isolate_data,
|
void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->PrototypeTemplate();
|
|
||||||
SetMethod(
|
SetMethod(
|
||||||
isolate, target, "getEmbedderEntryFunction", GetEmbedderEntryFunction);
|
isolate, target, "getEmbedderEntryFunction", GetEmbedderEntryFunction);
|
||||||
SetMethod(isolate, target, "compileSerializeMain", CompileSerializeMain);
|
SetMethod(isolate, target, "compileSerializeMain", CompileSerializeMain);
|
||||||
|
@ -45,9 +45,8 @@ using v8::Uint32;
|
|||||||
using v8::Value;
|
using v8::Value;
|
||||||
|
|
||||||
void StatWatcher::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void StatWatcher::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
|
|
||||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, StatWatcher::New);
|
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, StatWatcher::New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(
|
t->InstanceTemplate()->SetInternalFieldCount(
|
||||||
|
@ -40,7 +40,7 @@ class ExternalReferenceRegistry;
|
|||||||
class StatWatcher : public HandleWrap {
|
class StatWatcher : public HandleWrap {
|
||||||
public:
|
public:
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
v8::Local<v8::FunctionTemplate> ctor);
|
v8::Local<v8::ObjectTemplate> ctor);
|
||||||
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -19,7 +19,6 @@ using v8::CFunction;
|
|||||||
using v8::Context;
|
using v8::Context;
|
||||||
using v8::FastOneByteString;
|
using v8::FastOneByteString;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::HandleScope;
|
using v8::HandleScope;
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
@ -318,9 +317,8 @@ void BindingData::UpdateComponents(const ada::url_components& components,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
SetMethodNoSideEffect(isolate, target, "domainToASCII", DomainToASCII);
|
SetMethodNoSideEffect(isolate, target, "domainToASCII", DomainToASCII);
|
||||||
SetMethodNoSideEffect(isolate, target, "domainToUnicode", DomainToUnicode);
|
SetMethodNoSideEffect(isolate, target, "domainToUnicode", DomainToUnicode);
|
||||||
SetMethodNoSideEffect(isolate, target, "format", Format);
|
SetMethodNoSideEffect(isolate, target, "format", Format);
|
||||||
|
@ -57,7 +57,7 @@ class BindingData : public SnapshotableObject {
|
|||||||
static void Update(const v8::FunctionCallbackInfo<v8::Value>& args);
|
static void Update(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
v8::Local<v8::FunctionTemplate> ctor);
|
v8::Local<v8::ObjectTemplate> ctor);
|
||||||
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
||||||
v8::Local<v8::Value> unused,
|
v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
|
@ -902,9 +902,8 @@ void GetEnvMessagePort(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CreateWorkerPerIsolateProperties(IsolateData* isolate_data,
|
void CreateWorkerPerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> target) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> proto = target->PrototypeTemplate();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Local<FunctionTemplate> w = NewFunctionTemplate(isolate, Worker::New);
|
Local<FunctionTemplate> w = NewFunctionTemplate(isolate, Worker::New);
|
||||||
@ -923,7 +922,7 @@ void CreateWorkerPerIsolateProperties(IsolateData* isolate_data,
|
|||||||
SetProtoMethod(isolate, w, "loopIdleTime", Worker::LoopIdleTime);
|
SetProtoMethod(isolate, w, "loopIdleTime", Worker::LoopIdleTime);
|
||||||
SetProtoMethod(isolate, w, "loopStartTime", Worker::LoopStartTime);
|
SetProtoMethod(isolate, w, "loopStartTime", Worker::LoopStartTime);
|
||||||
|
|
||||||
SetConstructorFunction(isolate, proto, "Worker", w);
|
SetConstructorFunction(isolate, target, "Worker", w);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -940,7 +939,7 @@ void CreateWorkerPerIsolateProperties(IsolateData* isolate_data,
|
|||||||
wst->InstanceTemplate());
|
wst->InstanceTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMethod(isolate, proto, "getEnvMessagePort", GetEnvMessagePort);
|
SetMethod(isolate, target, "getEnvMessagePort", GetEnvMessagePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateWorkerPerContextProperties(Local<Object> target,
|
void CreateWorkerPerContextProperties(Local<Object> target,
|
||||||
|
@ -12,7 +12,6 @@ namespace timers {
|
|||||||
using v8::Context;
|
using v8::Context;
|
||||||
using v8::Function;
|
using v8::Function;
|
||||||
using v8::FunctionCallbackInfo;
|
using v8::FunctionCallbackInfo;
|
||||||
using v8::FunctionTemplate;
|
|
||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
using v8::Number;
|
using v8::Number;
|
||||||
@ -123,9 +122,8 @@ v8::CFunction BindingData::fast_toggle_immediate_ref_(
|
|||||||
v8::CFunction::Make(FastToggleImmediateRef));
|
v8::CFunction::Make(FastToggleImmediateRef));
|
||||||
|
|
||||||
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
|
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
Local<FunctionTemplate> ctor) {
|
Local<ObjectTemplate> target) {
|
||||||
Isolate* isolate = isolate_data->isolate();
|
Isolate* isolate = isolate_data->isolate();
|
||||||
Local<ObjectTemplate> target = ctor->InstanceTemplate();
|
|
||||||
|
|
||||||
SetMethod(isolate, target, "setupTimers", SetupTimers);
|
SetMethod(isolate, target, "setupTimers", SetupTimers);
|
||||||
SetFastMethod(
|
SetFastMethod(
|
||||||
|
@ -46,7 +46,7 @@ class BindingData : public SnapshotableObject {
|
|||||||
static void ToggleImmediateRefImpl(BindingData* data, bool ref);
|
static void ToggleImmediateRefImpl(BindingData* data, bool ref);
|
||||||
|
|
||||||
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
||||||
v8::Local<v8::FunctionTemplate> ctor);
|
v8::Local<v8::ObjectTemplate> target);
|
||||||
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
||||||
v8::Local<v8::Value> unused,
|
v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user