mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
vm: use default HDO when importModuleDynamically is not set
This makes it possile to hit the in-isolate compilation cache when host-defined options are not necessary. PR-URL: https://github.com/nodejs/node/pull/49950 Refs: https://github.com/nodejs/node/issues/35375 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
parent
1643adf771
commit
1d220b55ac
6 changed files with 81 additions and 6 deletions
|
@ -12,6 +12,10 @@ const {
|
|||
host_defined_option_symbol,
|
||||
},
|
||||
} = internalBinding('util');
|
||||
const {
|
||||
default_host_defined_options,
|
||||
} = internalBinding('symbols');
|
||||
|
||||
const {
|
||||
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
|
||||
ERR_INVALID_ARG_VALUE,
|
||||
|
@ -128,6 +132,13 @@ const moduleRegistries = new SafeWeakMap();
|
|||
*/
|
||||
function registerModule(referrer, registry) {
|
||||
const idSymbol = referrer[host_defined_option_symbol];
|
||||
if (idSymbol === default_host_defined_options) {
|
||||
// The referrer is compiled without custom callbacks, so there is
|
||||
// no registry to hold on to. We'll throw
|
||||
// ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING when a callback is
|
||||
// needed.
|
||||
return;
|
||||
}
|
||||
// To prevent it from being GC'ed.
|
||||
registry.callbackReferrer ??= referrer;
|
||||
moduleRegistries.set(idSymbol, registry);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue