Refine lock/unlock shared memory (#2682)

Split memory instance's field `uint32 ref_count` into `bool is_shared_memory`
and `uint16 ref_count`, and lock the memory only when `is_shared_memory`
flag is true, no need to acquire a lock for non-shared memory when shared
memory feature is enabled.
This commit is contained in:
Wenyong Huang
2023-10-31 11:46:03 +08:00
committed by GitHub
parent 3570a94a08
commit 52db362b89
7 changed files with 110 additions and 64 deletions

View File

@ -79,8 +79,11 @@ typedef union {
struct WASMMemoryInstance {
/* Module type */
uint32 module_type;
bool is_shared_memory;
/* Shared memory flag */
bh_atomic_32_t ref_count; /* 0: non-shared, > 0: reference count */
bh_atomic_16_t ref_count; /* 0: non-shared, > 0: reference count */
/* Number bytes per page */
uint32 num_bytes_per_page;