diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 8327b8ab61..a496eaef4b 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -857,7 +857,7 @@ static void memories_deinstantiate(AOTModuleInstance *module_inst) { /* import memories created by host or linker. released by them too */ - for (uint32 i = module_inst->module->import_memory_count; + for (uint32 i = ((AOTModule *)module_inst->module)->import_memory_count; i < module_inst->memory_count; i++) { memory_deinstantiate(module_inst->memories[i]); } @@ -1117,6 +1117,7 @@ aot_lookup_memory(AOTModuleInstance *module_inst, char const *name) return module_inst->export_memories[i].memory; return NULL; #else + (void)name; (void)module_inst->export_memories; return aot_get_default_memory(module_inst); #endif @@ -1179,6 +1180,7 @@ memories_instantiate(const AOTModule *module, AOTModuleInstance *module_inst, mem_index++, memory++) { AOTImportMemory *memory_type = module->import_memories + mem_index; +#if WASM_ENABLE_MULTI_MODULE == 0 const WASMExternInstance *extern_inst = wasm_runtime_get_extern_instance(imports, import_count, WASM_IMPORT_EXPORT_KIND_MEMORY, @@ -1209,6 +1211,22 @@ memories_instantiate(const AOTModule *module, AOTModuleInstance *module_inst, module_inst->memories[mem_index] = extern_inst->u.memory; bh_memcpy_s(memory, sizeof(AOTMemoryInstance), extern_inst->u.memory, sizeof(AOTMemoryInstance)); +#else + uint32 max_page_count = wasm_runtime_get_max_mem( + max_memory_pages, memory_type->mem_type.init_page_count, + memory_type->mem_type.max_page_count); + + module_inst->memories[mem_index] = memory_instantiate( + module, parent, memory, parent ? parent->memories[mem_index] : NULL, + memory_type->mem_type.num_bytes_per_page, + memory_type->mem_type.init_page_count, max_page_count, + /* only inst->memories[0] will have a app heap */ + mem_index == 0 ? heap_size : 0, memory_type->mem_type.flags, + aux_heap_base_global_data, error_buf, error_buf_size); + if (!module_inst->memories[mem_index]) { + return false; + } +#endif } /* process internal memories */ @@ -1887,7 +1905,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, */ set_error_buf(error_buf, error_buf_size, "imports is NULL while module has imports"); - return NULL; + // return NULL; } #endif @@ -3609,6 +3627,9 @@ static void const_string_node_size_cb(void *key, void *value, void *p_const_string_size) { uint32 const_string_size = 0; + + (void)key; + const_string_size += bh_hash_map_get_elem_struct_size(); const_string_size += strlen((const char *)value) + 1; *(uint32 *)p_const_string_size += const_string_size; @@ -3646,7 +3667,7 @@ aot_get_module_mem_consumption(const AOTModule *module, mem_conspn->memories_size = sizeof(AOTMemory) - * (module->memory_count + moudle->import_memory_count); + * (module->memory_count + module->import_memory_count); mem_conspn->globals_size = sizeof(AOTGlobal) * module->global_count; mem_conspn->exports_size = sizeof(AOTExport) * module->export_count; @@ -5428,10 +5449,12 @@ aot_resolve_import_func(AOTModule *module, AOTImportFunc *import_func) char error_buf[128]; AOTModule *sub_module = NULL; #endif + import_func->func_ptr_linked = wasm_native_resolve_symbol( import_func->module_name, import_func->func_name, import_func->func_type, &import_func->signature, &import_func->attachment, &import_func->call_conv_raw); + #if WASM_ENABLE_MULTI_MODULE != 0 if (!import_func->func_ptr_linked) { if (!wasm_runtime_is_built_in_module(import_func->module_name)) { @@ -5454,7 +5477,10 @@ aot_resolve_import_func(AOTModule *module, AOTImportFunc *import_func) } } } +#else + (void)module; #endif + return import_func->func_ptr_linked != NULL; } diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 7c764868ec..ce6f3d8b01 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -570,7 +570,7 @@ memories_instantiate(const WASMModule *module, WASMModuleInstance *module_inst, return NULL; } - if (!(memories[mem_index++] = wasm_lookup_memory( + if (!(memories[mem_index] = wasm_lookup_memory( module_inst_linked, memory_type->field_name))) { set_error_buf(error_buf, error_buf_size, "unknown memory"); memories_deinstantiate(module_inst, memories, memory_count); @@ -598,7 +598,6 @@ memories_instantiate(const WASMModule *module, WASMModuleInstance *module_inst, memories_deinstantiate(module_inst, memories, memory_count); return NULL; } - mem_index++; } #else @@ -609,7 +608,7 @@ memories_instantiate(const WASMModule *module, WASMModuleInstance *module_inst, if (!extern_inst) { LOG_ERROR("missing a import memory(%s, %s)", memory_type->module_name, memory_type->field_name); - return false; + return NULL; } /* just in case */ @@ -618,7 +617,7 @@ memories_instantiate(const WASMModule *module, WASMModuleInstance *module_inst, LOG_ERROR( "mismatched import memory name: expect \"%s\", got \"%s\"", memory_type->field_name, extern_inst->field_name); - return false; + return NULL; } #endif /* @@ -2068,6 +2067,7 @@ check_linked_symbol(WASMModuleInstance *module_inst, char *error_buf, for (i = 0; i < module->import_memory_count; i++) { WASMMemoryImport *type = &((module->import_memories + i)->u.memory); WASMMemoryInstance *memory = module_inst->memories[i]; + (void)memory; if ( #if WASM_ENABLE_MULTI_MODULE != 0 !wasm_runtime_is_built_in_module(type->module_name) diff --git a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c index 6d057a6a18..7dd1d148aa 100644 --- a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c +++ b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c @@ -82,6 +82,7 @@ wasi_ctx_get_curfds(wasi_ctx_t wasi_ctx) static inline struct argv_environ_values * wasi_ctx_get_argv_environ(wasm_module_inst_t module_inst, wasi_ctx_t wasi_ctx) { + (void)module_inst; if (!wasi_ctx) return NULL; return wasi_ctx->argv_environ; @@ -2171,6 +2172,8 @@ wasi_sock_send(wasm_exec_env_t exec_env, wasi_fd_t sock, wasi_errno_t err; size_t send_bytes = 0; + (void)si_flags; + if (!wasi_ctx) { return __WASI_EINVAL; } @@ -2241,6 +2244,8 @@ wasi_sock_shutdown(wasm_exec_env_t exec_env, wasi_fd_t sock, wasi_sdflags_t how) wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); + (void)how; + if (!wasi_ctx) return __WASI_EINVAL;