Skip to content

Commit

Permalink
add instance_execute_handle_restart_once
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jun 18, 2023
1 parent 320d8d9 commit 005284a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
14 changes: 12 additions & 2 deletions lib/instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ instance_execute_func_nocheck(struct exec_context *ctx, uint32_t funcidx,
}

int
instance_execute_handle_restart(struct exec_context *ctx, int exec_ret)
instance_execute_handle_restart_once(struct exec_context *ctx, int exec_ret)
{
int ret = exec_ret;
while (IS_RESTARTABLE(ret)) {
if (IS_RESTARTABLE(ret)) {
#if defined(TOYWASM_ENABLE_WASM_THREADS)
suspend_parked(ctx->cluster);
#endif
Expand All @@ -658,3 +658,13 @@ instance_execute_handle_restart(struct exec_context *ctx, int exec_ret)
}
return ret;
}

int
instance_execute_handle_restart(struct exec_context *ctx, int exec_ret)
{
int ret = exec_ret;
do {
ret = instance_execute_handle_restart_once(ctx, ret);
} while (IS_RESTARTABLE(ret));
return ret;
}
20 changes: 16 additions & 4 deletions lib/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,25 @@ int instance_execute_continue(struct exec_context *ctx);
/*
* instance_execute_handle_restart:
*
* perform the default handling of a restartable error.
* this function never returns a restartable error.
* if the given exec_ret is not a restartable error, this function just
* returns it as it is.
* an equivalent of keep calling instance_execute_handle_restart_once
* until it returns a success or a non-restartable error.
*/
int instance_execute_handle_restart(struct exec_context *ctx, int exec_ret);

/*
* instance_execute_handle_restart_once:
*
* after performing the default handling of a restartable error,
* continue the execution as instance_execute_continue does.
*
* Note: this function can return a restartable error.
*
* Note: if the given exec_ret is not a restartable error, this function
* just returns it as it is.
*/
int instance_execute_handle_restart_once(struct exec_context *ctx,
int exec_ret);

/*
* see the comment in type.h about the concept of import_object.
*/
Expand Down

0 comments on commit 005284a

Please sign in to comment.