Fix memory64 handling find_block_addr and execute_main (#3480)

This commit is contained in:
Wenyong Huang
2024-05-30 16:14:12 +08:00
committed by GitHub
parent 1f8a78d61a
commit 5623e4d22a
4 changed files with 40 additions and 18 deletions

View File

@ -3446,10 +3446,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
{
/* clang-format off */
#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0
local_offset = *frame_ip++;
local_offset = *frame_ip++;
#else
local_offset = *frame_ip;
frame_ip += 2;
local_offset = *frame_ip;
frame_ip += 2;
#endif
/* clang-format on */
*(uint32 *)(frame_lp + local_offset) =
@ -3463,10 +3463,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
{
/* clang-format off */
#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0
local_offset = *frame_ip++;
local_offset = *frame_ip++;
#else
local_offset = *frame_ip;
frame_ip += 2;
local_offset = *frame_ip;
frame_ip += 2;
#endif
/* clang-format on */
PUT_I64_TO_ADDR((uint32 *)(frame_lp + local_offset),

View File

@ -6414,7 +6414,7 @@ create_sections(const uint8 *buf, uint32 size, WASMSection **p_section_list,
char *error_buf, uint32 error_buf_size)
{
WASMSection *section_list_end = NULL, *section;
const uint8 *p = buf, *p_end = buf + size /*, *section_body*/;
const uint8 *p = buf, *p_end = buf + size;
uint8 section_type, section_index, last_section_index = (uint8)-1;
uint32 section_size;
@ -7658,7 +7658,6 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0)
case WASM_OP_SIMD_PREFIX:
{
/* TODO: memory64 offset type changes */
uint32 opcode1;
read_leb_uint32(p, p_end, opcode1);
@ -7683,8 +7682,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
case SIMD_v128_store:
/* memarg align */
skip_leb_uint32(p, p_end);
/* memarg offset*/
skip_leb_uint32(p, p_end);
/* memarg offset */
skip_leb_mem_offset(p, p_end);
break;
case SIMD_v128_const:
@ -7723,8 +7722,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
case SIMD_v128_store64_lane:
/* memarg align */
skip_leb_uint32(p, p_end);
/* memarg offset*/
skip_leb_uint32(p, p_end);
/* memarg offset */
skip_leb_mem_offset(p, p_end);
/* ImmLaneId */
CHECK_BUF(p, p_end, 1);
p++;
@ -7734,8 +7733,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
case SIMD_v128_load64_zero:
/* memarg align */
skip_leb_uint32(p, p_end);
/* memarg offset*/
skip_leb_uint32(p, p_end);
/* memarg offset */
skip_leb_mem_offset(p, p_end);
break;
default:

View File

@ -6942,7 +6942,8 @@ re_scan:
uint32 j;
for (i = 0; i < module->global_count; i++) {
if (module->globals[i].type == VALUE_TYPE_FUNCREF
if (module->globals[i].type.val_type
== VALUE_TYPE_FUNCREF
&& module->globals[i].init_expr.init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST
&& module->globals[i].init_expr.u.u32 == func_idx) {