Skip to content

Commit

Permalink
src: make BuiltinLoader threadsafe and non-global
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Nov 16, 2023
1 parent 3f8bbc0 commit a48d57c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions patches/node/fix_expose_lookupandcompile_with_parameters.patch
Expand Up @@ -10,11 +10,11 @@ parameters.
This should be upstreamed.

diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 4d4b59916bfdb203702c4e878ff2659b79de8c52..6451464c9fb411a1988bada86eabb4071ee07eb0 100644
index 7e4a43a6f13845c8a81bae96ec073ccdfc655999..26ebc322afa36994b4f1b93f992ac8b726263191 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -435,6 +435,22 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
return maybe;
@@ -482,6 +482,22 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
return fn->Call(context, undefined, argc, argv);
}

+MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
Expand All @@ -34,21 +34,22 @@ index 4d4b59916bfdb203702c4e878ff2659b79de8c52..6451464c9fb411a1988bada86eabb407
+}
+
bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) {
BuiltinLoader* loader = GetInstance();
std::vector<std::string> ids = loader->GetBuiltinIds();
std::vector<std::string_view> ids = GetBuiltinIds();
bool all_succeeded = true;
diff --git a/src/node_builtins.h b/src/node_builtins.h
index 8d9f7c409659a30747e5feeac6cfec4208791370..34a51c3e5a79154c3633143b352aa9e108497767 100644
index ba0c926a7968ec6a4cf07a469f1fd9314287a937..03ecd853b26a581f57b3311915fb7f46e713b00d 100644
--- a/src/node_builtins.h
+++ b/src/node_builtins.h
@@ -50,6 +50,11 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
v8::Local<v8::Context> context,
const char* id,
Environment* optional_env);
@@ -107,6 +107,12 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
const char* id,
Realm* realm);

+ static v8::MaybeLocal<v8::Function> LookupAndCompile(
+ v8::Local<v8::Context> context,
+ const char* id,
+ std::vector<v8::Local<v8::String>>* parameters,
+ Environment* optional_env);

static v8::Local<v8::Object> GetSourceObject(v8::Local<v8::Context> context);
+
// Returns config.gypi as a JSON string
v8::Local<v8::String> GetConfigString(v8::Isolate* isolate);
bool Exists(const char* id);

0 comments on commit a48d57c

Please sign in to comment.