Fix loader parse block type and calculate dynamic offset for loop args (#3482)

Fix several issues in wasm loader:
- Parse a block's type index with leb int32 instead leb uint32
- Correct dst dynamic offset of loop block arguments for opcode br
  when copying the stack operands to the arguments of loop block
- Free each frame_csp's param_frame_offsets when destroy loader ctx
- Fix compilation error in wasm_mini_loader.c
- Add test cases of failed issues

This PR fixes issue #3467 and #3468.
This commit is contained in:
Wenyong Huang
2024-05-31 11:32:36 +08:00
committed by GitHub
parent 67638e24f4
commit 23e1d51587
7 changed files with 139 additions and 32 deletions

View File

@ -1028,7 +1028,9 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
}
else {
frame_ip--;
read_leb_uint32(frame_ip, frame_ip_end, type_index);
read_leb_int32(frame_ip, frame_ip_end, type_index);
/* type index was checked in wasm loader */
bh_assert(type_index < comp_ctx->comp_data->type_count);
func_type =
(AOTFuncType *)comp_ctx->comp_data->types[type_index];
param_count = func_type->param_count;
@ -1048,7 +1050,9 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
case EXT_OP_LOOP:
case EXT_OP_IF:
{
read_leb_uint32(frame_ip, frame_ip_end, type_index);
read_leb_int32(frame_ip, frame_ip_end, type_index);
/* type index was checked in wasm loader */
bh_assert(type_index < comp_ctx->comp_data->type_count);
func_type =
(AOTFuncType *)comp_ctx->comp_data->types[type_index];
param_count = func_type->param_count;