Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[instantiation linking] create and import WASMMemoryInstance #3845

Draft
wants to merge 16 commits into
base: dev/instantiate_linking
Choose a base branch
from

Conversation

lum1n0us
Copy link
Collaborator

@lum1n0us lum1n0us commented Oct 9, 2024

No description provided.

@lum1n0us lum1n0us force-pushed the feat/inst_linking_memory branch 5 times, most recently from 62b7808 to 1821dfd Compare October 12, 2024 08:34
@lum1n0us lum1n0us force-pushed the feat/inst_linking_memory branch 3 times, most recently from 6508580 to 54d45c7 Compare October 18, 2024 09:14
including
- memory create and destroy
- instnace_new with imports
Besides, it is still an open question if a memory should be exported
This commit refactors the `memory_deinstantiate` function in the `wasm_runtime.c` file. It introduces a new helper function `memory_deinstantiate` to handle the destruction of memory instances. The function checks if the memory is shared and decrements the reference count before freeing the memory. It also destroys the heap handle and deallocates the linear memory.

Additionally, the commit fixes the `wasm_destroy_memory` function by calling the `memory_deinstantiate` function and freeing the memory instance.

These changes improve the memory management in the interpreter and ensure proper destruction of memory instances.
- Set CMAKE_BUILD_TYPE to Debug in CMakeLists.txt
- Add missing printf and fflush statements in import_memory.c
- Add assertion for memory data in import_memory.c
- Add assertion for memory growth in import_memory.c
Both `WASI_THREADS` and `THREAD_MGR` continue to use loader linking to keep a
separate memory instance for each thread they create.
This commit refactors the code related to memory instantiation and import handling in the `wasm_runtime.c` and `wasm_runtime.h` files. It introduces a new function `wasm_runtime_inherit_imports` that builds a list of imports from the parent's imports. The function is used in the `thread_spawn_wrapper` function in the `lib_wasi_threads_wrapper.c` file to instantiate a module for a spawned thread. Additionally, the code in the `main.c` file is modified to handle imports from the `spectest`, `foo`, and `env` modules.
@lum1n0us lum1n0us force-pushed the feat/inst_linking_memory branch 5 times, most recently from b8bdddc to 6c0b2fa Compare October 21, 2024 08:35
@lum1n0us lum1n0us changed the base branch from main to dev/instantiate_linking October 22, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant