Skip to content

Commit

Permalink
fast-interp: Fix dynamic offset error issue in else branch (#3058)
Browse files Browse the repository at this point in the history
Reported in #3026.
  • Loading branch information
xujuntwt95329 committed Jan 19, 2024
1 parent bc35602 commit 1977ad2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -7400,6 +7400,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
bh_memcpy_s(loader_ctx->frame_offset, size,
block->param_frame_offsets, size);
loader_ctx->frame_offset += (size / sizeof(int16));

/* recover dynamic offset */
for (i = 0; i < block->available_param_num; i++) {
if (block->param_frame_offsets[i]
>= loader_ctx->dynamic_offset) {
loader_ctx->dynamic_offset =
block->param_frame_offsets[i] + 1;
}
}
}
#endif

Expand Down
9 changes: 9 additions & 0 deletions core/iwasm/interpreter/wasm_mini_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5813,6 +5813,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
bh_memcpy_s(loader_ctx->frame_offset, size,
block->param_frame_offsets, size);
loader_ctx->frame_offset += (size / sizeof(int16));

/* recover dynamic offset */
for (i = 0; i < block->available_param_num; i++) {
if (block->param_frame_offsets[i]
>= loader_ctx->dynamic_offset) {
loader_ctx->dynamic_offset =
block->param_frame_offsets[i] + 1;
}
}
}
#endif

Expand Down

0 comments on commit 1977ad2

Please sign in to comment.