diff options
| author | Anna Henningsen <anna@addaleax.net> | 2023-01-18 23:03:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-18 22:03:00 +0000 |
| commit | d896f5befdf4dd9c3782a0d79940fbf5ca06ed01 (patch) | |
| tree | 3e7c458ac28306ab1769c2818be17439662885d1 /src/env.h | |
| parent | 5d560978ff5090d60946aff0bfcefca59cec01df (diff) | |
| download | node-new-d896f5befdf4dd9c3782a0d79940fbf5ca06ed01.tar.gz | |
src: make BuiltinLoader threadsafe and non-global
As discussed in https://github.com/nodejs/node/pull/45888, using a
global `BuiltinLoader` instance is probably undesirable in a world
in which embedders are able to create Node.js Environments with
different sources and therefore mutually incompatible code
caching properties.
This PR makes it so that `BuiltinLoader` is no longer a global
singleton and instead only shared between `Environment`s that
have a direct relation to each other, and addresses a few
thread safety issues along with that.
PR-URL: https://github.com/nodejs/node/pull/45942
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/env.h')
| -rw-r--r-- | src/env.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -721,6 +721,8 @@ class Environment : public MemoryRetainer { // List of id's that have been destroyed and need the destroy() cb called. inline std::vector<double>* destroy_async_id_list(); + builtins::BuiltinLoader* builtin_loader(); + std::unordered_multimap<int, loader::ModuleWrap*> hash_to_module_map; std::unordered_map<uint32_t, loader::ModuleWrap*> id_to_module_map; std::unordered_map<uint32_t, contextify::ContextifyScript*> @@ -1144,6 +1146,8 @@ class Environment : public MemoryRetainer { std::unique_ptr<Realm> principal_realm_ = nullptr; + builtins::BuiltinLoader builtin_loader_; + // Used by allocate_managed_buffer() and release_managed_buffer() to keep // track of the BackingStore for a given pointer. std::unordered_map<char*, std::unique_ptr<v8::BackingStore>> |
