Skip to content

Commit aab4adb

Browse files
Aditi-1400RafaelGSS
authored andcommitted
src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>
According to V8's public API documentation, local handles (i.e., objects of type v8::Local<T>) "should never be allocated on the heap". This replaces the usage of heap-allocated data structures containing instances of `v8::Local`, specifically the `std::vector<v8::Local<v8::String>>` with recently introduced `v8::LocalVector<T>`. This is first of the series of commits to replace all `std::vector<v8::Local<T>>` to use `v8::LocalVector<T>`. PR-URL: #57578 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8207828 commit aab4adb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/node_builtins.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using v8::FunctionCallbackInfo;
1919
using v8::IntegrityLevel;
2020
using v8::Isolate;
2121
using v8::Local;
22+
using v8::LocalVector;
2223
using v8::MaybeLocal;
2324
using v8::Name;
2425
using v8::NewStringType;
@@ -262,7 +263,7 @@ void BuiltinLoader::AddExternalizedBuiltin(const char* id,
262263
MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
263264
Local<Context> context,
264265
const char* id,
265-
std::vector<Local<String>>* parameters,
266+
LocalVector<String>* parameters,
266267
Realm* optional_realm) {
267268
Isolate* isolate = context->GetIsolate();
268269
EscapableHandleScope scope(isolate);
@@ -386,8 +387,8 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local<Function> fun) {
386387
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
387388
const char* id,
388389
Realm* optional_realm) {
389-
std::vector<Local<String>> parameters;
390390
Isolate* isolate = context->GetIsolate();
391+
LocalVector<String> parameters(isolate);
391392
// Detects parameters of the scripts based on module ids.
392393
// internal/bootstrap/realm: process, getLinkedBinding,
393394
// getInternalBinding, primordials
@@ -502,7 +503,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
502503
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
503504
Local<Context> context,
504505
const char* id,
505-
std::vector<Local<String>>* parameters,
506+
LocalVector<String>* parameters,
506507
Realm* optional_realm) {
507508
return LookupAndCompileInternal(context, id, parameters, optional_realm);
508509
}

src/node_builtins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
101101
v8::MaybeLocal<v8::Function> LookupAndCompile(
102102
v8::Local<v8::Context> context,
103103
const char* id,
104-
std::vector<v8::Local<v8::String>>* parameters,
104+
v8::LocalVector<v8::String>* parameters,
105105
Realm* optional_realm);
106106

107107
v8::MaybeLocal<v8::Value> CompileAndCall(v8::Local<v8::Context> context,
@@ -159,7 +159,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
159159
v8::MaybeLocal<v8::Function> LookupAndCompileInternal(
160160
v8::Local<v8::Context> context,
161161
const char* id,
162-
std::vector<v8::Local<v8::String>>* parameters,
162+
v8::LocalVector<v8::String>* parameters,
163163
Realm* optional_realm);
164164
void SaveCodeCache(const char* id, v8::Local<v8::Function> fn);
165165

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy