From 0d2074d27aba9bf8325a07c9bd99d6fec3a15ffe Mon Sep 17 00:00:00 2001 From: TL Date: Thu, 28 Mar 2024 15:21:15 +0800 Subject: [PATCH] cr suggestions --- core/iwasm/aot/aot_runtime.c | 2 +- core/iwasm/common/wasm_runtime_common.c | 3 ++- core/iwasm/interpreter/wasm_loader.c | 23 ++++++++++------------- core/iwasm/interpreter/wasm_mini_loader.c | 23 ++++++++++------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index a35e22245..bb5f1f002 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -914,7 +914,7 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, bh_assert(max_memory_data_size <= MAX_LINEAR_MEMORY_SIZE); (void)max_memory_data_size; - /* TODO: memory64 use is_memory64 flag */ + /* TODO: memory64 uses is_memory64 flag */ if (wasm_allocate_linear_memory(&p, is_shared_memory, false, num_bytes_per_page, init_page_count, max_page_count, &memory_data_size) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 9f1aa94c2..9429989e3 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -3732,7 +3732,8 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr, case VALUE_TYPE_I64: #if WASM_ENABLE_MEMORY64 != 0 { - PUT_I64_TO_ADDR((uint32 *)argv, GET_I64_FROM_ADDR(argv_src)); + PUT_I64_TO_ADDR((uint32 *)argv_dst, + GET_I64_FROM_ADDR(argv_src)); argv_src += 2; arg_i64 = *argv_dst; if (signature) { diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 44ce4b3d8..02fa022fb 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -10785,6 +10785,16 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif #if WASM_ENABLE_MEMORY64 != 0 bool is_memory64 = false; + /* TODO: multi-memories for now assuming the memory idx type is consistent + * across multi-memories */ + if (module->import_memory_count > 0) + is_memory64 = module->import_memories[0].u.memory.flags & MEMORY64_FLAG; + else if (module->memory_count > 0) + is_memory64 = module->memories[0].flags & MEMORY64_FLAG; + + mem_offset_type = is_memory64 ? VALUE_TYPE_I64 : VALUE_TYPE_I32; +#else + mem_offset_type = VALUE_TYPE_I32; #endif global_count = module->import_global_count + module->global_count; @@ -10838,19 +10848,6 @@ re_scan: } #endif -#if WASM_ENABLE_MEMORY64 != 0 - /* TODO: multi-memories for now assuming the memory idx type is consistent - * across multi-memories */ - if (module->import_memory_count > 0) - is_memory64 = module->import_memories[0].u.memory.flags & MEMORY64_FLAG; - else if (module->memory_count > 0) - is_memory64 = module->memories[0].flags & MEMORY64_FLAG; - - mem_offset_type = is_memory64 ? VALUE_TYPE_I64 : VALUE_TYPE_I32; -#else - mem_offset_type = VALUE_TYPE_I32; -#endif - PUSH_CSP(LABEL_TYPE_FUNCTION, func_block_type, p); while (p < p_end) { diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index a734595ab..5146535b8 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -5960,6 +5960,16 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif #if WASM_ENABLE_MEMORY64 != 0 bool is_memory64 = false; + /* TODO: multi-memories for now assuming the memory idx type is consistent + * across multi-memories */ + if (module->import_memory_count > 0) + is_memory64 = module->import_memories[0].u.memory.flags & MEMORY64_FLAG; + else if (module->memory_count > 0) + is_memory64 = module->memories[0].flags & MEMORY64_FLAG; + + mem_offset_type = is_memory64 ? VALUE_TYPE_I64 : VALUE_TYPE_I32; +#else + mem_offset_type = VALUE_TYPE_I32; #endif global_count = module->import_global_count + module->global_count; @@ -6001,19 +6011,6 @@ re_scan: } #endif -#if WASM_ENABLE_MEMORY64 != 0 - /* TODO: multi-memories for now assuming the memory idx type is consistent - * across multi-memories */ - if (module->import_memory_count > 0) - is_memory64 = module->import_memories[0].u.memory.flags & MEMORY64_FLAG; - else if (module->memory_count > 0) - is_memory64 = module->memories[0].flags & MEMORY64_FLAG; - - mem_offset_type = is_memory64 ? VALUE_TYPE_I64 : VALUE_TYPE_I32; -#else - mem_offset_type = VALUE_TYPE_I32; -#endif - PUSH_CSP(LABEL_TYPE_FUNCTION, func_block_type, p); while (p < p_end) {