From ff7cf875446533715544473c43f6d6286c287241 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sun, 20 Apr 2025 11:16:42 -0400 Subject: [PATCH] src: avoid calling SetPrototypeV2() --- src/api/environment.cc | 6 ++--- src/node_constants.cc | 54 +++++++++++++++--------------------------- 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index af5c62f64542a0..50792c6d767478 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -807,10 +807,10 @@ Maybe InitializePrimordials(Local context, // context. CHECK(!exports->Has(context, primordials_string).FromJust()); - Local primordials = Object::New(isolate); + Local primordials = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); // Create primordials and make it available to per-context scripts. - if (primordials->SetPrototypeV2(context, Null(isolate)).IsNothing() || - exports->Set(context, primordials_string, primordials).IsNothing()) { + if (exports->Set(context, primordials_string, primordials).IsNothing()) { return Nothing(); } diff --git a/src/node_constants.cc b/src/node_constants.cc index a390bc8616afc1..906e1f6a632d9b 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -24,6 +24,7 @@ #include "node_internals.h" #include "util-inl.h" +#include "v8-local-handle.h" #include "zlib.h" #if !defined(_MSC_VER) @@ -1288,41 +1289,24 @@ void CreatePerContextProperties(Local target, CHECK( target->SetPrototypeV2(env->context(), Null(env->isolate())).FromJust()); - Local os_constants = Object::New(isolate); - CHECK(os_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local err_constants = Object::New(isolate); - CHECK(err_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local sig_constants = Object::New(isolate); - CHECK(sig_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local priority_constants = Object::New(isolate); - CHECK(priority_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local fs_constants = Object::New(isolate); - CHECK(fs_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local crypto_constants = Object::New(isolate); - CHECK(crypto_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local zlib_constants = Object::New(isolate); - CHECK(zlib_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local dlopen_constants = Object::New(isolate); - CHECK(dlopen_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); - - Local trace_constants = Object::New(isolate); - CHECK(trace_constants->SetPrototypeV2(env->context(), Null(env->isolate())) - .FromJust()); + Local os_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local err_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local sig_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local priority_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local fs_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local crypto_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local zlib_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local dlopen_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); + Local trace_constants = + Object::New(isolate, Null(isolate), nullptr, nullptr, 0); DefineErrnoConstants(err_constants); DefineWindowsErrorConstants(err_constants);