Refactor shared heap feature for interpreter mode (#3794)

To add test cases and samples.
This commit is contained in:
Wenyong Huang
2024-09-18 14:53:41 +08:00
committed by GitHub
parent 92852f3719
commit 5e20cf383e
6 changed files with 543 additions and 385 deletions

View File

@ -1449,10 +1449,19 @@ wasm_cluster_attach_shared_heap(WASMModuleInstanceCommon *module_inst,
bh_assert(cluster);
os_mutex_lock(&cluster->lock);
/* Try attaching shared heap to this module instance first
to ensure that we can attach it to all other instances. */
if (!wasm_runtime_attach_shared_heap_internal(module_inst, heap)) {
os_mutex_unlock(&cluster->lock);
return false;
}
/* Detach the shared heap so it can be attached again. */
wasm_runtime_detach_shared_heap_internal(module_inst);
traverse_list(&cluster->exec_env_list, attach_shared_heap_visitor,
heap);
os_mutex_unlock(&cluster->lock);
}
return true;
}