Commit 45287a975f0 for nodejs
commit 45287a975f02d606ad7c6eedb4054c34eb4531bc
Author: Michaël Zasso <targos@protonmail.com>
Date: Thu Apr 30 08:19:48 2026 +0200
src: migrate from deprecated xxxV2 APIs
- Set/GetPrototype
- Holder
Co-Authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Signed-Off-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
diff --git a/src/api/environment.cc b/src/api/environment.cc
index ee9da42b606..f188b01b831 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -970,7 +970,7 @@ MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
Local<Object> private_symbols_object;
if (!private_symbols->NewInstance(context).ToLocal(&private_symbols_object) ||
- private_symbols_object->SetPrototypeV2(context, Null(isolate))
+ private_symbols_object->SetPrototype(context, Null(isolate))
.IsNothing()) {
return MaybeLocal<Object>();
}
@@ -996,7 +996,7 @@ MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
Local<Object> per_isolate_symbols_object;
if (!per_isolate_symbols->NewInstance(context).ToLocal(
&per_isolate_symbols_object) ||
- per_isolate_symbols_object->SetPrototypeV2(context, Null(isolate))
+ per_isolate_symbols_object->SetPrototype(context, Null(isolate))
.IsNothing()) {
return MaybeLocal<Object>();
}
diff --git a/src/internal_only_v8.cc b/src/internal_only_v8.cc
index 6a3c4e6952a..487b8b7adfd 100644
--- a/src/internal_only_v8.cc
+++ b/src/internal_only_v8.cc
@@ -33,8 +33,8 @@ class PrototypeChainHas : public v8::QueryObjectPredicate {
if (creation_context != context_) {
return false;
}
- for (Local<Value> proto = object->GetPrototypeV2(); proto->IsObject();
- proto = proto.As<Object>()->GetPrototypeV2()) {
+ for (Local<Value> proto = object->GetPrototype(); proto->IsObject();
+ proto = proto.As<Object>()->GetPrototype()) {
if (search_ == proto) return true;
}
return false;
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 6ae976df297..ba1ab6f1851 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -1585,7 +1585,7 @@ napi_status NAPI_CDECL node_api_set_prototype(napi_env env,
v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
- v8::Maybe<bool> set_maybe = obj->SetPrototypeV2(context, val);
+ v8::Maybe<bool> set_maybe = obj->SetPrototype(context, val);
RETURN_STATUS_IF_FALSE_WITH_PREAMBLE(
env, set_maybe.FromMaybe(false), napi_generic_failure);
@@ -1604,7 +1604,7 @@ napi_status NAPI_CDECL napi_get_prototype(napi_env env,
CHECK_TO_OBJECT(env, context, obj, object);
// This doesn't invokes Proxy's [[GetPrototypeOf]] handler.
- v8::Local<v8::Value> val = obj->GetPrototypeV2();
+ v8::Local<v8::Value> val = obj->GetPrototype();
*result = v8impl::JsValueFromV8LocalValue(val);
return GET_RETURN_STATUS(env);
}
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index aa6b3bc303f..9892f38d96b 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -1020,7 +1020,7 @@ void ModuleWrap::HasAsyncGraph(Local<Name> property,
Isolate* isolate = args.GetIsolate();
Environment* env = Environment::GetCurrent(isolate);
ModuleWrap* obj;
- ASSIGN_OR_RETURN_UNWRAP(&obj, args.HolderV2());
+ ASSIGN_OR_RETURN_UNWRAP(&obj, args.Holder());
Local<Module> module = obj->module_.Get(isolate);
if (module->GetStatus() < Module::kInstantiated) {
@@ -1236,7 +1236,7 @@ void ModuleWrap::SetImportMetaResolveInitializer(
static void ImportMetaResolveLazyGetter(
Local<v8::Name> name, const PropertyCallbackInfo<Value>& info) {
Isolate* isolate = info.GetIsolate();
- Local<Value> receiver_val = info.HolderV2();
+ Local<Value> receiver_val = info.Holder();
if (!receiver_val->IsObject()) {
THROW_ERR_INVALID_INVOCATION(isolate);
return;
@@ -1277,7 +1277,7 @@ static void PathHelpersLazyGetter(Local<v8::Name> name,
// When this getter is invoked in a vm context, the `Realm::GetCurrent(info)`
// returns a nullptr and retrieve the creation context via `this` object and
// get the creation Realm.
- Local<Value> receiver_val = info.HolderV2();
+ Local<Value> receiver_val = info.Holder();
if (!receiver_val->IsObject()) {
THROW_ERR_INVALID_INVOCATION(isolate);
return;
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index 67ba73dd488..5aee8dced2f 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -286,7 +286,7 @@ MaybeLocal<Uint8Array> New(Environment* env,
size_t length) {
CHECK(!env->buffer_prototype_object().IsEmpty());
Local<Uint8Array> ui = Uint8Array::New(ab, byte_offset, length);
- if (ui->SetPrototypeV2(env->context(), env->buffer_prototype_object())
+ if (ui->SetPrototype(env->context(), env->buffer_prototype_object())
.IsNothing()) {
return MaybeLocal<Uint8Array>();
}
diff --git a/src/node_constants.cc b/src/node_constants.cc
index bd3b66414d1..9dded5712d5 100644
--- a/src/node_constants.cc
+++ b/src/node_constants.cc
@@ -1354,7 +1354,7 @@ void CreatePerContextProperties(Local<Object> target,
Isolate* isolate = Isolate::GetCurrent();
Environment* env = Environment::GetCurrent(context);
- CHECK(target->SetPrototypeV2(env->context(), Null(isolate)).FromJust());
+ CHECK(target->SetPrototype(env->context(), Null(isolate)).FromJust());
Local<Object> os_constants =
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 838a65c1ff3..997f8b2c3ce 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -486,7 +486,7 @@ ContextifyContext* ContextifyContext::Get(const PropertyCallbackInfo<T>& args) {
// args.GetIsolate()->GetCurrentContext() and take the pointer at
// ContextEmbedderIndex::kContextifyContext, as V8 is supposed to
// push the creation context before invoking these callbacks.
- return Get(args.HolderV2());
+ return Get(args.Holder());
}
ContextifyContext* ContextifyContext::Get(Local<Object> object) {
diff --git a/src/node_ffi.cc b/src/node_ffi.cc
index 4ef22a80a42..2688bd28eba 100644
--- a/src/node_ffi.cc
+++ b/src/node_ffi.cc
@@ -873,7 +873,7 @@ void DynamicLibrary::GetFunctions(const FunctionCallbackInfo<Value>& args) {
}
Local<Object> functions = Object::New(isolate);
- if (!functions->SetPrototypeV2(context, Null(isolate)).FromMaybe(false)) {
+ if (!functions->SetPrototype(context, Null(isolate)).FromMaybe(false)) {
return;
}
@@ -1022,7 +1022,7 @@ void DynamicLibrary::GetSymbols(const FunctionCallbackInfo<Value>& args) {
}
Local<Object> symbols = Object::New(isolate);
- if (!symbols->SetPrototypeV2(context, Null(isolate)).FromMaybe(false)) {
+ if (!symbols->SetPrototype(context, Null(isolate)).FromMaybe(false)) {
return;
}
for (const auto& entry : lib->symbols_) {
diff --git a/src/node_options.cc b/src/node_options.cc
index 668b92695a5..911bb999ed2 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -2127,8 +2127,7 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
Local<Map> options = Map::New(isolate);
if (options
- ->SetPrototypeV2(context,
- env->primordials_safe_map_prototype_object())
+ ->SetPrototype(context, env->primordials_safe_map_prototype_object())
.IsNothing()) {
return;
}
@@ -2168,8 +2167,7 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
if (!ToV8Value(context, _ppop_instance.aliases_).ToLocal(&aliases)) return;
if (aliases.As<Object>()
- ->SetPrototypeV2(context,
- env->primordials_safe_map_prototype_object())
+ ->SetPrototype(context, env->primordials_safe_map_prototype_object())
.IsNothing()) {
return;
}
diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc
index 9ebc0cb9731..87f0f20169f 100644
--- a/src/node_sqlite.cc
+++ b/src/node_sqlite.cc
@@ -901,7 +901,7 @@ Intercepted DatabaseLimits::LimitsGetter(
}
DatabaseLimits* limits;
- ASSIGN_OR_RETURN_UNWRAP(&limits, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&limits, info.Holder(), Intercepted::kNo);
Environment* env = limits->env();
Isolate* isolate = env->isolate();
@@ -934,7 +934,7 @@ Intercepted DatabaseLimits::LimitsSetter(
}
DatabaseLimits* limits;
- ASSIGN_OR_RETURN_UNWRAP(&limits, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&limits, info.Holder(), Intercepted::kNo);
Environment* env = limits->env();
Isolate* isolate = env->isolate();
@@ -4197,9 +4197,9 @@ BaseObjectPtr<StatementIterator> StatementExecutionHelper::Iterate(
}
if (iter->object()
- ->GetPrototypeV2()
+ ->GetPrototype()
.As<Object>()
- ->SetPrototypeV2(context, js_iterator_prototype)
+ ->SetPrototype(context, js_iterator_prototype)
.IsNothing()) {
return BaseObjectPtr<StatementIterator>();
}
diff --git a/src/node_util.cc b/src/node_util.cc
index 6d02ecea1da..7238ffb80e0 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -360,7 +360,7 @@ static void DefineLazyPropertiesGetter(
// When this getter is invoked in a vm context, the `Realm::GetCurrent(info)`
// returns a nullptr and retrieve the creation context via `this` object and
// get the creation Realm.
- Local<Value> receiver_val = info.HolderV2();
+ Local<Value> receiver_val = info.Holder();
if (!receiver_val->IsObject()) {
THROW_ERR_INVALID_INVOCATION(isolate);
return;
diff --git a/src/node_webstorage.cc b/src/node_webstorage.cc
index d30dac02544..1a88f706876 100644
--- a/src/node_webstorage.cc
+++ b/src/node_webstorage.cc
@@ -614,7 +614,7 @@ template <typename T>
static bool ShouldIntercept(Local<Name> property,
const PropertyCallbackInfo<T>& info) {
Environment* env = Environment::GetCurrent(info);
- Local<Value> proto = info.HolderV2()->GetPrototypeV2();
+ Local<Value> proto = info.Holder()->GetPrototype();
if (proto->IsObject()) {
bool has_prop;
@@ -638,7 +638,7 @@ static Intercepted StorageGetter(Local<Name> property,
}
Storage* storage;
- ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&storage, info.Holder(), Intercepted::kNo);
Local<Value> result;
if (storage->Load(property).ToLocal(&result) && !result->IsNull()) {
@@ -652,7 +652,7 @@ static Intercepted StorageSetter(Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
Storage* storage;
- ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&storage, info.Holder(), Intercepted::kNo);
if (storage->Store(property, value).IsNothing()) {
info.GetReturnValue().SetFalse();
@@ -668,7 +668,7 @@ static Intercepted StorageQuery(Local<Name> property,
}
Storage* storage;
- ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&storage, info.Holder(), Intercepted::kNo);
Local<Value> result;
if (!storage->Load(property).ToLocal(&result) || result->IsNull()) {
return Intercepted::kNo;
@@ -681,7 +681,7 @@ static Intercepted StorageQuery(Local<Name> property,
static Intercepted StorageDeleter(Local<Name> property,
const PropertyCallbackInfo<Boolean>& info) {
Storage* storage;
- ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&storage, info.Holder(), Intercepted::kNo);
info.GetReturnValue().Set(storage->Remove(property).IsJust());
@@ -690,7 +690,7 @@ static Intercepted StorageDeleter(Local<Name> property,
static void StorageEnumerator(const PropertyCallbackInfo<Array>& info) {
Storage* storage;
- ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2());
+ ASSIGN_OR_RETURN_UNWRAP(&storage, info.Holder());
Local<Array> result;
if (!storage->Enumerate().ToLocal(&result)) {
return;
@@ -702,7 +702,7 @@ static Intercepted StorageDefiner(Local<Name> property,
const PropertyDescriptor& desc,
const PropertyCallbackInfo<void>& info) {
Storage* storage;
- ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo);
+ ASSIGN_OR_RETURN_UNWRAP(&storage, info.Holder(), Intercepted::kNo);
if (desc.has_value()) {
return StorageSetter(property, desc.value(), info);
diff --git a/src/util-inl.h b/src/util-inl.h
index 889b358bb7b..cecc03be2c7 100644
--- a/src/util-inl.h
+++ b/src/util-inl.h
@@ -835,7 +835,7 @@ inline v8::MaybeLocal<v8::Object> NewDictionaryInstanceNullProto(
if (value.IsEmpty()) return v8::MaybeLocal<v8::Object>();
}
v8::Local<v8::Object> obj = tmpl->NewInstance(context, property_values);
- if (obj->SetPrototypeV2(context, v8::Null(v8::Isolate::GetCurrent()))
+ if (obj->SetPrototype(context, v8::Null(v8::Isolate::GetCurrent()))
.IsNothing()) {
return v8::MaybeLocal<v8::Object>();
}