Skip to content

Commit

Permalink
do_host_call: keep the stack height while calling the host func
Browse files Browse the repository at this point in the history
to allow the host func to push more values onto the stack.
  • Loading branch information
yamt committed Oct 13, 2023
1 parent f11a505 commit e44366a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,8 @@ do_host_call(struct exec_context *ctx, const struct funcinst *finst)
return ret;
}
}
ctx->stack.lsize -= nparams;
ret = finst->u.host.func(ctx, finst->u.host.instance, ft,
&VEC_NEXTELEM(ctx->stack),
&VEC_NEXTELEM(ctx->stack));
struct cell *p = &VEC_ELEM(ctx->stack, ctx->stack.lsize - nparams);
ret = finst->u.host.func(ctx, finst->u.host.instance, ft, p, p);
assert(IS_RESTARTABLE(ret) || restart_info_is_none(ctx));
if (ret != 0) {
if (IS_RESTARTABLE(ret)) {
Expand All @@ -448,6 +446,7 @@ do_host_call(struct exec_context *ctx, const struct funcinst *finst)
}
return ret;
}
ctx->stack.lsize -= nparams;
ctx->stack.lsize += nresults;
assert(ctx->stack.lsize <= ctx->stack.psize);
return 0;
Expand Down

0 comments on commit e44366a

Please sign in to comment.