Skip to content

Commit

Permalink
src: switch from Get/SetPrototype to Get/SetPrototypeV2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
RedYetiDev authored Oct 22, 2024
1 parent 1c2eecd commit e4ca097
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
Expand Down
4 changes: 2 additions & 2 deletions src/internal_only_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 20 additions & 19 deletions src/node_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_webstorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e4ca097

Please sign in to comment.