Implement suspend flags as atomic variable (#2361)

We have observed a significant performance degradation after merging
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1991
Instead of protecting suspend flags with a mutex, we implement the flags
as atomic variable and only use mutex when atomics are not available
on a given platform.
This commit is contained in:
Marcin Kolny
2023-07-21 01:27:09 +01:00
committed by GitHub
parent fbe072c0d3
commit 0f4edf9735
8 changed files with 135 additions and 45 deletions

View File

@ -531,7 +531,8 @@ pthread_start_routine(void *arg)
else {
info_node->u.ret = (void *)(uintptr_t)argv[0];
#ifdef OS_ENABLE_HW_BOUND_CHECK
if (exec_env->suspend_flags.flags & 0x08)
if (WASM_SUSPEND_FLAGS_GET(exec_env->suspend_flags)
& WASM_SUSPEND_FLAG_EXIT)
/* argv[0] isn't set after longjmp(1) to
invoke_native_with_hw_bound_check */
info_node->u.ret = exec_env->thread_ret_value;