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 for interp #3845

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 10 times, most recently from a1d2c27 to 7678f4d Compare October 21, 2024 14:36
@lum1n0us lum1n0us changed the base branch from main to dev/instantiate_linking October 22, 2024 11:47
TianlongLiang and others added 12 commits October 23, 2024 14:48
…ealliance#3871)

* exclude fuzz test for scoreboard scan

* ci ignore osv-scanner.toml file name inconsistency
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.
@lum1n0us lum1n0us requested a review from yamt as a code owner October 24, 2024 05:46
core/iwasm/common/wasm_memory.c Outdated Show resolved Hide resolved
core/iwasm/include/wasm_export.h Outdated Show resolved Hide resolved
core/iwasm/include/wasm_export.h Outdated Show resolved Hide resolved
core/iwasm/include/wasm_export.h Outdated Show resolved Hide resolved
core/iwasm/common/wasm_runtime_common.c Outdated Show resolved Hide resolved
core/iwasm/common/wasm_runtime_common.c Outdated Show resolved Hide resolved
core/iwasm/common/wasm_runtime_common.c Outdated Show resolved Hide resolved
core/iwasm/common/wasm_runtime_common.c Show resolved Hide resolved
core/iwasm/common/wasm_runtime_common.c Show resolved Hide resolved
core/iwasm/include/wasm_export.h Outdated Show resolved Hide resolved
core/iwasm/interpreter/wasm_runtime.c Outdated Show resolved Hide resolved
core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c Outdated Show resolved Hide resolved
core/iwasm/libraries/thread-mgr/thread_manager.c Outdated Show resolved Hide resolved
product-mini/platforms/posix/main.c Outdated Show resolved Hide resolved
@lum1n0us lum1n0us force-pushed the feat/inst_linking_memory branch 2 times, most recently from 7c81eb8 to fbba2a3 Compare October 30, 2024 01:39
core/iwasm/common/wasm_runtime_common.c Outdated Show resolved Hide resolved
core/iwasm/common/wasm_memory.c Outdated Show resolved Hide resolved
core/iwasm/common/wasm_runtime_common.c Outdated Show resolved Hide resolved
core/iwasm/interpreter/wasm_runtime.c Outdated Show resolved Hide resolved
samples/linking/lib/CMakeLists.txt Show resolved Hide resolved
samples/linking/wasm/import_memory.c Show resolved Hide resolved
samples/linking/wasm/import_memory.c Show resolved Hide resolved
samples/linking/wasm/import_memory.c Show resolved Hide resolved
Copy link
Contributor

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lum1n0us lum1n0us merged commit e030350 into bytecodealliance:dev/instantiate_linking Nov 4, 2024
383 checks passed
@lum1n0us lum1n0us deleted the feat/inst_linking_memory branch November 4, 2024 07:38
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.

4 participants