Skip to content

Commit a8d539d

Browse files
committed
Merge branch 'main' into dev/merge_aot_data_text
2 parents 9423fee + cb3a69f commit a8d539d

27 files changed

Lines changed: 1680 additions & 273 deletions

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ env:
6868
WAMR_COMPILER_TEST_OPTIONS: "-s wamr_compiler -S -b -P"
6969
GC_TEST_OPTIONS: "-s spec -G -b -P"
7070
MEMORY64_TEST_OPTIONS: "-s spec -W -b -P"
71+
MULTI_MEMORY_TEST_OPTIONS: "-s spec -E -b -P"
7172

7273
jobs:
7374
build_llvm_libraries_on_ubuntu_2204:
@@ -148,6 +149,7 @@ jobs:
148149
"-DWAMR_BUILD_TAIL_CALL=1",
149150
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
150151
"-DWAMR_BUILD_MEMORY64=1",
152+
"-DWAMR_BUILD_MULTI_MEMORY=1",
151153
]
152154
os: [ubuntu-22.04]
153155
platform: [android, linux]
@@ -206,11 +208,9 @@ jobs:
206208
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
207209
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
208210
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
209-
# Memory64 only on CLASSIC INTERP mode, and only on 64-bit platform
211+
# Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
210212
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
211213
platform: android
212-
- make_options_run_mode: $AOT_BUILD_OPTIONS
213-
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
214214
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
215215
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
216216
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
@@ -221,6 +221,21 @@ jobs:
221221
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
222222
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
223223
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
224+
# Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
225+
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
226+
platform: android
227+
- make_options_run_mode: $AOT_BUILD_OPTIONS
228+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
229+
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
230+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
231+
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
232+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
233+
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
234+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
235+
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
236+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
237+
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
238+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
224239
# Fast-JIT and Multi-Tier-JIT mode don't support android
225240
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
226241
platform: android
@@ -593,6 +608,7 @@ jobs:
593608
$WASI_TEST_OPTIONS,
594609
$GC_TEST_OPTIONS,
595610
$MEMORY64_TEST_OPTIONS,
611+
$MULTI_MEMORY_TEST_OPTIONS,
596612
]
597613
wasi_sdk_release:
598614
[
@@ -640,18 +656,30 @@ jobs:
640656
test_option: $MEMORY64_TEST_OPTIONS
641657
- running_mode: "multi-tier-jit"
642658
test_option: $MEMORY64_TEST_OPTIONS
659+
# aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory
660+
- running_mode: "aot"
661+
test_option: $MULTI_MEMORY_TEST_OPTIONS
662+
- running_mode: "fast-interp"
663+
test_option: $MULTI_MEMORY_TEST_OPTIONS
664+
- running_mode: "fast-jit"
665+
test_option: $MULTI_MEMORY_TEST_OPTIONS
666+
- running_mode: "jit"
667+
test_option: $MULTI_MEMORY_TEST_OPTIONS
668+
- running_mode: "multi-tier-jit"
669+
test_option: $MULTI_MEMORY_TEST_OPTIONS
670+
643671
steps:
644672
- name: checkout
645673
uses: actions/checkout@v4
646674

647675
- name: Set-up OCaml
648676
uses: ocaml/setup-ocaml@v3
649-
if: matrix.test_option == '$GC_TEST_OPTIONS' || matrix.test_option == '$MEMORY64_TEST_OPTIONS'
677+
if: matrix.test_option == '$GC_TEST_OPTIONS'
650678
with:
651679
ocaml-compiler: 4.13
652680

653681
- name: Set-up Ocamlbuild
654-
if: matrix.test_option == '$GC_TEST_OPTIONS' || matrix.test_option == '$MEMORY64_TEST_OPTIONS'
682+
if: matrix.test_option == '$GC_TEST_OPTIONS'
655683
run: opam install ocamlbuild dune menhir
656684

657685
- name: download and install wasi-sdk
@@ -717,13 +745,13 @@ jobs:
717745

718746
- name: run tests
719747
timeout-minutes: 30
720-
if: matrix.test_option != '$GC_TEST_OPTIONS' && matrix.test_option != '$MEMORY64_TEST_OPTIONS'
748+
if: matrix.test_option != '$GC_TEST_OPTIONS'
721749
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
722750
working-directory: ./tests/wamr-test-suites
723751

724-
- name: run gc or memory64 tests
752+
- name: run gc tests
725753
timeout-minutes: 20
726-
if: matrix.test_option == '$GC_TEST_OPTIONS' || matrix.test_option == '$MEMORY64_TEST_OPTIONS'
754+
if: matrix.test_option == '$GC_TEST_OPTIONS'
727755
run: |
728756
eval $(opam env)
729757
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}

