Add WASI ABI compatibility check for multi-module (#913)

Refer to https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md
to check the WASI ABI compatibility:
- Command (main module) may export _start function with signature "()"
- Reactor (sub module) may export _initialize function with signature "()"
- _start and _initialize can not be exported at the same time
- Reactor cannot export _start function
- Command and Reactor must export memory

And
- Rename module->is_wasi_module to module->import_wasi_api
- Refactor wasm_loader_find_export()
- Remove MULTI_MODULE related codes from mini_loader
- Update multi-module samples
- Fix a "use-after-free" issue. Since we reuse the memory instance of sub module,
   just to protect it from freeing an imported memory instance
This commit is contained in:
liang.he
2021-12-29 11:04:36 +08:00
committed by GitHub
parent 936206f97b
commit 50b6474f54
20 changed files with 654 additions and 219 deletions

View File

@ -2294,13 +2294,13 @@ wasm_runtime_is_wasi_mode(WASMModuleInstanceCommon *module_inst)
{
#if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode
&& ((WASMModuleInstance *)module_inst)->module->is_wasi_module)
&& ((WASMModuleInstance *)module_inst)->module->import_wasi_api)
return true;
#endif
#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT
&& ((AOTModule *)((AOTModuleInstance *)module_inst)->aot_module.ptr)
->is_wasi_module)
->import_wasi_api)
return true;
#endif
return false;