Use shared memory lock for threads generated from same module (#1960)
Multiple threads generated from the same module should use the same lock to protect the atomic operations. Before this PR, each thread used a different lock to protect atomic operations (e.g. atomic add), making the lock ineffective. Fix #1958.
This commit is contained in:
@ -2725,7 +2725,8 @@ create_module(char *error_buf, uint32 error_buf_size)
|
||||
bh_assert(ret == BH_LIST_SUCCESS);
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT && WASM_ENABLE_LAZY_JIT != 0
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||
&& WASM_ENABLE_LAZY_JIT != 0
|
||||
if (os_mutex_init(&module->instance_list_lock) != 0) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"init instance list lock failed");
|
||||
@ -2946,7 +2947,8 @@ wasm_loader_unload(WASMModule *module)
|
||||
if (!module)
|
||||
return;
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT && WASM_ENABLE_LAZY_JIT != 0
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||
&& WASM_ENABLE_LAZY_JIT != 0
|
||||
module->orcjit_stop_compiling = true;
|
||||
if (module->llvm_jit_init_thread)
|
||||
os_thread_join(module->llvm_jit_init_thread, NULL);
|
||||
@ -2967,7 +2969,8 @@ wasm_loader_unload(WASMModule *module)
|
||||
aot_destroy_comp_data(module->comp_data);
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT && WASM_ENABLE_LAZY_JIT != 0
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||
&& WASM_ENABLE_LAZY_JIT != 0
|
||||
if (module->tierup_wait_lock_inited) {
|
||||
os_mutex_destroy(&module->tierup_wait_lock);
|
||||
os_cond_destroy(&module->tierup_wait_cond);
|
||||
@ -3063,7 +3066,8 @@ wasm_loader_unload(WASMModule *module)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT && WASM_ENABLE_LAZY_JIT != 0
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||
&& WASM_ENABLE_LAZY_JIT != 0
|
||||
os_mutex_destroy(&module->instance_list_lock);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user