.github/workflows/compilation_on_nuttx.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ jobs:
124124
repository: google/bloaty
125125
submodules: recursive
126126
path: bloaty
127+
ref: 34f4a66559ad4938c1e629e9b5f54630b2b4d7b0
127128

128129
- name: Build Bloaty
129130
run: |

.github/workflows/nightly_run.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ jobs:
132132
"-DWAMR_BUILD_TAIL_CALL=1",
133133
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
134134
"-DWAMR_BUILD_MEMORY64=1",
135+
"-DWAMR_BUILD_MULTI_MEMORY=1",
135136
]
136137
os: [ubuntu-20.04]
137138
platform: [android, linux]
@@ -190,11 +191,9 @@ jobs:
190191
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
191192
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
192193
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
193-
# Memory64 only on CLASSIC INTERP mode, and only on 64-bit platform
194+
# Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
194195
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
195196
platform: android
196-
- make_options_run_mode: $AOT_BUILD_OPTIONS
197-
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
198197
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
199198
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
200199
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
@@ -205,6 +204,21 @@ jobs:
205204
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
206205
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
207206
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
207+
# Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
208+
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
209+
platform: android
210+
- make_options_run_mode: $AOT_BUILD_OPTIONS
211+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
212+
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
213+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
214+
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
215+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
216+
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
217+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
218+
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
219+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
220+
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
221+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
208222
# Fast-JIT and Multi-Tier-JIT mode don't support android
209223
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
210224
platform: android
@@ -289,6 +303,7 @@ jobs:
289303
"-DWAMR_BUILD_TAIL_CALL=1",
290304
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
291305
"-DWAMR_BUILD_MEMORY64=1",
306+
"-DWAMR_BUILD_MULTI_MEMORY=1",
292307
]
293308
exclude:
294309
# incompatible feature and platform
@@ -322,6 +337,11 @@ jobs:
322337
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
323338
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
324339
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
340+
# Memory64 only on CLASSIC INTERP mode
341+
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
342+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
343+
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
344+
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
325345
steps:
326346
- name: Install dependencies
327347
run: |

build-scripts/config_common.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ if (WAMR_BUILD_MEMORY64 EQUAL 1)
265265
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
266266
message (" Memory64 memory enabled")
267267
endif ()
268+
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
269+
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
270+
message (" Multi memory enabled")
271+
set (WAMR_BUILD_DEBUG_INTERP 0)
272+
endif ()
268273
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
269274
message (" Thread manager enabled")
270275
endif ()

core/config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@
664664
#define WASM_ENABLE_MEMORY64 0
665665
#endif
666666

667+
/* Disable multi-memory by default */
668+
#ifndef WASM_ENABLE_MULTI_MEMORY
669+
#define WASM_ENABLE_MULTI_MEMORY 0
670+
#endif
671+
667672
#ifndef WASM_TABLE_MAX_SIZE
668673
#define WASM_TABLE_MAX_SIZE 1024
669674
#endif

core/iwasm/aot/aot_loader.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end,
579579
return false;
580580
}
581581

582+
/* for backwards compatibility with previous wamrc aot files */
583+
if (!strcmp(target_info.arch, "arm64"))
584+
bh_strcpy_s(target_info.arch, sizeof(target_info.arch), "aarch64v8");
585+
582586
/* Check machine info */
583587
if (!check_machine_info(&target_info, error_buf, error_buf_size)) {
584588
return false;

core/iwasm/aot/aot_runtime.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,6 +2817,13 @@ aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count)
28172817
return wasm_enlarge_memory(module_inst, inc_page_count);
28182818
}
28192819

2820+
bool
2821+
aot_enlarge_memory_with_idx(AOTModuleInstance *module_inst,
2822+
uint32 inc_page_count, uint32 memidx)
2823+
{
2824+
return wasm_enlarge_memory_with_idx(module_inst, inc_page_count, memidx);
2825+
}
2826+
28202827
bool
28212828
aot_invoke_native(WASMExecEnv *exec_env, uint32 func_idx, uint32 argc,
28222829
uint32 *argv)

core/iwasm/aot/aot_runtime.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ typedef enum AOTSectionType {
3939
AOT_SECTION_TYPE_FUNCTION = 3,
4040
AOT_SECTION_TYPE_EXPORT = 4,
4141
AOT_SECTION_TYPE_RELOCATION = 5,
42+
/*
43+
* Note: We haven't had anything to use AOT_SECTION_TYPE_SIGNATURE.
44+
* It's just reserved for possible module signing features.
45+
*/
4246
AOT_SECTION_TYPE_SIGNATURE = 6,
4347
AOT_SECTION_TYPE_CUSTOM = 100,
4448
} AOTSectionType;
@@ -612,6 +616,10 @@ aot_module_dup_data(AOTModuleInstance *module_inst, const char *src,
612616
bool
613617
aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count);
614618

