diff --git a/core/iwasm/libraries/thread-mgr/thread_manager.c b/core/iwasm/libraries/thread-mgr/thread_manager.c index c00685607..f6987c0c8 100644 --- a/core/iwasm/libraries/thread-mgr/thread_manager.c +++ b/core/iwasm/libraries/thread-mgr/thread_manager.c @@ -344,13 +344,13 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env) { WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); wasm_module_inst_t module_inst = get_module_inst(exec_env); - wasm_module_t module = wasm_exec_env_get_module(exec_env); + wasm_module_t module; wasm_module_inst_t new_module_inst; WASMExecEnv *new_exec_env; uint32 aux_stack_start, aux_stack_size; uint32 stack_size = 8192; - if (!module) { + if (!module_inst || !(module = wasm_exec_env_get_module(exec_env))) { return NULL; } @@ -373,11 +373,9 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env) return NULL; } - if (module_inst) { - /* Set custom_data to new module instance */ - wasm_runtime_set_custom_data_internal( - new_module_inst, wasm_runtime_get_custom_data(module_inst)); - } + /* Set custom_data to new module instance */ + wasm_runtime_set_custom_data_internal( + new_module_inst, wasm_runtime_get_custom_data(module_inst)); new_exec_env = wasm_exec_env_create_internal(new_module_inst, exec_env->wasm_stack_size); diff --git a/core/iwasm/libraries/thread-mgr/thread_manager.h b/core/iwasm/libraries/thread-mgr/thread_manager.h index ca1cd8f80..e99efc99c 100644 --- a/core/iwasm/libraries/thread-mgr/thread_manager.h +++ b/core/iwasm/libraries/thread-mgr/thread_manager.h @@ -15,65 +15,9 @@ #ifdef __cplusplus extern "C" { #endif + #if WASM_ENABLE_DEBUG_INTERP != 0 -#define WAMR_SIG_TRAP (5) -#define WAMR_SIG_STOP (19) -#define WAMR_SIG_TERM (15) -#define WAMR_SIG_SINGSTEP (0x1ff) - -#define STATUS_RUNNING (0) -#define STATUS_STOP (1) -#define STATUS_EXIT (2) -#define STATUS_STEP (3) - -#define IS_WAMR_TERM_SIG(signo) ((signo) == WAMR_SIG_TERM) - -#define IS_WAMR_STOP_SIG(signo) \ - ((signo) == WAMR_SIG_STOP || (signo) == WAMR_SIG_TRAP) - -typedef struct WASMCurrentEnvStatus { - uint64 signal_flag : 32; - uint64 step_count : 16; - uint64 running_status : 16; - korp_mutex wait_lock; - korp_cond wait_cond; -} WASMCurrentEnvStatus; - typedef struct WASMDebugInstance WASMDebugInstance; - -WASMCurrentEnvStatus * -wasm_cluster_create_exenv_status(); - -void -wasm_cluster_destroy_exenv_status(WASMCurrentEnvStatus *status); - -void -wasm_cluster_send_signal_all(WASMCluster *cluster, uint32 signo); - -void -wasm_cluster_thread_stopped(WASMExecEnv *exec_env); - -void -wasm_cluster_thread_waiting_run(WASMExecEnv *exec_env); - -void -wasm_cluster_wait_thread_status(WASMExecEnv *exec_env, uint32 *status); - -void -wasm_cluster_thread_exited(WASMExecEnv *exec_env); - -void -wasm_cluster_thread_continue(WASMExecEnv *exec_env); - -void -wasm_cluster_thread_send_signal(WASMExecEnv *exec_env, uint32 signo); - -void -wasm_cluster_thread_step(WASMExecEnv *exec_env); - -void -wasm_cluster_set_debug_inst(WASMCluster *cluster, WASMDebugInstance *inst); - #endif typedef struct WASMCluster { struct WASMCluster *next; @@ -183,6 +127,65 @@ void wasm_cluster_spread_custom_data(WASMModuleInstanceCommon *module_inst, void *custom_data); +#if WASM_ENABLE_DEBUG_INTERP != 0 +#define WAMR_SIG_TRAP (5) +#define WAMR_SIG_STOP (19) +#define WAMR_SIG_TERM (15) +#define WAMR_SIG_SINGSTEP (0x1ff) + +#define STATUS_RUNNING (0) +#define STATUS_STOP (1) +#define STATUS_EXIT (2) +#define STATUS_STEP (3) + +#define IS_WAMR_TERM_SIG(signo) ((signo) == WAMR_SIG_TERM) + +#define IS_WAMR_STOP_SIG(signo) \ + ((signo) == WAMR_SIG_STOP || (signo) == WAMR_SIG_TRAP) + +typedef struct WASMCurrentEnvStatus { + uint64 signal_flag : 32; + uint64 step_count : 16; + uint64 running_status : 16; + korp_mutex wait_lock; + korp_cond wait_cond; +} WASMCurrentEnvStatus; + +WASMCurrentEnvStatus * +wasm_cluster_create_exenv_status(); + +void +wasm_cluster_destroy_exenv_status(WASMCurrentEnvStatus *status); + +void +wasm_cluster_send_signal_all(WASMCluster *cluster, uint32 signo); + +void +wasm_cluster_thread_stopped(WASMExecEnv *exec_env); + +void +wasm_cluster_thread_waiting_run(WASMExecEnv *exec_env); + +void +wasm_cluster_wait_thread_status(WASMExecEnv *exec_env, uint32 *status); + +void +wasm_cluster_thread_exited(WASMExecEnv *exec_env); + +void +wasm_cluster_thread_continue(WASMExecEnv *exec_env); + +void +wasm_cluster_thread_send_signal(WASMExecEnv *exec_env, uint32 signo); + +void +wasm_cluster_thread_step(WASMExecEnv *exec_env); + +void +wasm_cluster_set_debug_inst(WASMCluster *cluster, WASMDebugInstance *inst); + +#endif /* end of WASM_ENABLE_DEBUG_INTERP != 0 */ + #ifdef __cplusplus } #endif