src: switch from Get/SetPrototype to Get/SetPrototypeV2

PR-URL: https://github.com/nodejs/node/pull/55453
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Aviv Keller 2024-10-22 01:05:19 -04:00 committed by GitHub
parent 1c2eecd669
commit e4ca097f56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 30 additions and 27 deletions

View File

@ -769,7 +769,7 @@ Maybe<void> InitializePrimordials(Local<Context> context) {
// Create primordials first and make it available to per-context scripts.
Local<Object> primordials = Object::New(isolate);
if (primordials->SetPrototype(context, Null(isolate)).IsNothing() ||
if (primordials->SetPrototypeV2(context, Null(isolate)).IsNothing() ||
!GetPerContextExports(context).ToLocal(&exports) ||
exports->Set(context, primordials_string, primordials).IsNothing()) {
return Nothing<void>();

View File

@ -32,8 +32,8 @@ class PrototypeChainHas : public v8::QueryObjectPredicate {
if (creation_context != context_) {
return false;
}
for (Local<Value> proto = object->GetPrototype(); proto->IsObject();
proto = proto.As<Object>()->GetPrototype()) {
for (Local<Value> proto = object->GetPrototypeV2(); proto->IsObject();
proto = proto.As<Object>()->GetPrototypeV2()) {
if (search_ == proto) return true;
}
return false;

View File

@ -1577,7 +1577,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->GetPrototype();
v8::Local<v8::Value> val = obj->GetPrototypeV2();
*result = v8impl::JsValueFromV8LocalValue(val);
return GET_RETURN_STATUS(env);
}

View File

@ -279,7 +279,7 @@ MaybeLocal<Uint8Array> New(Environment* env,
CHECK(!env->buffer_prototype_object().IsEmpty());
Local<Uint8Array> ui = Uint8Array::New(ab, byte_offset, length);
Maybe<bool> mb =
ui->SetPrototype(env->context(), env->buffer_prototype_object());
ui->SetPrototypeV2(env->context(), env->buffer_prototype_object());
if (mb.IsNothing())
return MaybeLocal<Uint8Array>();
return ui;

View File

@ -1285,43 +1285,44 @@ void CreatePerContextProperties(Local<Object> target,
Isolate* isolate = context->GetIsolate();
Environment* env = Environment::GetCurrent(context);
CHECK(target->SetPrototype(env->context(), Null(env->isolate())).FromJust());
CHECK(
target->SetPrototypeV2(env->context(), Null(env->isolate())).FromJust());
Local<Object> os_constants = Object::New(isolate);
CHECK(os_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(os_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> err_constants = Object::New(isolate);
CHECK(err_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(err_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> sig_constants = Object::New(isolate);
CHECK(sig_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(sig_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> priority_constants = Object::New(isolate);
CHECK(priority_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(priority_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> fs_constants = Object::New(isolate);
CHECK(fs_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(fs_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> crypto_constants = Object::New(isolate);
CHECK(crypto_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(crypto_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> zlib_constants = Object::New(isolate);
CHECK(zlib_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(zlib_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> dlopen_constants = Object::New(isolate);
CHECK(dlopen_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(dlopen_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
Local<Object> trace_constants = Object::New(isolate);
CHECK(trace_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
CHECK(trace_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
.FromJust());
DefineErrnoConstants(err_constants);
DefineWindowsErrorConstants(err_constants);

View File

@ -1395,7 +1395,8 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
Local<Map> options = Map::New(isolate);
if (options
->SetPrototype(context, env->primordials_safe_map_prototype_object())
->SetPrototypeV2(context,
env->primordials_safe_map_prototype_object())
.IsNothing()) {
return;
}
@ -1435,7 +1436,8 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
if (!ToV8Value(context, _ppop_instance.aliases_).ToLocal(&aliases)) return;
if (aliases.As<Object>()
->SetPrototype(context, env->primordials_safe_map_prototype_object())
->SetPrototypeV2(context,
env->primordials_safe_map_prototype_object())
.IsNothing()) {
return;
}

View File

@ -530,7 +530,7 @@ template <typename T>
static bool ShouldIntercept(Local<Name> property,
const PropertyCallbackInfo<T>& info) {
Environment* env = Environment::GetCurrent(info);
Local<Value> proto = info.This()->GetPrototype();
Local<Value> proto = info.This()->GetPrototypeV2();
if (proto->IsObject()) {
bool has_prop;