]> git.kaiwu.me - njs.git/commit
Replace per-VM indexed array for modules with hash-based lookup.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 18 Feb 2026 01:56:22 +0000 (17:56 -0800)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 27 Feb 2026 23:44:30 +0000 (15:44 -0800)
commit7ab46003dae80bdacc6ece30976a092b60d2dc3e
treebf356a7f425011bf0bd2790e27bef7873775cc00
parent8767aea55568baf1cc7dd5d23f81d9f44534a6b9
Replace per-VM indexed array for modules with hash-based lookup.

Previously, evaluated module values were cached in a separate
vm->modules array indexed by module->index assigned at compile time.
This required keeping the array size in sync with shared->module_items,
which was error-prone in interactive mode where new modules could be
compiled across commands.

Instead, store evaluated module values directly in the per-VM module
copy already maintained by vm->modules_hash.  This unifies the import
and require() caching paths and eliminates the index-based array along
with module->index and shared->module_items fields.

This fixes `make shell_test` when configured with --debug=YES.
src/njs_module.c
src/njs_module.h
src/njs_parser.c
src/njs_vm.c
src/njs_vm.h
src/njs_vmcode.c
src/test/njs_unit_test.c