Allow to set native stack boundary to exec_env (#3862)

Add runtime API wasm_runtime_set_native_stack_boundary.

p.s. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3816
This commit is contained in:
Wenyong Huang
2024-10-18 12:49:57 +08:00
committed by GitHub
parent 7e625a0624
commit 74d2427fdc
5 changed files with 43 additions and 2 deletions

View File

@ -282,8 +282,13 @@ wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
os_mutex_lock(&exec_env->wait_lock);
#endif
exec_env->handle = os_self_thread();
exec_env->native_stack_boundary =
stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL;
if (exec_env->user_native_stack_boundary)
/* WASM_STACK_GUARD_SIZE isn't added for flexibility to developer,
he must ensure that enough guard bytes are kept. */
exec_env->native_stack_boundary = exec_env->user_native_stack_boundary;
else
exec_env->native_stack_boundary =
stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL;
exec_env->native_stack_top_min = (void *)UINTPTR_MAX;
#if WASM_ENABLE_THREAD_MGR != 0
os_mutex_unlock(&exec_env->wait_lock);