Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! src: make BuiltinLoader threadsafe…
Browse files Browse the repository at this point in the history
… and non-global
  • Loading branch information
addaleax committed Jan 17, 2023
1 parent 93e411a commit ed986f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/api/environment.cc
Expand Up @@ -714,7 +714,12 @@ Maybe<bool> InitializePrimordials(Local<Context> context) {
"internal/per_context/messageport",
nullptr};

auto builtin_loader = builtins::BuiltinLoader::Create();
// We do not have access to a per-Environment BuiltinLoader instance
// at this point, because this code runs before an Environment exists
// in the first place. However, creating BuiltinLoader instances is
// relatively cheap and all the scripts that we may want to run at
// startup are always present in it.
thread_local auto builtin_loader = builtins::BuiltinLoader::Create();
for (const char** module = context_files; *module != nullptr; module++) {
Local<Value> arguments[] = {exports, primordials};
if (builtin_loader
Expand Down
1 change: 0 additions & 1 deletion src/node_builtins.cc
Expand Up @@ -563,7 +563,6 @@ void BuiltinLoader::GetBuiltinCategories(
Local<Context> context = env->context();
Local<Object> result = Object::New(isolate);

// Copy from the per-process categories
std::set<std::string> cannot_be_required =
env->builtin_loader()->GetCannotBeRequired();
std::set<std::string> can_be_required =
Expand Down

0 comments on commit ed986f9

Please sign in to comment.