Fix/Simplify the atomic.wait/nofity implementations (#2044)
Use the shared memory's shared_mem_lock to lock the whole atomic.wait and atomic.notify processes, and use it for os_cond_reltimedwait and os_cond_notify, so as to make the whole processes actual atomic operations: the original implementation accesses the wait address with shared_mem_lock and uses wait_node->wait_lock for os_cond_reltimedwait, which is not an atomic operation. And remove the unnecessary wait_map_lock and wait_lock, since the whole processes are already locked by shared_mem_lock.
This commit is contained in:
@ -3252,7 +3252,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
ret = wasm_runtime_atomic_notify(
|
||||
(WASMModuleInstanceCommon *)module, maddr,
|
||||
notify_count);
|
||||
bh_assert((int32)ret >= 0);
|
||||
if (ret == (uint32)-1)
|
||||
goto got_exception;
|
||||
|
||||
PUSH_I32(ret);
|
||||
break;
|
||||
@ -3307,7 +3308,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
}
|
||||
case WASM_OP_ATOMIC_FENCE:
|
||||
{
|
||||
os_atomic_thread_fence(os_memory_order_release);
|
||||
os_atomic_thread_fence(os_memory_order_seq_cst);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3555,9 +3556,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
|
||||
os_mutex_lock(&node->shared_mem_lock);
|
||||
readv = (uint64)LOAD_I64(maddr);
|
||||
if (readv == expect) {
|
||||
if (readv == expect)
|
||||
STORE_I64(maddr, sval);
|
||||
}
|
||||
os_mutex_unlock(&node->shared_mem_lock);
|
||||
}
|
||||
PUSH_I64(readv);
|
||||
|
||||
Reference in New Issue
Block a user