Skip to content

Conversation

XeniaLu
Copy link
Contributor

@XeniaLu XeniaLu commented Jun 23, 2024

  • split the aot_loader_resolve_function into two functions to prevent redundant module lookups and loads
  • access pre-associated module instances from func_module_insts, avoiding unnecessary instances lookups and improving performance

XeniaLu added 2 commits June 23, 2024 17:11
* split the `aot_loader_resolve_function` into two functions to prevent
redundant module lookups and loads
* access pre-associated module instances from `func_module_insts`,
avoiding unnecessary instances lookups and improving performance
* removed redundant NULL assignments
* avoided emitting warning logs for failed function linking when
multi-module is enabled
@@ -109,6 +109,7 @@ typedef struct AOTModuleInstanceExtra {
#if WASM_ENABLE_MULTI_MODULE != 0
bh_list sub_module_inst_list_head;
bh_list *sub_module_inst_list;
WASMModuleInstanceCommon **func_module_insts;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMU, sub_module_inst_list is a list to store all AOTSubModInstNode. Why need a new WASMModuleInstanceCommon[] to do the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, sub_module_inst_list and func_module_insts store the same data. But func_module_insts is indexed by the function index, which allows us to directly access the module instance without having to go through sub_module_inst_list and lookup by name each time. sub_module_inst_list is kept because there are still some places that require a complete and non-duplicated sub-module instances list.

XeniaLu added 2 commits June 25, 2024 15:52
* rename `func_module_insts` to `import_func_module_insts`
* allocate individual memory for `import_func_module_insts`
* add a function `init_import_func_module_insts` to initialize module
instances of import functions, and invoke it when initializing
`sub_module_list_node`
Copy link
Collaborator

@lum1n0us lum1n0us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenyongh wenyongh merged commit 6754b62 into bytecodealliance:main Jun 26, 2024
@XeniaLu XeniaLu deleted the optimize-multi-module branch June 26, 2024 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants