Skip to content

Commit 57f2661

Browse files
authored
Merge pull request #3631 from bytecodealliance/main
Merge branch main into dev/shared_heap
2 parents 84411c6 + 8af1550 commit 57f2661

24 files changed

Lines changed: 239 additions & 40 deletions

RELEASE_NOTES.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,74 @@
1+
## WAMR-2.1.1
2+
3+
### Breaking Changes
4+
- Sync up with latest wasi-nn spec (#3530)
5+
6+
### New Features
7+
- Add APIs to get package version (#3601)
8+
- Export API wasm_runtime_enlarge_memory (#3569)
9+
- Add table type API support (#3515)
10+
- Add wasm_runtime_get_module_package_type() and wasm_runtime_get_file_package_type() (#3600)
11+
12+
### Bug Fixes
13+
- wasm_application.c: Avoid null pointer dereference (#3620)
14+
- EH: Use the consistent type for EH handlers (#3619)
15+
- wasm loader: Fix several issues in GC and exception handling (#3586)
16+
- wasm loader: Fix push_frame_offset when pushing v128 type (#3588)
17+
- Add integer overflow check for some indices in wasm/aot loader (#3579)
18+
- aot-analyzer: Fix a few printf formats (#3590)
19+
- aot-analyzer: Fix macos build (#3589)
20+
- Fix compilation errors in aot-analyzer tool (#3584)
21+
- interp debugger: Fix setting invalid value to step_count (#3583)
22+
- aot loader: Check import global value type before using (#3571)
23+
- Fix missing stack frame alloc/free in AOT multi-module invoke (#3562)
24+
- aot loader: Verify global value type (#3560)
25+
- aot loader: Add more checks in load_native_symbol_section() (#3559)
26+
- core/shared/platform: Zero memory returned by os_mmap in some platforms (#3551)
27+
- dwarf_extractor.cpp: Fix buffer overruns (#3541)
28+
- aot loader: Prevent loading multiple native symbol sections (#3538)
29+
- Validate func type in aot loader (#3535)
30+
- wamrc: Fix truncated DW_AT_producer (#3537)
31+
- wasm loader: Fix pop invalid offset count when stack top is ANY (#3516)
32+
- Fix two fuzz issues (#3529)
33+
- Fix several issues reported by oss-fuzz (#3526)
34+
35+
### Enhancements
36+
- Fix compile warnings/error reported in Windows (#3616)
37+
- wasm loader: Reject v128 for interpreters (#3611)
38+
- Fix typos in wamrc and wasm_export.h (#3609)
39+
- Bump ocaml/setup-ocaml from 2 to 3 (#3604)
40+
- CMakeLists.txt: Fix Android pthread linkage (#3591)
41+
- Add more arm AOT reloc entries (#3587)
42+
- wasi-nn: Use numpy v1 in wasi-nn test requirements.txt (#3582)
43+
- Optimize for multi-module support in AOT mode (#3563)
44+
- aot compiler: Propagate const-ness by ourselves (#3567)
45+
- aot_resolve_target_info: Avoid in-place modification of e_type (#3564)
46+
- Allow missing imports in wasm loader and report error in wasm instantiation instead (#3539)
47+
- aot compiler: Use larger alignment for load/store when possible (#3552)
48+
- Consistent const keyword position in wasm_export.h (#3558)
49+
- wasm_memory.c: Fix typo: hasn't been initialize -> `hasn't been initialized` (#3547)
50+
- dwarf_extractor.cpp: Try to preserve link name (#3542)
51+
- dwarf_extractor.cpp: Enable limited support for C++ (#3540)
52+
- Sync up with latest wasi-nn spec (#3530)
53+
- Expose more functions related to emitting AOT files (#3520)
54+
- Make wasi-nn backends as separated shared libraries (#3509)
55+
- build_llvm.py: Speed up llvm build with multi procs on windows (#3512)
56+
- Fix compilation warnings of wasi-nn (#3497)
57+
- Add missing functions to make RIOT work with the 2.x.x version (#3508)
58+
59+
### Others
60+
- Update devcontainer.md (#3628)
61+
- Fix compile errors on workload bwa and benchmark jetstream (#3617)
62+
- wasm-mutator-fuzz: Set compilers earlier (#3585)
63+
- wasm-mutator-fuzz: Make compilers overridable (#3578)
64+
- wasi-nn: Add wasmedge-wasinn-example as smoke test (#3554)
65+
- Add standalone cases (#3536)
66+
- wasm-mutator-fuzz: Fix build errors and warnings for macOS (#3519)
67+
- wasm-mutator-fuzz: Use another variable to check if in oss-fuzz environment (#3518)
68+
- Add wasi-nn example as smoke test case (#3501)
69+
70+
---
71+
172
## WAMR-2.1.0
273

374
### Breaking Changes

core/iwasm/aot/aot_loader.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,6 +4168,8 @@ load(const uint8 *buf, uint32 size, AOTModule *module,
41684168
return false;
41694169
}
41704170

4171+
module->package_version = version;
4172+
41714173
if (!create_sections(module, buf, size, &section_list, error_buf,
41724174
error_buf_size))
41734175
return false;

core/iwasm/aot/aot_runtime.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
11391139

11401140
if (memory_inst->memory_data) {
11411141
bh_memcpy_s((uint8 *)memory_inst->memory_data + base_offset,
1142-
(uint32)memory_inst->memory_data_size - base_offset,
1142+
(uint32)(memory_inst->memory_data_size - base_offset),
11431143
data_seg->bytes, length);
11441144
}
11451145
}
@@ -1212,7 +1212,7 @@ aot_get_function_instance(AOTModuleInstance *module_inst, uint32 func_idx)
12121212
return NULL;
12131213
}
12141214

1215-
extra->function_count = func_count;
1215+
extra->function_count = (uint32)func_count;
12161216
}
12171217

12181218
/* instantiate function if needed */
@@ -1764,8 +1764,8 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
17641764
aot_get_data_section_addr(module, AOT_STACK_SIZES_SECTION_NAME, NULL);
17651765

17661766
#if WASM_ENABLE_PERF_PROFILING != 0
1767-
total_size = (uint64)sizeof(AOTFuncPerfProfInfo)
1768-
* (module->import_func_count + module->func_count);
1767+
total_size = sizeof(AOTFuncPerfProfInfo)
1768+
* ((uint64)module->import_func_count + module->func_count);
17691769
if (!(module_inst->func_perf_profilings =
17701770
runtime_malloc(total_size, error_buf, error_buf_size))) {
17711771
goto fail;
@@ -2536,7 +2536,7 @@ execute_malloc_function(AOTModuleInstance *module_inst, WASMExecEnv *exec_env,
25362536
if (ret) {
25372537
#if WASM_ENABLE_MEMORY64 != 0
25382538
if (is_memory64)
2539-
*p_result = GET_I64_FROM_ADDR(&argv.u64);
2539+
*p_result = argv.u64;
25402540
else
25412541
#endif
25422542
{

core/iwasm/aot/aot_runtime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ typedef struct LocalRefFlag {
130130
typedef struct AOTModule {
131131
uint32 module_type;
132132

133+
/* the package version read from the AOT file */
134+
uint32 package_version;
135+
133136
/* import memories */
134137
uint32 import_memory_count;
135138
AOTImportMemory *import_memories;

core/iwasm/common/wasm_application.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
513513
bh_memcpy_s(&u.val, sizeof(double), &ud.d,
514514
sizeof(double));
515515
}
516-
if (endptr[0] == ':') {
516+
if (endptr && endptr[0] == ':') {
517517
uint64 sig;
518518
union ieee754_double ud;
519519
sig = strtoull(endptr + 1, &endptr, 0);

core/iwasm/common/wasm_loader_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ bool
104104
is_valid_func_type(const WASMFuncType *func_type)
105105
{
106106
unsigned i;
107-
for (i = 0; i < func_type->param_count + func_type->result_count; i++) {
107+
for (i = 0;
108+
i < (unsigned)(func_type->param_count + func_type->result_count);
109+
i++) {
108110
if (!is_valid_value_type(func_type->types[i]))
109111
return false;
110112
}

core/iwasm/common/wasm_memory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,13 +930,13 @@ wasm_runtime_enlarge_memory(WASMModuleInstanceCommon *module_inst,
930930
#if WASM_ENABLE_AOT != 0
931931
if (module_inst->module_type == Wasm_Module_AoT) {
932932
return aot_enlarge_memory((AOTModuleInstance *)module_inst,
933-
inc_page_count);
933+
(uint32)inc_page_count);
934934
}
935935
#endif
936936
#if WASM_ENABLE_INTERP != 0
937937
if (module_inst->module_type == Wasm_Module_Bytecode) {
938938
return wasm_enlarge_memory((WASMModuleInstance *)module_inst,
939-
inc_page_count);
939+
(uint32)inc_page_count);
940940
}
941941
#endif
942942

core/iwasm/common/wasm_runtime_common.c

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,11 @@ wasm_runtime_set_default_running_mode(RunningMode running_mode)
858858
PackageType
859859
get_package_type(const uint8 *buf, uint32 size)
860860
{
861+
if (buf && size >= 4) {
861862
#if (WASM_ENABLE_WORD_ALIGN_READ != 0)
862-
uint32 buf32 = *(uint32 *)buf;
863-
buf = (const uint8 *)&buf32;
863+
uint32 buf32 = *(uint32 *)buf;
864+
buf = (const uint8 *)&buf32;
864865
#endif
865-
if (buf && size >= 4) {
866866
if (buf[0] == '\0' && buf[1] == 'a' && buf[2] == 's' && buf[3] == 'm')
867867
return Wasm_Module_Bytecode;
868868
if (buf[0] == '\0' && buf[1] == 'a' && buf[2] == 'o' && buf[3] == 't')
@@ -878,7 +878,7 @@ wasm_runtime_get_file_package_type(const uint8 *buf, uint32 size)
878878
}
879879

880880
PackageType
881-
wasm_runtime_get_module_package_type(WASMModuleCommon *module)
881+
wasm_runtime_get_module_package_type(WASMModuleCommon *const module)
882882
{
883883
if (!module) {
884884
return Package_Type_Unknown;
@@ -887,6 +887,62 @@ wasm_runtime_get_module_package_type(WASMModuleCommon *module)
887887
return module->module_type;
888888
}
889889

890+
uint32
891+
wasm_runtime_get_file_package_version(const uint8 *buf, uint32 size)
892+
{
893+
if (buf && size >= 8) {
894+
uint32 version;
895+
#if (WASM_ENABLE_WORD_ALIGN_READ != 0)
896+
uint32 buf32 = *(uint32 *)(buf + sizeof(uint32));
897+
buf = (const uint8 *)&buf32;
898+
version = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
899+
#else
900+
version = buf[4] | buf[5] << 8 | buf[6] << 16 | buf[7] << 24;
901+
#endif
902+
return version;
903+
}
904+
905+
return 0;
906+
}
907+
908+
uint32
909+
wasm_runtime_get_module_package_version(WASMModuleCommon *const module)
910+
{
911+
if (!module) {
912+
return 0;
913+
}
914+
915+
#if WASM_ENABLE_INTERP != 0
916+
if (module->module_type == Wasm_Module_Bytecode) {
917+
WASMModule *wasm_module = (WASMModule *)module;
918+
return wasm_module->package_version;
919+
}
920+
#endif
921+
922+
#if WASM_ENABLE_AOT != 0
923+
if (module->module_type == Wasm_Module_AoT) {
924+
AOTModule *aot_module = (AOTModule *)module;
925+
return aot_module->package_version;
926+
}
927+
#endif
928+
929+
return 0;
930+
}
931+
932+
uint32
933+
wasm_runtime_get_current_package_version(package_type_t package_type)
934+
{
935+
switch (package_type) {
936+
case Wasm_Module_Bytecode:
937+
return WASM_CURRENT_VERSION;
938+
case Wasm_Module_AoT:
939+
return AOT_CURRENT_VERSION;
940+
case Package_Type_Unknown:
941+
default:
942+
return 0;
943+
}
944+
}
945+
890946
#if WASM_ENABLE_AOT != 0
891947
static uint8 *
892948
align_ptr(const uint8 *p, uint32 b)

core/iwasm/compilation/aot_emit_memory.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ get_memory_check_bound(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
9191
return mem_check_bound;
9292
}
9393

94+
#if defined(_WIN32) || defined(_WIN32_)
95+
static inline int
96+
ffs(int n)
97+
{
98+
int pos = 0;
99+
100+
if (n == 0)
101+
return 0;
102+
103+
while (!(n & 1)) {
104+
pos++;
105+
n >>= 1;
106+
}
107+
return pos + 1;
108+
}
109+
#endif
110+
94111
static LLVMValueRef
95112
get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
96113

@@ -198,7 +215,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
198215
* has the natural alignment. for platforms using mmap, it can
199216
* be even larger. for now, use a conservative value.
200217
*/
201-
const int max_align = 8;
218+
const unsigned int max_align = 8;
202219
int shift = ffs((int)(unsigned int)mem_offset);
203220
if (shift == 0) {
204221
*alignp = max_align;

core/iwasm/compilation/aot_llvm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
749749
* and more importantly doesn't involve relocations.
750750
*/
751751
LLVMAttributeRef attr_short_call = LLVMCreateStringAttribute(
752-
comp_ctx->context, "short-call", strlen("short-call"), "", 0);
752+
comp_ctx->context, "short-call", (unsigned)strlen("short-call"),
753+
"", 0);
753754
LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex,
754755
attr_short_call);
755756
}
@@ -3529,7 +3530,7 @@ aot_block_destroy(AOTCompContext *comp_ctx, AOTBlock *block)
35293530

35303531
bool
35313532
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
3532-
uint32 offset, uint32 bytes)
3533+
uint64 offset, uint32 bytes)
35333534
{
35343535
AOTCheckedAddr *node = func_ctx->checked_addr_list;
35353536

@@ -3573,7 +3574,7 @@ aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx)
35733574

35743575
bool
35753576
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
3576-
uint32 offset, uint32 bytes)
3577+
uint64 offset, uint32 bytes)
35773578
{
35783579
AOTCheckedAddr *node = func_ctx->checked_addr_list;
35793580

0 commit comments

Comments
 (0)