Skip to content

Commit c48dd5c

Browse files
authored
Don't call os_thread_get_stack_boundary unless we actually use it (#4264)
Previously, if the user sets their own stack boundary, we still compute the thread stack boundary (which is expensive), then immediately discard the result. This change makes the expensive call only if we need it for sure.
1 parent 8f39610 commit c48dd5c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/iwasm/common/wasm_exec_env.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ wasm_exec_env_restore_module_inst(
276276
void
277277
wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
278278
{
279-
uint8 *stack_boundary = os_thread_get_stack_boundary();
280-
281279
#if WASM_ENABLE_THREAD_MGR != 0
282280
os_mutex_lock(&exec_env->wait_lock);
283281
#endif
@@ -286,9 +284,11 @@ wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
286284
/* WASM_STACK_GUARD_SIZE isn't added for flexibility to developer,
287285
he must ensure that enough guard bytes are kept. */
288286
exec_env->native_stack_boundary = exec_env->user_native_stack_boundary;
289-
else
287+
else {
288+
uint8 *stack_boundary = os_thread_get_stack_boundary();
290289
exec_env->native_stack_boundary =
291290
stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL;
291+
}
292292
exec_env->native_stack_top_min = (void *)UINTPTR_MAX;
293293
#if WASM_ENABLE_THREAD_MGR != 0
294294
os_mutex_unlock(&exec_env->wait_lock);

0 commit comments

Comments
 (0)