debug-interp: Only add lock when signal_flag is SIG_SINGSTEP (#3704)

As reported in #3500, when debug interpreter is enabled, the classic interpreter
performs a lock operation to read `exec_env->current_status->signal_flag` and
do further handling before fetching next opcode, which makes the interpreter
run slower.

This PR atomic loads the `exec_env->current_status->signal_flag` without mutex
lock when 32-bit atomic load is supported, and only adding lock for further
handling when the signal_flag is WAMR_SIG_SINGSTEP, which improves the
performance.
This commit is contained in:
Wenyong Huang
2024-08-14 09:03:01 +08:00
committed by GitHub
parent 37d7439ef9
commit da25906ed4
2 changed files with 60 additions and 27 deletions

View File

@ -184,9 +184,9 @@ wasm_cluster_is_thread_terminated(WASMExecEnv *exec_env);
((signo) == WAMR_SIG_STOP || (signo) == WAMR_SIG_TRAP)
struct WASMCurrentEnvStatus {
uint64 signal_flag : 32;
uint64 step_count : 16;
uint64 running_status : 16;
uint32 signal_flag;
uint16 step_count;
uint16 running_status;
};
WASMCurrentEnvStatus *