Skip to content

Shared heap enhancements for Interpreter and AOT #4400

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
85dabad
Merge pull request #4049 from bytecodealliance/main
TianlongLiang Feb 5, 2025
3179b10
shared heap create from preallocated buffer and use as a single memor…
TianlongLiang Jan 16, 2025
013306d
first draft of shared heap enhancement in interpreter and runtime
TianlongLiang Jan 23, 2025
5c22e61
first draft of shared heap enhancement in interpreter and runtime: up…
TianlongLiang Jan 24, 2025
1566ff1
first draft of shared heap enhancement in interpreter and runtime: up…
TianlongLiang Jan 26, 2025
aebb391
unify shared heap sample
TianlongLiang Jan 26, 2025
add6958
fix shared heap enhancement bugs and format code
TianlongLiang Jan 27, 2025
e911813
format and update shared heap boundary check in runtime API
TianlongLiang Feb 5, 2025
0b0ef2d
format
TianlongLiang Feb 5, 2025
91f1234
some refactor
TianlongLiang Feb 8, 2025
3296925
some refactor
TianlongLiang Feb 8, 2025
a9d776e
cr suggestions and some refactor
TianlongLiang Feb 12, 2025
3abea0c
some update
TianlongLiang Feb 12, 2025
88a7f16
some refactor
TianlongLiang Feb 21, 2025
f173354
code refactor
TianlongLiang Feb 21, 2025
948d981
aot data struct modification
TianlongLiang Feb 21, 2025
035f758
code refactor
TianlongLiang Feb 25, 2025
a62d104
format
TianlongLiang Feb 25, 2025
9e5ad76
Shared heap enhancements
TianlongLiang Feb 26, 2025
c5a33e0
Unit test and sample update for shared heap enhancement (#4070)
TianlongLiang Feb 27, 2025
c7473d5
Merge remote-tracking branch 'upstream/main' into fix/merge_into_dev_…
lum1n0us Jun 11, 2025
1394b8a
Merge pull request #4356 from lum1n0us/fix/merge_into_dev_shared_heap…
lum1n0us Jun 17, 2025
ccdc836
Shared heap enhancement for AOT and update tests and samples (#4226)
TianlongLiang Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/iwasm/aot/aot_reloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ typedef struct {
#define REG_STRINGREF_SYM()
#endif

#if WASM_ENABLE_SHARED_HEAP != 0
#define REG_SHARED_HEAP_SYM() \
REG_SYM(wasm_runtime_update_last_used_shared_heap),
#else
#define REG_SHARED_HEAP_SYM()
#endif

#define REG_COMMON_SYMBOLS \
REG_SYM(aot_set_exception_with_id), \
REG_SYM(aot_invoke_native), \
Expand Down Expand Up @@ -218,6 +225,7 @@ typedef struct {
REG_LLVM_PGO_SYM() \
REG_GC_SYM() \
REG_STRINGREF_SYM() \
REG_SHARED_HEAP_SYM() \

#define CHECK_RELOC_OFFSET(data_size) do { \
if (!check_reloc_offset(target_section_size, \
Expand Down
12 changes: 12 additions & 0 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ bh_static_assert(offsetof(AOTModuleInstanceExtra, stack_sizes) == 0);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_base_addr_adj)
== 8);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_start_off) == 16);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_end_off) == 24);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap) == 32);

bh_static_assert(offsetof(WASMSharedHeap, next) == 0);
bh_static_assert(offsetof(WASMSharedHeap, chain_next) == 8);
bh_static_assert(offsetof(WASMSharedHeap, heap_handle) == 16);
bh_static_assert(offsetof(WASMSharedHeap, base_addr) == 24);
bh_static_assert(offsetof(WASMSharedHeap, size) == 32);
bh_static_assert(offsetof(WASMSharedHeap, start_off_mem64) == 40);
bh_static_assert(offsetof(WASMSharedHeap, start_off_mem32) == 48);

bh_static_assert(sizeof(CApiFuncImport) == sizeof(uintptr_t) * 3);

Expand Down Expand Up @@ -1989,6 +1999,8 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
#else
extra->shared_heap_start_off.u32[0] = UINT32_MAX;
#endif
/* After shared heap chain, will early stop if shared heap is NULL */
extra->shared_heap = NULL;

#if WASM_ENABLE_PERF_PROFILING != 0
total_size = sizeof(AOTFuncPerfProfInfo)
Expand Down
5 changes: 2 additions & 3 deletions core/iwasm/aot/aot_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ typedef struct AOTModuleInstanceExtra {
*/
DefPointer(uint8 *, shared_heap_base_addr_adj);
MemBound shared_heap_start_off;
MemBound shared_heap_end_off;
DefPointer(WASMSharedHeap *, shared_heap);

WASMModuleInstanceExtraCommon common;

Expand All @@ -142,9 +144,6 @@ typedef struct AOTModuleInstanceExtra {
WASMModuleInstanceCommon **import_func_module_insts;
#endif

#if WASM_ENABLE_SHARED_HEAP != 0
WASMSharedHeap *shared_heap;
#endif
} AOTModuleInstanceExtra;

#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
Expand Down
Loading
Loading