Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>`.
  • Loading branch information
Aditi-1400 committed Mar 21, 2025
commit c8f2584e70e32c03479972111167f2b89c2d2c5b
7 changes: 4 additions & 3 deletions src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ using v8::FunctionCallbackInfo;
using v8::IntegrityLevel;
using v8::Isolate;
using v8::Local;
using v8::LocalVector;
using v8::MaybeLocal;
using v8::Name;
using v8::None;
Expand Down Expand Up @@ -258,7 +259,7 @@ void BuiltinLoader::AddExternalizedBuiltin(const char* id,
MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
Local<Context> context,
const char* id,
std::vector<Local<String>>* parameters,
LocalVector<String>* parameters,
Realm* optional_realm) {
Isolate* isolate = context->GetIsolate();
EscapableHandleScope scope(isolate);
Expand Down Expand Up @@ -382,8 +383,8 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local<Function> fun) {
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
const char* id,
Realm* optional_realm) {
std::vector<Local<String>> parameters;
Isolate* isolate = context->GetIsolate();
LocalVector<String> parameters(isolate);
// Detects parameters of the scripts based on module ids.
// internal/bootstrap/realm: process, getLinkedBinding,
// getInternalBinding, primordials
Expand Down Expand Up @@ -497,7 +498,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
Local<Context> context,
const char* id,
std::vector<Local<String>>* parameters,
LocalVector<String>* parameters,
Realm* optional_realm) {
return LookupAndCompileInternal(context, id, parameters, optional_realm);
}
Expand Down
4 changes: 2 additions & 2 deletions src/node_builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
v8::MaybeLocal<v8::Function> LookupAndCompile(
v8::Local<v8::Context> context,
const char* id,
std::vector<v8::Local<v8::String>>* parameters,
v8::LocalVector<v8::String>* parameters,
Realm* optional_realm);

v8::MaybeLocal<v8::Value> CompileAndCall(v8::Local<v8::Context> context,
Expand Down Expand Up @@ -159,7 +159,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
v8::MaybeLocal<v8::Function> LookupAndCompileInternal(
v8::Local<v8::Context> context,
const char* id,
std::vector<v8::Local<v8::String>>* parameters,
v8::LocalVector<v8::String>* parameters,
Realm* optional_realm);
void SaveCodeCache(const char* id, v8::Local<v8::Function> fn);

Expand Down