Skip to content

Commit c8f2584

Browse files
committed
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>`.
1 parent 046781e commit c8f2584

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
@@ -17,6 +17,7 @@ using v8::FunctionCallbackInfo;
1717
using v8::IntegrityLevel;
1818
using v8::Isolate;
1919
using v8::Local;
20+
using v8::LocalVector;
2021
using v8::MaybeLocal;
2122
using v8::Name;
2223
using v8::None;
@@ -258,7 +259,7 @@ void BuiltinLoader::AddExternalizedBuiltin(const char* id,
258259
MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
259260
Local<Context> context,
260261
const char* id,
261-
std::vector<Local<String>>* parameters,
262+
LocalVector<String>* parameters,
262263
Realm* optional_realm) {
263264
Isolate* isolate = context->GetIsolate();
264265
EscapableHandleScope scope(isolate);
@@ -382,8 +383,8 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local<Function> fun) {
382383
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
383384
const char* id,
384385
Realm* optional_realm) {
385-
std::vector<Local<String>> parameters;
386386
Isolate* isolate = context->GetIsolate();
387+
LocalVector<String> parameters(isolate);
387388
// Detects parameters of the scripts based on module ids.
388389
// internal/bootstrap/realm: process, getLinkedBinding,
389390
// getInternalBinding, primordials
@@ -497,7 +498,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
497498
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
498499
Local<Context> context,
499500
const char* id,
500-
std::vector<Local<String>>* parameters,
501+
LocalVector<String>* parameters,
501502
Realm* optional_realm) {
502503
return LookupAndCompileInternal(context, id, parameters, optional_realm);
503504
}

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)