619+
bool
620+
aot_enlarge_memory_with_idx(AOTModuleInstance *module_inst,
621+
uint32 inc_page_count, uint32 memidx);
622+
615623
/**
616624
* Invoke native function from aot code
617625
*/

core/iwasm/aot/arch/aot_reloc_aarch64.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ get_target_symbol_map(uint32 *sym_num)
5353
return target_sym_map;
5454
}
5555

56-
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__)
57-
#define BUILD_TARGET_AARCH64_DEFAULT "arm64"
58-
#else
59-
#define BUILD_TARGET_AARCH64_DEFAULT "aarch64v8"
60-
#endif
61-
6256
void
6357
get_current_target(char *target_buf, uint32 target_buf_size)
6458
{
@@ -68,8 +62,8 @@ get_current_target(char *target_buf, uint32 target_buf_size)
6862

6963
/* Set to "aarch64v8" by default if sub version isn't specified */
7064
if (strcmp(s, "AARCH64") == 0) {
71-
s = BUILD_TARGET_AARCH64_DEFAULT;
72-
s_size = sizeof(BUILD_TARGET_AARCH64_DEFAULT);
65+
s = "aarch64v8";
66+
s_size = 9; /* strlen("aarch64v8"); */
7367
}
7468
if (target_buf_size < s_size) {
7569
s_size = target_buf_size;
@@ -83,7 +77,6 @@ get_current_target(char *target_buf, uint32 target_buf_size)
8377
/* Ensure the string is null byte ('\0') terminated */
8478
*d = '\0';
8579
}
86-
#undef BUILD_TARGET_AARCH64_DEFAULT
8780

8881
static uint32
8982
get_plt_item_size()

core/iwasm/common/wasm_memory.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,16 @@ wasm_get_default_memory(WASMModuleInstance *module_inst)
670670
return NULL;
671671
}
672672

673+
WASMMemoryInstance *
674+
wasm_get_memory_with_idx(WASMModuleInstance *module_inst, uint32 index)
675+
{
676+
bh_assert(index < module_inst->memory_count);
677+
if (module_inst->memories)
678+
return module_inst->memories[index];
679+
else
680+
return NULL;
681+
}
682+
673683
void
674684
wasm_runtime_set_mem_bound_check_bytes(WASMMemoryInstance *memory,
675685
uint64 memory_data_size)
@@ -747,9 +757,14 @@ wasm_mmap_linear_memory(uint64_t map_size, uint64 commit_size)
747757
}
748758

749759
bool
750-
wasm_enlarge_memory_internal(WASMModuleInstance *module, uint32 inc_page_count)
760+
wasm_enlarge_memory_internal(WASMModuleInstance *module, uint32 inc_page_count,
761+
uint32 memidx)
751762
{
763+
#if WASM_ENABLE_MULTI_MEMORY != 0
764+
WASMMemoryInstance *memory = wasm_get_memory_with_idx(module, memidx);
765+
#else
752766
WASMMemoryInstance *memory = wasm_get_default_memory(module);
767+
#endif
753768
uint8 *memory_data_old, *memory_data_new, *heap_data_old;
754769
uint32 num_bytes_per_page, heap_size;
755770
uint32 cur_page_count, max_page_count, total_page_count;
@@ -960,7 +975,7 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count)
960975
if (module->memory_count > 0)
961976
shared_memory_lock(module->memories[0]);
962977
#endif
963-
ret = wasm_enlarge_memory_internal(module, inc_page_count);
978+
ret = wasm_enlarge_memory_internal(module, inc_page_count, 0);
964979
#if WASM_ENABLE_SHARED_MEMORY != 0
965980
if (module->memory_count > 0)
966981
shared_memory_unlock(module->memories[0]);
@@ -969,6 +984,25 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count)
969984
return ret;
970985
}
971986

987+
bool
988+
wasm_enlarge_memory_with_idx(WASMModuleInstance *module, uint32 inc_page_count,
989+
uint32 memidx)
990+
{
991+
bool ret = false;
992+
993+
#if WASM_ENABLE_SHARED_MEMORY != 0
994+
if (memidx < module->memory_count)
995+
shared_memory_lock(module->memories[memidx]);
996+
#endif
997+
ret = wasm_enlarge_memory_internal(module, inc_page_count, memidx);
998+
#if WASM_ENABLE_SHARED_MEMORY != 0
999+
if (memidx < module->memory_count)
1000+
shared_memory_unlock(module->memories[memidx]);
1001+
#endif
1002+
1003+
return ret;
1004+
}
1005+
9721006
void
9731007
wasm_deallocate_linear_memory(WASMMemoryInstance *memory_inst)
9741008
{

0 commit comments

Comments
 (0)