Skip to content

Commit b405515

Browse files
anonrigRafaelGSS
authored andcommitted
src: avoid calling SetPrototypeV2()
PR-URL: #57949 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 46062f1 commit b405515

File tree

2 files changed

+22
-38
lines changed

2 files changed

+22
-38
lines changed

src/api/environment.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,10 @@ Maybe<void> InitializePrimordials(Local<Context> context,
810810
// context.
811811
CHECK(!exports->Has(context, primordials_string).FromJust());
812812

813-
Local<Object> primordials = Object::New(isolate);
813+
Local<Object> primordials =
814+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
814815
// Create primordials and make it available to per-context scripts.
815-
if (primordials->SetPrototypeV2(context, Null(isolate)).IsNothing() ||
816-
exports->Set(context, primordials_string, primordials).IsNothing()) {
816+
if (exports->Set(context, primordials_string, primordials).IsNothing()) {
817817
return Nothing<void>();
818818
}
819819

src/node_constants.cc

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "node_internals.h"
2525
#include "util-inl.h"
2626

27+
#include "v8-local-handle.h"
2728
#include "zlib.h"
2829

2930
#if !defined(_MSC_VER)
@@ -1288,41 +1289,24 @@ void CreatePerContextProperties(Local<Object> target,
12881289
CHECK(
12891290
target->SetPrototypeV2(env->context(), Null(env->isolate())).FromJust());
12901291

1291-
Local<Object> os_constants = Object::New(isolate);
1292-
CHECK(os_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1293-
.FromJust());
1294-
1295-
Local<Object> err_constants = Object::New(isolate);
1296-
CHECK(err_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1297-
.FromJust());
1298-
1299-
Local<Object> sig_constants = Object::New(isolate);
1300-
CHECK(sig_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1301-
.FromJust());
1302-
1303-
Local<Object> priority_constants = Object::New(isolate);
1304-
CHECK(priority_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1305-
.FromJust());
1306-
1307-
Local<Object> fs_constants = Object::New(isolate);
1308-
CHECK(fs_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1309-
.FromJust());
1310-
1311-
Local<Object> crypto_constants = Object::New(isolate);
1312-
CHECK(crypto_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1313-
.FromJust());
1314-
1315-
Local<Object> zlib_constants = Object::New(isolate);
1316-
CHECK(zlib_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1317-
.FromJust());
1318-
1319-
Local<Object> dlopen_constants = Object::New(isolate);
1320-
CHECK(dlopen_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1321-
.FromJust());
1322-
1323-
Local<Object> trace_constants = Object::New(isolate);
1324-
CHECK(trace_constants->SetPrototypeV2(env->context(), Null(env->isolate()))
1325-
.FromJust());
1292+
Local<Object> os_constants =
1293+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1294+
Local<Object> err_constants =
1295+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1296+
Local<Object> sig_constants =
1297+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1298+
Local<Object> priority_constants =
1299+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1300+
Local<Object> fs_constants =
1301+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1302+
Local<Object> crypto_constants =
1303+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1304+
Local<Object> zlib_constants =
1305+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1306+
Local<Object> dlopen_constants =
1307+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
1308+
Local<Object> trace_constants =
1309+
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
13261310

13271311
DefineErrnoConstants(err_constants);
13281312
DefineWindowsErrorConstants(err_constants);

0 commit comments

Comments
 (0)