Skip to content

Commit cc775d3

Browse files
avivkelleraduh95
authored andcommitted
src: switch from Get/SetPrototype to Get/SetPrototypeV2
PR-URL: #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>
1 parent 04b41bd commit cc775d3

7 files changed

+30
-27
lines changed

src/api/environment.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ Maybe<void> InitializePrimordials(Local<Context> context) {
769769

770770
// Create primordials first and make it available to per-context scripts.
771771
Local<Object> primordials = Object::New(isolate);
772-
if (primordials->SetPrototype(context, Null(isolate)).IsNothing() ||
772+
if (primordials->SetPrototypeV2(context, Null(isolate)).IsNothing() ||
773773
!GetPerContextExports(context).ToLocal(&exports) ||
774774
exports->Set(context, primordials_string, primordials).IsNothing()) {
775775
return Nothing<void>();

src/internal_only_v8.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class PrototypeChainHas : public v8::QueryObjectPredicate {
3232
if (creation_context != context_) {
3333
return false;
3434
}
35-
for (Local<Value> proto = object->GetPrototype(); proto->IsObject();
36-
proto = proto.As<Object>()->GetPrototype()) {
35+
for (Local<Value> proto = object->GetPrototypeV2(); proto->IsObject();
36+
proto = proto.As<Object>()->GetPrototypeV2()) {
3737
if (search_ == proto) return true;
3838
}
3939
return false;

src/js_native_api_v8.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ napi_status NAPI_CDECL napi_get_prototype(napi_env env,
15771577
CHECK_TO_OBJECT(env, context, obj, object);
15781578

15791579
// This doesn't invokes Proxy's [[GetPrototypeOf]] handler.
1580-
v8::Local<v8::Value> val = obj->GetPrototype();
1580+
v8::Local<v8::Value> val = obj->GetPrototypeV2();
15811581
*result = v8impl::JsValueFromV8LocalValue(val);
15821582
return GET_RETURN_STATUS(env);
15831583
}

src/node_buffer.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ MaybeLocal<Uint8Array> New(Environment* env,
279279
CHECK(!env->buffer_prototype_object().IsEmpty());
280280
Local<Uint8Array> ui = Uint8Array::New(ab, byte_offset, length);
281281
Maybe<bool> mb =
282-
ui->SetPrototype(env->context(), env->buffer_prototype_object());
282+
ui->SetPrototypeV2(env->context(), env->buffer_prototype_object());
283283
if (mb.IsNothing())
284284
return MaybeLocal<Uint8Array>();
285285
return ui;

src/node_constants.cc

+20-19
Original file line numberDiff line numberDiff line change
@@ -1285,43 +1285,44 @@ void CreatePerContextProperties(Local<Object> target,
12851285
Isolate* isolate = context->GetIsolate();
12861286
Environment* env = Environment::GetCurrent(context);
12871287

1288-
CHECK(target->SetPrototype(env->context(), Null(env->isolate())).FromJust());
1288+
CHECK(
1289+
target->SetPrototypeV2(env->context(), Null(env->isolate())).FromJust());
12891290

12901291
Local<Object> os_constants = Object::New(isolate);
1291-
CHECK(os_constants->SetPrototype(env->context(),
1292-
Null(env->isolate())).FromJust());
1292+
CHECK(os_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1293+
.FromJust());
12931294

12941295
Local<Object> err_constants = Object::New(isolate);
1295-
CHECK(err_constants->SetPrototype(env->context(),
1296-
Null(env->isolate())).FromJust());
1296+
CHECK(err_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1297+
.FromJust());
12971298

12981299
Local<Object> sig_constants = Object::New(isolate);
1299-
CHECK(sig_constants->SetPrototype(env->context(),
1300-
Null(env->isolate())).FromJust());
1300+
CHECK(sig_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1301+
.FromJust());
13011302

13021303
Local<Object> priority_constants = Object::New(isolate);
1303-
CHECK(priority_constants->SetPrototype(env->context(),
1304-
Null(env->isolate())).FromJust());
1304+
CHECK(priority_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1305+
.FromJust());
13051306

13061307
Local<Object> fs_constants = Object::New(isolate);
1307-
CHECK(fs_constants->SetPrototype(env->context(),
1308-
Null(env->isolate())).FromJust());
1308+
CHECK(fs_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1309+
.FromJust());
13091310

13101311
Local<Object> crypto_constants = Object::New(isolate);
1311-
CHECK(crypto_constants->SetPrototype(env->context(),
1312-
Null(env->isolate())).FromJust());
1312+
CHECK(crypto_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1313+
.FromJust());
13131314

13141315
Local<Object> zlib_constants = Object::New(isolate);
1315-
CHECK(zlib_constants->SetPrototype(env->context(),
1316-
Null(env->isolate())).FromJust());
1316+
CHECK(zlib_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1317+
.FromJust());
13171318

13181319
Local<Object> dlopen_constants = Object::New(isolate);
1319-
CHECK(dlopen_constants->SetPrototype(env->context(),
1320-
Null(env->isolate())).FromJust());
1320+
CHECK(dlopen_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1321+
.FromJust());
13211322

13221323
Local<Object> trace_constants = Object::New(isolate);
1323-
CHECK(trace_constants->SetPrototype(env->context(),
1324-
Null(env->isolate())).FromJust());
1324+
CHECK(trace_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1325+
.FromJust());
13251326

13261327
DefineErrnoConstants(err_constants);
13271328
DefineWindowsErrorConstants(err_constants);

src/node_options.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,8 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
13951395

13961396
Local<Map> options = Map::New(isolate);
13971397
if (options
1398-
->SetPrototype(context, env->primordials_safe_map_prototype_object())
1398+
->SetPrototypeV2(context,
1399+
env->primordials_safe_map_prototype_object())
13991400
.IsNothing()) {
14001401
return;
14011402
}
@@ -1435,7 +1436,8 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
14351436
if (!ToV8Value(context, _ppop_instance.aliases_).ToLocal(&aliases)) return;
14361437

14371438
if (aliases.As<Object>()
1438-
->SetPrototype(context, env->primordials_safe_map_prototype_object())
1439+
->SetPrototypeV2(context,
1440+
env->primordials_safe_map_prototype_object())
14391441
.IsNothing()) {
14401442
return;
14411443
}

src/node_webstorage.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ template <typename T>
530530
static bool ShouldIntercept(Local<Name> property,
531531
const PropertyCallbackInfo<T>& info) {
532532
Environment* env = Environment::GetCurrent(info);
533-
Local<Value> proto = info.This()->GetPrototype();
533+
Local<Value> proto = info.This()->GetPrototypeV2();
534534

535535
if (proto->IsObject()) {
536536
bool has_prop;

0 commit comments

Comments
 (0)