From 68e4534822d1f1ccf353831e64853e221fd0bd77 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Fri, 17 Jan 2025 16:16:45 +0000 Subject: [PATCH 001/198] Iterate callstack API --- core/iwasm/aot/aot_runtime.c | 43 ++++++++++++++++++++ core/iwasm/aot/aot_runtime.h | 3 ++ core/iwasm/common/wasm_runtime_common.c | 28 +++++++++++++ core/iwasm/common/wasm_runtime_common.h | 3 ++ core/iwasm/include/wasm_export.h | 34 ++++++++++++++++ core/iwasm/interpreter/wasm_interp.h | 2 + core/iwasm/interpreter/wasm_interp_classic.c | 4 +- core/iwasm/interpreter/wasm_interp_fast.c | 5 ++- core/iwasm/interpreter/wasm_runtime.c | 30 ++++++++++++++ core/iwasm/interpreter/wasm_runtime.h | 4 ++ 10 files changed, 154 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 0f7b5d3d9..87f0775ec 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -10,6 +10,7 @@ #include "../common/wasm_runtime_common.h" #include "../common/wasm_memory.h" #include "../interpreter/wasm_runtime.h" +#include #if WASM_ENABLE_SHARED_MEMORY != 0 #include "../common/wasm_shared_memory.h" #endif @@ -4104,6 +4105,48 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */ #if WASM_ENABLE_DUMP_CALL_STACK != 0 +void +aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +{ +/* +* Note for devs: please refrain from such modifications inside of aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * For more details check wasm_iterate_callstack in wasm_export.h +*/ + if (!is_tiny_frame(exec_env)) { + //TODO: support standard frames + return; + } + uint8* top_boundary = exec_env->wasm_stack.top_boundary; + uint8* top = exec_env->wasm_stack.top; + uint8* bottom = exec_env->wasm_stack.bottom; + + bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); + if (!is_top_index_in_range) { + return; + } + bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; + if (!is_top_aligned_with_bottom) { + return; + } + + AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame)); + WASMCApiFrame record_frame; + while (frame && + (uint8_t*)frame >= bottom) { + record_frame.instance = exec_env->module_inst; + record_frame.module_offset = 0; + record_frame.func_index = frame->func_index; + record_frame.func_offset = frame->ip_offset; + if (!frame_handler(user_data, &record_frame)) { + break; + } + frame -= 1; + } +} + bool aot_create_call_stack(struct WASMExecEnv *exec_env) { diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index 297b2a5b5..5405772c9 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -777,6 +777,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame); bool aot_create_call_stack(struct WASMExecEnv *exec_env); +void +aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data); + /** * @brief Dump wasm call stack or get the size * diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 5517fe60f..b631a9e11 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -7,6 +7,7 @@ #include "bh_common.h" #include "bh_assert.h" #include "bh_log.h" +#include "wasm_export.h" #include "wasm_native.h" #include "wasm_runtime_common.h" #include "wasm_memory.h" @@ -1740,6 +1741,33 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env) wasm_exec_env_destroy(exec_env); } +void +wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback frame_callback, void* user_data) +{ +/* +* Note for devs: please refrain from such modifications inside of wasm_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * For more details check wasm_iterate_callstack in wasm_export.h +*/ + #if WASM_ENABLE_DUMP_CALL_STACK + WASMModuleInstance* module_inst = (WASMModuleInstance *)get_module_inst(exec_env); + + #if WASM_ENABLE_INTERP != 0 + if (module_inst->module_type == Wasm_Module_Bytecode) { + wasm_interp_iterate_callstack(exec_env, frame_callback, user_data); + } + #endif + + #if WASM_ENABLE_AOT != 0 + if (module_inst->module_type == Wasm_Module_AoT) { + aot_iterate_callstack(exec_env, frame_callback, user_data); + } + #endif + #endif +} + bool wasm_runtime_init_thread_env(void) { diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 4c7dfed4f..6157c6431 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -652,6 +652,9 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); +WASM_RUNTIME_API_EXTERN void +wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback frame_handler, void* user_data); + /* See wasm_export.h for description */ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon * wasm_runtime_get_module_inst(WASMExecEnv *exec_env); diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index 273657246..cf75eeb6c 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -126,6 +126,9 @@ typedef WASMFunctionInstanceCommon *wasm_function_inst_t; struct WASMMemoryInstance; typedef struct WASMMemoryInstance *wasm_memory_inst_t; +struct wasm_frame_t; +typedef struct wasm_frame_t * wasm_frame_ptr_t; + /* WASM section */ typedef struct wasm_section_t { struct wasm_section_t *next; @@ -864,6 +867,37 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); + +typedef bool (*wasm_frame_callback)(void*, wasm_frame_ptr_t); + +/** + * @brief Iterate over callstack frames and execute callback on it. + * + * Caution: This is not a thread-safe function. Ensure the exec_env + * is suspended before calling it from another thread. + * + * Usage: In the callback to read frames fields use APIs + * for wasm_frame_t from wasm_c_api.h + * + * Note: The function is async-signal-safe if called with verified arguments. + * Meaning it's safe to call it from a signal handler even on a signal interruption + * from another thread if next variables hold valid pointers + * - exec_env + * - exec_env->module_inst + * - exec_env->module_inst->module + * + * Note for devs: please refrain from such modifications inside of this call + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * + * @param exec_env the execution environment that containes frames + * @param callback the callback function provided by the user + * @param user_data context for callback provided by the user + */ +WASM_RUNTIME_API_EXTERN void +wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback callback, void *user_data); + /** * Get the singleton execution environment for the instance. * diff --git a/core/iwasm/interpreter/wasm_interp.h b/core/iwasm/interpreter/wasm_interp.h index 141640546..a4e31766d 100644 --- a/core/iwasm/interpreter/wasm_interp.h +++ b/core/iwasm/interpreter/wasm_interp.h @@ -26,6 +26,8 @@ typedef struct WASMInterpFrame { /* Instruction pointer of the bytecode array. */ uint8 *ip; + uint32 func_index; + #if WASM_ENABLE_FAST_JIT != 0 uint8 *jitted_return_addr; #endif diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 834311f7e..2d4eb82d9 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1264,9 +1264,11 @@ wasm_interp_call_func_native(WASMModuleInstance *module_inst, init_frame_refs(frame_ref, local_cell_num, cur_func); #endif + cur_func_index = (uint32)(cur_func - module_inst->e->functions); + frame->func_index = cur_func_index; + wasm_exec_env_set_cur_frame(exec_env, frame); - cur_func_index = (uint32)(cur_func - module_inst->e->functions); bh_assert(cur_func_index < module_inst->module->import_function_count); if (!func_import->call_conv_wasm_c_api) { native_func_pointer = module_inst->import_func_ptrs[cur_func_index]; diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index f44644e45..f61b24f7c 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1205,9 +1205,11 @@ wasm_interp_call_func_native(WASMModuleInstance *module_inst, init_frame_refs(frame->frame_ref, local_cell_num, cur_func); #endif + cur_func_index = (uint32)(cur_func - module_inst->e->functions); + frame->func_index = cur_func_index; + wasm_exec_env_set_cur_frame(exec_env, frame); - cur_func_index = (uint32)(cur_func - module_inst->e->functions); bh_assert(cur_func_index < module_inst->module->import_function_count); if (!func_import->call_conv_wasm_c_api) { native_func_pointer = module_inst->import_func_ptrs[cur_func_index]; @@ -6032,6 +6034,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, /* Initialize the interpreter context. */ frame->function = cur_func; + frame->func_index = (uint32)(cur_func - module->e->functions); frame_ip = wasm_get_func_code(cur_func); frame_ip_end = wasm_get_func_code_end(cur_func); diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index c3f35916c..529e0a2fc 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -5,6 +5,7 @@ #include "wasm_runtime.h" #include "wasm.h" +#include "wasm_exec_env.h" #include "wasm_loader.h" #include "wasm_interp.h" #include "bh_common.h" @@ -4196,6 +4197,35 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, || (WASM_ENABLE_MEMORY_TRACING != 0) */ #if WASM_ENABLE_DUMP_CALL_STACK != 0 +uint32 +wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +{ +/* +* Note for devs: please refrain from such modifications inside of wasm_interp_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * For more details check wasm_iterate_callstack in wasm_export.h +*/ + WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); + WASMInterpFrame* cur_frame = wasm_exec_env_get_cur_frame(exec_env); + uint8* top_boundary = exec_env->wasm_stack.top_boundary; + uint8* bottom = exec_env->wasm_stack.bottom; + + WASMCApiFrame record_frame; + while (cur_frame && + (uint8_t*)cur_frame >= bottom && + (uint8_t*)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) { + record_frame.instance = module_inst; + record_frame.module_offset = 0; + record_frame.func_index = cur_frame->func_index; + if (!frame_handler(user_data, &record_frame)) { + break; + } + cur_frame = cur_frame->prev_frame; + } +} + bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env) { diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 00e9ad107..7322bb16c 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -730,6 +730,10 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) } #if WASM_ENABLE_DUMP_CALL_STACK != 0 + +uint32 +wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data); + bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env); From d0c6da10ff45953565709005125a8649e1ab34da Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:28:30 +0000 Subject: [PATCH 002/198] wamr bool type --- core/iwasm/aot/aot_runtime.c | 1 - 1 file changed, 1 deletion(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 87f0775ec..2d5f6fde7 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -10,7 +10,6 @@ #include "../common/wasm_runtime_common.h" #include "../common/wasm_memory.h" #include "../interpreter/wasm_runtime.h" -#include #if WASM_ENABLE_SHARED_MEMORY != 0 #include "../common/wasm_shared_memory.h" #endif From 1f4d3dd4d476f0b97c2a1a6de1f2941edc208286 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:31:02 +0000 Subject: [PATCH 003/198] clang-format --- core/iwasm/aot/aot_runtime.c | 40 +++++++++++--------- core/iwasm/aot/aot_runtime.h | 5 ++- core/iwasm/common/wasm_runtime_common.c | 37 ++++++++++-------- core/iwasm/common/wasm_runtime_common.h | 6 ++- core/iwasm/include/wasm_export.h | 23 ++++++------ core/iwasm/interpreter/wasm_runtime.c | 50 +++++++++++++------------ core/iwasm/interpreter/wasm_runtime.h | 6 ++- 7 files changed, 93 insertions(+), 74 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 2d5f6fde7..134cd9858 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4104,37 +4104,41 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */ #if WASM_ENABLE_DUMP_CALL_STACK != 0 -void -aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +void +aot_iterate_callstack(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, void *user_data) { -/* -* Note for devs: please refrain from such modifications inside of aot_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary - * For more details check wasm_iterate_callstack in wasm_export.h -*/ + /* + * Note for devs: please refrain from such modifications inside of + * aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_iterate_callstack in + * wasm_export.h + */ if (!is_tiny_frame(exec_env)) { - //TODO: support standard frames + // TODO: support standard frames return; } - uint8* top_boundary = exec_env->wasm_stack.top_boundary; - uint8* top = exec_env->wasm_stack.top; - uint8* bottom = exec_env->wasm_stack.bottom; + uint8 *top_boundary = exec_env->wasm_stack.top_boundary; + uint8 *top = exec_env->wasm_stack.top; + uint8 *bottom = exec_env->wasm_stack.bottom; - bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); + bool is_top_index_in_range = + top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); if (!is_top_index_in_range) { return; } - bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; + bool is_top_aligned_with_bottom = + (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; if (!is_top_aligned_with_bottom) { return; } - AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame)); + AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame)); WASMCApiFrame record_frame; - while (frame && - (uint8_t*)frame >= bottom) { + while (frame && (uint8_t *)frame >= bottom) { record_frame.instance = exec_env->module_inst; record_frame.module_offset = 0; record_frame.func_index = frame->func_index; diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index 5405772c9..7a26be3ea 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -777,8 +777,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame); bool aot_create_call_stack(struct WASMExecEnv *exec_env); -void -aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data); +void +aot_iterate_callstack(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, void *user_data); /** * @brief Dump wasm call stack or get the size diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index b631a9e11..acf6f5544 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1741,31 +1741,36 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env) wasm_exec_env_destroy(exec_env); } -void -wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback frame_callback, void* user_data) +void +wasm_iterate_callstack(const wasm_exec_env_t exec_env, + const wasm_frame_callback frame_callback, + void *user_data) { -/* -* Note for devs: please refrain from such modifications inside of wasm_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary - * For more details check wasm_iterate_callstack in wasm_export.h -*/ - #if WASM_ENABLE_DUMP_CALL_STACK - WASMModuleInstance* module_inst = (WASMModuleInstance *)get_module_inst(exec_env); + /* + * Note for devs: please refrain from such modifications inside of + * wasm_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_iterate_callstack in + * wasm_export.h + */ +#if WASM_ENABLE_DUMP_CALL_STACK + WASMModuleInstance *module_inst = + (WASMModuleInstance *)get_module_inst(exec_env); - #if WASM_ENABLE_INTERP != 0 +#if WASM_ENABLE_INTERP != 0 if (module_inst->module_type == Wasm_Module_Bytecode) { wasm_interp_iterate_callstack(exec_env, frame_callback, user_data); } - #endif +#endif - #if WASM_ENABLE_AOT != 0 +#if WASM_ENABLE_AOT != 0 if (module_inst->module_type == Wasm_Module_AoT) { aot_iterate_callstack(exec_env, frame_callback, user_data); } - #endif - #endif +#endif +#endif } bool diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 6157c6431..1650615ef 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -652,8 +652,10 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); -WASM_RUNTIME_API_EXTERN void -wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback frame_handler, void* user_data); +WASM_RUNTIME_API_EXTERN void +wasm_iterate_callstack(const wasm_exec_env_t exec_env, + const wasm_frame_callback frame_handler, + void *user_data); /* See wasm_export.h for description */ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon * diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index cf75eeb6c..ca6020c3a 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -127,7 +127,7 @@ struct WASMMemoryInstance; typedef struct WASMMemoryInstance *wasm_memory_inst_t; struct wasm_frame_t; -typedef struct wasm_frame_t * wasm_frame_ptr_t; +typedef struct wasm_frame_t *wasm_frame_ptr_t; /* WASM section */ typedef struct wasm_section_t { @@ -867,21 +867,20 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); - -typedef bool (*wasm_frame_callback)(void*, wasm_frame_ptr_t); +typedef bool (*wasm_frame_callback)(void *, wasm_frame_ptr_t); /** * @brief Iterate over callstack frames and execute callback on it. * - * Caution: This is not a thread-safe function. Ensure the exec_env + * Caution: This is not a thread-safe function. Ensure the exec_env * is suspended before calling it from another thread. * - * Usage: In the callback to read frames fields use APIs + * Usage: In the callback to read frames fields use APIs * for wasm_frame_t from wasm_c_api.h * - * Note: The function is async-signal-safe if called with verified arguments. - * Meaning it's safe to call it from a signal handler even on a signal interruption - * from another thread if next variables hold valid pointers + * Note: The function is async-signal-safe if called with verified arguments. + * Meaning it's safe to call it from a signal handler even on a signal + * interruption from another thread if next variables hold valid pointers * - exec_env * - exec_env->module_inst * - exec_env->module_inst->module @@ -889,14 +888,16 @@ typedef bool (*wasm_frame_callback)(void*, wasm_frame_ptr_t); * Note for devs: please refrain from such modifications inside of this call * - any allocations/freeing memory * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary * * @param exec_env the execution environment that containes frames * @param callback the callback function provided by the user * @param user_data context for callback provided by the user */ -WASM_RUNTIME_API_EXTERN void -wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback callback, void *user_data); +WASM_RUNTIME_API_EXTERN void +wasm_iterate_callstack(const wasm_exec_env_t exec_env, + const wasm_frame_callback callback, void *user_data); /** * Get the singleton execution environment for the instance. diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 529e0a2fc..90fed59ba 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4197,32 +4197,36 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, || (WASM_ENABLE_MEMORY_TRACING != 0) */ #if WASM_ENABLE_DUMP_CALL_STACK != 0 -uint32 -wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +uint32 +wasm_interp_iterate_callstack(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, + void *user_data) { -/* -* Note for devs: please refrain from such modifications inside of wasm_interp_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary - * For more details check wasm_iterate_callstack in wasm_export.h -*/ - WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); - WASMInterpFrame* cur_frame = wasm_exec_env_get_cur_frame(exec_env); - uint8* top_boundary = exec_env->wasm_stack.top_boundary; - uint8* bottom = exec_env->wasm_stack.bottom; + /* + * Note for devs: please refrain from such modifications inside of + * wasm_interp_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_iterate_callstack in + * wasm_export.h + */ + WASMModuleInstance *module_inst = + (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); + WASMInterpFrame *cur_frame = wasm_exec_env_get_cur_frame(exec_env); + uint8 *top_boundary = exec_env->wasm_stack.top_boundary; + uint8 *bottom = exec_env->wasm_stack.bottom; WASMCApiFrame record_frame; - while (cur_frame && - (uint8_t*)cur_frame >= bottom && - (uint8_t*)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) { - record_frame.instance = module_inst; - record_frame.module_offset = 0; - record_frame.func_index = cur_frame->func_index; - if (!frame_handler(user_data, &record_frame)) { - break; - } - cur_frame = cur_frame->prev_frame; + while (cur_frame && (uint8_t *)cur_frame >= bottom + && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) { + record_frame.instance = module_inst; + record_frame.module_offset = 0; + record_frame.func_index = cur_frame->func_index; + if (!frame_handler(user_data, &record_frame)) { + break; + } + cur_frame = cur_frame->prev_frame; } } diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 7322bb16c..d67461e91 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -731,8 +731,10 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) #if WASM_ENABLE_DUMP_CALL_STACK != 0 -uint32 -wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data); +uint32 +wasm_interp_iterate_callstack(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, + void *user_data); bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env); From 1b82cccff3045cec5c576ff182ffb33b531eeab0 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:35:56 +0000 Subject: [PATCH 004/198] meaning of the return bool type in the callback --- core/iwasm/include/wasm_export.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index ca6020c3a..68e3d509a 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -867,6 +867,13 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); + +/** + * Callback to be called on wasm_frame_t*. + * It accepts void* as a context that can be used for closures. + * It returns bool so the iterating can stop when the callback returns false. + * E.g. callback that returns false after processing 100 frames + */ typedef bool (*wasm_frame_callback)(void *, wasm_frame_ptr_t); /** From 813831de0e8e76c7fe03d35b45f674248e0084c5 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:39:53 +0000 Subject: [PATCH 005/198] keep devs notes out of public API --- core/iwasm/common/wasm_runtime_common.c | 2 +- core/iwasm/include/wasm_export.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index acf6f5544..9aa4101ef 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1748,7 +1748,7 @@ wasm_iterate_callstack(const wasm_exec_env_t exec_env, { /* * Note for devs: please refrain from such modifications inside of - * wasm_iterate_callstack + * wasm_iterate_callstack to preserve async-signal-safety * - any allocations/freeing memory * - dereferencing any pointers other than: exec_env, exec_env->module_inst, * exec_env->module_inst->module, pointers between stack's bottom and diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index 68e3d509a..430555ca8 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -892,12 +892,6 @@ typedef bool (*wasm_frame_callback)(void *, wasm_frame_ptr_t); * - exec_env->module_inst * - exec_env->module_inst->module * - * Note for devs: please refrain from such modifications inside of this call - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and - * top_boundary - * * @param exec_env the execution environment that containes frames * @param callback the callback function provided by the user * @param user_data context for callback provided by the user From bf6b15521abf46af6bc776db543e994d09d9946a Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 11:42:12 +0000 Subject: [PATCH 006/198] format --- core/iwasm/include/wasm_export.h | 1 - 1 file changed, 1 deletion(-) diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index 430555ca8..aba7fd4ec 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -867,7 +867,6 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); - /** * Callback to be called on wasm_frame_t*. * It accepts void* as a context that can be used for closures. From c8b87318314ff71165e9efffec9d86a3a1e073c9 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 15:08:03 +0000 Subject: [PATCH 007/198] support standard frames as well --- core/iwasm/aot/aot_runtime.c | 87 ++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 134cd9858..e137e59ca 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4105,40 +4105,32 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #if WASM_ENABLE_DUMP_CALL_STACK != 0 void -aot_iterate_callstack(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, void *user_data) +aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) { - /* - * Note for devs: please refrain from such modifications inside of - * aot_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and - * top_boundary For more details check wasm_iterate_callstack in - * wasm_export.h - */ - if (!is_tiny_frame(exec_env)) { - // TODO: support standard frames - return; - } - uint8 *top_boundary = exec_env->wasm_stack.top_boundary; - uint8 *top = exec_env->wasm_stack.top; - uint8 *bottom = exec_env->wasm_stack.bottom; +/* + * Note for devs: please refrain from such modifications inside of aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * For more details check wasm_iterate_callstack in wasm_export.h +*/ + uint8* top_boundary = exec_env->wasm_stack.top_boundary; + uint8* top = exec_env->wasm_stack.top; + uint8* bottom = exec_env->wasm_stack.bottom; - bool is_top_index_in_range = - top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); + bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); if (!is_top_index_in_range) { return; } - bool is_top_aligned_with_bottom = - (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; + bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; if (!is_top_aligned_with_bottom) { return; } - AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame)); + AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame)); WASMCApiFrame record_frame; - while (frame && (uint8_t *)frame >= bottom) { + while (frame && + (uint8_t*)frame >= bottom) { record_frame.instance = exec_env->module_inst; record_frame.module_offset = 0; record_frame.func_index = frame->func_index; @@ -4150,6 +4142,53 @@ aot_iterate_callstack(WASMExecEnv *exec_env, } } +void +aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +{ +/* + * Note for devs: please refrain from such modifications inside of aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * For more details check wasm_iterate_callstack in wasm_export.h +*/ + WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); + AOTFrame* cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env); + uint8* top_boundary = exec_env->wasm_stack.top_boundary; + uint8* bottom = exec_env->wasm_stack.bottom; + + WASMCApiFrame record_frame; + while (cur_frame && + (uint8_t*)cur_frame >= bottom && + (uint8_t*)cur_frame + sizeof(AOTFrame) <= top_boundary) { + record_frame.instance = module_inst; + record_frame.module_offset = 0; + record_frame.func_index = (uint32)cur_frame->func_index; + record_frame.func_offset = (uint32)cur_frame->ip_offset; + if (!frame_handler(user_data, &record_frame)) { + break; + } + cur_frame = cur_frame->prev_frame; + } +} + +void +aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +{ +/* +* Note for devs: please refrain from such modifications inside of aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and top_boundary + * For more details check wasm_iterate_callstack in wasm_export.h +*/ + if (!is_tiny_frame(exec_env)) { + aot_iterate_callstack_standard_frame(exec_env, frame_handler, user_data); + } else { + aot_iterate_callstack_tiny_frame(exec_env, frame_handler, user_data); + } +} + bool aot_create_call_stack(struct WASMExecEnv *exec_env) { From 9ff80523291f7257d43fb2bdb5647c63403009b1 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 27 Jan 2025 15:08:58 +0000 Subject: [PATCH 008/198] format --- core/iwasm/aot/aot_runtime.c | 112 ++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index e137e59ca..408d6b5c8 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4105,32 +4105,37 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #if WASM_ENABLE_DUMP_CALL_STACK != 0 void -aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, + void *user_data) { -/* - * Note for devs: please refrain from such modifications inside of aot_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary - * For more details check wasm_iterate_callstack in wasm_export.h -*/ - uint8* top_boundary = exec_env->wasm_stack.top_boundary; - uint8* top = exec_env->wasm_stack.top; - uint8* bottom = exec_env->wasm_stack.bottom; + /* + * Note for devs: please refrain from such modifications inside of + * aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_iterate_callstack in + * wasm_export.h + */ + uint8 *top_boundary = exec_env->wasm_stack.top_boundary; + uint8 *top = exec_env->wasm_stack.top; + uint8 *bottom = exec_env->wasm_stack.bottom; - bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); + bool is_top_index_in_range = + top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); if (!is_top_index_in_range) { return; } - bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; + bool is_top_aligned_with_bottom = + (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; if (!is_top_aligned_with_bottom) { return; } - AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame)); + AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame)); WASMCApiFrame record_frame; - while (frame && - (uint8_t*)frame >= bottom) { + while (frame && (uint8_t *)frame >= bottom) { record_frame.instance = exec_env->module_inst; record_frame.module_offset = 0; record_frame.func_index = frame->func_index; @@ -4143,48 +4148,57 @@ aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, const wasm_frame_callbac } void -aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, + void *user_data) { -/* - * Note for devs: please refrain from such modifications inside of aot_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary - * For more details check wasm_iterate_callstack in wasm_export.h -*/ - WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); - AOTFrame* cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env); - uint8* top_boundary = exec_env->wasm_stack.top_boundary; - uint8* bottom = exec_env->wasm_stack.bottom; + /* + * Note for devs: please refrain from such modifications inside of + * aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_iterate_callstack in + * wasm_export.h + */ + WASMModuleInstance *module_inst = + (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); + AOTFrame *cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env); + uint8 *top_boundary = exec_env->wasm_stack.top_boundary; + uint8 *bottom = exec_env->wasm_stack.bottom; WASMCApiFrame record_frame; - while (cur_frame && - (uint8_t*)cur_frame >= bottom && - (uint8_t*)cur_frame + sizeof(AOTFrame) <= top_boundary) { - record_frame.instance = module_inst; - record_frame.module_offset = 0; - record_frame.func_index = (uint32)cur_frame->func_index; - record_frame.func_offset = (uint32)cur_frame->ip_offset; - if (!frame_handler(user_data, &record_frame)) { - break; - } - cur_frame = cur_frame->prev_frame; + while (cur_frame && (uint8_t *)cur_frame >= bottom + && (uint8_t *)cur_frame + sizeof(AOTFrame) <= top_boundary) { + record_frame.instance = module_inst; + record_frame.module_offset = 0; + record_frame.func_index = (uint32)cur_frame->func_index; + record_frame.func_offset = (uint32)cur_frame->ip_offset; + if (!frame_handler(user_data, &record_frame)) { + break; + } + cur_frame = cur_frame->prev_frame; } } void -aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data) +aot_iterate_callstack(WASMExecEnv *exec_env, + const wasm_frame_callback frame_handler, void *user_data) { -/* -* Note for devs: please refrain from such modifications inside of aot_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and top_boundary - * For more details check wasm_iterate_callstack in wasm_export.h -*/ + /* + * Note for devs: please refrain from such modifications inside of + * aot_iterate_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_iterate_callstack in + * wasm_export.h + */ if (!is_tiny_frame(exec_env)) { - aot_iterate_callstack_standard_frame(exec_env, frame_handler, user_data); - } else { + aot_iterate_callstack_standard_frame(exec_env, frame_handler, + user_data); + } + else { aot_iterate_callstack_tiny_frame(exec_env, frame_handler, user_data); } } From 6bfc08849a8bc8c2031442aef625e12b863a5bf5 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 11:09:32 +0000 Subject: [PATCH 009/198] Calculate func_index instead of adding an extra field to wasm frame --- core/iwasm/interpreter/wasm_interp.h | 2 -- core/iwasm/interpreter/wasm_interp_classic.c | 4 +--- core/iwasm/interpreter/wasm_interp_fast.c | 5 +---- core/iwasm/interpreter/wasm_runtime.c | 3 ++- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp.h b/core/iwasm/interpreter/wasm_interp.h index a4e31766d..141640546 100644 --- a/core/iwasm/interpreter/wasm_interp.h +++ b/core/iwasm/interpreter/wasm_interp.h @@ -26,8 +26,6 @@ typedef struct WASMInterpFrame { /* Instruction pointer of the bytecode array. */ uint8 *ip; - uint32 func_index; - #if WASM_ENABLE_FAST_JIT != 0 uint8 *jitted_return_addr; #endif diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 2d4eb82d9..834311f7e 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1264,11 +1264,9 @@ wasm_interp_call_func_native(WASMModuleInstance *module_inst, init_frame_refs(frame_ref, local_cell_num, cur_func); #endif - cur_func_index = (uint32)(cur_func - module_inst->e->functions); - frame->func_index = cur_func_index; - wasm_exec_env_set_cur_frame(exec_env, frame); + cur_func_index = (uint32)(cur_func - module_inst->e->functions); bh_assert(cur_func_index < module_inst->module->import_function_count); if (!func_import->call_conv_wasm_c_api) { native_func_pointer = module_inst->import_func_ptrs[cur_func_index]; diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index f61b24f7c..f44644e45 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1205,11 +1205,9 @@ wasm_interp_call_func_native(WASMModuleInstance *module_inst, init_frame_refs(frame->frame_ref, local_cell_num, cur_func); #endif - cur_func_index = (uint32)(cur_func - module_inst->e->functions); - frame->func_index = cur_func_index; - wasm_exec_env_set_cur_frame(exec_env, frame); + cur_func_index = (uint32)(cur_func - module_inst->e->functions); bh_assert(cur_func_index < module_inst->module->import_function_count); if (!func_import->call_conv_wasm_c_api) { native_func_pointer = module_inst->import_func_ptrs[cur_func_index]; @@ -6034,7 +6032,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, /* Initialize the interpreter context. */ frame->function = cur_func; - frame->func_index = (uint32)(cur_func - module->e->functions); frame_ip = wasm_get_func_code(cur_func); frame_ip_end = wasm_get_func_code_end(cur_func); diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 90fed59ba..4ac882bff 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4222,7 +4222,8 @@ wasm_interp_iterate_callstack(WASMExecEnv *exec_env, && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) { record_frame.instance = module_inst; record_frame.module_offset = 0; - record_frame.func_index = cur_frame->func_index; + // It's safe to dereference module_inst->e because "e" is asigned only once in wasm_instantiate + record_frame.func_index = (uint32)(cur_frame->function - module_inst->e->functions); if (!frame_handler(user_data, &record_frame)) { break; } From b6daacb8363a86b9b1dfb5b2902ad6c78f8a22c0 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 11:25:45 +0000 Subject: [PATCH 010/198] ignore frames with no function --- core/iwasm/interpreter/wasm_runtime.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 4ac882bff..6ab5d756b 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4220,10 +4220,16 @@ wasm_interp_iterate_callstack(WASMExecEnv *exec_env, WASMCApiFrame record_frame; while (cur_frame && (uint8_t *)cur_frame >= bottom && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) { + if (!cur_frame->function) { + cur_frame = cur_frame->prev_frame; + continue; + } record_frame.instance = module_inst; record_frame.module_offset = 0; - // It's safe to dereference module_inst->e because "e" is asigned only once in wasm_instantiate - record_frame.func_index = (uint32)(cur_frame->function - module_inst->e->functions); + // It's safe to dereference module_inst->e because "e" is asigned only + // once in wasm_instantiate + record_frame.func_index = + (uint32)(cur_frame->function - module_inst->e->functions); if (!frame_handler(user_data, &record_frame)) { break; } From 5bfbfd5f581050732f65d3a44283a66e47422ca4 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 11:36:59 +0000 Subject: [PATCH 011/198] update typo in the comment --- core/iwasm/aot/aot_runtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 408d6b5c8..df956549a 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4111,7 +4111,7 @@ aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, { /* * Note for devs: please refrain from such modifications inside of - * aot_iterate_callstack + * aot_iterate_callstack_tiny_frame * - any allocations/freeing memory * - dereferencing any pointers other than: exec_env, exec_env->module_inst, * exec_env->module_inst->module, pointers between stack's bottom and @@ -4154,7 +4154,7 @@ aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, { /* * Note for devs: please refrain from such modifications inside of - * aot_iterate_callstack + * aot_iterate_callstack_standard_frame * - any allocations/freeing memory * - dereferencing any pointers other than: exec_env, exec_env->module_inst, * exec_env->module_inst->module, pointers between stack's bottom and From 478b373cdaf776fe2499e2995b032713748a11ca Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 13:27:01 +0000 Subject: [PATCH 012/198] update signature --- core/iwasm/interpreter/wasm_runtime.c | 2 +- core/iwasm/interpreter/wasm_runtime.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 6ab5d756b..e0f55353d 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4197,7 +4197,7 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, || (WASM_ENABLE_MEMORY_TRACING != 0) */ #if WASM_ENABLE_DUMP_CALL_STACK != 0 -uint32 +void wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void *user_data) diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index d67461e91..1b439bac1 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -731,7 +731,7 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) #if WASM_ENABLE_DUMP_CALL_STACK != 0 -uint32 +void wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void *user_data); From fb6c05e3494d58c42ed258aaeb3947f104977b6c Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 16:14:01 +0000 Subject: [PATCH 013/198] add correct frame size for aot standard frames --- core/iwasm/aot/aot_runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index df956549a..ee483fa5b 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4166,10 +4166,11 @@ aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, AOTFrame *cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env); uint8 *top_boundary = exec_env->wasm_stack.top_boundary; uint8 *bottom = exec_env->wasm_stack.bottom; + uint32 frame_size = (uint32)offsetof(AOTFrame, lp); WASMCApiFrame record_frame; while (cur_frame && (uint8_t *)cur_frame >= bottom - && (uint8_t *)cur_frame + sizeof(AOTFrame) <= top_boundary) { + && (uint8_t *)cur_frame + frame_size <= top_boundary) { record_frame.instance = module_inst; record_frame.module_offset = 0; record_frame.func_index = (uint32)cur_frame->func_index; From f7204bddfb364dd1b595e5bb5f55fdc9e907127f Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 28 Jan 2025 16:33:52 +0000 Subject: [PATCH 014/198] standard frame is not supported when GC is enabled --- core/iwasm/aot/aot_runtime.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index ee483fa5b..028bfe89f 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4161,6 +4161,7 @@ aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, * top_boundary For more details check wasm_iterate_callstack in * wasm_export.h */ +#if WASM_ENABLE_GC == 0 WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); AOTFrame *cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env); @@ -4180,6 +4181,12 @@ aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, } cur_frame = cur_frame->prev_frame; } +#else +/* + * TODO: add support for standard frames when GC is enabled + * now it poses a risk due to variable size of the frame + */ +#endif } void From b2c7cb23758adc19f6c69f53c6ee3594f72927ca Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Wed, 5 Feb 2025 03:31:49 +0000 Subject: [PATCH 015/198] Use wasm32-wasip1 instead of wasm32-wasi target for rust code (#4057) Rust compiler previously deprecated, and now removed the wasm32-wasi target and replaced it with wasm32-wasip1. This change updates all the occurrences of wasm32-wasi in the context of Rust compilation. covers the wasi-nn/test. --- .../compilation_on_android_ubuntu.yml | 2 +- .../wasi-nn/test/Dockerfile.wasi-nn-smoke | 18 +++++++++--------- .../libraries/wasi-nn/test/run_smoke_test.py | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index b08498cc0..11a512448 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -675,7 +675,7 @@ jobs: test_option: $MEMORY64_TEST_OPTIONS - running_mode: "multi-tier-jit" test_option: $MEMORY64_TEST_OPTIONS - # aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory + # aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory - running_mode: "aot" test_option: $MULTI_MEMORY_TEST_OPTIONS - running_mode: "fast-interp" diff --git a/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke b/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke index fe3a8c512..fdbe971d2 100644 --- a/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke +++ b/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke @@ -13,7 +13,7 @@ RUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y --no-install-recommends cmake -RUN rustup target add wasm32-wasi +RUN rustup target add wasm32-wasip1 # # Openvino @@ -37,10 +37,10 @@ WORKDIR /workspaces/wasi-nn RUN git clone --depth 1 https://github.com/bytecodealliance/wasi-nn.git . WORKDIR /workspaces/wasi-nn/rust/examples/classification-example/ -RUN cargo build --target=wasm32-wasi +RUN cargo build --target=wasm32-wasip1 WORKDIR /workspaces/wasi-nn/rust/examples/classification-example/build -RUN cp ../target/wasm32-wasi/debug/wasi-nn-example.wasm . \ +RUN cp ../target/wasm32-wasip1/debug/wasi-nn-example.wasm . \ && wget -q --no-clobber https://github.com/intel/openvino-rs/raw/main/crates/openvino/tests/fixtures/mobilenet/mobilenet.xml \ && wget -q --no-clobber https://github.com/intel/openvino-rs/raw/main/crates/openvino/tests/fixtures/mobilenet/mobilenet.bin # There are model files(mobilenet*) and wasm files(wasi-nn-example.wasm) in the directory, @@ -67,30 +67,30 @@ RUN git apply ./bump_wasi_nn_to_0_6_0.patch # recompile with wasi-nn 0.6.0 WORKDIR /workspaces/wasmedge-wasinn-examples/openvino-mobilenet-image/ RUN pushd rust \ - && cargo build --target=wasm32-wasi \ + && cargo build --target=wasm32-wasip1 \ && popd \ && ./download_mobilenet.sh . \ && ls -l mobilenet.xml mobilenet.bin WORKDIR /workspaces/wasmedge-wasinn-examples/openvino-mobilenet-raw/ RUN pushd rust \ - && cargo build --target=wasm32-wasi \ + && cargo build --target=wasm32-wasip1 \ && popd \ && ./download_mobilenet.sh . \ && ls -l mobilenet.xml mobilenet.bin tensor-1x224x224x3-f32.bgr WORKDIR /workspaces/wasmedge-wasinn-examples/openvino-road-segmentation-adas/ RUN pushd openvino-road-seg-adas \ - && cargo build --target=wasm32-wasi + && cargo build --target=wasm32-wasip1 WORKDIR /workspaces/wasmedge-wasinn-examples/tflite-birds_v1-image/ RUN pushd rust \ - && cargo build --target=wasm32-wasi + && cargo build --target=wasm32-wasip1 # mount models when running WORKDIR /workspaces/wasmedge-wasinn-examples/wasmedge-ggml/qwen RUN wget --progress=dot:giga https://www.modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat-GGUF/resolve/master/qwen1_5-0_5b-chat-q2_k.gguf -RUN cargo build --target=wasm32-wasi +RUN cargo build --target=wasm32-wasip1 # # iwasm. build from source @@ -107,7 +107,7 @@ RUN OpenVINO_DIR=/usr/lib/openvino-2023.2.0 \ -DWAMR_BUILD_WASI_NN_LLAMACPP=1 \ && cmake --build build \ && cmake --install build - + ENV LD_LIBRARY_PATH=/usr/local/lib # add smoke test script diff --git a/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py b/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py index 304b0c977..00e126d88 100644 --- a/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py +++ b/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py @@ -53,7 +53,7 @@ def execute_openvino_road_segmentation_adas_once( """ wasm_file = ( - "./openvino-road-seg-adas/target/wasm32-wasi/debug/openvino-road-seg-adas.wasm" + "./openvino-road-seg-adas/target/wasm32-wasip1/debug/openvino-road-seg-adas.wasm" ) wasm_args = [ "./model/road-segmentation-adas-0001.xml", @@ -70,7 +70,7 @@ def execute_openvino_mobilenet_raw_once( execute openvino-mobilenet-image with iwasm and wasmedge """ - wasm_file = "./rust/target/wasm32-wasi/debug/wasmedge-wasinn-example-mobilenet.wasm" + wasm_file = "./rust/target/wasm32-wasip1/debug/wasmedge-wasinn-example-mobilenet.wasm" wasm_args = [ "mobilenet.xml", "mobilenet.bin", @@ -87,7 +87,7 @@ def execute_openvino_mobilenet_image_once( """ wasm_file = ( - "./rust/target/wasm32-wasi/debug/wasmedge-wasinn-example-mobilenet-image.wasm" + "./rust/target/wasm32-wasip1/debug/wasmedge-wasinn-example-mobilenet-image.wasm" ) wasm_args = [ "mobilenet.xml", @@ -105,7 +105,7 @@ def execute_tflite_birds_v1_image_once( """ wasm_file = ( - "rust/target/wasm32-wasi/debug/wasmedge-wasinn-example-tflite-bird-image.wasm" + "rust/target/wasm32-wasip1/debug/wasmedge-wasinn-example-tflite-bird-image.wasm" ) wasm_args = ["lite-model_aiy_vision_classifier_birds_V1_3.tflite", "bird.jpg"] return execute_once(runtime_bin, runtime_args, wasm_file, wasm_args, cwd) @@ -262,7 +262,7 @@ def execute_openvino_road_segmentation_adas( def execute_wasmedge_ggml_qwen(iwasm_bin: str, wasmedge_bin: str, cwd: Path): iwasm_args = ["--dir=."] - wasm_file = ["./target/wasm32-wasi/debug/wasmedge-ggml-qwen.wasm"] + wasm_file = ["./target/wasm32-wasip1/debug/wasmedge-ggml-qwen.wasm"] wasm_args = ["./qwen1_5-0_5b-chat-q2_k.gguf"] cmd = [iwasm_bin] From c6712b4033fa119fe96013736eb6f174891701fd Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 5 Feb 2025 15:21:49 +0800 Subject: [PATCH 016/198] add a validator for aot module (#3995) - Add AOT module validation to ensure memory constraints are met - Enable AOT validator in build configuration and update related source files --- build-scripts/config_common.cmake | 4 +++ core/config.h | 4 +++ core/iwasm/aot/aot_loader.c | 13 ++++++--- core/iwasm/aot/aot_perf_map.c | 2 -- core/iwasm/aot/aot_validator.c | 45 +++++++++++++++++++++++++++++++ core/iwasm/aot/aot_validator.h | 15 +++++++++++ core/iwasm/aot/iwasm_aot.cmake | 14 +++++++++- wamr-compiler/CMakeLists.txt | 1 + 8 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 core/iwasm/aot/aot_validator.c create mode 100644 core/iwasm/aot/aot_validator.h diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 6a30bfb7b..6173e73b5 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -610,4 +610,8 @@ if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1) else () add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0) message (" Shrunk memory disabled") +endif() +if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1) + message (" AOT validator enabled") + add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1) endif () diff --git a/core/config.h b/core/config.h index 27d26f093..fbbbf6771 100644 --- a/core/config.h +++ b/core/config.h @@ -702,4 +702,8 @@ #define WASM_ENABLE_SHRUNK_MEMORY 1 #endif +#ifndef WASM_ENABLE_AOT_VALIDATOR +#define WASM_ENABLE_AOT_VALIDATOR 0 +#endif + #endif /* end of _CONFIG_H_ */ diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index bde3ee034..97360e73e 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -10,6 +10,9 @@ #include "../common/wasm_native.h" #include "../common/wasm_loader_common.h" #include "../compilation/aot.h" +#if WASM_ENABLE_AOT_VALIDATOR != 0 +#include "aot_validator.h" +#endif #if WASM_ENABLE_DEBUG_AOT != 0 #include "debug/elf_parser.h" @@ -1106,9 +1109,6 @@ load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, const uint8 *buf = *p_buf; read_uint32(buf, buf_end, module->import_memory_count); - /* We don't support import_memory_count > 0 currently */ - if (module->import_memory_count > 0) - return false; read_uint32(buf, buf_end, module->memory_count); total_size = sizeof(AOTMemory) * (uint64)module->memory_count; @@ -4403,6 +4403,13 @@ aot_load_from_aot_file(const uint8 *buf, uint32 size, const LoadArgs *args, os_thread_jit_write_protect_np(true); /* Make memory executable */ os_icache_flush(module->code, module->code_size); +#if WASM_ENABLE_AOT_VALIDATOR != 0 + if (!aot_module_validate(module, error_buf, error_buf_size)) { + aot_unload(module); + return NULL; + } +#endif /* WASM_ENABLE_AOT_VALIDATOR != 0 */ + LOG_VERBOSE("Load module success.\n"); return module; } diff --git a/core/iwasm/aot/aot_perf_map.c b/core/iwasm/aot/aot_perf_map.c index 22700dcdd..b96bcd1bf 100644 --- a/core/iwasm/aot/aot_perf_map.c +++ b/core/iwasm/aot/aot_perf_map.c @@ -7,7 +7,6 @@ #include "bh_log.h" #include "bh_platform.h" -#if WASM_ENABLE_LINUX_PERF != 0 struct func_info { uint32 idx; void *ptr; @@ -117,4 +116,3 @@ quit: return ret; } -#endif /* WASM_ENABLE_LINUX_PERF != 0 */ \ No newline at end of file diff --git a/core/iwasm/aot/aot_validator.c b/core/iwasm/aot/aot_validator.c new file mode 100644 index 000000000..58757f767 --- /dev/null +++ b/core/iwasm/aot/aot_validator.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "aot_validator.h" + +static void +set_error_buf(char *error_buf, uint32 error_buf_size, const char *string) +{ + if (error_buf != NULL) { + snprintf(error_buf, error_buf_size, + "AOT module load failed: from validator. %s", string); + } +} + +static bool +aot_memory_info_validate(const AOTModule *module, char *error_buf, + uint32 error_buf_size) +{ + if (module->import_memory_count > 0) { + set_error_buf(error_buf, error_buf_size, + "import memory is not supported"); + return false; + } + + if (module->memory_count < 1) { + set_error_buf(error_buf, error_buf_size, + "there should be >=1 memory in one aot module"); + return false; + } + + return true; +} + +bool +aot_module_validate(const AOTModule *module, char *error_buf, + uint32 error_buf_size) +{ + if (!aot_memory_info_validate(module, error_buf, error_buf_size)) { + return false; + } + + return true; +} diff --git a/core/iwasm/aot/aot_validator.h b/core/iwasm/aot/aot_validator.h new file mode 100644 index 000000000..dd8f0ecb5 --- /dev/null +++ b/core/iwasm/aot/aot_validator.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#ifndef _AOT_VALIDATOR_H_ +#define _AOT_VALIDATOR_H_ + +#include "aot_runtime.h" + +bool +aot_module_validate(const AOTModule *module, char *error_buf, + uint32 error_buf_size); + +#endif /* _AOT_VALIDATOR_H_ */ diff --git a/core/iwasm/aot/iwasm_aot.cmake b/core/iwasm/aot/iwasm_aot.cmake index efff88dd0..c82501fad 100644 --- a/core/iwasm/aot/iwasm_aot.cmake +++ b/core/iwasm/aot/iwasm_aot.cmake @@ -7,7 +7,19 @@ add_definitions (-DWASM_ENABLE_AOT=1) include_directories (${IWASM_AOT_DIR}) -file (GLOB c_source_all ${IWASM_AOT_DIR}/*.c) +list (APPEND c_source_all + ${IWASM_AOT_DIR}/aot_intrinsic.c + ${IWASM_AOT_DIR}/aot_loader.c + ${IWASM_AOT_DIR}/aot_runtime.c +) + +if (WAMR_BUILD_LINUX_PERF EQUAL 1) + list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_perf_map.c) +endif () + +if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1) + list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_validator.c) +endif () if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_64.c) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index bc56f4030..f54a3e542 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -58,6 +58,7 @@ if (WAMR_BUILD_LLVM_LEGACY_PM EQUAL 1) endif () if (LINUX) + set(WAMR_BUILD_LINUX_PERF 1) add_definitions(-DWASM_ENABLE_LINUX_PERF=1) endif () From 41b2c6d0d59f07db2ce44f7ba96cf58d7f16c66c Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 5 Feb 2025 15:28:26 +0800 Subject: [PATCH 017/198] Show wasm proposals status during compilation and execution (#3989) - add default build configuration options and enhance message output for WAMR features - Add Wasm proposal status printing functionality --- build-scripts/config_common.cmake | 189 ++++++++++++------ doc/stability_wasm_proposals.md | 2 +- product-mini/platforms/common/wasm_proposal.c | 48 +++++ product-mini/platforms/posix/main.c | 4 + 4 files changed, 177 insertions(+), 66 deletions(-) create mode 100644 product-mini/platforms/common/wasm_proposal.c diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 6173e73b5..0e9364d4f 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -167,16 +167,61 @@ if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY) set (WAMR_BUILD_SHRUNK_MEMORY 1) endif () +######################################## +# Default values +######################################## +if (NOT DEFINED WAMR_BUILD_BULK_MEMORY) + set (WAMR_BUILD_BULK_MEMORY 1) +endif () + +if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING) + set (WAMR_BUILD_EXCE_HANDLING 0) +endif () + +if (NOT DEFINED WAMR_BUILD_GC) + set (WAMR_BUILD_GC 0) +endif () + +if (NOT DEFINED WAMR_BUILD_MEMORY64) + set (WAMR_BUILD_MEMORY64 0) +endif () + +if (NOT DEFINED WAMR_BUILD_MULTI_MEMORY) + set (WAMR_BUILD_MULTI_MEMORY 0) +endif () + +if (NOT DEFINED WAMR_BUILD_SHARED_MEMORY) + set(WAMR_BUILD_SHARED_MEMORY 0) +endif () + +if (NOT DEFINED WAMR_BUILD_STRINGREF) + set(WAMR_BUILD_STRINGREF 0) +endif () + +if (NOT DEFINED WAMR_BUILD_TAIL_CALL) + set (WAMR_BUILD_TAIL_CALL 0) +endif () + +######################################## +# Compilation options to marco ######################################## message ("-- Build Configurations:") message (" Build as target ${WAMR_BUILD_TARGET}") message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE}) +################## running mode ################## if (WAMR_BUILD_INTERP EQUAL 1) message (" WAMR Interpreter enabled") else () message (" WAMR Interpreter disabled") endif () +if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1)) + add_definitions (-DWASM_ENABLE_FAST_INTERP=1) + message (" Fast interpreter enabled") +else () + add_definitions (-DWASM_ENABLE_FAST_INTERP=0) + message (" Fast interpreter disabled") +endif () if (WAMR_BUILD_AOT EQUAL 1) message (" WAMR AOT enabled") else () @@ -207,6 +252,16 @@ if (WAMR_BUILD_FAST_JIT EQUAL 1 AND WAMR_BUILD_JIT EQUAL 1 AND WAMR_BUILD_LAZY_JIT EQUAL 1) message (" Multi-tier JIT enabled") endif () +################## test modes ################## +if (WAMR_BUILD_SPEC_TEST EQUAL 1) + add_definitions (-DWASM_ENABLE_SPEC_TEST=1) + message (" spec test compatible mode is on") +endif () +if (WAMR_BUILD_WASI_TEST EQUAL 1) + add_definitions (-DWASM_ENABLE_WASI_TEST=1) + message (" wasi test compatible mode is on") +endif () +################## native ################## if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) message (" Libc builtin enabled") else () @@ -219,64 +274,6 @@ elseif (WAMR_BUILD_LIBC_WASI EQUAL 1) else () message (" Libc WASI disabled") endif () -if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1)) - add_definitions (-DWASM_ENABLE_FAST_INTERP=1) - message (" Fast interpreter enabled") -else () - add_definitions (-DWASM_ENABLE_FAST_INTERP=0) - message (" Fast interpreter disabled") -endif () -if (WAMR_BUILD_MULTI_MODULE EQUAL 1) - add_definitions (-DWASM_ENABLE_MULTI_MODULE=1) - message (" Multiple modules enabled") -else () - add_definitions (-DWASM_ENABLE_MULTI_MODULE=0) - message (" Multiple modules disabled") -endif () -if (WAMR_BUILD_SPEC_TEST EQUAL 1) - add_definitions (-DWASM_ENABLE_SPEC_TEST=1) - message (" spec test compatible mode is on") -endif () -if (WAMR_BUILD_WASI_TEST EQUAL 1) - add_definitions (-DWASM_ENABLE_WASI_TEST=1) - message (" wasi test compatible mode is on") -endif () -if (NOT DEFINED WAMR_BUILD_BULK_MEMORY) - # Enable bulk memory by default - set (WAMR_BUILD_BULK_MEMORY 1) -endif () -if (WAMR_BUILD_BULK_MEMORY EQUAL 1) - add_definitions (-DWASM_ENABLE_BULK_MEMORY=1) - message (" Bulk memory feature enabled") -else () - add_definitions (-DWASM_ENABLE_BULK_MEMORY=0) - message (" Bulk memory feature disabled") -endif () -if (WAMR_BUILD_SHARED_MEMORY EQUAL 1) - add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1) - message (" Shared memory enabled") -else () - add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0) -endif () -if (WAMR_BUILD_SHARED_HEAP EQUAL 1) - add_definitions (-DWASM_ENABLE_SHARED_HEAP=1) - message (" Shared heap enabled") -endif() - -if (WAMR_BUILD_MEMORY64 EQUAL 1) - # if native is 32-bit or cross-compiled to 32-bit - if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*") - message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target") - endif() - add_definitions (-DWASM_ENABLE_MEMORY64=1) - set (WAMR_DISABLE_HW_BOUND_CHECK 1) - message (" Memory64 memory enabled") -endif () -if (WAMR_BUILD_MULTI_MEMORY EQUAL 1) - add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1) - message (" Multi memory enabled") - set (WAMR_BUILD_DEBUG_INTERP 0) -endif () if (WAMR_BUILD_THREAD_MGR EQUAL 1) message (" Thread manager enabled") endif () @@ -295,6 +292,42 @@ endif () if (WAMR_BUILD_LIB_RATS EQUAL 1) message (" Lib rats enabled") endif() +################## WAMR features ################## +if (WAMR_BUILD_MULTI_MODULE EQUAL 1) + add_definitions (-DWASM_ENABLE_MULTI_MODULE=1) + message (" Multiple modules enabled") +else () + add_definitions (-DWASM_ENABLE_MULTI_MODULE=0) + message (" Multiple modules disabled") +endif () +if (WAMR_BUILD_BULK_MEMORY EQUAL 1) + add_definitions (-DWASM_ENABLE_BULK_MEMORY=1) +else () + add_definitions (-DWASM_ENABLE_BULK_MEMORY=0) +endif () +if (WAMR_BUILD_SHARED_MEMORY EQUAL 1) + add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1) + message (" Shared memory enabled") +else () + add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0) +endif () +if (WAMR_BUILD_SHARED_HEAP EQUAL 1) + add_definitions (-DWASM_ENABLE_SHARED_HEAP=1) + message (" Shared heap enabled") +endif() + +if (WAMR_BUILD_MEMORY64 EQUAL 1) + # if native is 32-bit or cross-compiled to 32-bit + if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*") + message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target") + endif() + add_definitions (-DWASM_ENABLE_MEMORY64=1) + set (WAMR_DISABLE_HW_BOUND_CHECK 1) +endif () +if (WAMR_BUILD_MULTI_MEMORY EQUAL 1) + add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1) + set (WAMR_BUILD_DEBUG_INTERP 0) +endif () if (WAMR_BUILD_MINI_LOADER EQUAL 1) add_definitions (-DWASM_ENABLE_MINI_LOADER=1) message (" WASM mini loader enabled") @@ -324,7 +357,6 @@ endif () if (WAMR_BUILD_SIMD EQUAL 1) if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*") add_definitions (-DWASM_ENABLE_SIMD=1) - message (" SIMD enabled") else () message (" SIMD disabled due to not supported on target RISCV64") endif () @@ -354,16 +386,11 @@ if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1) endif () if (WAMR_BUILD_TAIL_CALL EQUAL 1) add_definitions (-DWASM_ENABLE_TAIL_CALL=1) - message (" Tail call enabled") endif () if (WAMR_BUILD_REF_TYPES EQUAL 1) add_definitions (-DWASM_ENABLE_REF_TYPES=1) - message (" Reference types enabled") -else () - message (" Reference types disabled") endif () if (WAMR_BUILD_GC EQUAL 1) - message (" GC enabled") if (WAMR_TEST_GC EQUAL 1) message(" GC testing enabled") endif() @@ -375,7 +402,6 @@ else () message (" GC performance profiling disabled") endif () if (WAMR_BUILD_STRINGREF EQUAL 1) - message (" Stringref enabled") if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE) message (" Using WAMR builtin implementation for stringref") else () @@ -615,3 +641,36 @@ if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1) message (" AOT validator enabled") add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1) endif () + +######################################## +# Show Phase4 Wasm proposals status. +######################################## + +message ( +"-- About Wasm Proposals:\n" +" Always-on:\n" +" \"Extended Constant Expressions\"\n" +" \"Multi-value\"\n" +" \"Non-trapping float-to-int conversions\"\n" +" \"Sign-extension operators\"\n" +" \"WebAssembly C and C++ API\"\n" +" Configurable. 0 is OFF. 1 is ON:\n" +" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n" +" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n" +" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n" +" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n" +" \"Memory64\" via WAMR_BUILD_MEMORY64: ${WAMR_BUILD_MEMORY64}\n" +" \"Multiple memories\" via WAMR_BUILD_MULTI_MEMORY: ${WAMR_BUILD_MULTI_MEMORY}\n" +" \"Reference Types\" via WAMR_BUILD_REF_TYPES: ${WAMR_BUILD_REF_TYPES}\n" +" \"Reference-Typed Strings\" via WAMR_BUILD_STRINGREF: ${WAMR_BUILD_STRINGREF}\n" +" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n" +" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n" +" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n" +" Unsupported (>= Phase4):\n" +" \"Branch Hinting\"\n" +" \"Custom Annotation Syntax in the Text Format\"\n" +" \"Exception handling\"\n" +" \"Import/Export of Mutable Globals\"\n" +" \"JS String Builtins\"\n" +" \"Relaxed SIMD\"\n" +) diff --git a/doc/stability_wasm_proposals.md b/doc/stability_wasm_proposals.md index 98617d15b..715f2f3bd 100644 --- a/doc/stability_wasm_proposals.md +++ b/doc/stability_wasm_proposals.md @@ -35,7 +35,7 @@ Users can turn those features on or off by using compilation options. If a relev | Multiple memories[^3] | Yes | `WAMR_BUILD_MULTI_MEMORY` | | Reference-Typed Strings | No | `WAMR_BUILD_STRINGREF` | | Tail call | Yes | `WAMR_BUILD_TAIL_CALL` | -| Thread[^4] | Yes | `WAMR_BUILD_SHARED_MEMORY` | +| Threads[^4] | Yes | `WAMR_BUILD_SHARED_MEMORY` | | Typed Function References | Yes | `WAMR_BUILD_GC` | [^2]: diff --git a/product-mini/platforms/common/wasm_proposal.c b/product-mini/platforms/common/wasm_proposal.c new file mode 100644 index 000000000..4bf6ab3e9 --- /dev/null +++ b/product-mini/platforms/common/wasm_proposal.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +void +wasm_proposal_print_status(void) +{ + printf("About Wasm Proposals:\n"); + printf(" Always-on:\n"); + printf(" - Extended Constant Expressions\n"); + printf(" - Multi-value\n"); + printf(" - Non-trapping float-to-int conversions\n"); + printf(" - Sign-extension operators\n"); + printf(" - WebAssembly C and C++ API\n"); + printf(" Compilation Configurable. 0 is OFF. 1 is ON:\n"); + printf(" - Bulk Memory Operation via WASM_ENABLE_BULK_MEMORY: %u\n", + WASM_ENABLE_BULK_MEMORY); + printf(" - Fixed-Width SIMD via WASM_ENABLE_SIMD: %u\n", + WASM_ENABLE_SIMD); + printf(" - Garbage Collection via WASM_ENABLE_GC: %u\n", WASM_ENABLE_GC); + printf( + " - Legacy Exception Handling via WASM_ENABLE_EXCE_HANDLING: %u\n", + WASM_ENABLE_EXCE_HANDLING); + printf(" - Memory64 via WASM_ENABLE_MEMORY64: %u\n", + WASM_ENABLE_MEMORY64); + printf(" - Multiple Memory via WASM_ENABLE_MULTI_MEMORY: %u\n", + WASM_ENABLE_MULTI_MEMORY); + printf(" - Reference Types via WASM_ENABLE_REF_TYPES: %u\n", + WASM_ENABLE_REF_TYPES); + printf(" - Reference-Typed Strings via WASM_ENABLE_REF_TYPES: %u\n", + WASM_ENABLE_REF_TYPES); + printf(" - Tail Call via WASM_ENABLE_TAIL_CALL: %u\n", + WASM_ENABLE_TAIL_CALL); + printf(" - Threads via WASM_ENABLE_SHARED_MEMORY: %u\n", + WASM_ENABLE_SHARED_MEMORY); + printf(" - Typed Function References via WASM_ENABLE_GC: %u\n", + WASM_ENABLE_GC); + printf(" Unsupported (>= Phase4):\n"); + printf(" - Branch Hinting\n"); + printf(" - Custom Annotation Syntax in the Text Format\n"); + printf(" - Exception handling\n"); + printf(" - Import/Export of Mutable Globals\n"); + printf(" - JS String Builtins\n"); + printf(" - Relaxed SIMD\n"); +} diff --git a/product-mini/platforms/posix/main.c b/product-mini/platforms/posix/main.c index af50223a4..fa5dcb2c3 100644 --- a/product-mini/platforms/posix/main.c +++ b/product-mini/platforms/posix/main.c @@ -18,6 +18,8 @@ #include "../common/libc_wasi.c" #endif +#include "../common/wasm_proposal.c" + #if BH_HAS_DLFCN #include #endif @@ -798,6 +800,8 @@ main(int argc, char *argv[]) wasm_runtime_get_version(&major, &minor, &patch); printf("iwasm %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, minor, patch); + printf("\n"); + wasm_proposal_print_status(); return 0; } else { From 67cd5043d3a6a5a62dfa19cd08ccfe2a3571ef98 Mon Sep 17 00:00:00 2001 From: Viacheslav Palchikov Date: Thu, 30 Jan 2025 01:15:14 +0300 Subject: [PATCH 018/198] initial --- core/iwasm/aot/aot_runtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 0f7b5d3d9..18a098a45 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -2630,7 +2630,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function, ret = invoke_native_internal(exec_env, func_ptr, func_type, NULL, attachment, argv, argc, argv); - if (aot_copy_exception(module_inst, NULL)) { + if (!ret) { #ifdef AOT_STACK_FRAME_DEBUG if (aot_stack_frame_callback) { aot_stack_frame_callback(exec_env); @@ -2651,7 +2651,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function, aot_free_frame(exec_env); #endif - return ret && !aot_copy_exception(module_inst, NULL) ? true : false; + return ret; } } From e64685f43c8533b680a68729a3564efe7ed217f0 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 26 Nov 2024 03:39:03 +0000 Subject: [PATCH 019/198] Add versioning support and update CMake configuration --- CMakeLists.txt | 3 +++ build-scripts/config_common.cmake | 3 +++ build-scripts/version.cmake | 25 +++++++++++++++++++++ core/version.h | 11 +++++++++ core/version.h.in | 22 ++++++++++++++++++ product-mini/platforms/linux/CMakeLists.txt | 3 +++ 6 files changed, 67 insertions(+) create mode 100644 build-scripts/version.cmake create mode 100644 core/version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a637c3643..6362d0e56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,7 @@ if (WAMR_BUILD_STATIC) target_link_libraries(iwasm_static PRIVATE ntdll) endif() + set_version_info (iwasm_static) install (TARGETS iwasm_static ARCHIVE DESTINATION lib) endif () @@ -196,6 +197,7 @@ if (WAMR_BUILD_SHARED) target_link_libraries(iwasm_shared PRIVATE ntdll) endif() + set_version_info (iwasm_shared) install (TARGETS iwasm_shared LIBRARY DESTINATION lib) endif () @@ -204,4 +206,5 @@ install (FILES ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h + ${WAMR_ROOT_DIR}/core/version.h DESTINATION include) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 0e9364d4f..88abf7324 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -131,6 +131,9 @@ else () unset (LLVM_AVAILABLE_LIBS) endif () +# Version +include (${WAMR_ROOT_DIR}/build-scripts/version.cmake) + # Sanitizers if (NOT DEFINED WAMR_BUILD_SANITIZER) diff --git a/build-scripts/version.cmake b/build-scripts/version.cmake new file mode 100644 index 000000000..d5304bcd0 --- /dev/null +++ b/build-scripts/version.cmake @@ -0,0 +1,25 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# BE AWARE: This file depends on ${WAMR_ROOT_DIR} + +set(WAMR_VERSION_MAJOR 2) +set(WAMR_VERSION_MINOR 2) +set(WAMR_VERSION_PATCH 0) + +message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}") + +# Configure the version header file +configure_file( + ${WAMR_ROOT_DIR}/core/version.h.in + ${WAMR_ROOT_DIR}/core/version.h +) + +# Set the library version and SOVERSION +function(set_version_info target) + set_target_properties(${target} + PROPERTIES + VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH} + SOVERSION ${WAMR_VERSION_MAJOR} +) +endfunction() diff --git a/core/version.h b/core/version.h index 4fe37e2d7..43ce5b96a 100644 --- a/core/version.h +++ b/core/version.h @@ -3,9 +3,20 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* + * version.h.in is a template file. version.h is a generated file. + * Please do not edit both files directly. + * + * Any changes to the version should be done in the version.cmake file. + */ + #ifndef _WAMR_VERSION_H_ #define _WAMR_VERSION_H_ + +/* clang-format off */ #define WAMR_VERSION_MAJOR 2 #define WAMR_VERSION_MINOR 2 #define WAMR_VERSION_PATCH 0 +/* clang-format on */ + #endif diff --git a/core/version.h.in b/core/version.h.in new file mode 100644 index 000000000..495b8d3b6 --- /dev/null +++ b/core/version.h.in @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * version.h.in is a template file. version.h is a generated file. + * Please do not edit both files directly. + * + * Any changes to the version should be done in the version.cmake file. + */ + +#ifndef _WAMR_VERSION_H_ +#define _WAMR_VERSION_H_ + +/* clang-format off */ +#define WAMR_VERSION_MAJOR @WAMR_VERSION_MAJOR@ +#define WAMR_VERSION_MINOR @WAMR_VERSION_MINOR@ +#define WAMR_VERSION_PATCH @WAMR_VERSION_PATCH@ +/* clang-format on */ + +#endif diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt index 321c4a955..c3d02da6b 100644 --- a/product-mini/platforms/linux/CMakeLists.txt +++ b/product-mini/platforms/linux/CMakeLists.txt @@ -142,6 +142,7 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) check_pie_supported() add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_target_properties (vmlib PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_version_info (vmlib) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") @@ -169,6 +170,7 @@ endif () include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +set_version_info (iwasm) set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -184,6 +186,7 @@ target_link_libraries(iwasm install (TARGETS iwasm DESTINATION bin) add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (libiwasm) install (TARGETS libiwasm DESTINATION lib) From b144e611a25c839b8f138ada0397d3a4fcc5e1bd Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 24 Dec 2024 02:01:18 +0000 Subject: [PATCH 020/198] Add versioning information for libraries and executables across multiple platforms --- product-mini/platforms/android/CMakeLists.txt | 3 +++ product-mini/platforms/cosmopolitan/CMakeLists.txt | 5 +++++ product-mini/platforms/darwin/CMakeLists.txt | 5 +++++ product-mini/platforms/freebsd/CMakeLists.txt | 5 +++++ product-mini/platforms/ios/CMakeLists.txt | 1 + product-mini/platforms/linux-sgx/CMakeLists.txt | 1 + product-mini/platforms/linux-sgx/CMakeLists_minimal.txt | 1 + product-mini/platforms/linux/CMakeLists.txt | 2 ++ product-mini/platforms/riot/CMakeLists.txt | 2 ++ product-mini/platforms/vxworks/CMakeLists.txt | 5 +++++ product-mini/platforms/windows/CMakeLists.txt | 5 +++++ wamr-compiler/CMakeLists.txt | 1 + 12 files changed, 36 insertions(+) diff --git a/product-mini/platforms/android/CMakeLists.txt b/product-mini/platforms/android/CMakeLists.txt index 5c0525917..19bc1b11e 100644 --- a/product-mini/platforms/android/CMakeLists.txt +++ b/product-mini/platforms/android/CMakeLists.txt @@ -107,6 +107,8 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security") @@ -135,6 +137,7 @@ endif() set (distribution_DIR ${CMAKE_BINARY_DIR}/distribution) set_target_properties (iwasm PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${distribution_DIR}/wasm/lib") +set_version_info (iwasm) add_custom_command (TARGET iwasm POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory "${WAMR_ROOT_DIR}/core/iwasm/include" "${distribution_DIR}/wasm/include/" diff --git a/product-mini/platforms/cosmopolitan/CMakeLists.txt b/product-mini/platforms/cosmopolitan/CMakeLists.txt index 8533ea68c..7676ea6fb 100644 --- a/product-mini/platforms/cosmopolitan/CMakeLists.txt +++ b/product-mini/platforms/cosmopolitan/CMakeLists.txt @@ -132,6 +132,7 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) check_pie_supported() add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_target_properties (vmlib PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_version_info (vmlib) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") @@ -160,6 +161,8 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +set_version_info (iwasm) + set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON) install (TARGETS iwasm DESTINATION bin) @@ -168,6 +171,8 @@ target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} ${WASI_NN add_library (libiwasm STATIC ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (libiwasm) + install (TARGETS libiwasm DESTINATION lib) set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index 12ed8052f..1f955a10b 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -116,11 +116,14 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +set_version_info (iwasm) + install (TARGETS iwasm DESTINATION bin) target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) @@ -131,5 +134,7 @@ install (TARGETS libiwasm DESTINATION lib) set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) +set_version_info (libiwasm) + target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) diff --git a/product-mini/platforms/freebsd/CMakeLists.txt b/product-mini/platforms/freebsd/CMakeLists.txt index dd1bbc41a..5640a384a 100644 --- a/product-mini/platforms/freebsd/CMakeLists.txt +++ b/product-mini/platforms/freebsd/CMakeLists.txt @@ -113,17 +113,22 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +set_version_info (iwasm) + install (TARGETS iwasm DESTINATION bin) target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (libiwasm) + install (TARGETS libiwasm DESTINATION lib) set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) diff --git a/product-mini/platforms/ios/CMakeLists.txt b/product-mini/platforms/ios/CMakeLists.txt index ea5a4f4b9..ca54aa155 100644 --- a/product-mini/platforms/ios/CMakeLists.txt +++ b/product-mini/platforms/ios/CMakeLists.txt @@ -139,6 +139,7 @@ endif() set (distribution_DIR ${CMAKE_BINARY_DIR}/distribution) set_target_properties (iwasm PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${distribution_DIR}/wasm/lib") +set_version_info (iwasm) add_custom_command (TARGET iwasm POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory "${WAMR_ROOT_DIR}/core/iwasm/include" "${distribution_DIR}/wasm/include/" diff --git a/product-mini/platforms/linux-sgx/CMakeLists.txt b/product-mini/platforms/linux-sgx/CMakeLists.txt index 20b3fdfac..927e6f459 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists.txt @@ -107,6 +107,7 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) add_custom_command ( OUTPUT libvmlib_untrusted.a diff --git a/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt b/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt index aa3de6dac..a29dbd69c 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt @@ -78,6 +78,7 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) add_custom_command ( OUTPUT libvmlib_untrusted.a diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt index c3d02da6b..527d18035 100644 --- a/product-mini/platforms/linux/CMakeLists.txt +++ b/product-mini/platforms/linux/CMakeLists.txt @@ -170,6 +170,7 @@ endif () include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) + set_version_info (iwasm) set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -186,6 +187,7 @@ target_link_libraries(iwasm install (TARGETS iwasm DESTINATION bin) add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) + set_version_info (libiwasm) install (TARGETS libiwasm DESTINATION lib) diff --git a/product-mini/platforms/riot/CMakeLists.txt b/product-mini/platforms/riot/CMakeLists.txt index 003283262..c32a0b977 100644 --- a/product-mini/platforms/riot/CMakeLists.txt +++ b/product-mini/platforms/riot/CMakeLists.txt @@ -62,3 +62,5 @@ include_directories(SYSTEM ${RIOT_INCLUDES_LIST}) # executable linking is done by RIOT build system add_library( wamr ${WAMR_RUNTIME_LIB_SOURCE}) + +set_version_info (wamr) diff --git a/product-mini/platforms/vxworks/CMakeLists.txt b/product-mini/platforms/vxworks/CMakeLists.txt index 0dc5d9699..dd03cb356 100644 --- a/product-mini/platforms/vxworks/CMakeLists.txt +++ b/product-mini/platforms/vxworks/CMakeLists.txt @@ -78,17 +78,22 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +set_version_info (iwasm) + install (TARGETS iwasm DESTINATION bin) target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} -lm -ldl -lunix) add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (libiwasm) + install (TARGETS libiwasm DESTINATION lib) set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index 40e925b16..ff438ee8c 100644 --- a/product-mini/platforms/windows/CMakeLists.txt +++ b/product-mini/platforms/windows/CMakeLists.txt @@ -106,6 +106,7 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info(vmlib) #set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN") if (NOT MINGW) @@ -134,6 +135,8 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +set_version_info (iwasm) + install (TARGETS iwasm DESTINATION bin) target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS}) @@ -144,6 +147,8 @@ endif () add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (libiwasm) + install (TARGETS libiwasm DESTINATION lib) set_target_properties (libiwasm PROPERTIES OUTPUT_NAME libiwasm) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index f54a3e542..4c32fa9e6 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -376,6 +376,7 @@ add_library (aotclib ${IWASM_COMPL_SOURCE}) add_executable (wamrc main.c) check_pie_supported() set_target_properties (wamrc PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_version_info (wamrc) if (LLVM_LINK_LLVM_DYLIB) set(WAMRC_LINK_LLVM_LIBS LLVM) From 77e8a7d4037cfd6b4e6234e6d18abcf0abd1d8aa Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Thu, 26 Dec 2024 00:56:22 +0000 Subject: [PATCH 021/198] Refactor versioning documentation and adopt semantic versioning guidelines --- build-scripts/version.cmake | 5 ++++- doc/semantic_version.md | 21 --------------------- doc/stability_release.md | 28 ++++++++++++++++++++++++++++ wamr-compiler/CMakeLists.txt | 1 + 4 files changed, 33 insertions(+), 22 deletions(-) delete mode 100644 doc/semantic_version.md create mode 100644 doc/stability_release.md diff --git a/build-scripts/version.cmake b/build-scripts/version.cmake index d5304bcd0..04c4e1ccb 100644 --- a/build-scripts/version.cmake +++ b/build-scripts/version.cmake @@ -1,7 +1,10 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# BE AWARE: This file depends on ${WAMR_ROOT_DIR} +if(NOT WAMR_ROOT_DIR) + # if from wamr-compiler + set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) +endif() set(WAMR_VERSION_MAJOR 2) set(WAMR_VERSION_MINOR 2) diff --git a/doc/semantic_version.md b/doc/semantic_version.md deleted file mode 100644 index 9fdd65d60..000000000 --- a/doc/semantic_version.md +++ /dev/null @@ -1,21 +0,0 @@ -# WAMR uses semantic versioning - -WAMR uses the _semantic versioning_ to replace the current _date versioning_ system. - -There are three parts in the new version string: - -- _major_. Any incompatible modification, on both ABI and APIs, will lead an increment - in the value of _major_. APIs includes: `wasm_export.h`, `wasm_c_api.h`, - _sections in AOT files_, and so on. -- _minor_. It represents new features. It includes not just MVP or POST-MVP features - but also WASI features and WAMR private ones. -- _patch_. It represents patches. - -## Legacy versions - -All legacy versions(tags) will keep their current status. No existing release names -and links will be changed. - -## Reference - -- [Semantic Versioning 2.0.0](https://semver.org/) diff --git a/doc/stability_release.md b/doc/stability_release.md new file mode 100644 index 000000000..a08040c22 --- /dev/null +++ b/doc/stability_release.md @@ -0,0 +1,28 @@ +# Semantic Versioning + +WAMR has adopted [semantic versioning](https://semver.org/) to replace the former *date versioning system*. The new version string consists of three parts: + +- *major*: Any change that is not compatible with previous versions, affecting either the ABI or APIs, will result in an increase in the major version number. APIs include: wasm_export.h, wasm_c_api.h, sections in AOT files, among others. +- *minor*: This number increases with the addition of new features. This encompasses not only MVP (Minimum Viable Product) or POST-MVP features but also WebAssembly System Interface (WASI) features and WAMR-specific features. +- *patch*: This number is incremented for patches. + +## Legacy releases + +All previous versions (tags) will retain their current status. There will be no changes to existing release names and links. + +# Release Process + +WAMR has been deployed across various devices. A frequent release cycle would strain customers' testing resources and add extra deployment work. Two factors can trigger a new WAMR release: + +- Community requests, particularly following the integration of significant and new features. +- Security vulnerabilities and critical bug fixes that ensure correctness. + +Patch releases will be made only to address security vulnerabilities and critical issues related to default behavior in prior releases. + +Once a release decision has been made: + +- Create a PR that: + 1. Modifies *build-scripts/version.cmake*. + 2. Updates *RELEASE.md*. +- Once the PR is merged, create a new tag. +- Initiate the release process by triggering *the binary release processes* in *Actions*. diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index 4c32fa9e6..9975dab7b 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -285,6 +285,7 @@ include (${IWASM_DIR}/common/gc/iwasm_gc.cmake) include (${IWASM_DIR}/interpreter/iwasm_interp.cmake) include (${IWASM_DIR}/aot/iwasm_aot.cmake) include (${IWASM_DIR}/compilation/iwasm_compl.cmake) +include (${PROJECT_SOURCE_DIR}/../build-scripts/version.cmake) if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake) From 4f7c5af0461af3abac79e814c901128e4aa924ba Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Fri, 10 Jan 2025 08:03:32 +0000 Subject: [PATCH 022/198] Remove deprecated version.h file and update versioning documentation --- core/version.h | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 core/version.h diff --git a/core/version.h b/core/version.h deleted file mode 100644 index 43ce5b96a..000000000 --- a/core/version.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -/* - * version.h.in is a template file. version.h is a generated file. - * Please do not edit both files directly. - * - * Any changes to the version should be done in the version.cmake file. - */ - -#ifndef _WAMR_VERSION_H_ -#define _WAMR_VERSION_H_ - -/* clang-format off */ -#define WAMR_VERSION_MAJOR 2 -#define WAMR_VERSION_MINOR 2 -#define WAMR_VERSION_PATCH 0 -/* clang-format on */ - -#endif From 10f12c030f52ca3de44790c96ad4cd9c52d97388 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Fri, 17 Jan 2025 04:05:05 +0000 Subject: [PATCH 023/198] Add version.h and update versioning documentation for embedded platforms --- core/version.h | 24 ++++++++++++++++++++++++ core/version.h.in | 4 +++- doc/stability_release.md | 7 ++++++- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 core/version.h diff --git a/core/version.h b/core/version.h new file mode 100644 index 000000000..d1becac61 --- /dev/null +++ b/core/version.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * version.h.in is a template file. version.h is a generated file. + * Please do not edit both files directly. + * + * Any changes to the version should be done in build-scripts/version.cmake. + * + * Continue to maintain the version.h for certain embedded platforms. + */ + +#ifndef _WAMR_VERSION_H_ +#define _WAMR_VERSION_H_ + +/* clang-format off */ +#define WAMR_VERSION_MAJOR 2 +#define WAMR_VERSION_MINOR 2 +#define WAMR_VERSION_PATCH 0 +/* clang-format on */ + +#endif diff --git a/core/version.h.in b/core/version.h.in index 495b8d3b6..e28df65ce 100644 --- a/core/version.h.in +++ b/core/version.h.in @@ -7,7 +7,9 @@ * version.h.in is a template file. version.h is a generated file. * Please do not edit both files directly. * - * Any changes to the version should be done in the version.cmake file. + * Any changes to the version should be done in build-scripts/version.cmake. + * + * Continue to maintain the version.h for certain embedded platforms. */ #ifndef _WAMR_VERSION_H_ diff --git a/doc/stability_release.md b/doc/stability_release.md index a08040c22..78e034a3d 100644 --- a/doc/stability_release.md +++ b/doc/stability_release.md @@ -23,6 +23,11 @@ Once a release decision has been made: - Create a PR that: 1. Modifies *build-scripts/version.cmake*. - 2. Updates *RELEASE.md*. + 2. Executes cmake configuration to update the version. + 3. Updates *RELEASE_NOTES.md*. +- A checklist of the PR includes + - [ ] *build-scripts/version.cmake* + - [ ] *core/version.h* + - [ ] *RELEASE_NOTES.md* - Once the PR is merged, create a new tag. - Initiate the release process by triggering *the binary release processes* in *Actions*. From 2c2829ffa58951093b971703059acfd11388dde7 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 20 Jan 2025 03:16:10 +0000 Subject: [PATCH 024/198] Add workflow to confirm version.h is in sync and integrate it into Android compilation workflow --- .github/workflows/check_version_h.yml | 34 +++++++++++++++++++ .../compilation_on_android_ubuntu.yml | 6 ++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/check_version_h.yml diff --git a/.github/workflows/check_version_h.yml b/.github/workflows/check_version_h.yml new file mode 100644 index 000000000..7d82dddc6 --- /dev/null +++ b/.github/workflows/check_version_h.yml @@ -0,0 +1,34 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +name: confirm version.h stay in sync + +on: + workflow_call: + +permissions: + contents: read + +jobs: + confirm_version: + runs-on: ubuntu-latest + outputs: + key: ${{ steps.create_version_h_cache_key.outputs.key}} + permissions: + contents: read + actions: write # for uploading cached artifact + + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: cmake execute to generate version.h + run: cmake -B build_version -S . + + - name: confirm version.h + run: | + if [ -z "$(git status --porcelain | grep version.h)" ]; then + echo "version.h is in sync" + else + echo "version.h is not in sync" + exit 1 + fi diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 11a512448..057082ebc 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -74,6 +74,12 @@ permissions: contents: read jobs: + check_version_h: + permissions: + contents: read + actions: write + uses: ./.github/workflows/check_version_h.yml + build_llvm_libraries_on_ubuntu_2204: permissions: contents: read From 171d35698ae775dc2e1abf287bce471c59483d39 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 21 Jan 2025 01:49:29 +0000 Subject: [PATCH 025/198] Cleanup check_version_h workflow by removing unnecessary outputs and permissions --- .github/workflows/check_version_h.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/check_version_h.yml b/.github/workflows/check_version_h.yml index 7d82dddc6..ab23ecf9e 100644 --- a/.github/workflows/check_version_h.yml +++ b/.github/workflows/check_version_h.yml @@ -11,11 +11,6 @@ permissions: jobs: confirm_version: runs-on: ubuntu-latest - outputs: - key: ${{ steps.create_version_h_cache_key.outputs.key}} - permissions: - contents: read - actions: write # for uploading cached artifact steps: - name: checkout From 376385c60823884b3361dc4cdcb9dd389c099085 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 6 Feb 2025 13:15:00 +0800 Subject: [PATCH 026/198] Update memory allocation functions to use allocator user data (#4043) --- core/iwasm/common/wasm_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 74df84e56..4f3d8689f 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -1367,7 +1367,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module, if (!(memory_data_new = realloc_func(Alloc_For_LinearMemory, full_size_mmaped, #if WASM_MEM_ALLOC_WITH_USER_DATA != 0 - NULL, + allocator_user_data, #endif memory_data_old, total_size_new))) { ret = false; @@ -1680,7 +1680,7 @@ wasm_deallocate_linear_memory(WASMMemoryInstance *memory_inst) (void)map_size; free_func(Alloc_For_LinearMemory, #if WASM_MEM_ALLOC_WITH_USER_DATA != 0 - NULL, + allocator_user_data, #endif memory_inst->memory_data); #else @@ -1733,7 +1733,7 @@ wasm_allocate_linear_memory(uint8 **data, bool is_shared_memory, (void)wasm_mmap_linear_memory; if (!(*data = malloc_func(Alloc_For_LinearMemory, #if WASM_MEM_ALLOC_WITH_USER_DATA != 0 - NULL, + allocator_user_data, #endif *memory_data_size))) { return BHT_ERROR; From c99ae24fb6798201c70697f3ac6f431758d81b4a Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 6 Feb 2025 13:15:56 +0800 Subject: [PATCH 027/198] [fuzzing] execute every exported function (#3959) - Enhance wasm mutator fuzz tests by adding export function execution and random value generation - Use --fuel to limit loop size - Use predefined values and enhance argument logging in execution --- tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh | 4 +- .../wasm-mutator-fuzz/wasm_mutator_fuzz.cc | 145 +++++++++++++++++- 2 files changed, 147 insertions(+), 2 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh b/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh index 02ac83174..097e5348b 100755 --- a/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh +++ b/tests/fuzz/wasm-mutator-fuzz/smith_wasm.sh @@ -41,7 +41,9 @@ function try_generate_wasm() printf -- "-- output ${GENERATED_WASM_NAME} in %d retries\n" $try_i } -WASM_SHAPE=" --allow-invalid-funcs true \ +WASM_SHAPE=" --ensure-termination \ +--export-everything true \ +--fuel 7 \ --generate-custom-sections true \ --min-funcs 5 \ --max-instructions 1024 \ diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc b/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc index 2d5a66703..4b3d8d942 100644 --- a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc +++ b/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc @@ -13,6 +13,149 @@ using namespace std; +static bool +is_supported_val_kind(wasm_valkind_t kind) +{ + return kind == WASM_I32 || kind == WASM_I64 || kind == WASM_F32 + || kind == WASM_F64 || kind == WASM_EXTERNREF + || kind == WASM_FUNCREF; +} + +static wasm_val_t +pre_defined_val(wasm_valkind_t kind) +{ + if (kind == WASM_I32) { + return wasm_val_t{ .kind = WASM_I32, .of = { .i32 = 2025 } }; + } + else if (kind == WASM_I64) { + return wasm_val_t{ .kind = WASM_I64, .of = { .i64 = 168 } }; + } + else if (kind == WASM_F32) { + return wasm_val_t{ .kind = WASM_F32, .of = { .f32 = 3.14159f } }; + } + else if (kind == WASM_F64) { + return wasm_val_t{ .kind = WASM_F64, .of = { .f64 = 2.71828 } }; + } + else if (kind == WASM_EXTERNREF) { + return wasm_val_t{ .kind = WASM_EXTERNREF, + .of = { .foreign = 0xabcddead } }; + } + // because aft is_supported_val_kind() check, so we can safely return as + // WASM_FUNCREF + else { + return wasm_val_t{ .kind = WASM_FUNCREF, .of = { .ref = nullptr } }; + } +} +void +print_execution_args(const wasm_export_t &export_type, + const std::vector &args, unsigned param_count) +{ + std::cout << "[EXECUTION] " << export_type.name << "("; + for (unsigned p_i = 0; p_i < param_count; p_i++) { + if (p_i != 0) { + std::cout << ", "; + } + + switch (args[p_i].kind) { + case WASM_I32: + std::cout << "i32:" << args[p_i].of.i32; + break; + case WASM_I64: + std::cout << "i64:" << args[p_i].of.i64; + break; + case WASM_F32: + std::cout << "f32:" << args[p_i].of.f32; + break; + case WASM_F64: + std::cout << "f64:" << args[p_i].of.f64; + break; + case WASM_EXTERNREF: + std::cout << "externref:" << args[p_i].of.foreign; + break; + default: + // because aft is_supported_val_kind() check, so we can safely + // return as WASM_FUNCREF + std::cout << "funcref:" << args[p_i].of.ref; + break; + } + } + std::cout << ")" << std::endl; +} + +static bool +execute_export_functions(wasm_module_t module, wasm_module_inst_t inst) +{ + int32_t export_count = wasm_runtime_get_export_count(module); + + for (int e_i = 0; e_i < export_count; e_i++) { + wasm_export_t export_type = { 0 }; + wasm_runtime_get_export_type(module, e_i, &export_type); + + if (export_type.kind != WASM_IMPORT_EXPORT_KIND_FUNC) { + continue; + } + + wasm_function_inst_t func = + wasm_runtime_lookup_function(inst, export_type.name); + if (!func) { + std::cout << "Failed to lookup function: " << export_type.name + << std::endl; + continue; + } + + wasm_func_type_t func_type = export_type.u.func_type; + uint32_t param_count = wasm_func_type_get_param_count(func_type); + + /* build arguments */ + std::vector args; + for (unsigned p_i = 0; p_i < param_count; p_i++) { + wasm_valkind_t param_type = + wasm_func_type_get_param_valkind(func_type, p_i); + + if (!is_supported_val_kind(param_type)) { + std::cout + << "Bypass execution because of unsupported value kind: " + << param_type << std::endl; + return true; + } + + wasm_val_t arg = pre_defined_val(param_type); + args.push_back(arg); + } + + /* build results storage */ + uint32_t result_count = wasm_func_type_get_result_count(func_type); + std::vector results = std::vector(result_count); + + print_execution_args(export_type, args, param_count); + + /* execute the function */ + wasm_exec_env_t exec_env = wasm_runtime_get_exec_env_singleton(inst); + if (!exec_env) { + std::cout << "Failed to get exec env" << std::endl; + return false; + } + + bool ret = wasm_runtime_call_wasm_a(exec_env, func, result_count, + results.data(), param_count, args.data()); + if (!ret) { + const char *exception = wasm_runtime_get_exception(inst); + if (!exception) { + std::cout << "[EXECUTION] " << export_type.name + << "() failed. No exception info." << std::endl; + } + else { + std::cout << "[EXECUTION] " << export_type.name << "() failed. " + << exception << std::endl; + } + } + + wasm_runtime_clear_exception(inst); + } + + return true; +} + extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { @@ -43,7 +186,7 @@ LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) return 0; } - std::cout << "PASS" << std::endl; + execute_export_functions(module, inst); wasm_runtime_deinstantiate(inst); wasm_runtime_unload(module); From e6a47d5ceea40cbcb7bffb1dcd89cdb776d8ceae Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:48:53 +0800 Subject: [PATCH 028/198] In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064) fix enlarge 65536 pages conversion overflow in wasm32 --- core/iwasm/common/wasm_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 4f3d8689f..d4ec6158f 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -1389,7 +1389,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module, if (full_size_mmaped) { #ifdef BH_PLATFORM_WINDOWS if (!os_mem_commit(memory->memory_data_end, - (mem_offset_t)(total_size_new - total_size_old), + total_size_new - total_size_old, MMAP_PROT_READ | MMAP_PROT_WRITE)) { ret = false; goto return_func; @@ -1397,12 +1397,12 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module, #endif if (os_mprotect(memory->memory_data_end, - (mem_offset_t)(total_size_new - total_size_old), + total_size_new - total_size_old, MMAP_PROT_READ | MMAP_PROT_WRITE) != 0) { #ifdef BH_PLATFORM_WINDOWS os_mem_decommit(memory->memory_data_end, - (mem_offset_t)(total_size_new - total_size_old)); + total_size_new - total_size_old); #endif ret = false; goto return_func; From 7b724e23821567464a86cac950d3d2fe284c26db Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 6 Feb 2025 20:05:33 +0800 Subject: [PATCH 029/198] fix(aot): ensure value_cmp does not exceed br_count in branch table compilation (#4065) --- core/iwasm/compilation/aot_emit_control.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/iwasm/compilation/aot_emit_control.c b/core/iwasm/compilation/aot_emit_control.c index 1c50fe75f..80e379513 100644 --- a/core/iwasm/compilation/aot_emit_control.c +++ b/core/iwasm/compilation/aot_emit_control.c @@ -1218,6 +1218,28 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, return aot_handle_next_reachable_block(comp_ctx, func_ctx, p_frame_ip); } + /* + * if (value_cmp > br_count) + * value_cmp = br_count; + */ + LLVMValueRef br_count_value = I32_CONST(br_count); + CHECK_LLVM_CONST(br_count_value); + + LLVMValueRef clap_value_cmp_cond = + LLVMBuildICmp(comp_ctx->builder, LLVMIntUGT, value_cmp, br_count_value, + "cmp_w_br_count"); + if (!clap_value_cmp_cond) { + aot_set_last_error("llvm build icmp failed."); + return false; + } + + value_cmp = LLVMBuildSelect(comp_ctx->builder, clap_value_cmp_cond, + br_count_value, value_cmp, "clap_value_cmp"); + if (!value_cmp) { + aot_set_last_error("llvm build select failed."); + return false; + } + if (!LLVMIsEfficientConstInt(value_cmp)) { if (comp_ctx->aot_frame) { if (comp_ctx->enable_gc From aa05360a209a1d0a995eb162d92978e973a25eb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 06:49:09 +0800 Subject: [PATCH 030/198] build(deps): Bump github/codeql-action from 3.28.8 to 3.28.9 (#4074) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.8 to 3.28.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.8...v3.28.9) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a98d5f1a9..0c3a2ad15 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.8 + uses: github/codeql-action/init@v3.28.9 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.8 + uses: github/codeql-action/analyze@v3.28.9 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.8 + uses: github/codeql-action/upload-sarif@v3.28.9 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 4c743d2ec..f373e1b0b 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@0701025a8b1600e416be4f3bb5a830b1aa6af01e # v2.2.4 + uses: github/codeql-action/upload-sarif@0a35e8f6866a39b001e5f7ad1d0daf9836786896 # v2.2.4 with: sarif_file: results.sarif From 1465c3c0eb9760cbad5427e46463db9ea4278223 Mon Sep 17 00:00:00 2001 From: yangkun27 Date: Fri, 14 Feb 2025 16:13:00 +0800 Subject: [PATCH 031/198] Unit test:type matching issue and code redundancy (#4079) --- tests/unit/interpreter/interpreter_test.cc | 2 +- tests/unit/wasm-vm/wasm_vm.cc | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/unit/interpreter/interpreter_test.cc b/tests/unit/interpreter/interpreter_test.cc index e9fa8f9e1..af00020c9 100644 --- a/tests/unit/interpreter/interpreter_test.cc +++ b/tests/unit/interpreter/interpreter_test.cc @@ -45,6 +45,6 @@ TEST_F(InterpreterTest, wasm_runtime_is_built_in_module) bool ret = wasm_runtime_is_built_in_module("env"); ASSERT_TRUE(ret); - ret = ret = wasm_runtime_is_built_in_module("env1"); + ret = wasm_runtime_is_built_in_module("env1"); ASSERT_FALSE(ret); } \ No newline at end of file diff --git a/tests/unit/wasm-vm/wasm_vm.cc b/tests/unit/wasm-vm/wasm_vm.cc index f4f5a834d..73c2c761f 100644 --- a/tests/unit/wasm-vm/wasm_vm.cc +++ b/tests/unit/wasm-vm/wasm_vm.cc @@ -65,7 +65,7 @@ class WasmVMTest : public testing::Test TEST_F(WasmVMTest, Test_app1) { - unsigned argv[10]; + uint32 argv[10]; ASSERT_TRUE(app1_wasm != NULL); @@ -151,7 +151,7 @@ TEST_F(WasmVMTest, Test_app1) TEST_F(WasmVMTest, Test_app2) { - unsigned argv[10]; + uint32 argv[10]; /* Load module */ module = wasm_runtime_load(app2_wasm, sizeof(app2_wasm), error_buf, @@ -416,7 +416,7 @@ TEST_F(WasmVMTest, Test_app2) TEST_F(WasmVMTest, Test_app3) { - unsigned argv[10]; + uint32 argv[10]; /* Load module */ module = wasm_runtime_load(app3_wasm, sizeof(app3_wasm), error_buf, @@ -465,7 +465,6 @@ TEST_F(WasmVMTest, Test_app3) ASSERT_TRUE(buf != NULL); ASSERT_EQ(wasm_runtime_addr_native_to_app(module_inst, buf), argv[0]); - int32 buf_offset = argv[0]; /* call my_malloc */ func_inst = wasm_runtime_lookup_function(module_inst, "my_malloc"); @@ -482,7 +481,6 @@ TEST_F(WasmVMTest, Test_app3) ASSERT_TRUE(buf1 != NULL); ASSERT_EQ(wasm_runtime_addr_native_to_app(module_inst, buf1), argv[0]); - int32 buf_offset1 = argv[0]; wasm_runtime_deinstantiate(module_inst); wasm_runtime_unload(module); @@ -526,7 +524,7 @@ TEST_F(WasmVMTest, Test_app4_single) uint8 *buffer = NULL; uint32 buffer_size = 0; bool ret = false; - unsigned argv[10]; + uint32 argv[10]; wasm_runtime_set_module_reader(&module_reader_callback, &module_destroyer_callback); @@ -584,7 +582,7 @@ TEST_F(WasmVMTest, Test_app4_plus_one) uint8 *buffer = NULL; uint32 buffer_size = 0; bool ret = false; - uint32_t argv[10] = { 0 }; + uint32 argv[10] = { 0 }; wasm_runtime_set_module_reader(&module_reader_callback, &module_destroyer_callback); From 71bc3c2d15268b2a92a1e8e60b3f7823f7727140 Mon Sep 17 00:00:00 2001 From: yangkun27 Date: Fri, 14 Feb 2025 16:13:15 +0800 Subject: [PATCH 032/198] Add a conditional check for the macro __STDC_VERSION__ (#4080) --- core/iwasm/include/wasm_c_api.h | 2 +- core/shared/utils/bh_assert.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/include/wasm_c_api.h b/core/iwasm/include/wasm_c_api.h index 9fc460148..241a0eec8 100644 --- a/core/iwasm/include/wasm_c_api.h +++ b/core/iwasm/include/wasm_c_api.h @@ -46,7 +46,7 @@ extern "C" { // Auxiliaries // Machine types -#if (__STDC_VERSION__) > 199901L +#if defined(__STDC_VERSION__) && (__STDC_VERSION__) > 199901L inline void assertions(void) { static_assert(sizeof(float) == sizeof(uint32_t), "incompatible float type"); static_assert(sizeof(double) == sizeof(uint64_t), "incompatible double type"); diff --git a/core/shared/utils/bh_assert.h b/core/shared/utils/bh_assert.h index b7c995af8..ec9e632af 100644 --- a/core/shared/utils/bh_assert.h +++ b/core/shared/utils/bh_assert.h @@ -26,7 +26,7 @@ bh_assert_internal(int64 v, const char *file_name, int line_number, #define __has_extension(a) 0 #endif -#if __STDC_VERSION__ >= 201112L \ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \ || (defined(__GNUC__) && __GNUC__ * 0x100 + __GNUC_MINOR__ >= 0x406) \ || __has_extension(c_static_assert) From 46904dce0fb19b4a8f543991d4df59ce96996beb Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Fri, 14 Feb 2025 16:15:45 +0800 Subject: [PATCH 033/198] build_llvm.py: Allow to build xtensa target on non-xtensa host Signed-off-by: Huang Qi --- build-scripts/build_llvm.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index ec6bb3954..d44afd7ba 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -117,12 +117,6 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl LLVM_EXTRA_COMPILE_OPTIONS["arc"] ) - if platform != "Xtensa" and "Xtensa" in backends: - print( - "Currently it's not supported to build Xtensa backend on non-Xtensa platform" - ) - return None - LLVM_PROJECTS_TO_BUILD = [ '-DLLVM_ENABLE_PROJECTS:STRING="' + ";".join(projects) + '"' if projects else "" ] From d86bd7c0bc5887c47f260f0762c7ff787f7b3dd3 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Sat, 15 Feb 2025 16:25:06 +0800 Subject: [PATCH 034/198] fix(build_llvm.py): clean up whitespace and formatting in build script Signed-off-by: Huang Qi --- build-scripts/build_llvm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index d44afd7ba..d8bcbd26c 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -112,7 +112,7 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl ] # if not on ARC platform, but want to add expeirmental backend ARC as target - if platform != "ARC" and "ARC" in backends: + if platform != "ARC" and "ARC" in backends: LLVM_TARGETS_TO_BUILD.extend( LLVM_EXTRA_COMPILE_OPTIONS["arc"] ) @@ -211,11 +211,11 @@ def repackage_llvm_windows(llvm_dir): if not packs_path: raise Exception("Didn't find any LLVM-* package") return - + llvm_package_path = f"_CPack_Packages/win64/NSIS/{packs_path[0].name}" windows_package_dir = build_dir.joinpath(llvm_package_path).resolve() - # mv package dir outside of build + # mv package dir outside of build shutil.move(str(windows_package_dir), str(llvm_dir)) # rm -r build shutil.rmtree(str(build_dir)) @@ -225,7 +225,7 @@ def repackage_llvm_windows(llvm_dir): moved_package_dir = llvm_dir.joinpath(packs_path[0].name) for sub_dir in moved_package_dir.iterdir(): shutil.move(str(sub_dir), str(build_dir)) - moved_package_dir.rmdir() + moved_package_dir.rmdir() def main(): parser = argparse.ArgumentParser(description="build necessary LLVM libraries") From 159f5890a6fada41955d301205c97a7fcb75850f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Mon, 17 Feb 2025 04:55:58 +0100 Subject: [PATCH 035/198] [gc] Subtyping fix (#4075) --- core/iwasm/common/gc/gc_type.c | 22 +++++++++++++--------- core/iwasm/interpreter/wasm_loader.c | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/iwasm/common/gc/gc_type.c b/core/iwasm/common/gc/gc_type.c index c9e6d206e..bafa3c86c 100644 --- a/core/iwasm/common/gc/gc_type.c +++ b/core/iwasm/common/gc/gc_type.c @@ -1145,6 +1145,14 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1, return true; else { int32 heap_type = ref_type1->ref_ht_common.heap_type; + // We dont care whether type2 is nullable or not. So + // we normalize it into its related one-byte type. + if (type2 == REF_TYPE_HT_NULLABLE + || type2 == REF_TYPE_HT_NON_NULLABLE) { + bh_assert(ref_type2); + type2 = (uint8)(ref_type2->ref_ht_common.heap_type + + REF_TYPE_FUNCREF - HEAP_TYPE_FUNC); + } if (heap_type == HEAP_TYPE_ANY) { /* (ref any) <: anyref */ return type2 == REF_TYPE_ANYREF ? true : false; @@ -1188,19 +1196,15 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1, } #endif else if (heap_type == HEAP_TYPE_NONE) { - /* (ref none) */ - /* TODO */ - bh_assert(0); + return wasm_is_reftype_supers_of_none(type2, NULL, types, + type_count); } else if (heap_type == HEAP_TYPE_NOEXTERN) { - /* (ref noextern) */ - /* TODO */ - bh_assert(0); + return wasm_is_reftype_supers_of_noextern(type2); } else if (heap_type == HEAP_TYPE_NOFUNC) { - /* (ref nofunc) */ - /* TODO */ - bh_assert(0); + return wasm_is_reftype_supers_of_nofunc(type2, NULL, types, + type_count); } else { bh_assert(0); diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 559d1c33e..e72bf94fa 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -246,7 +246,7 @@ type2str(uint8 type) "", /* reserved */ "arrayref", "structref", - "i32ref", + "i31ref", "eqref", "anyref", "externref", From 964037c9b5756d4034aae6d730325ed0ef19301e Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 17 Feb 2025 13:34:18 +0800 Subject: [PATCH 036/198] feat: add support for EXTERNREF value type and enable AOT validator in fuzz tests (#4083) --- core/iwasm/common/wasm_runtime_common.c | 3 ++- tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 2 ++ tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index cc6badd9e..95cea7fe9 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -4458,8 +4458,9 @@ wasm_func_type_get_param_valkind(WASMFuncType *const func_type, return WASM_V128; case VALUE_TYPE_FUNCREF: return WASM_FUNCREF; - case VALUE_TYPE_EXTERNREF: + return WASM_EXTERNREF; + case VALUE_TYPE_VOID: default: { diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index 6177d27e7..c0c7622c9 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -119,6 +119,8 @@ endif () # sanitizer may use kHandleSignalExclusive to handle SIGSEGV # like `UBSAN_OPTIONS=handle_segv=2:...` set (WAMR_DISABLE_HW_BOUND_CHECK 1) +# Enable aot validator +set (WAMR_BUILD_AOT_VALIDATOR 1) set (REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) message([ceith]:REPO_ROOT_DIR, ${REPO_ROOT_DIR}) diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc b/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc index 4b3d8d942..391d899cf 100644 --- a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc +++ b/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc @@ -136,8 +136,9 @@ execute_export_functions(wasm_module_t module, wasm_module_inst_t inst) return false; } - bool ret = wasm_runtime_call_wasm_a(exec_env, func, result_count, - results.data(), param_count, args.data()); + bool ret = + wasm_runtime_call_wasm_a(exec_env, func, result_count, + results.data(), param_count, args.data()); if (!ret) { const char *exception = wasm_runtime_get_exception(inst); if (!exception) { From 45db4ba2ee6b343f099eafaebe44a6cb5179e413 Mon Sep 17 00:00:00 2001 From: peter-tatrai Date: Mon, 17 Feb 2025 06:34:40 +0100 Subject: [PATCH 037/198] fix(unit-test): libc_builtin_test issues (#4073) - uninitialized buffer pointers (crashes) - match integer constant size with printf specifier Signed-off-by: Peter Tatrai --- tests/unit/libc-builtin/libc_builtin_test.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/libc-builtin/libc_builtin_test.cc b/tests/unit/libc-builtin/libc_builtin_test.cc index 6598f7a8b..f4f02bff6 100644 --- a/tests/unit/libc-builtin/libc_builtin_test.cc +++ b/tests/unit/libc-builtin/libc_builtin_test.cc @@ -185,7 +185,7 @@ TEST_F(LibcBuiltinTest, printf) va_list.add(20); //%zd va_list.add(20); //%ld - va_list.add(20L); //%jd + va_list.add(intmax_t(20)); //%jd testing::internal::CaptureStdout(); @@ -323,7 +323,7 @@ TEST_F(LibcBuiltinTest, printf) TEST_F(LibcBuiltinTest, sprintf) { - const char *buf; + char buf[200] = {0}; const char *str = "Hello Wrold"; const char *str_sig = "c"; const char *str_f = "20, 3.140000, Hello World"; @@ -508,7 +508,7 @@ TEST_F(LibcBuiltinTest, memcmp) TEST_F(LibcBuiltinTest, memcpy) { const char *src = "Hell World"; - char *dest; + char dest[sizeof(src)] = {0}; AppData src_app{ dummy_exec_env.get(), src }; AppData dest_app{ dummy_exec_env.get(), dest }; @@ -535,7 +535,7 @@ TEST_F(LibcBuiltinTest, memcpy) TEST_F(LibcBuiltinTest, memmove) { const char *src = "Hell World"; - char *dest; + char dest[sizeof(src)] = {0}; AppData src_app{ dummy_exec_env.get(), src }; AppData dest_app{ dummy_exec_env.get(), dest }; @@ -673,7 +673,7 @@ TEST_F(LibcBuiltinTest, strncmp) TEST_F(LibcBuiltinTest, strcpy) { char *src = (char *)"Hello World!"; - char *dest; + char dest[sizeof(src)] = {0}; AppData src_app{ dummy_exec_env.get(), src }; AppData dest_app{ dummy_exec_env.get(), dest }; @@ -696,7 +696,7 @@ TEST_F(LibcBuiltinTest, strcpy) TEST_F(LibcBuiltinTest, strncpy) { char *src = (char *)"Hello World!"; - char *dest; + char dest[sizeof(src)] = {0}; AppData src_app{ dummy_exec_env.get(), src }; AppData dest_app{ dummy_exec_env.get(), dest }; @@ -1295,7 +1295,7 @@ TEST_F(LibcBuiltinTest, isalnum) TEST_F(LibcBuiltinTest, emscripten_memcpy_big) { const char *src = "Hell World"; - char *dest; + char dest[sizeof(src)] = {0}; AppData src_app{ dummy_exec_env.get(), src }; AppData dest_app{ dummy_exec_env.get(), dest }; From ff10b8693801e4cc7f8cf8b381a0da578513c4e8 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 17 Feb 2025 12:23:04 +0800 Subject: [PATCH 038/198] fix(build_llvm_libraries.yml): Correct script path for build_llvm.py Signed-off-by: Huang Qi --- .github/workflows/build_llvm_libraries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_llvm_libraries.yml b/.github/workflows/build_llvm_libraries.yml index bdfd4fcb2..e4b7732bc 100644 --- a/.github/workflows/build_llvm_libraries.yml +++ b/.github/workflows/build_llvm_libraries.yml @@ -65,6 +65,7 @@ jobs: shell: bash run: | echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT + working-directory: build-scripts # Bump the prefix number to evict all previous caches and # enforce a clean build, in the unlikely case that some From d0e2a7271c877ac3f6955500386bf49c1ee326ee Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 21 Feb 2025 07:46:20 +0800 Subject: [PATCH 039/198] fix(aot_emit_aot_file): prevent buffer emission for zero byte_count (#4095) if using a debug building of wamrc to run spec test. there will be: core/iwasm/compilation/aot_emit_aot_file.c:1794:13: runtime error: null pointer passed as argument 2, which is declared to never be null --- core/iwasm/compilation/aot_emit_aot_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index 9b2436a2b..cfb27fdeb 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -1790,7 +1790,9 @@ aot_emit_mem_info(uint8 *buf, uint8 *buf_end, uint32 *p_offset, &init_datas[i]->offset)) return false; EMIT_U32(init_datas[i]->byte_count); - EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count); + if (init_datas[i]->byte_count) { + EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count); + } } if (offset - *p_offset != get_mem_info_size(comp_ctx, comp_data)) { From f2ef9ee62ed471aab99dea798bf935aefaff7c25 Mon Sep 17 00:00:00 2001 From: peter-tatrai Date: Fri, 21 Feb 2025 08:29:49 +0100 Subject: [PATCH 040/198] Cmake improvements (#4076) - Utilizes the standard CMake variable BUILD_SHARED_LIBS to simplify the CMake configuration. - Allows the use of a single library definition for both static and shared library cases, improving maintainability and readability of the CMake configuration. - Install vmlib public header files - Installs the public header files for the vmlib target to the include/iwasm directory. - Install cmake package - Adds the necessary CMake configuration files (iwasmConfig.cmake and iwasmConfigVersion.cmake). - Configures the installation of these files to the appropriate directory (lib/cmake/iwasm). - Ensures compatibility with the same major version. - Improve windows product-mini CMakeLists.txt - Fix missing symbols when linking windows product-mini with shared vmlib - Improve Darwin product-mini CMakeLists.txt --------- Signed-off-by: Peter Tatrai --- CMakeLists.txt | 88 +++++++------------ build-scripts/config_common.cmake | 5 ++ build-scripts/iwasmConfig.cmake.in | 6 ++ build-scripts/package.cmake | 28 ++++++ product-mini/platforms/darwin/CMakeLists.txt | 37 +++++--- product-mini/platforms/linux/CMakeLists.txt | 52 ++++++----- product-mini/platforms/windows/CMakeLists.txt | 56 +++++++----- 7 files changed, 163 insertions(+), 109 deletions(-) create mode 100644 build-scripts/iwasmConfig.cmake.in create mode 100644 build-scripts/package.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6362d0e56..e52c86cf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required (VERSION 3.0) +option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) + if(ESP_PLATFORM) include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt) return() @@ -18,13 +20,6 @@ if (NOT DEFINED WAMR_BUILD_PLATFORM) string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) endif () -if (NOT DEFINED WAMR_BUILD_STATIC) - set (WAMR_BUILD_STATIC 1) -endif () -if (NOT DEFINED WAMR_BUILD_SHARED) - set (WAMR_BUILD_SHARED 1) -endif () - # Reset default linker flags set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") @@ -156,55 +151,40 @@ if (MSVC) add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) endif () -# STATIC LIBRARY -if (WAMR_BUILD_STATIC) - add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE}) - set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib) - target_include_directories(iwasm_static INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include) - target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT}) - if (WAMR_BUILD_WASM_CACHE EQUAL 1) - target_link_libraries(iwasm_static INTERFACE boringssl_crypto) - endif () +add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm) +target_include_directories(vmlib INTERFACE + $ + $ +) - if (MINGW) - target_link_libraries (iwasm_static PRIVATE ws2_32) - endif () - - if (WIN32) - target_link_libraries(iwasm_static PRIVATE ntdll) - endif() - - set_version_info (iwasm_static) - install (TARGETS iwasm_static ARCHIVE DESTINATION lib) +target_link_libraries (vmlib PUBLIC ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT}) +if (WAMR_BUILD_WASM_CACHE EQUAL 1) + target_link_libraries(vmlib INTERFACE boringssl_crypto) endif () -# SHARED LIBRARY -if (WAMR_BUILD_SHARED) - add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE}) - set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm) - target_include_directories(iwasm_shared INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include) - target_link_libraries (iwasm_shared PUBLIC ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT}) - if (WAMR_BUILD_WASM_CACHE EQUAL 1) - target_link_libraries(iwasm_shared INTERFACE boringssl_crypto) - endif () - - if (MINGW) - target_link_libraries(iwasm_shared INTERFACE -lWs2_32 -lwsock32) - target_link_libraries(iwasm_shared PRIVATE ws2_32) - endif () - - if (WIN32) - target_link_libraries(iwasm_shared PRIVATE ntdll) - endif() - - set_version_info (iwasm_shared) - install (TARGETS iwasm_shared LIBRARY DESTINATION lib) +if (MINGW) + target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32) + target_link_libraries(vmlib PRIVATE ws2_32) endif () -# HEADERS -install (FILES - ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h - ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h - ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h - ${WAMR_ROOT_DIR}/core/version.h - DESTINATION include) +if (WIN32) + target_link_libraries(vmlib PRIVATE ntdll) +endif() + +set (WAMR_PUBLIC_HEADERS + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h + ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h +) +set_target_properties (vmlib PROPERTIES PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}") + +set_version_info (vmlib) + +install (TARGETS vmlib + EXPORT iwasmTargets + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include/iwasm +) + +install_iwasm_package () diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 88abf7324..614830094 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -134,6 +134,9 @@ endif () # Version include (${WAMR_ROOT_DIR}/build-scripts/version.cmake) +# Package +include (${WAMR_ROOT_DIR}/build-scripts/package.cmake) + # Sanitizers if (NOT DEFINED WAMR_BUILD_SANITIZER) @@ -211,7 +214,9 @@ endif () message ("-- Build Configurations:") message (" Build as target ${WAMR_BUILD_TARGET}") +message (" Build for platform ${WAMR_BUILD_PLATFORM}") message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE}) +message (" BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS}) ################## running mode ################## if (WAMR_BUILD_INTERP EQUAL 1) message (" WAMR Interpreter enabled") diff --git a/build-scripts/iwasmConfig.cmake.in b/build-scripts/iwasmConfig.cmake.in new file mode 100644 index 000000000..05ec5a8cd --- /dev/null +++ b/build-scripts/iwasmConfig.cmake.in @@ -0,0 +1,6 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/iwasmTargets.cmake") diff --git a/build-scripts/package.cmake b/build-scripts/package.cmake new file mode 100644 index 000000000..4ebb1d799 --- /dev/null +++ b/build-scripts/package.cmake @@ -0,0 +1,28 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +function(install_iwasm_package) + install (EXPORT iwasmTargets + FILE iwasmTargets.cmake + NAMESPACE iwasm:: + DESTINATION lib/cmake/iwasm + ) + + include (CMakePackageConfigHelpers) + configure_package_config_file (${CMAKE_CURRENT_FUNCTION_LIST_DIR}/iwasmConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake" + INSTALL_DESTINATION lib/cmake/iwasm + ) + + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake" + VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH} + COMPATIBILITY SameMajorVersion + ) + + install (FILES + "${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake" + DESTINATION lib/cmake/iwasm + ) +endfunction() diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index 1f955a10b..594110a44 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -1,10 +1,12 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (iwasm) +option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) + set (WAMR_BUILD_PLATFORM "darwin") # Reset default linker flags @@ -115,9 +117,6 @@ set (CMAKE_MACOSX_RPATH True) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) -add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) -set_version_info (vmlib) - include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) @@ -126,15 +125,33 @@ set_version_info (iwasm) install (TARGETS iwasm DESTINATION bin) -target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) +target_link_libraries (iwasm vmlib) -add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) -install (TARGETS libiwasm DESTINATION lib) +set_version_info (vmlib) -set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) +target_include_directories(vmlib INTERFACE + $ +) -set_version_info (libiwasm) +set (WAMR_PUBLIC_HEADERS + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h + ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h +) -target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) +set_target_properties (vmlib PROPERTIES + OUTPUT_NAME iwasm + PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}" +) +target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) + +install (TARGETS vmlib + EXPORT iwasmTargets + DESTINATION lib + PUBLIC_HEADER DESTINATION include/iwasm +) + +install_iwasm_package () diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt index 527d18035..be0c57ede 100644 --- a/product-mini/platforms/linux/CMakeLists.txt +++ b/product-mini/platforms/linux/CMakeLists.txt @@ -7,6 +7,8 @@ include(CheckPIESupported) project (iwasm) +option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) + set (CMAKE_VERBOSE_MAKEFILE OFF) set (WAMR_BUILD_PLATFORM "linux") @@ -126,13 +128,7 @@ endif () # if enable wasi-nn, both wasi-nn-backends and iwasm # need to use same WAMR (dynamic) libraries if (WAMR_BUILD_WASI_NN EQUAL 1) - set (WAMR_BUILD_SHARED 1) -endif () - -if (NOT DEFINED WAMR_BUILD_SHARED) - set (WAMR_BUILD_SHARED 0) -elseif (WAMR_BUILD_SHARED EQUAL 1) - message ("build WAMR as shared libraries") + set (BUILD_SHARED_LIBS ON) endif () set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) @@ -140,9 +136,6 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) check_pie_supported() -add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) -set_target_properties (vmlib PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_version_info (vmlib) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") @@ -175,23 +168,36 @@ set_version_info (iwasm) set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(iwasm - $<$:libiwasm> $<$>:vmlib> - ${LLVM_AVAILABLE_LIBS} - ${UV_A_LIBS} - -lm - -ldl - -lpthread -) +target_link_libraries(iwasm vmlib) install (TARGETS iwasm DESTINATION bin) -add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) -set_version_info (libiwasm) +set_version_info (vmlib) -install (TARGETS libiwasm DESTINATION lib) +target_include_directories(vmlib INTERFACE + $ +) -set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) +set (WAMR_PUBLIC_HEADERS + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h + ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h +) -target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) +set_target_properties (vmlib PROPERTIES + OUTPUT_NAME iwasm + PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}" + POSITION_INDEPENDENT_CODE ON +) + +target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) + +install (TARGETS vmlib + EXPORT iwasmTargets + DESTINATION lib + PUBLIC_HEADER DESTINATION include/iwasm +) + +install_iwasm_package () diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index ff438ee8c..5fcc276a1 100644 --- a/product-mini/platforms/windows/CMakeLists.txt +++ b/product-mini/platforms/windows/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required (VERSION 2.9) project (iwasm C ASM CXX) # set (CMAKE_VERBOSE_MAKEFILE 1) +option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) + set (WAMR_BUILD_PLATFORM "windows") # Reset default linker flags @@ -105,8 +107,6 @@ endif() set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) -add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) -set_version_info(vmlib) #set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN") if (NOT MINGW) @@ -133,34 +133,46 @@ endif () include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) -add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) +add_executable (iwasm main.c ${PLATFORM_SHARED_SOURCE} ${UNCOMMON_SHARED_SOURCE} ${UTILS_SHARED_SOURCE}) set_version_info (iwasm) install (TARGETS iwasm DESTINATION bin) -target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS}) +target_link_libraries (iwasm vmlib) +add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +set_version_info (vmlib) + +target_include_directories(vmlib INTERFACE + $ +) + +set (WAMR_PUBLIC_HEADERS + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h + ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h + ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h +) + +set_target_properties (vmlib PROPERTIES + OUTPUT_NAME libiwasm + PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}" + POSITION_INDEPENDENT_CODE ON +) + +target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS}) if (MINGW) - target_link_libraries (iwasm ws2_32) -endif () - -add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) - -set_version_info (libiwasm) - -install (TARGETS libiwasm DESTINATION lib) - -set_target_properties (libiwasm PROPERTIES OUTPUT_NAME libiwasm) - -target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS}) - -if (MINGW) - target_link_libraries (libiwasm ws2_32) + target_link_libraries (vmlib ws2_32) endif () if (WIN32) - target_link_libraries(libiwasm ntdll) - - target_link_libraries(iwasm ntdll) + target_link_libraries(vmlib ntdll) endif() + +install (TARGETS vmlib + EXPORT iwasmTargets + DESTINATION lib + PUBLIC_HEADER DESTINATION include/iwasm +) + +install_iwasm_package () From d9c01b39d11a068558363b20be39c7364d871322 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 21 Feb 2025 15:33:36 +0800 Subject: [PATCH 041/198] fix: when load aot init expr,no type_idx set. (#4094) Fix an assertion from *gc_object.c line 91* `bh_assert(rtt_type->type_flag == WASM_TYPE_STRUCT;` --- core/iwasm/aot/aot_loader.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 97360e73e..0ba3de7bd 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -1251,6 +1251,7 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, } free_if_fail = true; init_values->count = field_count; + init_values->type_idx = type_idx; expr->u.data = init_values; if (type_idx >= module->type_count) { From 32338bb7d6564064b84bbbb775178d49962de515 Mon Sep 17 00:00:00 2001 From: "Georgii Rylov :slightly_smiling_face" Date: Mon, 24 Feb 2025 17:22:05 +0000 Subject: [PATCH 042/198] Copy read only API behind a flag instead of using user defined callback --- CMakeLists.txt | 5 ++ build-scripts/config_common.cmake | 8 +++ core/iwasm/aot/aot_runtime.c | 70 ++++++++++++++++--------- core/iwasm/aot/aot_runtime.h | 10 ++-- core/iwasm/common/wasm_runtime_common.c | 19 ++++--- core/iwasm/common/wasm_runtime_common.h | 23 +++----- core/iwasm/include/wasm_export.h | 41 ++++++++++----- core/iwasm/interpreter/wasm_runtime.c | 46 ++++++++++------ core/iwasm/interpreter/wasm_runtime.h | 10 ++-- 9 files changed, 143 insertions(+), 89 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6362d0e56..287559ff1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,11 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS) set (WAMR_BUILD_LIB_WASI_THREADS 0) endif () +if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK) + # Disable copy callstack by default + set (WAMR_ENABLE_COPY_CALLSTACK 0) +endif() + if (NOT DEFINED WAMR_BUILD_MINI_LOADER) # Disable wasm mini loader by default set (WAMR_BUILD_MINI_LOADER 0) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 88abf7324..c7cfff842 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -319,6 +319,14 @@ if (WAMR_BUILD_SHARED_HEAP EQUAL 1) message (" Shared heap enabled") endif() +if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1) + add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1) + message(" Copy callstack enabled") +else () + add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0) + message(" Copy callstack disabled") +endif() + if (WAMR_BUILD_MEMORY64 EQUAL 1) # if native is 32-bit or cross-compiled to 32-bit if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*") diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index f5a135be9..0cd53e4a5 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4103,11 +4103,11 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) } #endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */ -#if WASM_ENABLE_DUMP_CALL_STACK != 0 -void -aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, - void *user_data) +#if WAMR_ENABLE_COPY_CALLSTACK != 0 +uint32 +aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, + const uint32 length, + const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of @@ -4122,35 +4122,43 @@ aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, uint8 *top = exec_env->wasm_stack.top; uint8 *bottom = exec_env->wasm_stack.bottom; + uint32 count = 0; + bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); if (!is_top_index_in_range) { - return; + return count; } bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; if (!is_top_aligned_with_bottom) { - return; + return count; } AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame)); WASMCApiFrame record_frame; - while (frame && (uint8_t *)frame >= bottom) { + while (frame && (uint8_t *)frame >= bottom + && count < (skip_n + length)) { + if (count < skip_n) { + ++count; + frame -= 1; + continue; + } record_frame.instance = exec_env->module_inst; record_frame.module_offset = 0; record_frame.func_index = frame->func_index; record_frame.func_offset = frame->ip_offset; - if (!frame_handler(user_data, &record_frame)) { - break; - } + buffer[count - skip_n] = record_frame; frame -= 1; + ++count; } + return count; } -void -aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, - void *user_data) +uint32 +aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, + const uint32 length, + const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of @@ -4169,17 +4177,24 @@ aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, uint8 *bottom = exec_env->wasm_stack.bottom; uint32 frame_size = (uint32)offsetof(AOTFrame, lp); + uint32 count = 0; + WASMCApiFrame record_frame; while (cur_frame && (uint8_t *)cur_frame >= bottom - && (uint8_t *)cur_frame + frame_size <= top_boundary) { + && (uint8_t *)cur_frame + frame_size <= top_boundary + && count < (skip_n + length)) { + if (count < skip_n) { + ++count; + cur_frame = cur_frame->prev_frame; + continue; + } record_frame.instance = module_inst; record_frame.module_offset = 0; record_frame.func_index = (uint32)cur_frame->func_index; record_frame.func_offset = (uint32)cur_frame->ip_offset; - if (!frame_handler(user_data, &record_frame)) { - break; - } + buffer[count - skip_n] = record_frame; cur_frame = cur_frame->prev_frame; + ++count; } #else /* @@ -4189,9 +4204,11 @@ aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, #endif } -void -aot_iterate_callstack(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, void *user_data) + +uint32 +aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, + const uint32 length, + const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of @@ -4203,14 +4220,15 @@ aot_iterate_callstack(WASMExecEnv *exec_env, * wasm_export.h */ if (!is_tiny_frame(exec_env)) { - aot_iterate_callstack_standard_frame(exec_env, frame_handler, - user_data); + return aot_copy_callstack_standard_frame(exec_env, buffer, length, skip_n); } else { - aot_iterate_callstack_tiny_frame(exec_env, frame_handler, user_data); + return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n); } } +#endif // WAMR_ENABLE_COPY_CALLSTACK +#if WASM_ENABLE_DUMP_CALL_STACK != 0 bool aot_create_call_stack(struct WASMExecEnv *exec_env) { @@ -4391,7 +4409,7 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len) return total_len + 1; } -#endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 */ +#endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 && WASM_ENABLE_AOT_STACK_FRAME != 0 */ #if WASM_ENABLE_PERF_PROFILING != 0 void diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index 7a26be3ea..0cc66c4b6 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -10,6 +10,7 @@ #include "../common/wasm_runtime_common.h" #include "../interpreter/wasm_runtime.h" #include "../compilation/aot.h" +#include "platform_common.h" #if WASM_ENABLE_GC != 0 #include "gc_export.h" #endif @@ -777,9 +778,12 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame); bool aot_create_call_stack(struct WASMExecEnv *exec_env); -void -aot_iterate_callstack(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, void *user_data); +#if WAMR_ENABLE_COPY_CALLSTACK != 0 +uint32 +aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, + const uint32 length, + const uint32 skip_n); +#endif // WAMR_ENABLE_COPY_CALLSTACK /** * @brief Dump wasm call stack or get the size diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 7046c3b1a..8d04f3799 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -7,6 +7,7 @@ #include "bh_common.h" #include "bh_assert.h" #include "bh_log.h" +#include "platform_common.h" #include "wasm_export.h" #include "wasm_native.h" #include "wasm_runtime_common.h" @@ -1741,18 +1742,19 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env) wasm_exec_env_destroy(exec_env); } -void -wasm_iterate_callstack(const wasm_exec_env_t exec_env, - const wasm_frame_callback frame_callback, - void *user_data) +#if WAMR_ENABLE_COPY_CALLSTACK != 0 +uint32 +wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, + const uint32 length, + const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of - * wasm_iterate_callstack to preserve async-signal-safety + * wasm_copy_callstack to preserve async-signal-safety * - any allocations/freeing memory * - dereferencing any pointers other than: exec_env, exec_env->module_inst, * exec_env->module_inst->module, pointers between stack's bottom and - * top_boundary For more details check wasm_iterate_callstack in + * top_boundary For more details check wasm_copy_callstack in * wasm_export.h */ #if WASM_ENABLE_DUMP_CALL_STACK @@ -1761,17 +1763,18 @@ wasm_iterate_callstack(const wasm_exec_env_t exec_env, #if WASM_ENABLE_INTERP != 0 if (module_inst->module_type == Wasm_Module_Bytecode) { - wasm_interp_iterate_callstack(exec_env, frame_callback, user_data); + return wasm_interp_copy_callstack(exec_env, buffer, length, skip_n); } #endif #if WASM_ENABLE_AOT != 0 if (module_inst->module_type == Wasm_Module_AoT) { - aot_iterate_callstack(exec_env, frame_callback, user_data); + return aot_copy_callstack(exec_env, buffer, length, skip_n); } #endif #endif } +#endif // WAMR_ENABLE_COPY_CALLSTACK bool wasm_runtime_init_thread_env(void) diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 1650615ef..19f11bd48 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -8,6 +8,7 @@ #include "bh_platform.h" #include "bh_common.h" +#include "platform_common.h" #include "wasm_exec_env.h" #include "wasm_native.h" #include "../include/wasm_export.h" @@ -464,19 +465,6 @@ typedef struct WASMRegisteredModule { typedef package_type_t PackageType; typedef wasm_section_t WASMSection, AOTSection; -typedef struct wasm_frame_t { - /* wasm_instance_t */ - void *instance; - uint32 module_offset; - uint32 func_index; - uint32 func_offset; - const char *func_name_wp; - - uint32 *sp; - uint8 *frame_ref; - uint32 *lp; -} WASMCApiFrame; - #if WASM_ENABLE_JIT != 0 typedef struct LLVMJITOptions { uint32 opt_level; @@ -652,10 +640,11 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); -WASM_RUNTIME_API_EXTERN void -wasm_iterate_callstack(const wasm_exec_env_t exec_env, - const wasm_frame_callback frame_handler, - void *user_data); +#if WAMR_ENABLE_COPY_CALLSTACK != 0 +WASM_RUNTIME_API_EXTERN uint32_t +wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, + const uint32 length, const uint32 skip_n); +#endif // WAMR_ENABLE_COPY_CALLSTACK /* See wasm_export.h for description */ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon * diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index aba7fd4ec..18a417cc9 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -126,8 +126,23 @@ typedef WASMFunctionInstanceCommon *wasm_function_inst_t; struct WASMMemoryInstance; typedef struct WASMMemoryInstance *wasm_memory_inst_t; -struct wasm_frame_t; + +typedef struct wasm_frame_t { + /* wasm_instance_t */ + void *instance; + uint32_t module_offset; + uint32_t func_index; + uint32_t func_offset; + const char *func_name_wp; + + uint32_t *sp; + uint8_t *frame_ref; + uint32_t *lp; +} WASMCApiFrame; + +// #if WAMR_ENABLE_COPY_CALLSTACK != 0 typedef struct wasm_frame_t *wasm_frame_ptr_t; +// #endif // WAMR_ENABLE_COPY_CALLSTACK /* WASM section */ typedef struct wasm_section_t { @@ -867,16 +882,10 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); -/** - * Callback to be called on wasm_frame_t*. - * It accepts void* as a context that can be used for closures. - * It returns bool so the iterating can stop when the callback returns false. - * E.g. callback that returns false after processing 100 frames - */ -typedef bool (*wasm_frame_callback)(void *, wasm_frame_ptr_t); +// #if WAMR_ENABLE_COPY_CALLSTACK != 0 /** - * @brief Iterate over callstack frames and execute callback on it. + * @brief Copy callstack frames. * * Caution: This is not a thread-safe function. Ensure the exec_env * is suspended before calling it from another thread. @@ -892,12 +901,16 @@ typedef bool (*wasm_frame_callback)(void *, wasm_frame_ptr_t); * - exec_env->module_inst->module * * @param exec_env the execution environment that containes frames - * @param callback the callback function provided by the user - * @param user_data context for callback provided by the user + * @param buffer the buffer of size equal length * sizeof(frame) to copy frames to + * @param length the number of frames to copy + * @param skip_n the number of frames to skip from the top of the stack + * + * @return number of copied frames */ -WASM_RUNTIME_API_EXTERN void -wasm_iterate_callstack(const wasm_exec_env_t exec_env, - const wasm_frame_callback callback, void *user_data); +WASM_RUNTIME_API_EXTERN uint32_t +wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, + const uint32_t length, const uint32_t skip_n); +// #endif /** * Get the singleton execution environment for the instance. diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 9dd68cca0..c616ac44b 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -6,6 +6,7 @@ #include "wasm_runtime.h" #include "wasm.h" #include "wasm_exec_env.h" +#include "wasm_export.h" #include "wasm_loader.h" #include "wasm_interp.h" #include "bh_common.h" @@ -4196,46 +4197,57 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, #endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0) \ || (WASM_ENABLE_MEMORY_TRACING != 0) */ -#if WASM_ENABLE_DUMP_CALL_STACK != 0 -void -wasm_interp_iterate_callstack(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, - void *user_data) + +#if WAMR_ENABLE_COPY_CALLSTACK != 0 +uint32 +wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, + uint32 length, uint32 skip_n) { /* - * Note for devs: please refrain from such modifications inside of - * wasm_interp_iterate_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and - * top_boundary For more details check wasm_iterate_callstack in - * wasm_export.h - */ + * Note for devs: please refrain from such modifications inside of + * wasm_interp_copy_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_copy_callstack in + * wasm_export.h + */ WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); WASMInterpFrame *cur_frame = wasm_exec_env_get_cur_frame(exec_env); uint8 *top_boundary = exec_env->wasm_stack.top_boundary; uint8 *bottom = exec_env->wasm_stack.bottom; + uint32 count = 0; + WASMCApiFrame record_frame; while (cur_frame && (uint8_t *)cur_frame >= bottom - && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) { + && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary + && count < (skip_n + length)) { if (!cur_frame->function) { cur_frame = cur_frame->prev_frame; continue; } + if (count < skip_n) { + ++count; + cur_frame = cur_frame->prev_frame; + continue; + } record_frame.instance = module_inst; record_frame.module_offset = 0; // It's safe to dereference module_inst->e because "e" is asigned only // once in wasm_instantiate record_frame.func_index = (uint32)(cur_frame->function - module_inst->e->functions); - if (!frame_handler(user_data, &record_frame)) { - break; - } + buffer[count - skip_n] = record_frame; cur_frame = cur_frame->prev_frame; + ++count; } + return count; } +#endif // WAMR_ENABLE_COPY_CALLSTACK + +#if WASM_ENABLE_DUMP_CALL_STACK != 0 bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env) diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 1b439bac1..84abf63b1 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -12,6 +12,7 @@ #include "bh_hashmap.h" #include "../common/wasm_runtime_common.h" #include "../common/wasm_exec_env.h" +#include "wasm_export.h" #ifdef __cplusplus extern "C" { @@ -731,10 +732,11 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) #if WASM_ENABLE_DUMP_CALL_STACK != 0 -void -wasm_interp_iterate_callstack(WASMExecEnv *exec_env, - const wasm_frame_callback frame_handler, - void *user_data); +#if WAMR_ENABLE_COPY_CALLSTACK != 0 +uint32 +wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, + uint32 length, uint32 skip_n); +#endif // WAMR_ENABLE_COPY_CALLSTACK bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env); From cc3f0a096bc31f95f78dda5880c7ca0c3e658865 Mon Sep 17 00:00:00 2001 From: "Georgii Rylov :slightly_smiling_face" Date: Mon, 24 Feb 2025 17:33:14 +0000 Subject: [PATCH 043/198] Cleaning up --- build-scripts/config_common.cmake | 4 ++-- core/iwasm/aot/aot_runtime.c | 6 +++--- core/iwasm/aot/aot_runtime.h | 1 - core/iwasm/common/wasm_runtime_common.c | 1 - core/iwasm/common/wasm_runtime_common.h | 1 - core/iwasm/include/wasm_export.h | 4 ---- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index c7cfff842..df71198f1 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -321,10 +321,10 @@ endif() if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1) add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1) - message(" Copy callstack enabled") + message(" Copy callstack enabled") else () add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0) - message(" Copy callstack disabled") + message(" Copy callstack disabled") endif() if (WAMR_BUILD_MEMORY64 EQUAL 1) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 0cd53e4a5..78b4b60f4 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4111,11 +4111,11 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, { /* * Note for devs: please refrain from such modifications inside of - * aot_iterate_callstack_tiny_frame + * aot_copy_callstack_tiny_frame * - any allocations/freeing memory * - dereferencing any pointers other than: exec_env, exec_env->module_inst, * exec_env->module_inst->module, pointers between stack's bottom and - * top_boundary For more details check wasm_iterate_callstack in + * top_boundary For more details check wasm_copy_callstack in * wasm_export.h */ uint8 *top_boundary = exec_env->wasm_stack.top_boundary; @@ -4409,7 +4409,7 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len) return total_len + 1; } -#endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 && WASM_ENABLE_AOT_STACK_FRAME != 0 */ +#endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 */ #if WASM_ENABLE_PERF_PROFILING != 0 void diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index 0cc66c4b6..764403f72 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -10,7 +10,6 @@ #include "../common/wasm_runtime_common.h" #include "../interpreter/wasm_runtime.h" #include "../compilation/aot.h" -#include "platform_common.h" #if WASM_ENABLE_GC != 0 #include "gc_export.h" #endif diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 8d04f3799..5ce16a14d 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -7,7 +7,6 @@ #include "bh_common.h" #include "bh_assert.h" #include "bh_log.h" -#include "platform_common.h" #include "wasm_export.h" #include "wasm_native.h" #include "wasm_runtime_common.h" diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 19f11bd48..44406cdb4 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -8,7 +8,6 @@ #include "bh_platform.h" #include "bh_common.h" -#include "platform_common.h" #include "wasm_exec_env.h" #include "wasm_native.h" #include "../include/wasm_export.h" diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index 18a417cc9..a17f13f24 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -140,9 +140,7 @@ typedef struct wasm_frame_t { uint32_t *lp; } WASMCApiFrame; -// #if WAMR_ENABLE_COPY_CALLSTACK != 0 typedef struct wasm_frame_t *wasm_frame_ptr_t; -// #endif // WAMR_ENABLE_COPY_CALLSTACK /* WASM section */ typedef struct wasm_section_t { @@ -883,7 +881,6 @@ WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); -// #if WAMR_ENABLE_COPY_CALLSTACK != 0 /** * @brief Copy callstack frames. * @@ -910,7 +907,6 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); WASM_RUNTIME_API_EXTERN uint32_t wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, const uint32_t length, const uint32_t skip_n); -// #endif /** * Get the singleton execution environment for the instance. From dfcadc62028dc610c13ff03e475e121f461def48 Mon Sep 17 00:00:00 2001 From: TL Date: Sat, 8 Feb 2025 17:18:01 +0800 Subject: [PATCH 044/198] prevent data overflow on 32 bit platform for memory.grow --- core/iwasm/common/wasm_memory.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index d4ec6158f..8e008f11b 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -1253,6 +1253,12 @@ wasm_mremap_linear_memory(void *mapped_mem, uint64 old_size, uint64 new_size, bh_assert(new_size > 0); bh_assert(new_size > old_size); +#if UINTPTR_MAX == UINT32_MAX + if (new_size == 4 * (uint64)BH_GB) { + return NULL; + } +#endif + if (mapped_mem) { new_mem = os_mremap(mapped_mem, old_size, new_size); } From 2e4ebfb20a2c5b30ae6f78d469ac72e43ba086dd Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 12 Feb 2025 16:41:34 +0800 Subject: [PATCH 045/198] cr suggestions --- .../platform/common/posix/posix_memmap.c | 21 +++++++++++++------ core/shared/platform/linux-sgx/sgx_platform.c | 10 ++++++--- core/shared/platform/windows/win_memmap.c | 5 +++-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/core/shared/platform/common/posix/posix_memmap.c b/core/shared/platform/common/posix/posix_memmap.c index 1d972f5fa..1b65b15d1 100644 --- a/core/shared/platform/common/posix/posix_memmap.c +++ b/core/shared/platform/common/posix/posix_memmap.c @@ -61,14 +61,16 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) request_size += HUGE_PAGE_SIZE; #endif - if ((size_t)request_size < size) - /* integer overflow */ + if ((size_t)request_size < size) { + os_printf("mmap failed: request size overflow due to paging\n"); return NULL; + } #if WASM_ENABLE_MEMORY64 == 0 - if (request_size > 16 * (uint64)UINT32_MAX) - /* at most 64 G is allowed */ + if (request_size > 16 * (uint64)UINT32_MAX) { + os_printf("mmap failed: for memory64 at most 64G is allowed\n"); return NULL; + } #endif if (prot & MMAP_PROT_READ) @@ -155,7 +157,7 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) if (addr == MAP_FAILED) { os_printf("mmap failed with errno: %d, hint: %p, size: %" PRIu64 - ", prot: %d, flags: %d", + ", prot: %d, flags: %d\n", errno, hint, request_size, map_prot, map_flags); return NULL; } @@ -268,6 +270,8 @@ os_mprotect(void *addr, size_t size, int prot) int map_prot = PROT_NONE; uint64 page_size = (uint64)getpagesize(); uint64 request_size = (size + page_size - 1) & ~(page_size - 1); + // printf("mprotect addr: %p, size: %llu, prot: %d\n", addr, request_size, + // prot); if (!addr) return 0; @@ -281,12 +285,17 @@ os_mprotect(void *addr, size_t size, int prot) if (prot & MMAP_PROT_EXEC) map_prot |= PROT_EXEC; + if (mprotect(addr, request_size, map_prot) == -1) { + printf("mprotect failed\n"); + } + return mprotect(addr, request_size, map_prot); } void os_dcache_flush(void) -{} +{ +} void os_icache_flush(void *start, size_t len) diff --git a/core/shared/platform/linux-sgx/sgx_platform.c b/core/shared/platform/linux-sgx/sgx_platform.c index d97883a8e..0c5bb1c09 100644 --- a/core/shared/platform/linux-sgx/sgx_platform.c +++ b/core/shared/platform/linux-sgx/sgx_platform.c @@ -149,8 +149,10 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) page_size = getpagesize(); aligned_size = (size + page_size - 1) & ~(page_size - 1); - if (aligned_size >= UINT32_MAX) + if (aligned_size >= UINT32_MAX) { + os_printf("mmap failed: request size overflow due to paging\n"); return NULL; + } ret = sgx_alloc_rsrv_mem(aligned_size); if (ret == NULL) { @@ -214,8 +216,10 @@ os_mprotect(void *addr, size_t size, int prot) void os_dcache_flush(void) -{} +{ +} void os_icache_flush(void *start, size_t len) -{} +{ +} diff --git a/core/shared/platform/windows/win_memmap.c b/core/shared/platform/windows/win_memmap.c index db0f38a56..994c3e4e2 100644 --- a/core/shared/platform/windows/win_memmap.c +++ b/core/shared/platform/windows/win_memmap.c @@ -39,9 +39,10 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) page_size = os_getpagesize(); request_size = (size + page_size - 1) & ~(page_size - 1); - if (request_size < size) - /* integer overflow */ + if (request_size < size) { + printf("mmap failed: request size overflow due to paging\n"); return NULL; + } #if WASM_ENABLE_JIT != 0 /** From f1ffbb5b37704991206b5f0fc1ff50cde7e12cfb Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 12 Feb 2025 16:42:25 +0800 Subject: [PATCH 046/198] cr suggestions --- core/iwasm/common/wasm_memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 8e008f11b..1f942ec6c 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -1255,6 +1255,8 @@ wasm_mremap_linear_memory(void *mapped_mem, uint64 old_size, uint64 new_size, #if UINTPTR_MAX == UINT32_MAX if (new_size == 4 * (uint64)BH_GB) { + LOG_WARNING("On 32 bit platform, linear memory can't reach maximum " + "size of 4GB\n"); return NULL; } #endif From e72338b54d39e3a0e53721de86da922f5610c2f1 Mon Sep 17 00:00:00 2001 From: TL Date: Wed, 12 Feb 2025 16:47:52 +0800 Subject: [PATCH 047/198] format --- core/shared/platform/common/posix/posix_memmap.c | 3 +-- core/shared/platform/linux-sgx/sgx_platform.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/core/shared/platform/common/posix/posix_memmap.c b/core/shared/platform/common/posix/posix_memmap.c index 1b65b15d1..7f54c5706 100644 --- a/core/shared/platform/common/posix/posix_memmap.c +++ b/core/shared/platform/common/posix/posix_memmap.c @@ -294,8 +294,7 @@ os_mprotect(void *addr, size_t size, int prot) void os_dcache_flush(void) -{ -} +{} void os_icache_flush(void *start, size_t len) diff --git a/core/shared/platform/linux-sgx/sgx_platform.c b/core/shared/platform/linux-sgx/sgx_platform.c index 0c5bb1c09..db350bc8f 100644 --- a/core/shared/platform/linux-sgx/sgx_platform.c +++ b/core/shared/platform/linux-sgx/sgx_platform.c @@ -216,10 +216,8 @@ os_mprotect(void *addr, size_t size, int prot) void os_dcache_flush(void) -{ -} +{} void os_icache_flush(void *start, size_t len) -{ -} +{} From 851a26dbba050798427e9c547ef54a66e8c3e20e Mon Sep 17 00:00:00 2001 From: TL Date: Tue, 18 Feb 2025 16:35:42 +0800 Subject: [PATCH 048/198] cr suggestions --- core/shared/platform/common/posix/posix_memmap.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/core/shared/platform/common/posix/posix_memmap.c b/core/shared/platform/common/posix/posix_memmap.c index 7f54c5706..d5cad885c 100644 --- a/core/shared/platform/common/posix/posix_memmap.c +++ b/core/shared/platform/common/posix/posix_memmap.c @@ -270,8 +270,6 @@ os_mprotect(void *addr, size_t size, int prot) int map_prot = PROT_NONE; uint64 page_size = (uint64)getpagesize(); uint64 request_size = (size + page_size - 1) & ~(page_size - 1); - // printf("mprotect addr: %p, size: %llu, prot: %d\n", addr, request_size, - // prot); if (!addr) return 0; @@ -285,10 +283,6 @@ os_mprotect(void *addr, size_t size, int prot) if (prot & MMAP_PROT_EXEC) map_prot |= PROT_EXEC; - if (mprotect(addr, request_size, map_prot) == -1) { - printf("mprotect failed\n"); - } - return mprotect(addr, request_size, map_prot); } From 1252f723c2043685302d7db29145f188305c76d2 Mon Sep 17 00:00:00 2001 From: jia xiang <58927968+Jiax-cn@users.noreply.github.com> Date: Tue, 25 Feb 2025 07:01:16 +0800 Subject: [PATCH 049/198] feat: use C linkage in aot_comp_option.h for C++ embeding (#4106) Co-authored-by: xiangjia.xj --- core/iwasm/include/aot_comp_option.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/iwasm/include/aot_comp_option.h b/core/iwasm/include/aot_comp_option.h index a97275d24..fda17d5a7 100644 --- a/core/iwasm/include/aot_comp_option.h +++ b/core/iwasm/include/aot_comp_option.h @@ -8,6 +8,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { /* Enables or disables bounds checks for stack frames. When enabled, the AOT * compiler generates code to check if the stack pointer is within the @@ -88,4 +92,8 @@ typedef struct AOTCompOption { const char *builtin_intrinsics; } AOTCompOption, *aot_comp_option_t; +#ifdef __cplusplus +} #endif + +#endif /* end of __AOT_COMP_OPTION_H__ */ \ No newline at end of file From 8288190d577df2462e9bbe1474e08ac04ef58527 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:33:12 +0000 Subject: [PATCH 050/198] build(deps): Bump actions/upload-artifact from 4.6.0 to 4.6.1 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.0 to 4.6.1. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.0...v4.6.1) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 2 +- .github/workflows/spec_test_on_nuttx.yml | 2 +- .github/workflows/supply_chain.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0c3a2ad15..fd4415014 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -106,7 +106,7 @@ jobs: - name: Upload CodeQL results as an artifact if: success() || failure() - uses: actions/upload-artifact@v4.6.0 + uses: actions/upload-artifact@v4.6.1 with: name: codeql-results path: ${{ steps.step1.outputs.sarif-output }} diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index 8138a8612..eabe01788 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -351,7 +351,7 @@ jobs: - name: upload the log if: always() - uses: actions/upload-artifact@v4.6.0 + uses: actions/upload-artifact@v4.6.1 with: name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }} path: log diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index f373e1b0b..442ef7364 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -52,7 +52,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v3.1.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v3.1.0 with: name: SARIF file path: results.sarif From e158f6620e8ec02a069fa19cbf26efa44c7e283e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:33:28 +0000 Subject: [PATCH 051/198] build(deps): Bump github/codeql-action from 3.28.9 to 3.28.10 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.9 to 3.28.10. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.9...v3.28.10) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fd4415014..302b27274 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.9 + uses: github/codeql-action/init@v3.28.10 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.9 + uses: github/codeql-action/analyze@v3.28.10 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.9 + uses: github/codeql-action/upload-sarif@v3.28.10 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 442ef7364..497820c15 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@0a35e8f6866a39b001e5f7ad1d0daf9836786896 # v2.2.4 + uses: github/codeql-action/upload-sarif@ff79de67cc25c7617163ae1e4b8aa23b902fdf15 # v2.2.4 with: sarif_file: results.sarif From 8b4ef085fc4ec0a883dc80d06923611d1a26c740 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 25 Feb 2025 06:49:37 +0800 Subject: [PATCH 052/198] Apply suggestions from code review remove confusing comments. --- .github/workflows/supply_chain.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 497820c15..e00638ab1 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@ff79de67cc25c7617163ae1e4b8aa23b902fdf15 # v2.2.4 + uses: github/codeql-action/upload-sarif@ff79de67cc25c7617163ae1e4b8aa23b902fdf15 with: sarif_file: results.sarif From 3f268e5150ad2e592f02ac0d467452c38aaa6ae7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:33:32 +0000 Subject: [PATCH 053/198] build(deps): Bump ossf/scorecard-action from 2.4.0 to 2.4.1 Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits](https://github.com/ossf/scorecard-action/compare/62b2cac7ed8198b15735ed49ab1e5cf35480ba46...f49aabe0b5af0936a0987cfb85d86b75731b0186) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/supply_chain.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index e00638ab1..768b0eff4 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -39,7 +39,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 with: results_file: results.sarif results_format: sarif From 188eb1c9416444368818fdb269e9b683aa0c4d2a Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 25 Feb 2025 17:42:06 +0000 Subject: [PATCH 054/198] remove unnecessary includes --- core/iwasm/common/wasm_runtime_common.c | 1 - core/iwasm/interpreter/wasm_runtime.c | 1 - core/iwasm/interpreter/wasm_runtime.h | 1 - 3 files changed, 3 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 5ce16a14d..a007c41f1 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -7,7 +7,6 @@ #include "bh_common.h" #include "bh_assert.h" #include "bh_log.h" -#include "wasm_export.h" #include "wasm_native.h" #include "wasm_runtime_common.h" #include "wasm_memory.h" diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index c616ac44b..9431b0bed 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -6,7 +6,6 @@ #include "wasm_runtime.h" #include "wasm.h" #include "wasm_exec_env.h" -#include "wasm_export.h" #include "wasm_loader.h" #include "wasm_interp.h" #include "bh_common.h" diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 84abf63b1..1cdce10ed 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -12,7 +12,6 @@ #include "bh_hashmap.h" #include "../common/wasm_runtime_common.h" #include "../common/wasm_exec_env.h" -#include "wasm_export.h" #ifdef __cplusplus extern "C" { From 968b7d4ea0073e469d6bec16518dedd024bb22b3 Mon Sep 17 00:00:00 2001 From: jia xiang <58927968+Jiax-cn@users.noreply.github.com> Date: Wed, 26 Feb 2025 12:57:46 +0800 Subject: [PATCH 055/198] fix: add dispose of the debug information builder when destroying compilation context (#4105) Co-authored-by: xiangjia.xj --- core/iwasm/compilation/aot_llvm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index 14ee4dd2b..a3ac5113c 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -3334,6 +3334,11 @@ aot_destroy_comp_context(AOTCompContext *comp_ctx) if (comp_ctx->builder) LLVMDisposeBuilder(comp_ctx->builder); +#if WASM_ENABLE_DEBUG_AOT != 0 + if (comp_ctx->debug_builder) + LLVMDisposeDIBuilder(comp_ctx->debug_builder); +#endif + if (comp_ctx->orc_thread_safe_context) LLVMOrcDisposeThreadSafeContext(comp_ctx->orc_thread_safe_context); From f2e3348305d16cde5a45f4dda585a0caf01a0fb4 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 26 Feb 2025 12:58:45 +0800 Subject: [PATCH 056/198] wasm_loader allocates more spaces for elements (#4099) - allocate memory for array initialization based on length - update reference type mapping for struct initialization --- core/iwasm/interpreter/wasm_loader.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index e72bf94fa..d00f761df 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -513,14 +513,15 @@ destroy_init_expr_data_recursive(WASMModule *module, void *data) if (wasm_type->type_flag == WASM_TYPE_STRUCT) { WASMStructType *struct_type = (WASMStructType *)wasm_type; - WASMRefTypeMap *ref_type_map = struct_type->ref_type_maps; WASMRefType *ref_type; uint8 field_type; + uint16 ref_type_map_index = 0; for (i = 0; i < struct_init_values->count; i++) { field_type = struct_type->fields[i].field_type; if (wasm_is_type_multi_byte_type(field_type)) - ref_type = ref_type_map->ref_type; + ref_type = + struct_type->ref_type_maps[ref_type_map_index++].ref_type; else ref_type = NULL; if (wasm_reftype_is_subtype_of(field_type, ref_type, @@ -1073,23 +1074,25 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, } if (opcode1 == WASM_OP_ARRAY_NEW) { - WASMValue len_val; - - if (!(array_init_values = loader_malloc( - sizeof(WASMArrayNewInitValues), - error_buf, error_buf_size))) { - goto fail; - } - array_init_values->type_idx = type_idx; + WASMValue len_val = { 0 }; + uint64 size = 0; if (!pop_const_expr_stack( &const_expr_ctx, NULL, VALUE_TYPE_I32, NULL, NULL, &len_val, error_buf, error_buf_size)) { - destroy_init_expr_data_recursive( - module, array_init_values); goto fail; } + + size = + sizeof(WASMArrayNewInitValues) + + sizeof(WASMValue) * (uint64)len_val.i32; + if (!(array_init_values = loader_malloc( + size, error_buf, error_buf_size))) { + goto fail; + } + + array_init_values->type_idx = type_idx; array_init_values->length = len_val.i32; if (!pop_const_expr_stack( From 857e6b73c88ffb680764fbe019606200d7e35464 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 26 Feb 2025 10:57:50 +0000 Subject: [PATCH 057/198] formatting --- core/iwasm/aot/aot_runtime.h | 3 +-- core/iwasm/common/wasm_runtime_common.c | 3 +-- core/iwasm/common/wasm_runtime_common.h | 2 +- core/iwasm/include/wasm_export.h | 7 +++---- core/iwasm/interpreter/wasm_runtime.c | 23 +++++++++++------------ core/iwasm/interpreter/wasm_runtime.h | 2 +- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index 764403f72..a338cb4ef 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -780,8 +780,7 @@ aot_create_call_stack(struct WASMExecEnv *exec_env); #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, - const uint32 skip_n); + const uint32 length, const uint32 skip_n); #endif // WAMR_ENABLE_COPY_CALLSTACK /** diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index a007c41f1..065bff1da 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1743,8 +1743,7 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, - const uint32 length, - const uint32 skip_n) + const uint32 length, const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 44406cdb4..61b44aef6 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -642,7 +642,7 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); #if WAMR_ENABLE_COPY_CALLSTACK != 0 WASM_RUNTIME_API_EXTERN uint32_t wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, - const uint32 length, const uint32 skip_n); + const uint32 length, const uint32 skip_n); #endif // WAMR_ENABLE_COPY_CALLSTACK /* See wasm_export.h for description */ diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index a17f13f24..cacc68e2a 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -126,7 +126,6 @@ typedef WASMFunctionInstanceCommon *wasm_function_inst_t; struct WASMMemoryInstance; typedef struct WASMMemoryInstance *wasm_memory_inst_t; - typedef struct wasm_frame_t { /* wasm_instance_t */ void *instance; @@ -880,7 +879,6 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); - /** * @brief Copy callstack frames. * @@ -898,7 +896,8 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); * - exec_env->module_inst->module * * @param exec_env the execution environment that containes frames - * @param buffer the buffer of size equal length * sizeof(frame) to copy frames to + * @param buffer the buffer of size equal length * sizeof(frame) to copy frames + * to * @param length the number of frames to copy * @param skip_n the number of frames to skip from the top of the stack * @@ -906,7 +905,7 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); */ WASM_RUNTIME_API_EXTERN uint32_t wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, - const uint32_t length, const uint32_t skip_n); + const uint32_t length, const uint32_t skip_n); /** * Get the singleton execution environment for the instance. diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 9431b0bed..0f75eb9f9 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4196,21 +4196,20 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, #endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0) \ || (WASM_ENABLE_MEMORY_TRACING != 0) */ - #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - uint32 length, uint32 skip_n) + uint32 length, uint32 skip_n) { /* - * Note for devs: please refrain from such modifications inside of - * wasm_interp_copy_callstack - * - any allocations/freeing memory - * - dereferencing any pointers other than: exec_env, exec_env->module_inst, - * exec_env->module_inst->module, pointers between stack's bottom and - * top_boundary For more details check wasm_copy_callstack in - * wasm_export.h - */ + * Note for devs: please refrain from such modifications inside of + * wasm_interp_copy_callstack + * - any allocations/freeing memory + * - dereferencing any pointers other than: exec_env, exec_env->module_inst, + * exec_env->module_inst->module, pointers between stack's bottom and + * top_boundary For more details check wasm_copy_callstack in + * wasm_export.h + */ WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); WASMInterpFrame *cur_frame = wasm_exec_env_get_cur_frame(exec_env); @@ -4221,8 +4220,8 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, WASMCApiFrame record_frame; while (cur_frame && (uint8_t *)cur_frame >= bottom - && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary - && count < (skip_n + length)) { + && (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary + && count < (skip_n + length)) { if (!cur_frame->function) { cur_frame = cur_frame->prev_frame; continue; diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 1cdce10ed..3747eb80f 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -734,7 +734,7 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - uint32 length, uint32 skip_n); + uint32 length, uint32 skip_n); #endif // WAMR_ENABLE_COPY_CALLSTACK bool From a5d8c0b477a9a9e57dfb7d1892b46bfee72baeab Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 26 Feb 2025 11:11:17 +0000 Subject: [PATCH 058/198] define if not defined --- core/iwasm/common/wasm_runtime_common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 61b44aef6..f89c8b5ee 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -639,6 +639,10 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); +#ifndef WAMR_ENABLE_COPY_CALLSTACK +#define WAMR_ENABLE_COPY_CALLSTACK 0 +#endif + #if WAMR_ENABLE_COPY_CALLSTACK != 0 WASM_RUNTIME_API_EXTERN uint32_t wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, From 99cb6ec27e4a1c5ce01fa57091f6c34118adc693 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 26 Feb 2025 11:22:31 +0000 Subject: [PATCH 059/198] formatting --- core/iwasm/aot/aot_runtime.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 78b4b60f4..19e71889d 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4106,8 +4106,7 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, - const uint32 skip_n) + const uint32 length, const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of @@ -4137,8 +4136,7 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame)); WASMCApiFrame record_frame; - while (frame && (uint8_t *)frame >= bottom - && count < (skip_n + length)) { + while (frame && (uint8_t *)frame >= bottom && count < (skip_n + length)) { if (count < skip_n) { ++count; frame -= 1; @@ -4156,9 +4154,9 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, } uint32 -aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, - const uint32 skip_n) +aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, + wasm_frame_ptr_t buffer, const uint32 length, + const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of @@ -4204,11 +4202,9 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer #endif } - uint32 aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, - const uint32 skip_n) + const uint32 length, const uint32 skip_n) { /* * Note for devs: please refrain from such modifications inside of @@ -4220,7 +4216,8 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, * wasm_export.h */ if (!is_tiny_frame(exec_env)) { - return aot_copy_callstack_standard_frame(exec_env, buffer, length, skip_n); + return aot_copy_callstack_standard_frame(exec_env, buffer, length, + skip_n); } else { return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n); From fc3077b74d2550d59fcd86d098931782d2e6bf66 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Thu, 27 Feb 2025 14:32:17 +0000 Subject: [PATCH 060/198] address comments --- core/config.h | 4 ++++ core/iwasm/aot/aot_runtime.c | 25 +++++++++++++++---------- core/iwasm/aot/aot_runtime.h | 5 +++-- core/iwasm/common/wasm_runtime_common.c | 11 +++++++---- core/iwasm/common/wasm_runtime_common.h | 9 +++------ core/iwasm/include/wasm_export.h | 11 ++++++----- core/iwasm/interpreter/wasm_runtime.c | 6 ++++-- core/iwasm/interpreter/wasm_runtime.h | 5 +++-- 8 files changed, 45 insertions(+), 31 deletions(-) diff --git a/core/config.h b/core/config.h index fbbbf6771..d71aaca39 100644 --- a/core/config.h +++ b/core/config.h @@ -193,6 +193,10 @@ #error "Heap aux stack allocation must be enabled for WASI threads" #endif +#ifndef WAMR_ENABLE_COPY_CALLSTACK +#define WAMR_ENABLE_COPY_CALLSTACK 0 +#endif + #ifndef WASM_ENABLE_BASE_LIB #define WASM_ENABLE_BASE_LIB 0 #endif diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 19e71889d..b06b19af1 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -10,6 +10,7 @@ #include "../common/wasm_runtime_common.h" #include "../common/wasm_memory.h" #include "../interpreter/wasm_runtime.h" +#include #if WASM_ENABLE_SHARED_MEMORY != 0 #include "../common/wasm_shared_memory.h" #endif @@ -4105,8 +4106,8 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 -aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, const uint32 skip_n) +aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t* buffer, + const uint32 length, const uint32 skip_n, char *error_buf, uint32 error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -4126,12 +4127,16 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); if (!is_top_index_in_range) { - return count; + char* err_msg = "Top of the stack pointer is outside of the stack boundaries"; + strncpy(error_buf, err_msg, error_buf_size); + return 0; } bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; if (!is_top_aligned_with_bottom) { - return count; + char* err_msg = "Top of the stack is not aligned with the bottom"; + strncpy(error_buf, err_msg, error_buf_size); + return 0; } AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame)); @@ -4155,8 +4160,8 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, uint32 aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, - wasm_frame_ptr_t buffer, const uint32 length, - const uint32 skip_n) + wasm_frame_t* buffer, const uint32 length, + const uint32 skip_n, char *error_buf, uint32_t error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -4203,8 +4208,8 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, } uint32 -aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, const uint32 skip_n) +aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t* buffer, + const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -4217,10 +4222,10 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, */ if (!is_tiny_frame(exec_env)) { return aot_copy_callstack_standard_frame(exec_env, buffer, length, - skip_n); + skip_n, error_buf, error_buf_size); } else { - return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n); + return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n, error_buf, error_buf_size); } } #endif // WAMR_ENABLE_COPY_CALLSTACK diff --git a/core/iwasm/aot/aot_runtime.h b/core/iwasm/aot/aot_runtime.h index a338cb4ef..5be51c05a 100644 --- a/core/iwasm/aot/aot_runtime.h +++ b/core/iwasm/aot/aot_runtime.h @@ -779,8 +779,9 @@ aot_create_call_stack(struct WASMExecEnv *exec_env); #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 -aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - const uint32 length, const uint32 skip_n); +aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, + const uint32 length, const uint32 skip_n, char *error_buf, + uint32_t error_buf_size); #endif // WAMR_ENABLE_COPY_CALLSTACK /** diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 065bff1da..99f0522e9 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1742,8 +1742,9 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 -wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, - const uint32 length, const uint32 skip_n) +wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, + const uint32 length, const uint32 skip_n, char *error_buf, + uint32_t error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -1760,13 +1761,15 @@ wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, #if WASM_ENABLE_INTERP != 0 if (module_inst->module_type == Wasm_Module_Bytecode) { - return wasm_interp_copy_callstack(exec_env, buffer, length, skip_n); + return wasm_interp_copy_callstack(exec_env, buffer, length, skip_n, + error_buf, error_buf_size); } #endif #if WASM_ENABLE_AOT != 0 if (module_inst->module_type == Wasm_Module_AoT) { - return aot_copy_callstack(exec_env, buffer, length, skip_n); + return aot_copy_callstack(exec_env, buffer, length, skip_n, error_buf, + error_buf_size); } #endif #endif diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index f89c8b5ee..c6425af20 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -639,14 +639,11 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst, WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); -#ifndef WAMR_ENABLE_COPY_CALLSTACK -#define WAMR_ENABLE_COPY_CALLSTACK 0 -#endif - #if WAMR_ENABLE_COPY_CALLSTACK != 0 WASM_RUNTIME_API_EXTERN uint32_t -wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, - const uint32 length, const uint32 skip_n); +wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, + const uint32 length, const uint32 skip_n, char *error_buf, + uint32 error_buf_size); #endif // WAMR_ENABLE_COPY_CALLSTACK /* See wasm_export.h for description */ diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index cacc68e2a..e63ff0124 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -139,7 +139,7 @@ typedef struct wasm_frame_t { uint32_t *lp; } WASMCApiFrame; -typedef struct wasm_frame_t *wasm_frame_ptr_t; +typedef WASMCApiFrame wasm_frame_t; /* WASM section */ typedef struct wasm_section_t { @@ -896,16 +896,17 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env); * - exec_env->module_inst->module * * @param exec_env the execution environment that containes frames - * @param buffer the buffer of size equal length * sizeof(frame) to copy frames - * to + * @param buffer the buffer of size equal length * sizeof(wasm_frame_t) to copy + * frames to * @param length the number of frames to copy * @param skip_n the number of frames to skip from the top of the stack * * @return number of copied frames */ WASM_RUNTIME_API_EXTERN uint32_t -wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_ptr_t buffer, - const uint32_t length, const uint32_t skip_n); +wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, + const uint32_t length, const uint32_t skip_n, + char *error_buf, uint32_t error_buf_size); /** * Get the singleton execution environment for the instance. diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 0f75eb9f9..38fc02292 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -5,6 +5,7 @@ #include "wasm_runtime.h" #include "wasm.h" +#include "wasm_c_api.h" #include "wasm_exec_env.h" #include "wasm_loader.h" #include "wasm_interp.h" @@ -4198,8 +4199,9 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst, #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 -wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - uint32 length, uint32 skip_n) +wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, + uint32 length, uint32 skip_n, char *error_buf, + uint32_t error_buf_size) { /* * Note for devs: please refrain from such modifications inside of diff --git a/core/iwasm/interpreter/wasm_runtime.h b/core/iwasm/interpreter/wasm_runtime.h index 3747eb80f..8d38c8831 100644 --- a/core/iwasm/interpreter/wasm_runtime.h +++ b/core/iwasm/interpreter/wasm_runtime.h @@ -733,8 +733,9 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 -wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer, - uint32 length, uint32 skip_n); +wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, + uint32 length, uint32 skip_n, char *error_buf, + uint32_t error_buf_size); #endif // WAMR_ENABLE_COPY_CALLSTACK bool From bda012e990a78c7efd0a7d6a0630d7d0d1174413 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Thu, 27 Feb 2025 14:35:53 +0000 Subject: [PATCH 061/198] formatting --- core/iwasm/aot/aot_runtime.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index b06b19af1..6335ec405 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4106,8 +4106,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame) #if WAMR_ENABLE_COPY_CALLSTACK != 0 uint32 -aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t* buffer, - const uint32 length, const uint32 skip_n, char *error_buf, uint32 error_buf_size) +aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, + const uint32 length, const uint32 skip_n, + char *error_buf, uint32 error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -4127,14 +4128,15 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t* buffer, bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame)); if (!is_top_index_in_range) { - char* err_msg = "Top of the stack pointer is outside of the stack boundaries"; + char *err_msg = + "Top of the stack pointer is outside of the stack boundaries"; strncpy(error_buf, err_msg, error_buf_size); return 0; } bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0; if (!is_top_aligned_with_bottom) { - char* err_msg = "Top of the stack is not aligned with the bottom"; + char *err_msg = "Top of the stack is not aligned with the bottom"; strncpy(error_buf, err_msg, error_buf_size); return 0; } @@ -4159,9 +4161,9 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t* buffer, } uint32 -aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, - wasm_frame_t* buffer, const uint32 length, - const uint32 skip_n, char *error_buf, uint32_t error_buf_size) +aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, + const uint32 length, const uint32 skip_n, + char *error_buf, uint32_t error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -4208,8 +4210,9 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, } uint32 -aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t* buffer, - const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size) +aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, + const uint32 length, const uint32 skip_n, char *error_buf, + uint32_t error_buf_size) { /* * Note for devs: please refrain from such modifications inside of @@ -4221,11 +4224,12 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t* buffer, * wasm_export.h */ if (!is_tiny_frame(exec_env)) { - return aot_copy_callstack_standard_frame(exec_env, buffer, length, - skip_n, error_buf, error_buf_size); + return aot_copy_callstack_standard_frame( + exec_env, buffer, length, skip_n, error_buf, error_buf_size); } else { - return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n, error_buf, error_buf_size); + return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n, + error_buf, error_buf_size); } } #endif // WAMR_ENABLE_COPY_CALLSTACK From 0b5084cb632d6f5bf49ce59d6781d8b67166e26d Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Thu, 27 Feb 2025 15:06:31 +0000 Subject: [PATCH 062/198] remove spare diff line --- core/iwasm/interpreter/wasm_runtime.c | 1 - 1 file changed, 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 38fc02292..609ad4a3b 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4248,7 +4248,6 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, #endif // WAMR_ENABLE_COPY_CALLSTACK #if WASM_ENABLE_DUMP_CALL_STACK != 0 - bool wasm_interp_create_call_stack(struct WASMExecEnv *exec_env) { From e6936084766e504c66cd47ef008aac26d1b889ba Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Sat, 1 Mar 2025 16:46:41 +0800 Subject: [PATCH 063/198] log warning instaed of assertion (#4119) --- core/iwasm/aot/aot_loader.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 0ba3de7bd..0817f6c78 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -317,9 +317,12 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size) map_flags = MMAP_MAP_32BIT; if ((mem = os_mmap(NULL, size, map_prot, map_flags, os_get_invalid_handle()))) { - /* The mmapped memory must be in the first 2 Gigabytes of the + /* Test whether the mmapped memory in the first 2 Gigabytes of the process address space */ - bh_assert((uintptr_t)mem < INT32_MAX); + if ((uintptr_t)mem >= INT32_MAX) + LOG_WARNING( + "Warning: loader mmap memory address is not in the first 2 " + "Gigabytes of the process address space."); return mem; } #endif From beb34c3675312ab746b0bb37b8c146379379dd1b Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sun, 2 Mar 2025 23:32:04 -0500 Subject: [PATCH 064/198] Expose WAMR_BUILD_GC_HEAP_SIZE_DEFAULT as a CMake option This is wired through to the GC_HEAP_SIZE_DEFAULT constant. Also honor this value when configuring the engine with the wasm_c_api. --- core/iwasm/common/wasm_c_api.c | 1 + core/shared/mem-alloc/mem_alloc.cmake | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index d5c45a441..0019b5eee 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -393,6 +393,7 @@ wasm_engine_new_internal(wasm_config_t *config) WASM_C_DUMP_PROC_MEM(); /* wasm_config_t->MemAllocOption -> RuntimeInitArgs->MemAllocOption */ + init_args.gc_heap_size = GC_HEAP_SIZE_DEFAULT; init_args.mem_alloc_type = config->mem_alloc_type; memcpy(&init_args.mem_alloc_option, &config->mem_alloc_option, sizeof(MemAllocOption)); diff --git a/core/shared/mem-alloc/mem_alloc.cmake b/core/shared/mem-alloc/mem_alloc.cmake index 5f47cce13..76d1706dc 100644 --- a/core/shared/mem-alloc/mem_alloc.cmake +++ b/core/shared/mem-alloc/mem_alloc.cmake @@ -24,6 +24,10 @@ if (WAMR_BUILD_GC_CORRUPTION_CHECK EQUAL 0) add_definitions (-DBH_ENABLE_GC_CORRUPTION_CHECK=0) endif () +if (DEFINED WAMR_BUILD_GC_HEAP_SIZE_DEFAULT) + add_definitions ("-DGC_HEAP_SIZE_DEFAULT=${WAMR_BUILD_GC_HEAP_SIZE_DEFAULT}") +endif () + file (GLOB_RECURSE source_all ${MEM_ALLOC_DIR}/ems/*.c ${MEM_ALLOC_DIR}/tlsf/*.c From bc00b3e492ecbd76230e2f21ba90c64d5ceb9afa Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 13:36:05 +0000 Subject: [PATCH 065/198] address comments --- core/iwasm/aot/aot_runtime.c | 2 +- core/iwasm/common/wasm_runtime_common.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 6335ec405..85b686ef9 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -10,7 +10,6 @@ #include "../common/wasm_runtime_common.h" #include "../common/wasm_memory.h" #include "../interpreter/wasm_runtime.h" -#include #if WASM_ENABLE_SHARED_MEMORY != 0 #include "../common/wasm_shared_memory.h" #endif @@ -4201,6 +4200,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, cur_frame = cur_frame->prev_frame; ++count; } + return count; #else /* * TODO: add support for standard frames when GC is enabled diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 99f0522e9..ce4d46528 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1773,6 +1773,10 @@ wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, } #endif #endif + char *err_msg = + "No copy_callstack API was actually executed"; + strncpy(error_buf, err_msg, error_buf_size); + return 0; } #endif // WAMR_ENABLE_COPY_CALLSTACK From ffcc1579ea2f8c665fd50fcd215ad8769ebeeaab Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 13:41:35 +0000 Subject: [PATCH 066/198] clang format --- core/iwasm/common/wasm_runtime_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index ce4d46528..d900dc233 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1773,8 +1773,7 @@ wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, } #endif #endif - char *err_msg = - "No copy_callstack API was actually executed"; + char *err_msg = "No copy_callstack API was actually executed"; strncpy(error_buf, err_msg, error_buf_size); return 0; } From 32d0f5503e144bfc5cea5e07c27ed3e12c0c1020 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 14:06:45 +0000 Subject: [PATCH 067/198] spare line --- core/iwasm/interpreter/wasm_runtime.c | 1 - 1 file changed, 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 609ad4a3b..b4b55e65a 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4217,7 +4217,6 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, WASMInterpFrame *cur_frame = wasm_exec_env_get_cur_frame(exec_env); uint8 *top_boundary = exec_env->wasm_stack.top_boundary; uint8 *bottom = exec_env->wasm_stack.bottom; - uint32 count = 0; WASMCApiFrame record_frame; From 6166788c33c8e1244119d29a7e6e5917d06951f2 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Mon, 3 Mar 2025 15:17:57 +0000 Subject: [PATCH 068/198] spare lines --- core/iwasm/aot/aot_runtime.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 85b686ef9..585a30728 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4121,7 +4121,6 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, uint8 *top_boundary = exec_env->wasm_stack.top_boundary; uint8 *top = exec_env->wasm_stack.top; uint8 *bottom = exec_env->wasm_stack.bottom; - uint32 count = 0; bool is_top_index_in_range = @@ -4180,7 +4179,6 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, uint8 *top_boundary = exec_env->wasm_stack.top_boundary; uint8 *bottom = exec_env->wasm_stack.bottom; uint32 frame_size = (uint32)offsetof(AOTFrame, lp); - uint32 count = 0; WASMCApiFrame record_frame; From de82d1946f8a215e529fca04268d096051a2b313 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Mon, 3 Mar 2025 20:45:59 -0500 Subject: [PATCH 069/198] Address code review feedback --- core/iwasm/common/wasm_c_api.c | 2 +- doc/build_wamr.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index 0019b5eee..04ec4e383 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -392,8 +392,8 @@ wasm_engine_new_internal(wasm_config_t *config) WASM_C_DUMP_PROC_MEM(); - /* wasm_config_t->MemAllocOption -> RuntimeInitArgs->MemAllocOption */ init_args.gc_heap_size = GC_HEAP_SIZE_DEFAULT; + /* wasm_config_t->MemAllocOption -> RuntimeInitArgs->MemAllocOption */ init_args.mem_alloc_type = config->mem_alloc_type; memcpy(&init_args.mem_alloc_option, &config->mem_alloc_option, sizeof(MemAllocOption)); diff --git a/doc/build_wamr.md b/doc/build_wamr.md index cde884457..64be528bd 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -141,6 +141,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM ### **Enable Garbage Collection** - **WAMR_BUILD_GC**=1/0, default to disable if not set +- **WAMR_BUILD_GC_HEAP_SIZE_DEFAULT**=n, default to 128 kB (131072) if not set ### **Configure Debug** From 73998e4c855c8aa71713041e1893414a35b44177 Mon Sep 17 00:00:00 2001 From: jia xiang <58927968+Jiax-cn@users.noreply.github.com> Date: Tue, 4 Mar 2025 16:45:47 +0800 Subject: [PATCH 070/198] fix: fix load aarch64 aot failed (#4114) Co-authored-by: xiangjia.xj --- core/iwasm/aot/aot_loader.c | 3 ++- core/iwasm/aot/arch/aot_reloc_aarch64.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 0817f6c78..83f393c89 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -590,7 +590,8 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end, } /* for backwards compatibility with previous wamrc aot files */ - if (!strcmp(target_info.arch, "arm64")) + if (!strcmp(target_info.arch, "arm64") + || !strcmp(target_info.arch, "aarch64")) bh_strcpy_s(target_info.arch, sizeof(target_info.arch), "aarch64v8"); /* Check machine info */ diff --git a/core/iwasm/aot/arch/aot_reloc_aarch64.c b/core/iwasm/aot/arch/aot_reloc_aarch64.c index 26815334f..e42d2cd8e 100644 --- a/core/iwasm/aot/arch/aot_reloc_aarch64.c +++ b/core/iwasm/aot/arch/aot_reloc_aarch64.c @@ -63,7 +63,7 @@ get_current_target(char *target_buf, uint32 target_buf_size) /* Set to "aarch64v8" by default if sub version isn't specified */ if (strcmp(s, "AARCH64") == 0) { s = "aarch64v8"; - s_size = 9; /* strlen("aarch64v8"); */ + s_size = 10; /* sizeof("aarch64v8"); */ } if (target_buf_size < s_size) { s_size = target_buf_size; From d609acf1eec336ec1ed078123b12016c70e878ac Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 4 Mar 2025 18:43:30 -0500 Subject: [PATCH 071/198] Move the default heap size initialization --- core/iwasm/common/wasm_c_api.c | 1 - core/iwasm/common/wasm_runtime_common.c | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index 04ec4e383..d5c45a441 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -392,7 +392,6 @@ wasm_engine_new_internal(wasm_config_t *config) WASM_C_DUMP_PROC_MEM(); - init_args.gc_heap_size = GC_HEAP_SIZE_DEFAULT; /* wasm_config_t->MemAllocOption -> RuntimeInitArgs->MemAllocOption */ init_args.mem_alloc_type = config->mem_alloc_type; memcpy(&init_args.mem_alloc_option, &config->mem_alloc_option, diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 95cea7fe9..5a2206b6e 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -757,7 +757,10 @@ wasm_runtime_full_init_internal(RuntimeInitArgs *init_args) #endif #if WASM_ENABLE_GC != 0 - gc_heap_size_default = init_args->gc_heap_size; + uint32 gc_heap_size = init_args->gc_heap_size; + if (gc_heap_size > 0) { + gc_heap_size_default = gc_heap_size; + } #endif #if WASM_ENABLE_JIT != 0 From 56bb7e715bc335ed344b94a70f2a8057d6ee7ddf Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 5 Mar 2025 09:11:21 +0000 Subject: [PATCH 072/198] last fixes --- core/iwasm/aot/aot_runtime.c | 4 ++-- core/iwasm/interpreter/wasm_runtime.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 585a30728..2e267e950 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4172,6 +4172,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, * top_boundary For more details check wasm_iterate_callstack in * wasm_export.h */ + uint32 count = 0; #if WASM_ENABLE_GC == 0 WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env); @@ -4179,7 +4180,6 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, uint8 *top_boundary = exec_env->wasm_stack.top_boundary; uint8 *bottom = exec_env->wasm_stack.bottom; uint32 frame_size = (uint32)offsetof(AOTFrame, lp); - uint32 count = 0; WASMCApiFrame record_frame; while (cur_frame && (uint8_t *)cur_frame >= bottom @@ -4198,13 +4198,13 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, cur_frame = cur_frame->prev_frame; ++count; } - return count; #else /* * TODO: add support for standard frames when GC is enabled * now it poses a risk due to variable size of the frame */ #endif + return count; } uint32 diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index b4b55e65a..400a6ae6c 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -5,8 +5,6 @@ #include "wasm_runtime.h" #include "wasm.h" -#include "wasm_c_api.h" -#include "wasm_exec_env.h" #include "wasm_loader.h" #include "wasm_interp.h" #include "bh_common.h" From 811f35bf7d4cf4684fdc45a4785ccba9f1ac9d6b Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 5 Mar 2025 10:23:57 +0000 Subject: [PATCH 073/198] identation --- core/iwasm/aot/aot_runtime.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 2e267e950..db9002bb1 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4172,6 +4172,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, * top_boundary For more details check wasm_iterate_callstack in * wasm_export.h */ + uint32 count = 0; #if WASM_ENABLE_GC == 0 WASMModuleInstance *module_inst = From e488345607fb503ce37dd6ce00426406a763ef66 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Wed, 5 Mar 2025 11:47:56 +0000 Subject: [PATCH 074/198] fix bug for return value when skip_n is passed --- core/iwasm/aot/aot_runtime.c | 4 ++-- core/iwasm/interpreter/wasm_runtime.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index db9002bb1..bf7f51964 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -4155,7 +4155,7 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, frame -= 1; ++count; } - return count; + return count >= skip_n ? count - skip_n : 0; } uint32 @@ -4205,7 +4205,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, * now it poses a risk due to variable size of the frame */ #endif - return count; + return count >= skip_n ? count - skip_n : 0; } uint32 diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 400a6ae6c..64719f7f5 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -4240,7 +4240,7 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, cur_frame = cur_frame->prev_frame; ++count; } - return count; + return count >= skip_n ? count - skip_n : 0; } #endif // WAMR_ENABLE_COPY_CALLSTACK From 9027b2dce27529d4216e5c8cc1dc973b4c21b543 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 4 Mar 2025 18:46:14 -0500 Subject: [PATCH 075/198] Restore the doc heading. --- doc/build_wamr.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 64be528bd..b8cfcc989 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -141,6 +141,8 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM ### **Enable Garbage Collection** - **WAMR_BUILD_GC**=1/0, default to disable if not set + +### **Set the Garbage Collection heap size** - **WAMR_BUILD_GC_HEAP_SIZE_DEFAULT**=n, default to 128 kB (131072) if not set ### **Configure Debug** From 412631ac1379f74a65c21ca9a6f2f95a155aafbd Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Fri, 7 Mar 2025 08:21:54 +0800 Subject: [PATCH 076/198] fix: correct typos and improve comments across multiple files by codespell (#4116) Signed-off-by: Huang Qi --- CONTRIBUTING.md | 2 +- build-scripts/runtime_lib.cmake | 2 +- core/iwasm/aot/aot_loader.c | 2 +- core/iwasm/aot/arch/aot_reloc_xtensa.c | 2 +- core/iwasm/common/arch/invokeNative_aarch64.s | 4 +-- .../common/arch/invokeNative_aarch64_simd.s | 4 +-- core/iwasm/common/arch/invokeNative_arm_vfp.s | 2 +- core/iwasm/common/arch/invokeNative_riscv.S | 6 ++-- .../common/arch/invokeNative_thumb_vfp.s | 2 +- core/iwasm/common/wasm_application.c | 2 +- core/iwasm/common/wasm_c_api.c | 2 +- core/iwasm/common/wasm_exec_env.c | 2 +- core/iwasm/compilation/aot_compiler.h | 2 +- core/iwasm/compilation/aot_emit_aot_file.c | 2 +- core/iwasm/compilation/aot_emit_memory.c | 6 ++-- core/iwasm/compilation/aot_llvm.c | 6 ++-- core/iwasm/compilation/iwasm_compl.cmake | 2 +- core/iwasm/compilation/simd/simd_int_arith.c | 2 +- .../fast-jit/cg/x86-64/jit_codegen_x86_64.cpp | 20 +++++------ core/iwasm/fast-jit/fe/jit_emit_compare.c | 2 +- core/iwasm/fast-jit/fe/jit_emit_control.c | 2 +- core/iwasm/fast-jit/jit_frontend.c | 4 +-- core/iwasm/fast-jit/jit_ir.h | 10 +++--- core/iwasm/fast-jit/jit_regalloc.c | 8 ++--- core/iwasm/include/wasm_export.h | 2 +- core/iwasm/interpreter/wasm_interp_classic.c | 12 +++---- core/iwasm/interpreter/wasm_interp_fast.c | 8 ++--- core/iwasm/interpreter/wasm_loader.c | 20 +++++------ core/iwasm/interpreter/wasm_mini_loader.c | 2 +- .../lib-socket/inc/wasi_socket_ext.h | 2 +- .../stress_test_threads_creation.c | 2 +- .../libraries/libc-wasi/libc_wasi_wrapper.h | 2 +- .../include/wasmtime_ssp.h | 2 +- .../libraries/wasi-nn/src/wasi_nn_llamacpp.c | 2 +- .../wasi-nn/src/wasi_nn_tensorflowlite.cpp | 8 ++--- .../libraries/wasi-nn/test/run_smoke_test.py | 4 +-- core/shared/mem-alloc/ems/ems_alloc.c | 4 +-- core/shared/mem-alloc/ems/ems_gc.h | 2 +- core/shared/mem-alloc/ems/ems_gc_internal.h | 4 +-- core/shared/mem-alloc/ems/ems_hmu.c | 2 +- core/shared/mem-alloc/ems/ems_kfc.c | 2 +- .../platform/common/posix/posix_thread.c | 4 +-- .../platform/include/platform_api_extension.h | 34 +++++++++---------- core/shared/platform/linux-sgx/sgx_ipfs.c | 2 +- core/shared/platform/linux-sgx/sgx_socket.h | 2 +- core/shared/platform/riot/riot_thread.c | 2 +- core/shared/utils/bh_list.c | 2 +- doc/build_wasm_app.md | 4 +-- doc/other_wasm_compilers.md | 2 +- doc/source_debugging_aot.md | 2 +- product-mini/README.md | 10 +++--- product-mini/platforms/common/libc_wasi.c | 2 +- .../linux-sgx/enclave-sample/App/App.cpp | 4 +-- .../linux-sgx/enclave-sample/App/pal_api.h | 2 +- product-mini/platforms/nuttx/CMakeLists.txt | 2 +- product-mini/platforms/riot/Makefile | 2 +- product-mini/platforms/rt-thread/iwasm.c | 4 +-- .../platforms/zephyr/simple/README.md | 4 +-- samples/basic/src/native_impl.c | 2 +- samples/linux-perf/README.md | 2 +- samples/multi-module/README.md | 2 +- samples/native-lib/README.md | 2 +- samples/sgx-ra/non-sgx-verify/README.md | 2 +- samples/socket-api/README.md | 6 ++-- samples/socket-api/wasm-src/tcp_client.c | 2 +- samples/socket-api/wasm-src/tcp_server.c | 6 ++-- samples/socket-api/wasm-src/timeout_server.c | 2 +- samples/socket-api/wasm-src/udp_client.c | 2 +- samples/socket-api/wasm-src/udp_server.c | 4 +-- samples/wasm-c-api-imports/README.md | 4 +-- samples/wasm-c-api/README.md | 2 +- samples/workload/README.md | 2 +- test-tools/aot-analyzer/src/aot_file.cc | 12 +++---- test-tools/aot-analyzer/src/main.cc | 10 +++--- .../append-aot-to-wasm/append_aot_to_wasm.py | 2 +- test-tools/dynamic-aot-debug/README.md | 2 +- .../collect_files.py | 4 +-- test-tools/wamr-ide/Script/build.sh | 2 +- .../VSCode-Extension/formatters/rust.py | 4 +-- .../resource/scripts/destroy.bat | 2 +- tests/unit/aot/aot_test.cc | 2 +- tests/unit/compilation/aot_compiler_test.cc | 2 +- .../compilation/aot_emit_aot_file_test.cc | 2 +- .../unit/compilation/aot_emit_control_test.cc | 2 +- .../compilation/aot_emit_function_test.cc | 2 +- .../compilation/aot_emit_numberic_test.cc | 2 +- .../compilation/aot_emit_parametric_test.cc | 2 +- tests/unit/compilation/aot_emit_table_test.cc | 2 +- tests/unit/compilation/aot_llvm_test.cc | 2 +- .../custom-section/custom_section_test.cc | 2 +- tests/unit/interpreter/interpreter_test.cc | 2 +- tests/unit/libc-builtin/libc_builtin_test.cc | 34 +++++++++---------- .../linear_memory_aot_test.cc | 2 +- .../linear_memory_wasm_test.cc | 2 +- tests/unit/memory64/memory64_test.cc | 2 +- .../running-modes/wasm_running_modes_test.cc | 2 +- .../unit/runtime-common/wasm_exec_env_test.cc | 2 +- .../wasm_runtime_common_test.cc | 2 +- .../runtime-common/wasm_runtime_init_test.cc | 2 +- tests/unit/shared-utils/bh_assert_test.cc | 2 +- tests/unit/shared-utils/bh_common_test.cc | 2 +- tests/unit/shared-utils/bh_hashmap_test.cc | 2 +- tests/unit/shared-utils/bh_list_test.cc | 4 +-- tests/unit/shared-utils/bh_log_test.cc | 2 +- tests/unit/shared-utils/bh_queue_test.cc | 2 +- tests/unit/shared-utils/bh_vector_test.cc | 2 +- tests/unit/shared-utils/shared_utils_test.cc | 2 +- tests/unit/wasm-vm/wasm_vm.cc | 2 +- 108 files changed, 215 insertions(+), 215 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e04101d2..a8ab96427 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ Code changes We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests: - If you've added code that should be tested, add tests. Ensure the test suite passes. -- Avoid use macros for different platforms. Use seperate folder of source files to host diffeent platform logic. +- Avoid use macros for different platforms. Use separate folder of source files to host different platform logic. - Put macro definitions inside share_lib/include/config.h if you have to use macro. - Make sure your code lints and compliant to our coding style. - Extend the application library is highly welcome. diff --git a/build-scripts/runtime_lib.cmake b/build-scripts/runtime_lib.cmake index c57cfc57a..c3edfe503 100644 --- a/build-scripts/runtime_lib.cmake +++ b/build-scripts/runtime_lib.cmake @@ -14,7 +14,7 @@ if (NOT DEFINED DEPS_DIR) set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps) endif () if (NOT DEFINED SHARED_PLATFORM_CONFIG) - # CMake file for platform configuration. The PLATFORM_SHARED_SOURCE varable + # CMake file for platform configuration. The PLATFORM_SHARED_SOURCE variable # should point to a list of platform-specfic source files to compile. set (SHARED_PLATFORM_CONFIG ${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake) endif () diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 83f393c89..9ca64f9c8 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -1715,7 +1715,7 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, read_uint16(buf, buf_end, type_flag); read_uint8(buf, buf_end, is_equivalence_type); - /* If there is an equivalence type, re-use it */ + /* If there is an equivalence type, reuse it */ if (is_equivalence_type) { uint8 u8; /* padding */ diff --git a/core/iwasm/aot/arch/aot_reloc_xtensa.c b/core/iwasm/aot/arch/aot_reloc_xtensa.c index fca1b80da..a866883d7 100644 --- a/core/iwasm/aot/arch/aot_reloc_xtensa.c +++ b/core/iwasm/aot/arch/aot_reloc_xtensa.c @@ -154,7 +154,7 @@ check_reloc_offset(uint32 target_section_size, uint64 reloc_offset, * CPU like esp32 can read and write data through the instruction bus, but only * in a word aligned manner; non-word-aligned access will cause a CPU exception. * This function uses a world aligned manner to write 16bit value to instruction - * addreess. + * address. */ static void put_imm16_to_addr(int16 imm16, int16 *addr) diff --git a/core/iwasm/common/arch/invokeNative_aarch64.s b/core/iwasm/common/arch/invokeNative_aarch64.s index ea5cbcb36..f48a429c5 100644 --- a/core/iwasm/common/arch/invokeNative_aarch64.s +++ b/core/iwasm/common/arch/invokeNative_aarch64.s @@ -45,7 +45,7 @@ _invokeNative: /* Now x20 points to stack args */ - /* Directly call the fucntion if no args in stack */ + /* Directly call the function if no args in stack */ cmp x21, #0 beq call_func @@ -69,7 +69,7 @@ loop_stack_args: /* copy stack arguments to stack */ call_func: mov x20, x30 /* save x30(lr) */ blr x19 - mov sp, x22 /* restore sp which is saved before calling fuction*/ + mov sp, x22 /* restore sp which is saved before calling function*/ return: mov x30, x20 /* restore x30(lr) */ diff --git a/core/iwasm/common/arch/invokeNative_aarch64_simd.s b/core/iwasm/common/arch/invokeNative_aarch64_simd.s index a6ccc1508..f940c3403 100644 --- a/core/iwasm/common/arch/invokeNative_aarch64_simd.s +++ b/core/iwasm/common/arch/invokeNative_aarch64_simd.s @@ -43,7 +43,7 @@ _invokeNative: /* Now x20 points to stack args */ - /* Directly call the fucntion if no args in stack */ + /* Directly call the function if no args in stack */ cmp x21, #0 beq call_func @@ -67,7 +67,7 @@ loop_stack_args: /* copy stack arguments to stack */ call_func: mov x20, x30 /* save x30(lr) */ blr x19 - mov sp, x22 /* restore sp which is saved before calling fuction*/ + mov sp, x22 /* restore sp which is saved before calling function*/ return: mov x30, x20 /* restore x30(lr) */ diff --git a/core/iwasm/common/arch/invokeNative_arm_vfp.s b/core/iwasm/common/arch/invokeNative_arm_vfp.s index 78a4bab82..19bc5d67c 100644 --- a/core/iwasm/common/arch/invokeNative_arm_vfp.s +++ b/core/iwasm/common/arch/invokeNative_arm_vfp.s @@ -53,7 +53,7 @@ _invokeNative: vldr s13, [r4, #52] vldr s14, [r4, #56] vldr s15, [r4, #60] - /* Directly call the fucntion if no args in stack */ + /* Directly call the function if no args in stack */ cmp r5, #0 beq call_func diff --git a/core/iwasm/common/arch/invokeNative_riscv.S b/core/iwasm/common/arch/invokeNative_riscv.S index 0908f73cc..87039f44c 100644 --- a/core/iwasm/common/arch/invokeNative_riscv.S +++ b/core/iwasm/common/arch/invokeNative_riscv.S @@ -4,7 +4,7 @@ */ /* - * The float abi macros used bellow are from risc-v c api: + * The float abi macros used below are from risc-v c api: * https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md * */ @@ -130,7 +130,7 @@ _invokeNative: loop_stack_args: beq t2, x0, call_func RV_OP_LOADREG t5, 0(t1) /* load stack argument, t5 = argv[i] */ - RV_OP_STOREREG t5, 0(t4) /* store t5 to reseved stack, sp[j] = t5 */ + RV_OP_STOREREG t5, 0(t4) /* store t5 to reserved stack, sp[j] = t5 */ addi t1, t1, RV_REG_SIZE /* move to next stack argument */ addi t4, t4, RV_REG_SIZE /* move to next stack pointer */ addi t2, t2, -1 /* decrease t2 every loop, nstacks = nstacks -1 */ @@ -142,7 +142,7 @@ call_func: /* restore registers pushed in stack or saved in another register */ return: mv sp, fp /* restore sp saved in fp before function call */ - RV_OP_LOADREG fp, 0 * RV_REG_SIZE(sp) /* load previous frame poniter to fp register */ + RV_OP_LOADREG fp, 0 * RV_REG_SIZE(sp) /* load previous frame pointer to fp register */ RV_OP_LOADREG ra, 1 * RV_REG_SIZE(sp) /* load previous return address to ra register */ addi sp, sp, 2 * RV_REG_SIZE /* pop frame, restore sp */ jr ra diff --git a/core/iwasm/common/arch/invokeNative_thumb_vfp.s b/core/iwasm/common/arch/invokeNative_thumb_vfp.s index 218cd91e0..3f12b91d3 100644 --- a/core/iwasm/common/arch/invokeNative_thumb_vfp.s +++ b/core/iwasm/common/arch/invokeNative_thumb_vfp.s @@ -55,7 +55,7 @@ _invokeNative: vldr s13, [r4, #52] vldr s14, [r4, #56] vldr s15, [r4, #60] - /* Directly call the fucntion if no args in stack */ + /* Directly call the function if no args in stack */ cmp r5, #0 beq call_func diff --git a/core/iwasm/common/wasm_application.c b/core/iwasm/common/wasm_application.c index b5928d95c..85f3770f6 100644 --- a/core/iwasm/common/wasm_application.c +++ b/core/iwasm/common/wasm_application.c @@ -118,7 +118,7 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[]) #if WASM_ENABLE_LIBC_WASI != 0 /* In wasi mode, we should call the function named "_start" - which initializes the wasi envrionment and then calls + which initializes the wasi environment and then calls the actual main function. Directly calling main function may cause exception thrown. */ if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) { diff --git a/core/iwasm/common/wasm_c_api.c b/core/iwasm/common/wasm_c_api.c index d5c45a441..269ec5776 100644 --- a/core/iwasm/common/wasm_c_api.c +++ b/core/iwasm/common/wasm_c_api.c @@ -2257,7 +2257,7 @@ wasm_module_new_ex(wasm_store_t *store, wasm_byte_vec_t *binary, LoadArgs *args) if (!store || !binary || binary->size == 0 || binary->size > UINT32_MAX) goto quit; - /* whether the combination of compilation flags are compatable with the + /* whether the combination of compilation flags are compatible with the * package type */ { PackageType pkg_type; diff --git a/core/iwasm/common/wasm_exec_env.c b/core/iwasm/common/wasm_exec_env.c index 48465fc94..e33fd9f3a 100644 --- a/core/iwasm/common/wasm_exec_env.c +++ b/core/iwasm/common/wasm_exec_env.c @@ -202,7 +202,7 @@ wasm_exec_env_destroy(WASMExecEnv *exec_env) wasm_cluster_wait_for_all_except_self(cluster, exec_env); #if WASM_ENABLE_DEBUG_INTERP != 0 /* Must fire exit event after other threads exits, otherwise - the stopped thread will be overriden by other threads */ + the stopped thread will be overridden by other threads */ wasm_cluster_thread_exited(exec_env); #endif /* We have waited for other threads, this is the only alive thread, so diff --git a/core/iwasm/compilation/aot_compiler.h b/core/iwasm/compilation/aot_compiler.h index 06d8e42bd..889e2304b 100644 --- a/core/iwasm/compilation/aot_compiler.h +++ b/core/iwasm/compilation/aot_compiler.h @@ -790,7 +790,7 @@ set_local_gc_ref(AOTCompFrame *frame, int n, LLVMValueRef value, uint8 ref_type) } \ else { \ char *func_name = #name; \ - /* AOT mode, delcare the function */ \ + /* AOT mode, declare the function */ \ if (!(func = LLVMGetNamedFunction(func_ctx->module, func_name)) \ && !(func = LLVMAddFunction(func_ctx->module, func_name, \ func_type))) { \ diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index cfb27fdeb..ecb75968f 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -3846,7 +3846,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, } } - /* pares each relocation */ + /* parse each relocation */ if (!(rel_itr = LLVMGetRelocations(rel_sec))) { aot_set_last_error("llvm get relocations failed."); return false; diff --git a/core/iwasm/compilation/aot_emit_memory.c b/core/iwasm/compilation/aot_emit_memory.c index 9adf96ac5..e685fccd9 100644 --- a/core/iwasm/compilation/aot_emit_memory.c +++ b/core/iwasm/compilation/aot_emit_memory.c @@ -345,7 +345,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, memory allocator, the hmu node includes hmu header and hmu memory, only the latter is returned to the caller as the allocated memory, the hmu header isn't returned so the - first byte of the shared heap won't be accesed, (2) using + first byte of the shared heap won't be accessed, (2) using IntUGT gets better performance than IntUGE in some cases */ BUILD_ICMP(LLVMIntUGT, offset1, func_ctx->shared_heap_start_off, is_in_shared_heap, "is_in_shared_heap"); @@ -1101,7 +1101,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) } else { char *func_name = "aot_enlarge_memory"; - /* AOT mode, delcare the function */ + /* AOT mode, declare the function */ if (!(func = LLVMGetNamedFunction(func_ctx->module, func_name)) && !(func = LLVMAddFunction(func_ctx->module, func_name, func_type))) { @@ -1184,7 +1184,7 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, * Note: not throw the integer-overflow-exception here since it must * have been thrown when converting float to integer before */ - /* return addres directly if constant offset and inside memory space */ + /* return address directly if constant offset and inside memory space */ if (LLVMIsEfficientConstInt(offset) && LLVMIsEfficientConstInt(bytes)) { uint64 mem_offset = (uint64)LLVMConstIntGetZExtValue(offset); uint64 mem_len = (uint64)LLVMConstIntGetZExtValue(bytes); diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index a3ac5113c..a9fd68c24 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -1720,7 +1720,7 @@ aot_create_stack_sizes(const AOTCompData *comp_data, AOTCompContext *comp_ctx) * This value is a placeholder, which will be replaced * after the corresponding functions are compiled. * - * Don't use zeros becasue LLVM can optimize them to + * Don't use zeros because LLVM can optimize them to * zeroinitializer. */ values[i] = I32_NEG_ONE; @@ -2354,7 +2354,7 @@ create_target_machine_detect_host(AOTCompContext *comp_ctx) } if (!LLVMTargetHasJIT(target)) { - aot_set_last_error("unspported JIT on this platform."); + aot_set_last_error("unsupported JIT on this platform."); goto fail; } @@ -3412,7 +3412,7 @@ aot_get_native_symbol_index(AOTCompContext *comp_ctx, const char *symbol) sym = bh_list_first_elem(&comp_ctx->native_symbols); - /* Lookup an existing symobl record */ + /* Lookup an existing symbol record */ while (sym) { if (strcmp(sym->symbol, symbol) == 0) { diff --git a/core/iwasm/compilation/iwasm_compl.cmake b/core/iwasm/compilation/iwasm_compl.cmake index 77925d62d..9db1d5bfe 100644 --- a/core/iwasm/compilation/iwasm_compl.cmake +++ b/core/iwasm/compilation/iwasm_compl.cmake @@ -17,7 +17,7 @@ endif() set (IWASM_COMPL_SOURCE ${source_all}) -# Disalbe rtti to works with LLVM +# Disable rtti to works with LLVM if (MSVC) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") diff --git a/core/iwasm/compilation/simd/simd_int_arith.c b/core/iwasm/compilation/simd/simd_int_arith.c index 6a1902d1f..ada4b5d35 100644 --- a/core/iwasm/compilation/simd/simd_int_arith.c +++ b/core/iwasm/compilation/simd/simd_int_arith.c @@ -32,7 +32,7 @@ simd_integer_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, result = LLVMBuildMul(comp_ctx->builder, lhs, rhs, "product"); break; default: - HANDLE_FAILURE("Unsupport arith_op"); + HANDLE_FAILURE("Unsupported arith_op"); break; } diff --git a/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp b/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp index 79c72503e..967bf14b5 100644 --- a/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp +++ b/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp @@ -423,7 +423,7 @@ jmp_from_label_to_label(x86::Assembler &a, bh_list *jmp_info_list, /** * Encode detecting compare result register according to condition code - * and then jumping to suitable label when the condtion is met + * and then jumping to suitable label when the condition is met * * @param cc the compiler context * @param a the assembler to emit the code @@ -431,7 +431,7 @@ jmp_from_label_to_label(x86::Assembler &a, bh_list *jmp_info_list, * @param label_src the index of src label * @param op the opcode of condition operation * @param r1 the label info when condition is met - * @param r2 the label info when condition is unmet, do nonthing if VOID + * @param r2 the label info when condition is unmet, do nothing if VOID * @param is_last_insn if current insn is the last insn of current block * * @return true if success, false if failed @@ -2589,7 +2589,7 @@ alu_r_r_r_i32(x86::Assembler &a, ALU_OP op, int32 reg_no_dst, int32 reg_no1_src, if (reg_no2_src == REG_EDX_IDX) { /* convert `REM_S edx, eax, edx` into `mov esi, edx` and `REM_S edx eax, rsi` to - avoid overwritting edx when a.cdq() */ + avoid overwriting edx when a.cdq() */ a.mov(regs_i32[REG_I32_FREE_IDX], regs_i32[REG_EDX_IDX]); reg_no2_src = REG_I32_FREE_IDX; } @@ -2609,7 +2609,7 @@ alu_r_r_r_i32(x86::Assembler &a, ALU_OP op, int32 reg_no_dst, int32 reg_no1_src, if (reg_no2_src == REG_EDX_IDX) { /* convert `REM_U edx, eax, edx` into `mov esi, edx` and `REM_U edx eax, rsi` to - avoid overwritting edx when unsigned extend + avoid overwriting edx when unsigned extend eax to edx:eax */ a.mov(regs_i32[REG_I32_FREE_IDX], regs_i32[REG_EDX_IDX]); reg_no2_src = REG_I32_FREE_IDX; @@ -5602,7 +5602,7 @@ fail: a.jmp(imm); \ if (!err_handler->err) { \ /* The offset written by asmjit is always 0, we patch it \ - again, 6 is the size of jmp instruciton */ \ + again, 6 is the size of jmp instruction */ \ stream = (char *)a.code()->sectionById(0)->buffer().data() \ + a.code()->sectionById(0)->buffer().size() - 6; \ _offset = label_offsets[label_dst] \ @@ -6169,7 +6169,7 @@ fail: * Replace all the jmp address pre-saved when the code cache hasn't been * allocated with actual address after code cache allocated * - * @param cc compiler context containting the allocated code cacha info + * @param cc compiler context containing the allocated code cacha info * @param jmp_info_list the jmp info list */ static void @@ -6557,7 +6557,7 @@ at_cmpxchg_r_ra_base_r_offset_imm(x86::Assembler &a, uint32 bytes_dst, * @param a the assembler to emit the code * @param bytes_dst the bytes number of the data to actual operated on(load, * compare, replacement) could be 1(byte), 2(short), 4(int32), 8(int64) - * @param data_xchg the immediate data for exchange(conditionally replacment + * @param data_xchg the immediate data for exchange(conditionally replacement * value) * @param reg_no_base the no of register that stores the base address * of src&dst memory @@ -6587,7 +6587,7 @@ at_cmpxchg_imm_ra_base_r_offset_r(x86::Assembler &a, uint32 bytes_dst, * @param a the assembler to emit the code * @param bytes_dst the bytes number of the data to actual operated on(load, * compare, replacement) could be 1(byte), 2(short), 4(int32), 8(int64) - * @param data_xchg the immediate data for exchange(conditionally replacment + * @param data_xchg the immediate data for exchange(conditionally replacement * value) * @param reg_no_base the no of register that stores the base address * of src&dst memory @@ -8820,7 +8820,7 @@ jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx) /* If yes, set eax to 0, return to caller */ - /* Pop all integer arument registers */ + /* Pop all integer argument registers */ for (i = 0; i < MAX_REG_INTS; i++) { a.pop(regs_i64[reg_idx_of_int_args[i]]); } @@ -9084,7 +9084,7 @@ jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx) a.mov(m, x86::rdx); } - /* Pop all integer arument registers */ + /* Pop all integer argument registers */ for (i = 0; i < MAX_REG_INTS; i++) { a.pop(regs_i64[reg_idx_of_int_args[i]]); } diff --git a/core/iwasm/fast-jit/fe/jit_emit_compare.c b/core/iwasm/fast-jit/fe/jit_emit_compare.c index 8fe48f142..02619a4d2 100644 --- a/core/iwasm/fast-jit/fe/jit_emit_compare.c +++ b/core/iwasm/fast-jit/fe/jit_emit_compare.c @@ -14,7 +14,7 @@ jit_compile_op_compare_integer(JitCompContext *cc, IntCond cond, bool is64Bit) JitReg lhs, rhs, res, const_zero, const_one; if (cond < INT_EQZ || cond > INT_GE_U) { - jit_set_last_error(cc, "unsupported comparation operation"); + jit_set_last_error(cc, "unsupported comparison operation"); goto fail; } diff --git a/core/iwasm/fast-jit/fe/jit_emit_control.c b/core/iwasm/fast-jit/fe/jit_emit_control.c index 9274e7217..04140b6ae 100644 --- a/core/iwasm/fast-jit/fe/jit_emit_control.c +++ b/core/iwasm/fast-jit/fe/jit_emit_control.c @@ -1230,7 +1230,7 @@ jit_compile_op_br_table(JitCompContext *cc, uint32 *br_depths, uint32 br_count, copy_arities = check_copy_arities(block_dst, cc->jit_frame); if (!copy_arities) { - /* No need to create new basic block, direclty jump to + /* No need to create new basic block, directly jump to the existing basic block when no need to copy arities */ if (i == br_count) { if (block_dst->label_type == LABEL_TYPE_LOOP) { diff --git a/core/iwasm/fast-jit/jit_frontend.c b/core/iwasm/fast-jit/jit_frontend.c index ca5521a14..566783b6f 100644 --- a/core/iwasm/fast-jit/jit_frontend.c +++ b/core/iwasm/fast-jit/jit_frontend.c @@ -31,7 +31,7 @@ get_global_base_offset(const WASMModule *module) * (module->import_memory_count + module->memory_count); #if WASM_ENABLE_JIT != 0 - /* If the module dosen't have memory, reserve one mem_info space + /* If the module doesn't have memory, reserve one mem_info space with empty content to align with llvm jit compiler */ if (mem_inst_size == 0) mem_inst_size = (uint32)sizeof(WASMMemoryInstance); @@ -1169,7 +1169,7 @@ init_func_translation(JitCompContext *cc) time_started = jit_cc_new_reg_I64(cc); /* Call os_time_thread_cputime_us() to get time_started firstly as there is stack frame switching below, calling native in them - may cause register spilling work inproperly */ + may cause register spilling work improperly */ if (!jit_emit_callnative(cc, os_time_thread_cputime_us, time_started, NULL, 0)) { return NULL; diff --git a/core/iwasm/fast-jit/jit_ir.h b/core/iwasm/fast-jit/jit_ir.h index bef3fcc0c..6b3acfa0b 100644 --- a/core/iwasm/fast-jit/jit_ir.h +++ b/core/iwasm/fast-jit/jit_ir.h @@ -94,7 +94,7 @@ typedef uint32 JitReg; /* * Constant index flag of non-constant-value (constant value flag is * not set in register no. field) integer, floating point and vector - * regisers. If this flag is set, the rest bits of the register + * registers. If this flag is set, the rest bits of the register * no. represent an index to the constant value table of the * corresponding type of the register and the register is read-only. */ @@ -1084,7 +1084,7 @@ typedef struct JitCompContext { /* Capacity of register annotations of each kind. */ uint32 _capacity[JIT_REG_KIND_L32]; - /* Constant vallues of each kind. */ + /* Constant values of each kind. */ uint8 *_value[JIT_REG_KIND_L32]; /* Next element on the list of values with the same hash code. */ @@ -1145,7 +1145,7 @@ typedef struct JitCompContext { JitInsn **_table; } _insn_hash_table; - /* indicate if the last comparision is about floating-point numbers or not + /* indicate if the last comparison is about floating-point numbers or not */ bool last_cmp_on_fp; } JitCompContext; @@ -1203,7 +1203,7 @@ typedef struct JitCompContext { * Annotation disabling functions jit_annl_disable_NAME, * jit_anni_disable_NAME and jit_annr_disable_NAME, which release * memory of the annotations. Before calling these functions, - * resources owned by the annotations must be explictely released. + * resources owned by the annotations must be explicitly released. */ #define ANN_LABEL(TYPE, NAME) void jit_annl_disable_##NAME(JitCompContext *cc); #define ANN_INSN(TYPE, NAME) void jit_anni_disable_##NAME(JitCompContext *cc); @@ -1559,7 +1559,7 @@ _jit_cc_new_insn_norm(JitCompContext *cc, JitReg *result, JitInsn *insn); * * @param cc the compilationo context * @param result returned result of the instruction. If the value is - * non-zero, it is the result of the constant-folding or an exsiting + * non-zero, it is the result of the constant-folding or an existing * equivalent instruction, in which case no instruction is added into * the compilation context. Otherwise, a new normalized instruction * has been added into the compilation context. diff --git a/core/iwasm/fast-jit/jit_regalloc.c b/core/iwasm/fast-jit/jit_regalloc.c index 70ca228ac..96e5a57cf 100644 --- a/core/iwasm/fast-jit/jit_regalloc.c +++ b/core/iwasm/fast-jit/jit_regalloc.c @@ -221,7 +221,7 @@ get_reg_stride(JitReg reg) * @param rc the regalloc context * @param vreg the virtual register * - * @return the spill slot encoded in a consant register + * @return the spill slot encoded in a constant register */ static JitReg rc_alloc_spill_slot(RegallocContext *rc, JitReg vreg) @@ -478,7 +478,7 @@ reload_vreg(RegallocContext *rc, JitReg vreg, JitInsn *cur_insn) JitReg fp_reg = rc->cc->fp_reg, offset; if (!vr->slot && !(vr->slot = rc_alloc_spill_slot(rc, vreg))) - /* Cannot allocte spill slot (due to OOM or frame size limit). */ + /* Cannot allocate spill slot (due to OOM or frame size limit). */ return NULL; offset = offset_of_spill_slot(rc->cc, vr->slot); @@ -579,7 +579,7 @@ spill_vreg(RegallocContext *rc, JitReg vreg, JitInsn *cur_insn) /** * Allocate a hard register for the virtual register. Necessary - * reloade instruction will be inserted after the given instruction. + * reload instruction will be inserted after the given instruction. * * @param rc the regalloc context * @param vreg the virtual register @@ -665,7 +665,7 @@ allocate_hreg(RegallocContext *rc, JitReg vreg, JitInsn *insn, int distance) /** * Allocate a hard register for the virtual register if not allocated - * yet. Necessary spill and reloade instructions will be inserted + * yet. Necessary spill and reload instructions will be inserted * before/after and after the given instruction. This operation will * convert the virtual register's state from 1 or 3 to 2. * diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index 273657246..17beb3ad7 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -2283,7 +2283,7 @@ wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst); * @param size required memory size * @param p_native_addr native address of allocated memory * - * @return return the allocated memory address, which re-uses part of the wasm + * @return return the allocated memory address, which reuses part of the wasm * address space and is in the range of [UINT32 - shared_heap_size + 1, UINT32] * (when the wasm memory is 32-bit) or [UINT64 - shared_heap_size + 1, UINT64] * (when the wasm memory is 64-bit). Note that it is not an absolute address. diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 98668470f..d504e984c 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1934,7 +1934,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, UNWIND_CSP(relative_depth, LABEL_TYPE_FUNCTION); /* push exception values for catch * The values are copied to the CALLER FRAME - * (prev_frame->sp) same behvior ad WASM_OP_RETURN + * (prev_frame->sp) same behavior ad WASM_OP_RETURN */ if (cell_num_to_copy > 0) { word_copy(prev_frame->sp, @@ -4963,7 +4963,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of i32 */ + /* numeric instructions of i32 */ HANDLE_OP(WASM_OP_I32_CLZ) { DEF_OP_BIT_COUNT(uint32, I32, clz32); @@ -5120,7 +5120,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of i64 */ + /* numeric instructions of i64 */ HANDLE_OP(WASM_OP_I64_CLZ) { DEF_OP_BIT_COUNT(uint64, I64, clz64); @@ -5277,7 +5277,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of f32 */ + /* numeric instructions of f32 */ HANDLE_OP(WASM_OP_F32_ABS) { DEF_OP_MATH(float32, F32, fabsf); @@ -5381,7 +5381,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of f64 */ + /* numeric instructions of f64 */ HANDLE_OP(WASM_OP_F64_ABS) { DEF_OP_MATH(float64, F64, fabs); @@ -6680,7 +6680,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, tag++, t++) { /* compare the module and the external index with the - * imort tag data */ + * import tag data */ if ((cur_func->u.func_import->import_module == tag->u.tag_import->import_module) && (ext_exception diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 359a6979c..96b9ba2b2 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -4149,7 +4149,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of i32 */ + /* numeric instructions of i32 */ HANDLE_OP(WASM_OP_I32_CLZ) { DEF_OP_BIT_COUNT(uint32, I32, clz32); @@ -4319,7 +4319,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of i64 */ + /* numeric instructions of i64 */ HANDLE_OP(WASM_OP_I64_CLZ) { DEF_OP_BIT_COUNT(uint64, I64, clz64); @@ -4476,7 +4476,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of f32 */ + /* numeric instructions of f32 */ HANDLE_OP(WASM_OP_F32_ABS) { DEF_OP_MATH(float32, F32, fabsf); @@ -4581,7 +4581,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } - /* numberic instructions of f64 */ + /* numeric instructions of f64 */ HANDLE_OP(WASM_OP_F64_ABS) { DEF_OP_MATH(float64, F64, fabs); diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index d00f761df..31424d21e 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -399,7 +399,7 @@ check_array_type(const WASMModule *module, uint32 type_index, char *error_buf, return false; } if (module->types[type_index]->type_flag != WASM_TYPE_ARRAY) { - set_error_buf(error_buf, error_buf_size, "unkown array type"); + set_error_buf(error_buf, error_buf_size, "unknown array type"); return false; } @@ -954,7 +954,7 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, if (struct_type->base_type.type_flag != WASM_TYPE_STRUCT) { set_error_buf(error_buf, error_buf_size, - "unkown struct type"); + "unknown struct type"); goto fail; } field_count = struct_type->field_count; @@ -1020,7 +1020,7 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, if (module->types[type_idx]->type_flag != WASM_TYPE_STRUCT) { set_error_buf(error_buf, error_buf_size, - "unkown struct type"); + "unknown struct type"); goto fail; } @@ -1059,7 +1059,7 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, if (array_type->base_type.type_flag != WASM_TYPE_ARRAY) { set_error_buf(error_buf, error_buf_size, - "unkown array type"); + "unknown array type"); goto fail; } @@ -11420,7 +11420,7 @@ re_scan: if (!check_offset_push(loader_ctx, error_buf, error_buf_size)) goto fail; - /* for following dummy value assignemnt */ + /* for following dummy value assignment */ loader_ctx->frame_offset -= cell_num; } @@ -11732,7 +11732,7 @@ re_scan: */ cur_block->label_type = LABEL_TYPE_CATCH; - /* RESET_STACK removes the values pushed in TRY or pervious + /* RESET_STACK removes the values pushed in TRY or previous * CATCH Blocks */ RESET_STACK(); @@ -11774,7 +11774,7 @@ re_scan: /* replace frame_csp by LABEL_TYPE_CATCH_ALL */ cur_block->label_type = LABEL_TYPE_CATCH_ALL; - /* RESET_STACK removes the values pushed in TRY or pervious + /* RESET_STACK removes the values pushed in TRY or previous * CATCH Blocks */ RESET_STACK(); @@ -12128,7 +12128,7 @@ re_scan: } if (module->types[type_idx1]->type_flag != WASM_TYPE_FUNC) { set_error_buf(error_buf, error_buf_size, - "unkown function type"); + "unknown function type"); goto fail; } if (!wasm_loader_pop_nullable_typeidx(loader_ctx, &type, @@ -12145,7 +12145,7 @@ re_scan: } if (module->types[type_idx]->type_flag != WASM_TYPE_FUNC) { set_error_buf(error_buf, error_buf_size, - "unkown function type"); + "unknown function type"); goto fail; } if (!wasm_func_type_is_super_of( @@ -13911,7 +13911,7 @@ re_scan: if (module->types[type_idx]->type_flag != WASM_TYPE_STRUCT) { set_error_buf(error_buf, error_buf_size, - "unkown struct type"); + "unknown struct type"); goto fail; } diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index d20c28d7d..ecda490df 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -2457,7 +2457,7 @@ orcjit_thread_callback(void *arg) i + j * group_stride + module->import_function_count, (void *)func_addr); - /* Try to switch to call this llvm jit funtion instead of + /* Try to switch to call this llvm jit function instead of fast jit function from fast jit jitted code */ jit_compiler_set_call_to_llvm_jit( module, diff --git a/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h b/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h index 98429bbb0..78eb457f5 100644 --- a/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h +++ b/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h @@ -991,7 +991,7 @@ __wasi_sock_get_ipv6_only(__wasi_fd_t fd, bool *option) /** * TODO: modify recv() and send() * since don't want to re-compile the wasi-libc, - * we tend to keep original implentations of recv() and send(). + * we tend to keep original implementations of recv() and send(). */ #ifdef __cplusplus diff --git a/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c b/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c index c4c2d2857..79baebfa4 100644 --- a/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c +++ b/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c @@ -65,7 +65,7 @@ test(int iter_num, int max_threads_num, int retry_num, int retry_time_us) } while ((__atomic_load_n(&threads_in_use, __ATOMIC_SEQ_CST) != 0)) { - // Casting to int* to supress compiler warning + // Casting to int* to suppress compiler warning __builtin_wasm_memory_atomic_wait32((int *)(&threads_in_use), 0, second_us); } diff --git a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h index d958fa39c..580ce7987 100644 --- a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h +++ b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h @@ -26,7 +26,7 @@ typedef __wasi_dircookie_t wasi_dircookie_t; // result are not guaranteed to be zero'ed by us so the result essentially // contains garbage from the WASM app perspective. To prevent this, we return // uint32 directly instead so as not to be reliant on the correct behaviour of -// any current/future WASI SDK implemenations. +// any current/future WASI SDK implementations. typedef uint32_t wasi_errno_t; typedef __wasi_event_t wasi_event_t; typedef __wasi_exitcode_t wasi_exitcode_t; diff --git a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h index ed8463866..3972c76ed 100644 --- a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h +++ b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h @@ -6,7 +6,7 @@ */ /** - * The defitions of type, macro and structure in this file should be + * The definitions of type, macro and structure in this file should be * consistent with those in wasi-libc: * https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/wasi/api.h */ diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c index 58d29163c..23c867b0a 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c @@ -14,7 +14,7 @@ extern char const *LLAMA_COMMIT; extern char const *LLAMA_COMPILER; extern char const *LLAMA_BUILD_TARGET; -// compatable with WasmEdge +// compatible with WasmEdge // https://github.com/second-state/WasmEdge-WASINN-examples/blob/master/wasmedge-ggml/README.md#parameters // https://github.com/WasmEdge/WasmEdge/blob/master/plugins/wasi_nn/ggml.cpp struct wasi_nn_llama_config { diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp index 6a3b5a47d..f63d57e07 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp @@ -56,7 +56,7 @@ initialize_g(TFLiteContext *tfl_ctx, graph *g) os_mutex_lock(&tfl_ctx->g_lock); if (tfl_ctx->current_models == MAX_GRAPHS_PER_INST) { os_mutex_unlock(&tfl_ctx->g_lock); - NN_ERR_PRINTF("Excedded max graphs per WASM instance"); + NN_ERR_PRINTF("Exceeded max graphs per WASM instance"); return runtime_error; } *g = tfl_ctx->current_models++; @@ -70,7 +70,7 @@ initialize_graph_ctx(TFLiteContext *tfl_ctx, graph g, os_mutex_lock(&tfl_ctx->g_lock); if (tfl_ctx->current_interpreters == MAX_GRAPH_EXEC_CONTEXTS_PER_INST) { os_mutex_unlock(&tfl_ctx->g_lock); - NN_ERR_PRINTF("Excedded max graph execution context per WASM instance"); + NN_ERR_PRINTF("Exceeded max graph execution context per WASM instance"); return runtime_error; } *ctx = tfl_ctx->current_interpreters++; @@ -325,7 +325,7 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index, int size = model_tensor_size * sizeof(float); bh_memcpy_s(it, size, input_tensor->data, size); } - else { // TODO: Assumming uint8 quantized networks. + else { // TODO: Assuming uint8 quantized networks. TfLiteAffineQuantization *quant_info = (TfLiteAffineQuantization *)tensor->quantization.params; if (quant_info->scale->size != 1 || quant_info->zero_point->size != 1) { @@ -406,7 +406,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, int size = model_tensor_size * sizeof(float); bh_memcpy_s(output_tensor, size, ot, size); } - else { // TODO: Assumming uint8 quantized networks. + else { // TODO: Assuming uint8 quantized networks. TfLiteAffineQuantization *quant_info = (TfLiteAffineQuantization *)tensor->quantization.params; if (quant_info->scale->size != 1 || quant_info->zero_point->size != 1) { diff --git a/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py b/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py index 00e126d88..3637bc371 100644 --- a/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py +++ b/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py @@ -286,7 +286,7 @@ def execute_wasmedge_ggml_qwen(iwasm_bin: str, wasmedge_bin: str, cwd: Path): p.stdin.write(b"hi\n") p.stdin.flush() - # ASSITANT + # ASSISTANT p.stdout.readline() # xxx p.stdout.readline() @@ -296,7 +296,7 @@ def execute_wasmedge_ggml_qwen(iwasm_bin: str, wasmedge_bin: str, cwd: Path): p.stdin.write(prompt.encode()) p.stdin.write(b"\n") p.stdin.flush() - # ASSITANT + # ASSISTANT p.stdout.readline() # xxx answer = p.stdout.readline().decode("utf-8") diff --git a/core/shared/mem-alloc/ems/ems_alloc.c b/core/shared/mem-alloc/ems/ems_alloc.c index e272b3014..74214b224 100644 --- a/core/shared/mem-alloc/ems/ems_alloc.c +++ b/core/shared/mem-alloc/ems/ems_alloc.c @@ -40,7 +40,7 @@ hmu_is_in_heap(void *hmu, gc_uint8 *heap_base_addr, gc_uint8 *heap_end_addr) * the node will be removed from the tree, and the left, right and * parent pointers of the node @p will be set to be NULL. Other fields * won't be touched. The tree will be re-organized so that the order - * conditions are still satisified. + * conditions are still satisfied. */ static bool remove_tree_node(gc_heap_t *heap, hmu_tree_node_t *p) @@ -648,7 +648,7 @@ gc_realloc_vo_internal(void *vheap, void *ptr, gc_size_t size, const char *file, hmu_old = obj_to_hmu(obj_old); tot_size_old = hmu_get_size(hmu_old); if (tot_size <= tot_size_old) - /* current node alreay meets requirement */ + /* current node already meets requirement */ return obj_old; } diff --git a/core/shared/mem-alloc/ems/ems_gc.h b/core/shared/mem-alloc/ems/ems_gc.h index ff65b4e7c..9913ca2b6 100644 --- a/core/shared/mem-alloc/ems/ems_gc.h +++ b/core/shared/mem-alloc/ems/ems_gc.h @@ -115,7 +115,7 @@ gc_init_with_struct_and_pool(char *struct_buf, gc_size_t struct_buf_size, char *pool_buf, gc_size_t pool_buf_size); /** - * Destroy heap which is initilized from a buffer + * Destroy heap which is initialized from a buffer * * @param handle handle to heap needed destroy * diff --git a/core/shared/mem-alloc/ems/ems_gc_internal.h b/core/shared/mem-alloc/ems/ems_gc_internal.h index c902d5711..c90494201 100644 --- a/core/shared/mem-alloc/ems/ems_gc_internal.h +++ b/core/shared/mem-alloc/ems/ems_gc_internal.h @@ -287,7 +287,7 @@ typedef struct gc_heap_struct { additional memory fails. When the fast mode fails, the marking process can still be done in the slow mode, which doesn't need additional memory (by walking through all - blocks and marking sucessors of marked nodes until no new + blocks and marking successors of marked nodes until no new node is marked). TODO: slow mode is not implemented. */ unsigned is_fast_marking_failed : 1; @@ -319,7 +319,7 @@ typedef struct gc_heap_struct { * the nodes, a new space will be allocated from heap */ extra_info_node_t *extra_info_normal_nodes[EXTRA_INFO_NORMAL_NODE_CNT]; /* Used to store extra information such as finalizer for specified nodes, we - * introduce a seperate space to store these information so only nodes who + * introduce a separate space to store these information so only nodes who * really require extra information will occupy additional memory spaces. */ extra_info_node_t **extra_info_nodes; gc_size_t extra_info_node_cnt; diff --git a/core/shared/mem-alloc/ems/ems_hmu.c b/core/shared/mem-alloc/ems/ems_hmu.c index e4c79e339..ea84d98cd 100644 --- a/core/shared/mem-alloc/ems/ems_hmu.c +++ b/core/shared/mem-alloc/ems/ems_hmu.c @@ -9,7 +9,7 @@ /** * Set default value to prefix and suffix - * @param hmu should not be NULL and should have been correctly initilized + * @param hmu should not be NULL and should have been correctly initialized * (except prefix and suffix part) * @param tot_size is offered here because hmu_get_size can not be used * till now. tot_size should not be smaller than OBJ_EXTRA_SIZE. diff --git a/core/shared/mem-alloc/ems/ems_kfc.c b/core/shared/mem-alloc/ems/ems_kfc.c index 8ab2df545..893dd5638 100644 --- a/core/shared/mem-alloc/ems/ems_kfc.c +++ b/core/shared/mem-alloc/ems/ems_kfc.c @@ -232,7 +232,7 @@ gc_migrate(gc_handle_t handle, char *pool_buf_new, gc_size_t pool_buf_size) heap_max_size = (uint32)(pool_buf_end - base_addr_new) & (uint32)~7; if (pool_buf_end < base_addr_new || heap_max_size < heap->current_size) { - LOG_ERROR("[GC_ERROR]heap migrate invlaid pool buf size\n"); + LOG_ERROR("[GC_ERROR]heap migrate invalid pool buf size\n"); return GC_ERROR; } diff --git a/core/shared/platform/common/posix/posix_thread.c b/core/shared/platform/common/posix/posix_thread.c index 1d1024606..80b7d6545 100644 --- a/core/shared/platform/common/posix/posix_thread.c +++ b/core/shared/platform/common/posix/posix_thread.c @@ -495,7 +495,7 @@ os_thread_jit_write_protect_np(bool enabled) #define SIG_ALT_STACK_SIZE (32 * 1024) /** - * Whether thread signal enviornment is initialized: + * Whether thread signal environment is initialized: * the signal handler is registered, the stack pages are touched, * the stack guard pages are set and signal alternate stack are set. */ @@ -696,7 +696,7 @@ os_thread_signal_init(os_signal_handler handler) memset(&prev_sig_act_SIGSEGV, 0, sizeof(struct sigaction)); memset(&prev_sig_act_SIGBUS, 0, sizeof(struct sigaction)); - /* Install signal hanlder */ + /* Install signal handler */ sig_act.sa_sigaction = signal_callback; sig_act.sa_flags = SA_SIGINFO | SA_NODEFER; #if WASM_DISABLE_STACK_HW_BOUND_CHECK == 0 diff --git a/core/shared/platform/include/platform_api_extension.h b/core/shared/platform/include/platform_api_extension.h index 37b8399b8..12843b7c1 100644 --- a/core/shared/platform/include/platform_api_extension.h +++ b/core/shared/platform/include/platform_api_extension.h @@ -209,7 +209,7 @@ int os_cond_wait(korp_cond *cond, korp_mutex *mutex); /** - * Wait a condition varible or return if time specified passes. + * Wait a condition variable or return if time specified passes. * * @param cond pointer to condition variable * @param mutex pointer to mutex to protect the condition variable @@ -766,7 +766,7 @@ int os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us); /** - * Enable re-use of local addresses + * Enable reuse of local addresses * * @param socket the socket to set * @param is_enabled 1 to enable or 0 to disable @@ -777,7 +777,7 @@ int os_socket_set_reuse_addr(bh_socket_t socket, bool is_enabled); /** - * Get whether re-use of local addresses is enabled + * Get whether reuse of local addresses is enabled * * @param socket the socket to set * @param is_enabled 1 for enabled or 0 for disabled @@ -788,7 +788,7 @@ int os_socket_get_reuse_addr(bh_socket_t socket, bool *is_enabled); /** - * Enable re-use of local ports + * Enable reuse of local ports * * @param socket the socket to set * @param is_enabled 1 to enable or 0 to disable @@ -799,7 +799,7 @@ int os_socket_set_reuse_port(bh_socket_t socket, bool is_enabled); /** - * Get whether re-use of local ports is enabled + * Get whether reuse of local ports is enabled * * @param socket the socket to set * @param is_enabled 1 for enabled or 0 for disabled @@ -1120,7 +1120,7 @@ os_dumps_proc_mem_info(char *out, unsigned int size); /** * NOTES: - * Fileystem APIs are required for WASI libc support. If you don't need to + * Filesystem APIs are required for WASI libc support. If you don't need to * support WASI libc, there is no need to implement these APIs. With a * few exceptions, each filesystem function has been named after the equivalent * POSIX filesystem function with an os_ prefix. @@ -1134,12 +1134,12 @@ os_dumps_proc_mem_info(char *out, unsigned int size); * os_file_handle: the file handle type used in the WASI libc fd * table. Filesystem implementations can use it as a means to store any * necessary platform-specific information which may not be directly available - * through the raw OS file handle. Similiar to POSIX file descriptors, file + * through the raw OS file handle. Similar to POSIX file descriptors, file * handles may also refer to sockets, directories, symbolic links or character * devices and any of the filesystem operations which make sense for these * resource types should be supported as far as possible. * - * os_dir_stream: a directory stream type in which fileystem implementations + * os_dir_stream: a directory stream type in which filesystem implementations * can store any necessary state to iterate over the entries in a directory. */ @@ -1166,7 +1166,7 @@ os_fstatat(os_file_handle handle, const char *path, struct __wasi_filestat_t *buf, __wasi_lookupflags_t lookup_flags); /** - * Obtain the file status flags for the provided handle. This is similiar to the + * Obtain the file status flags for the provided handle. This is similar to the * POSIX function fcntl called with the F_GETFL command. * * @param handle the handle for which to obtain the file status flags @@ -1176,7 +1176,7 @@ __wasi_errno_t os_file_get_fdflags(os_file_handle handle, __wasi_fdflags_t *flags); /** - * Set the file status flags for the provided handle. This is similiar to the + * Set the file status flags for the provided handle. This is similar to the * POSIX function fcntl called with the F_SETFL command. * * @param handle the handle for which to set the file status flags @@ -1235,7 +1235,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, wasi_libc_file_access_mode access_mode, os_file_handle *out); /** - * Obtain the file access mode for the provided handle. This is similiar to the + * Obtain the file access mode for the provided handle. This is similar to the * POSIX function fcntl called with the F_GETFL command combined with the * O_ACCMODE mask. * @@ -1480,9 +1480,9 @@ os_file_handle os_convert_stdin_handle(os_raw_file_handle raw_stdin); /** - * Converts a raw file handle to STDOUT to a correponding file handle to STDOUT. - * If the provided raw file handle is invalid, the platform-default raw handle - * for STDOUT will be used. + * Converts a raw file handle to STDOUT to a corresponding file handle to + * STDOUT. If the provided raw file handle is invalid, the platform-default raw + * handle for STDOUT will be used. * * @param raw_stdout a raw file handle to STDOUT * @@ -1492,9 +1492,9 @@ os_file_handle os_convert_stdout_handle(os_raw_file_handle raw_stdout); /** - * Converts a raw file handle to STDERR to a correponding file handle to STDERR. - * If the provided raw file handle is invalid, the platform-default raw handle - * for STDERR will be used. + * Converts a raw file handle to STDERR to a corresponding file handle to + * STDERR. If the provided raw file handle is invalid, the platform-default raw + * handle for STDERR will be used. * * @param raw_stderr a raw file handle to STDERR * diff --git a/core/shared/platform/linux-sgx/sgx_ipfs.c b/core/shared/platform/linux-sgx/sgx_ipfs.c index 4f4bbef9b..3a46a4170 100644 --- a/core/shared/platform/linux-sgx/sgx_ipfs.c +++ b/core/shared/platform/linux-sgx/sgx_ipfs.c @@ -53,7 +53,7 @@ convert_sgx_errno(int error) * continue (only used when no EXXX is returned) */ case SGX_ERROR_FILE_CANT_WRITE_RECOVERY_FILE: return EIO; - /* When openeing the file, recovery is needed, but the recovery + /* When opening the file, recovery is needed, but the recovery * process failed */ case SGX_ERROR_FILE_RECOVERY_NEEDED: return EIO; diff --git a/core/shared/platform/linux-sgx/sgx_socket.h b/core/shared/platform/linux-sgx/sgx_socket.h index edf977dd6..b1a91cf1c 100644 --- a/core/shared/platform/linux-sgx/sgx_socket.h +++ b/core/shared/platform/linux-sgx/sgx_socket.h @@ -51,7 +51,7 @@ extern "C" { #define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ #define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ #define TCP_INFO 11 /* Information about this connection. */ -#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ +#define TCP_QUICKACK 12 /* Bock/re-enable quick ACKs. */ #define TCP_CONGESTION 13 /* Congestion control algorithm. */ #define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ #define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */ diff --git a/core/shared/platform/riot/riot_thread.c b/core/shared/platform/riot/riot_thread.c index a9062bfec..893ed0b45 100644 --- a/core/shared/platform/riot/riot_thread.c +++ b/core/shared/platform/riot/riot_thread.c @@ -282,7 +282,7 @@ os_thread_join(korp_tid thread, void **value_ptr) mutex_unlock(&thread_data->wait_list_lock); sema_wait(&node.sem); - // get the return value pointer conted may not be availible after return + // get the return value pointer conted may not be available after return if (value_ptr) (*value_ptr) = node.ret; /* Wait some time for the thread to be actually terminated */ diff --git a/core/shared/utils/bh_list.c b/core/shared/utils/bh_list.c index 7102d42a1..3265ba601 100644 --- a/core/shared/utils/bh_list.c +++ b/core/shared/utils/bh_list.c @@ -7,7 +7,7 @@ #if BH_DEBUG != 0 /** - * Test whehter a pointer value has exist in given list. + * Test whether a pointer value has exist in given list. * * @param list pointer to list. * @param elem pointer to elem that will be inserted into list. diff --git a/doc/build_wasm_app.md b/doc/build_wasm_app.md index 95d237346..ef9bea9e2 100644 --- a/doc/build_wasm_app.md +++ b/doc/build_wasm_app.md @@ -90,7 +90,7 @@ There are some useful options that are used to compile C/C++ to Wasm (for a full - **-Wl,--max-memory=\** Maximum size of the linear memory, which must be a multiple of 65536 -- **-z stack-size=\** The auxiliary stack size, which is an area of linear memory, must be smaller than the initial memory size. +- **-z stack-size=\** The auxiliary stack size, which is an area of linear memory, must be smaller than the initial memory size. - **-Wl,--strip-all** Strip all symbols @@ -343,7 +343,7 @@ Usage: wamrc [options] -o output_file wasm_file Use --cpu-features=+help to list all the features supported --opt-level=n Set the optimization level (0 to 3, default is 3) --size-level=n Set the code size level (0 to 3, default is 3) - -sgx Generate code for SGX platform (Intel Software Guard Extention) + -sgx Generate code for SGX platform (Intel Software Guard Extension) --bounds-checks=1/0 Enable or disable the bounds checks for memory access: by default it is disabled in all 64-bit platforms except SGX and in these platforms runtime does bounds checks with hardware trap, diff --git a/doc/other_wasm_compilers.md b/doc/other_wasm_compilers.md index 5aa505ab3..1ab5901fa 100644 --- a/doc/other_wasm_compilers.md +++ b/doc/other_wasm_compilers.md @@ -62,7 +62,7 @@ You will get ```test.wasm``` which is the WASM app binary. ## Using Docker -Another method availble is using [Docker](https://www.docker.com/). We assume you've already configured Docker (see Platform section above) and have a running interactive shell. Currently the Dockerfile only supports compiling apps with clang, with Emscripten planned for the future. +Another method available is using [Docker](https://www.docker.com/). We assume you've already configured Docker (see Platform section above) and have a running interactive shell. Currently the Dockerfile only supports compiling apps with clang, with Emscripten planned for the future. Use the clang-8 command below to build the WASM C source code into the WASM binary. diff --git a/doc/source_debugging_aot.md b/doc/source_debugging_aot.md index 129287bde..62ed51e0b 100644 --- a/doc/source_debugging_aot.md +++ b/doc/source_debugging_aot.md @@ -90,7 +90,7 @@ wamrc -o test.aot test.wasm function of the AOT-compiled wasm module. * WAMR AOT debugging uses the GDB JIT loader mechanism to load - the debug info of the debugee module. + the debug info of the debuggee module. On some platforms including macOS, you need to enable it explicitly. (`settings set plugin.jit-loader.gdb.enable on`) diff --git a/product-mini/README.md b/product-mini/README.md index 1e7a1f3cf..5563d9579 100644 --- a/product-mini/README.md +++ b/product-mini/README.md @@ -87,8 +87,8 @@ make ``` Note: -By default, the LLVM Orc JIT with Lazy compilation is enabled to speedup the lanuching process and reduce -the JIT compilation time by creating backend threads to compile the WASM functions parallely, and for the +By default, the LLVM Orc JIT with Lazy compilation is enabled to speedup the launching process and reduce +the JIT compilation time by creating backend threads to compile the WASM functions parallelly, and for the main thread, the functions in the module will not be compiled until they are firstly called and haven't been compiled by the compilation threads. @@ -114,7 +114,7 @@ mkdir build && cd build cmake .. -DWAMR_BUILD_FAST_JTI=1 -DWAMR_BUILD_JIT=1 make ``` -The Multi-tier JIT is a two level JIT tier-up engine, which launchs Fast JIT to run the wasm module as soon as possible and creates backend threads to compile the LLVM JIT functions at the same time, and when the LLVM JIT functions are compiled, the runtime will switch the extecution from the Fast JIT jitted code to LLVM JIT jitted code gradually, so as to gain the best performance. +The Multi-tier JIT is a two level JIT tier-up engine, which launches Fast JIT to run the wasm module as soon as possible and creates backend threads to compile the LLVM JIT functions at the same time, and when the LLVM JIT functions are compiled, the runtime will switch the extecution from the Fast JIT jitted code to LLVM JIT jitted code gradually, so as to gain the best performance. ## Linux SGX (Intel Software Guard Extension) @@ -335,7 +335,7 @@ $ cd build $ cmake .. $ make $ # check output in distribution/wasm -$ # include/ includes all necesary head files +$ # include/ includes all necessary head files $ # lib includes libiwasm.so ``` @@ -350,7 +350,7 @@ $ cmake .. -DWAMR_BUILD_TARGET=AARCH64 -DANDROID_ABI=arm64-v8a # 64-bit ARM C ## NuttX -WAMR is intergrated with NuttX, just enable the WAMR in Kconfig option (Application Configuration/Interpreters). +WAMR is integrated with NuttX, just enable the WAMR in Kconfig option (Application Configuration/Interpreters). ## ESP-IDF diff --git a/product-mini/platforms/common/libc_wasi.c b/product-mini/platforms/common/libc_wasi.c index 2f0b35125..b0f86e5f4 100644 --- a/product-mini/platforms/common/libc_wasi.c +++ b/product-mini/platforms/common/libc_wasi.c @@ -47,7 +47,7 @@ libc_wasi_print_help(void) "--map-dir=\n"); printf(" --addr-pool= Grant wasi access to the given network " "addresses in\n"); - printf(" CIDR notation to the program, seperated " + printf(" CIDR notation to the program, separated " "with ',',\n"); printf(" for example:\n"); printf(" --addr-pool=1.2.3.4/15,2.3.4.5/16\n"); diff --git a/product-mini/platforms/linux-sgx/enclave-sample/App/App.cpp b/product-mini/platforms/linux-sgx/enclave-sample/App/App.cpp index 9f24cdaa0..fc997868b 100644 --- a/product-mini/platforms/linux-sgx/enclave-sample/App/App.cpp +++ b/product-mini/platforms/linux-sgx/enclave-sample/App/App.cpp @@ -153,7 +153,7 @@ enclave_init(sgx_enclave_id_t *p_eid) return 0; } - /* reopen the file with write capablity */ + /* reopen the file with write capability */ fp = freopen(token_path, "wb", fp); if (fp == NULL) return 0; @@ -228,7 +228,7 @@ print_help() printf(" to the program, for example:\n"); printf(" --dir= --dir=\n"); printf(" --addr-pool= Grant wasi access to the given network addresses in\n"); - printf(" CIDR notation to the program, seperated with ',',\n"); + printf(" CIDR notation to the program, separated with ',',\n"); printf(" for example:\n"); printf(" --addr-pool=1.2.3.4/15,2.3.4.5/16\n"); printf(" --max-threads=n Set maximum thread number per cluster, default is 4\n"); diff --git a/product-mini/platforms/linux-sgx/enclave-sample/App/pal_api.h b/product-mini/platforms/linux-sgx/enclave-sample/App/pal_api.h index 6f6ae7327..2db1fbb25 100644 --- a/product-mini/platforms/linux-sgx/enclave-sample/App/pal_api.h +++ b/product-mini/platforms/linux-sgx/enclave-sample/App/pal_api.h @@ -67,7 +67,7 @@ struct wamr_pal_create_process_args { // Mandatory field. Must not be NULL. const char *path; - // Argments array pass to new process. + // Arguments array pass to new process. // // The arguments to the command. By convention, the argv[0] should be the // program name. And the last element of the array must be NULL to indicate diff --git a/product-mini/platforms/nuttx/CMakeLists.txt b/product-mini/platforms/nuttx/CMakeLists.txt index 27ddd9fa9..edbfb62f7 100644 --- a/product-mini/platforms/nuttx/CMakeLists.txt +++ b/product-mini/platforms/nuttx/CMakeLists.txt @@ -200,7 +200,7 @@ set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) # enable WAMR build system include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) -# NuttX wamr lib complie required: `WAMR_SOURCES` `WAMR_CFLAGS` `WAMR_INCDIRS` +# NuttX wamr lib compile required: `WAMR_SOURCES` `WAMR_CFLAGS` `WAMR_INCDIRS` # `WAMR_DEFINITIONS` set(WAMR_SOURCES ${WAMR_RUNTIME_LIB_SOURCE}) set(WAMR_CFLAGS -Wno-shadow -Wno-unused-variable diff --git a/product-mini/platforms/riot/Makefile b/product-mini/platforms/riot/Makefile index 8c7aef30c..d564a85a1 100644 --- a/product-mini/platforms/riot/Makefile +++ b/product-mini/platforms/riot/Makefile @@ -22,7 +22,7 @@ QUIET ?= 1 ARCHIVES += $(BINDIR)/libwamr.a -#Load the usual RIOT make infastructure +#Load the usual RIOT make infrastructure include $(RIOTBASE)/Makefile.include diff --git a/product-mini/platforms/rt-thread/iwasm.c b/product-mini/platforms/rt-thread/iwasm.c index f8932bdec..9c2b43b79 100644 --- a/product-mini/platforms/rt-thread/iwasm.c +++ b/product-mini/platforms/rt-thread/iwasm.c @@ -395,7 +395,7 @@ iwasm(int argc, char **argv) else { exception = app_instance_main(wasm_module_inst, argc - i_arg_begin, &argv[i_arg_begin]); - rt_kprintf("finshed run app_instance_main\n"); + rt_kprintf("finished run app_instance_main\n"); } if (exception) @@ -448,4 +448,4 @@ fail1: wasm_runtime_destroy(); return 0; } -MSH_CMD_EXPORT(iwasm, Embeded VM of WebAssembly); +MSH_CMD_EXPORT(iwasm, Embedded VM of WebAssembly); diff --git a/product-mini/platforms/zephyr/simple/README.md b/product-mini/platforms/zephyr/simple/README.md index 5f8bd41ae..aab096b8c 100644 --- a/product-mini/platforms/zephyr/simple/README.md +++ b/product-mini/platforms/zephyr/simple/README.md @@ -47,9 +47,9 @@ to setup for local development. ## Building for a Specific Board With an environment setup either locally or in a Docker container, you can build -for a Zephyr suppported board using +for a Zephyr supported board using [`west`](https://docs.zephyrproject.org/latest/develop/west/index.html). There -are already [configuaration files](./boards) for a few boards in this sample. +are already [configuration files](./boards) for a few boards in this sample. However, if you are using a new board, you will need to add your own file for the board, or define configuration in the [`prj.conf](./prj.conf). After doing so, use the following command with your board identifier to build the sample diff --git a/samples/basic/src/native_impl.c b/samples/basic/src/native_impl.c index 1374c8dd8..0d0c45ae5 100644 --- a/samples/basic/src/native_impl.c +++ b/samples/basic/src/native_impl.c @@ -7,7 +7,7 @@ #include "wasm_export.h" #include "math.h" -// The first parameter is not exec_env because it is invoked by native funtions +// The first parameter is not exec_env because it is invoked by native functions void reverse(char *str, int len) { diff --git a/samples/linux-perf/README.md b/samples/linux-perf/README.md index 5a8dc578f..0dd25a99e 100644 --- a/samples/linux-perf/README.md +++ b/samples/linux-perf/README.md @@ -30,7 +30,7 @@ $ ./FlameGraph/stackcollapse-perf.pl out.perf > out.folded $ ./FlameGraph/flamegraph.pl out.folded > perf.svg ``` -In this result, you'll see two modules's profiling result and all wasm functions are named as "aot_func#N" which is a little hard to distinguish. +In this result, you'll see two modules' profiling result and all wasm functions are named as "aot_func#N" which is a little hard to distinguish. ![perf.png](./pics/perf.png) diff --git a/samples/multi-module/README.md b/samples/multi-module/README.md index 731ba62c2..5aac0a5f4 100644 --- a/samples/multi-module/README.md +++ b/samples/multi-module/README.md @@ -12,7 +12,7 @@ $ make $ # It will build multi_module runtime and $ # wasm file under the ./build . $ # If you have built wamrc, -$ # aot file will also genrate. +$ # aot file will also generate. $ ./multi_module mC.wasm $ ... $ ./multi_module mC.aot diff --git a/samples/native-lib/README.md b/samples/native-lib/README.md index be1cc6e74..8af01b23c 100644 --- a/samples/native-lib/README.md +++ b/samples/native-lib/README.md @@ -2,7 +2,7 @@ This sample demonstrates how to write required interfaces in native library, build it into a shared library and register the shared library to iwasm. -The native library should provide `get_native_lib` API for iwasm to return the native library info, including the module name, the native symbol list and the native symbol count, so that iwasm can use them to regiter the native library, for example: +The native library should provide `get_native_lib` API for iwasm to return the native library info, including the module name, the native symbol list and the native symbol count, so that iwasm can use them to register the native library, for example: ```C static int diff --git a/samples/sgx-ra/non-sgx-verify/README.md b/samples/sgx-ra/non-sgx-verify/README.md index e4e9d87d4..5b9b35430 100644 --- a/samples/sgx-ra/non-sgx-verify/README.md +++ b/samples/sgx-ra/non-sgx-verify/README.md @@ -1,5 +1,5 @@ # Examples of evidence verification without Intel SGX -Intel SGX evidence generated using WAMR can be validated on trusted plaforms without Intel SGX, or an Intel processors. +Intel SGX evidence generated using WAMR can be validated on trusted platforms without Intel SGX, or an Intel processors. ## Using C# The sample [csharp/](csharp/) demonstrates such validation using C# as a managed language. diff --git a/samples/socket-api/README.md b/samples/socket-api/README.md index 911dfb7ab..522cbf47b 100644 --- a/samples/socket-api/README.md +++ b/samples/socket-api/README.md @@ -54,7 +54,7 @@ The output of client is like: [Client] Connect socket [Client] Client receive [Client] 115 bytes received: -Buffer recieved: +Buffer received: Say Hi from the Server Say Hi from the Server Say Hi from the Server @@ -117,7 +117,7 @@ The output is: ```bash Wait for client to connect Client connected, sleeping for 10s -Shuting down +Shutting down ``` ```bash @@ -195,7 +195,7 @@ The output of client is like: [Client] Create socket [Client] Client send [Client] Client receive -[Client] Buffer recieved: Hello from server +[Client] Buffer received: Hello from server [Client] BYE ``` diff --git a/samples/socket-api/wasm-src/tcp_client.c b/samples/socket-api/wasm-src/tcp_client.c index aad449483..ec5009b13 100644 --- a/samples/socket-api/wasm-src/tcp_client.c +++ b/samples/socket-api/wasm-src/tcp_client.c @@ -97,7 +97,7 @@ main(int argc, char *argv[]) printf("[Client] %d bytes received:\n", total_size); if (total_size > 0) { - printf("Buffer recieved:\n%s\n", buffer); + printf("Buffer received:\n%s\n", buffer); } close(socket_fd); diff --git a/samples/socket-api/wasm-src/tcp_server.c b/samples/socket-api/wasm-src/tcp_server.c index 2798dc252..2cc03e2b8 100644 --- a/samples/socket-api/wasm-src/tcp_server.c +++ b/samples/socket-api/wasm-src/tcp_server.c @@ -37,7 +37,7 @@ run(void *arg) } } - printf("[Server] Shuting down the new connection #%u ..\n", new_socket); + printf("[Server] Shutting down the new connection #%u ..\n", new_socket); shutdown(new_socket, SHUT_RDWR); return NULL; @@ -137,14 +137,14 @@ main(int argc, char *argv[]) pthread_join(workers[i], NULL); } - printf("[Server] Shuting down ..\n"); + printf("[Server] Shutting down ..\n"); shutdown(socket_fd, SHUT_RDWR); sleep(3); printf("[Server] BYE \n"); return EXIT_SUCCESS; fail: - printf("[Server] Shuting down ..\n"); + printf("[Server] Shutting down ..\n"); if (socket_fd >= 0) close(socket_fd); sleep(3); diff --git a/samples/socket-api/wasm-src/timeout_server.c b/samples/socket-api/wasm-src/timeout_server.c index c71cf4553..2aaf0b5ef 100644 --- a/samples/socket-api/wasm-src/timeout_server.c +++ b/samples/socket-api/wasm-src/timeout_server.c @@ -56,7 +56,7 @@ main(int argc, char *argv[]) printf("Client connected, sleeping for 10s\n"); sleep(10); - printf("Shuting down\n"); + printf("Shutting down\n"); shutdown(client_socket_fd, SHUT_RDWR); close(client_socket_fd); shutdown(socket_fd, SHUT_RDWR); diff --git a/samples/socket-api/wasm-src/udp_client.c b/samples/socket-api/wasm-src/udp_client.c index 810a455f8..c800764a9 100644 --- a/samples/socket-api/wasm-src/udp_client.c +++ b/samples/socket-api/wasm-src/udp_client.c @@ -75,7 +75,7 @@ main(int argc, char *argv[]) if (ret > 0) { buffer[ret] = '\0'; - printf("[Client] Buffer recieved: %s\n", buffer); + printf("[Client] Buffer received: %s\n", buffer); } close(socket_fd); diff --git a/samples/socket-api/wasm-src/udp_server.c b/samples/socket-api/wasm-src/udp_server.c index 588964145..2feac5720 100644 --- a/samples/socket-api/wasm-src/udp_server.c +++ b/samples/socket-api/wasm-src/udp_server.c @@ -106,7 +106,7 @@ main(int argc, char *argv[]) printf("[Server] Achieve maximum amount of connections\n"); } - printf("[Server] Shuting down ..\n"); + printf("[Server] Shutting down ..\n"); shutdown(socket_fd, SHUT_RDWR); close(socket_fd); sleep(3); @@ -114,7 +114,7 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; fail: - printf("[Server] Shuting down ..\n"); + printf("[Server] Shutting down ..\n"); if (socket_fd >= 0) close(socket_fd); sleep(3); diff --git a/samples/wasm-c-api-imports/README.md b/samples/wasm-c-api-imports/README.md index 9b61a6e74..44ac35fc1 100644 --- a/samples/wasm-c-api-imports/README.md +++ b/samples/wasm-c-api-imports/README.md @@ -93,14 +93,14 @@ also not economical to code for those functions. Using module names as a filter seems to be a simple way. But some private additional c/c++ libraries are supported in WAMR. Those supporting will bring more import items that don't use `wasi_snapshot_preview1` as module names but are still -covered by the WASM runtime. Like `env.pthread_`. Plus, [the native lib registeration](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/export_native_api.md) +covered by the WASM runtime. Like `env.pthread_`. Plus, [the native lib registration](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/export_native_api.md) provides another possible way to fill in the requirement of _the import section_. Let's take summarize. A proper `wasm_extern_vec_t *imports` should include: 1. provides all necessary host implementations for items in _the import section_ 2. should not override runtime provided implementation or covered by native - registrations. functinal or econmical. + registrations. functional or econmical. 3. keep them in a right order ## A recommendation diff --git a/samples/wasm-c-api/README.md b/samples/wasm-c-api/README.md index b23276706..22595d155 100644 --- a/samples/wasm-c-api/README.md +++ b/samples/wasm-c-api/README.md @@ -1,6 +1,6 @@ WAMR supports *wasm-c-api* in both *interpreter* mode and *aot* mode. -Before staring, we need to download and intall [WABT](https://github.com/WebAssembly/wabt/releases/latest). +Before staring, we need to download and install [WABT](https://github.com/WebAssembly/wabt/releases/latest). ``` shell $ cd /opt diff --git a/samples/workload/README.md b/samples/workload/README.md index 0e6a3a41b..af13d5d3e 100644 --- a/samples/workload/README.md +++ b/samples/workload/README.md @@ -1,4 +1,4 @@ -All workloads have similar requirment of software dependencies, including **emsdk** and **binaryen** +All workloads have similar requirement of software dependencies, including **emsdk** and **binaryen** > There might be slight differences when using MacOS and other Linux distro than Ubuntu. This document targets Ubuntu 20.04 as an example. diff --git a/test-tools/aot-analyzer/src/aot_file.cc b/test-tools/aot-analyzer/src/aot_file.cc index 14ce06387..a8ad3cffb 100644 --- a/test-tools/aot-analyzer/src/aot_file.cc +++ b/test-tools/aot-analyzer/src/aot_file.cc @@ -48,22 +48,22 @@ AoTFile::ParseTargetInfo() CHECK_RESULT(ReadT(&abi_type, this, "uint16_t")); target_info_.abi_type = abi_type; - // exectuion type + // execution type uint16_t e_type = 0; CHECK_RESULT(ReadT(&e_type, this, "uint16_t")); target_info_.e_type = e_type; - // exectuion machine + // execution machine uint16_t e_machine = 0; CHECK_RESULT(ReadT(&e_machine, this, "uint16_t")); target_info_.e_machine = e_machine; - // exectuion version + // execution version uint32_t e_version = 0; CHECK_RESULT(ReadT(&e_version, this, "uint32_t")); target_info_.e_version = e_version; - // exectuion flags + // execution flags uint32_t e_flags = 0; CHECK_RESULT(ReadT(&e_flags, this, "uint32_t")); target_info_.e_flags = e_flags; @@ -165,7 +165,7 @@ AoTFile::GetExectuionTypeName(uint16_t e_type) break; } default: - name = "bad exectuion type"; + name = "bad execution type"; } return name; } @@ -251,7 +251,7 @@ AoTFile::GetExectuionMachineName(uint16_t e_machine) break; } default: - machine = "bad exectuion machine type"; + machine = "bad execution machine type"; } return machine; } diff --git a/test-tools/aot-analyzer/src/main.cc b/test-tools/aot-analyzer/src/main.cc index f42e9217b..0dee1c8d1 100644 --- a/test-tools/aot-analyzer/src/main.cc +++ b/test-tools/aot-analyzer/src/main.cc @@ -163,12 +163,12 @@ DumpInfo(AoTFile *aot) printf("Binary type: %s\n", aot->GetBinTypeName(target_info.bin_type).c_str()); printf("ABI type: %d\n", target_info.abi_type); - printf("Exectuion type: %s\n", + printf("Execution type: %s\n", aot->GetExectuionTypeName(target_info.e_type).c_str()); - printf("Exectuion machine: %s\n", + printf("Execution machine: %s\n", aot->GetExectuionMachineName(target_info.e_machine).c_str()); - printf("Exectuion version: %u\n", target_info.e_version); - printf("Exectuion flags: %u\n", target_info.e_flags); + printf("Execution version: %u\n", target_info.e_version); + printf("Execution flags: %u\n", target_info.e_flags); printf("Feature flags: %" PRId64 "\n", target_info.feature_flags); printf("Reserved: %" PRId64 "\n", target_info.reserved); printf("Arch: %s\n", target_info.arch); @@ -546,7 +546,7 @@ ProgramMain(int argc, char **argv) reader = new WasmFile(filename); } else { - printf("unkown file extension: %s\n", dot); + printf("unknown file extension: %s\n", dot); continue; } diff --git a/test-tools/append-aot-to-wasm/append_aot_to_wasm.py b/test-tools/append-aot-to-wasm/append_aot_to_wasm.py index 9a0740464..bba411ade 100644 --- a/test-tools/append-aot-to-wasm/append_aot_to_wasm.py +++ b/test-tools/append-aot-to-wasm/append_aot_to_wasm.py @@ -104,7 +104,7 @@ def create_custom_section_aligned( full_content_bin = b"" pos = start_pos - # custome section id 0 + # custom section id 0 pos, full_content_bin = build_content(full_content_bin, pos, b"\x00") # custom section length diff --git a/test-tools/dynamic-aot-debug/README.md b/test-tools/dynamic-aot-debug/README.md index 6325a803a..f9611c4bb 100644 --- a/test-tools/dynamic-aot-debug/README.md +++ b/test-tools/dynamic-aot-debug/README.md @@ -70,7 +70,7 @@ gdbserver hostip:port ./iwasm test.aot #### Local remote debugging ```bash -expport OBJ_PATH=~/aot_debug +export OBJ_PATH=~/aot_debug cd ~/aot_debug # This directory contains iwasm, test.c, test obj file and dynamic_aot_debug.py gdb ./iwasm (gdb) target remote hostip:port diff --git a/test-tools/pick-up-emscripten-headers/collect_files.py b/test-tools/pick-up-emscripten-headers/collect_files.py index 7e832145f..c110551c5 100755 --- a/test-tools/pick-up-emscripten-headers/collect_files.py +++ b/test-tools/pick-up-emscripten-headers/collect_files.py @@ -40,7 +40,7 @@ external_repos = { } } -# TOOD: can we use headers from wasi-libc and clang directly ? +# TODO: can we use headers from wasi-libc and clang directly ? emscripten_headers_src_dst = [ ("include/compat/emmintrin.h", "sse/emmintrin.h"), ("include/compat/immintrin.h", "sse/immintrin.h"), @@ -159,7 +159,7 @@ def download_repo(name, root): download_flag.touch() # leave download files in /tmp - logger.info(f"Has downloaed and stored in {store_dir.relative_to(root)}") + logger.info(f"Has downloaded and stored in {store_dir.relative_to(root)}") return True diff --git a/test-tools/wamr-ide/Script/build.sh b/test-tools/wamr-ide/Script/build.sh index c30cb5af2..856105afb 100755 --- a/test-tools/wamr-ide/Script/build.sh +++ b/test-tools/wamr-ide/Script/build.sh @@ -26,7 +26,7 @@ else exit 1 fi -# setup docker command exectuion without sudo permission +# setup docker command execution without sudo permission sudo groupadd docker sudo gpasswd -a ${USER} docker sudo service docker restart diff --git a/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py b/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py index 6fd5f1682..91c639687 100644 --- a/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py +++ b/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py @@ -170,9 +170,9 @@ def obj_summary(valobj, unavailable='{...}'): return unavailable -def sequence_summary(childern, maxsize=32): +def sequence_summary(children, maxsize=32): s = '' - for child in childern: + for child in children: if len(s) > 0: s += ', ' s += obj_summary(child) diff --git a/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat b/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat index faf316ab3..d96703ad1 100644 --- a/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat +++ b/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat @@ -12,7 +12,7 @@ IF %ERRORLEVEL% GTR 0 ( call docker images>nul 2>nul IF %ERRORLEVEL% GTR 0 ( - echo "Docker is not ready, please lanuch docker desktop firstly." + echo "Docker is not ready, please launch docker desktop firstly." echo exit /b 2 ) diff --git a/tests/unit/aot/aot_test.cc b/tests/unit/aot/aot_test.cc index 261b378e4..31d8cccb4 100644 --- a/tests/unit/aot/aot_test.cc +++ b/tests/unit/aot/aot_test.cc @@ -103,7 +103,7 @@ class AOTTest : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() { diff --git a/tests/unit/compilation/aot_compiler_test.cc b/tests/unit/compilation/aot_compiler_test.cc index 8592a4b61..6fbccbb17 100644 --- a/tests/unit/compilation/aot_compiler_test.cc +++ b/tests/unit/compilation/aot_compiler_test.cc @@ -44,7 +44,7 @@ class aot_compiler_test_suit : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_emit_aot_file_test.cc b/tests/unit/compilation/aot_emit_aot_file_test.cc index 64c5533bb..8b0f63a8e 100644 --- a/tests/unit/compilation/aot_emit_aot_file_test.cc +++ b/tests/unit/compilation/aot_emit_aot_file_test.cc @@ -44,7 +44,7 @@ class aot_emit_aot_file_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_emit_control_test.cc b/tests/unit/compilation/aot_emit_control_test.cc index a269f51eb..849189c90 100644 --- a/tests/unit/compilation/aot_emit_control_test.cc +++ b/tests/unit/compilation/aot_emit_control_test.cc @@ -39,7 +39,7 @@ class aot_emit_control_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_emit_function_test.cc b/tests/unit/compilation/aot_emit_function_test.cc index 8c4c93fce..d10d639a1 100644 --- a/tests/unit/compilation/aot_emit_function_test.cc +++ b/tests/unit/compilation/aot_emit_function_test.cc @@ -38,7 +38,7 @@ class aot_emit_function_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_emit_numberic_test.cc b/tests/unit/compilation/aot_emit_numberic_test.cc index f7e6e8ee7..70f119f9e 100644 --- a/tests/unit/compilation/aot_emit_numberic_test.cc +++ b/tests/unit/compilation/aot_emit_numberic_test.cc @@ -39,7 +39,7 @@ class aot_emit_numberic_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_emit_parametric_test.cc b/tests/unit/compilation/aot_emit_parametric_test.cc index f9dabe1c8..aa7b08df3 100644 --- a/tests/unit/compilation/aot_emit_parametric_test.cc +++ b/tests/unit/compilation/aot_emit_parametric_test.cc @@ -38,7 +38,7 @@ class aot_emit_parametric_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_emit_table_test.cc b/tests/unit/compilation/aot_emit_table_test.cc index fc4bfe2f1..c77d16c6d 100644 --- a/tests/unit/compilation/aot_emit_table_test.cc +++ b/tests/unit/compilation/aot_emit_table_test.cc @@ -38,7 +38,7 @@ class aot_emit_table_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/compilation/aot_llvm_test.cc b/tests/unit/compilation/aot_llvm_test.cc index dcebe04b4..de4ab17c4 100644 --- a/tests/unit/compilation/aot_llvm_test.cc +++ b/tests/unit/compilation/aot_llvm_test.cc @@ -38,7 +38,7 @@ class aot_llvm_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/custom-section/custom_section_test.cc b/tests/unit/custom-section/custom_section_test.cc index 9bf04664a..e1ee9e15d 100644 --- a/tests/unit/custom-section/custom_section_test.cc +++ b/tests/unit/custom-section/custom_section_test.cc @@ -16,7 +16,7 @@ class CustomSectionTest : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/interpreter/interpreter_test.cc b/tests/unit/interpreter/interpreter_test.cc index af00020c9..5bceccec8 100644 --- a/tests/unit/interpreter/interpreter_test.cc +++ b/tests/unit/interpreter/interpreter_test.cc @@ -16,7 +16,7 @@ class InterpreterTest : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() { diff --git a/tests/unit/libc-builtin/libc_builtin_test.cc b/tests/unit/libc-builtin/libc_builtin_test.cc index f4f02bff6..444120c1a 100644 --- a/tests/unit/libc-builtin/libc_builtin_test.cc +++ b/tests/unit/libc-builtin/libc_builtin_test.cc @@ -32,7 +32,7 @@ class LibcBuiltinTest : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() { @@ -88,8 +88,8 @@ TEST_F(LibcBuiltinTest, puts) /* Capture the stdout */ testing::internal::CaptureStdout(); - EXPECT_EQ(CALL_FUNC(puts, "Hello Wrold"), strlen("Hello Wrold\n")); - EXPECT_EQ(testing::internal::GetCapturedStdout(), "Hello Wrold\n"); + EXPECT_EQ(CALL_FUNC(puts, "Hello World"), strlen("Hello World\n")); + EXPECT_EQ(testing::internal::GetCapturedStdout(), "Hello World\n"); testing::internal::CaptureStdout(); EXPECT_EQ(CALL_FUNC(puts, "c"), strlen("c\n")); @@ -113,9 +113,9 @@ TEST_F(LibcBuiltinTest, printf) /* Capture the stdout */ testing::internal::CaptureStdout(); - EXPECT_EQ(CALL_FUNC(printf, "Hello Wrold", empty_va_list.get()), - strlen("Hello Wrold")); - EXPECT_EQ(testing::internal::GetCapturedStdout(), "Hello Wrold"); + EXPECT_EQ(CALL_FUNC(printf, "Hello World", empty_va_list.get()), + strlen("Hello World")); + EXPECT_EQ(testing::internal::GetCapturedStdout(), "Hello World"); testing::internal::CaptureStdout(); EXPECT_EQ(CALL_FUNC(printf, "c", empty_va_list.get()), strlen("c")); @@ -290,7 +290,7 @@ TEST_F(LibcBuiltinTest, printf) va_list.add(0x7FFFFFFF); //%ld 2147483647 - sing long va_list.add(0xFFFFFFFF); //%lu 4294967295 -unsigned long va_list.add(0x7FFFFFFFFFFFFFFF); //%lld 9223372036854775807 sing long long - va_list.add(0xFFFFFFFFFFFFFFFF);//%llu 18446744073709551615 unsiged long long + va_list.add(0xFFFFFFFFFFFFFFFF);//%llu 18446744073709551615 unsigned long long testing::internal::CaptureStdout(); @@ -300,17 +300,17 @@ TEST_F(LibcBuiltinTest, printf) /* clang-format on */ } - EXPECT_EQ(CALL_FUNC(printf, "Hello Wrold", 0), 0); + EXPECT_EQ(CALL_FUNC(printf, "Hello World", 0), 0); EXPECT_STREQ(dummy_exec_env.get_exception(), "Exception: out of bounds memory access"); dummy_exec_env.clear_exception(); - EXPECT_EQ(CALL_FUNC(printf, "Hello Wrold", NULL), 0); + EXPECT_EQ(CALL_FUNC(printf, "Hello World", NULL), 0); EXPECT_STREQ(dummy_exec_env.get_exception(), "Exception: out of bounds memory access"); dummy_exec_env.clear_exception(); - EXPECT_EQ(CALL_FUNC(printf, "Hello Wrold", (char *)-1), 0); + EXPECT_EQ(CALL_FUNC(printf, "Hello World", (char *)-1), 0); EXPECT_STREQ(dummy_exec_env.get_exception(), "Exception: out of bounds memory access"); dummy_exec_env.clear_exception(); @@ -324,7 +324,7 @@ TEST_F(LibcBuiltinTest, printf) TEST_F(LibcBuiltinTest, sprintf) { char buf[200] = {0}; - const char *str = "Hello Wrold"; + const char *str = "Hello World"; const char *str_sig = "c"; const char *str_f = "20, 3.140000, Hello World"; const char *str_long = "eqwewerwerqwer34were"; // test ok @@ -399,19 +399,19 @@ TEST_F(LibcBuiltinTest, snprintf) WAMRVaList empty_va_list(dummy_exec_env.get()); - EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen("Hello Wrold"), "Hello Wrold", 0), + EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen("Hello World"), "Hello World", 0), 0); EXPECT_EQ( - CALL_FUNC(snprintf, buf, strlen("Hello Wrold"), "Hello Wrold", NULL), + CALL_FUNC(snprintf, buf, strlen("Hello World"), "Hello World", NULL), 0); - EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen("Hello Wrold"), "Hello Wrold", + EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen("Hello World"), "Hello World", (char *)-1), 0); - EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen("Hello Wrold"), "Hello Wrold", + EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen("Hello World"), "Hello World", empty_va_list.get()), - strlen("Hello Wrold")); - EXPECT_EQ(CALL_FUNC(memcmp, buf, "Hello Wrold", strlen("Hello Wrold")), 0); + strlen("Hello World")); + EXPECT_EQ(CALL_FUNC(memcmp, buf, "Hello World", strlen("Hello World")), 0); EXPECT_EQ(CALL_FUNC(snprintf, buf, strlen(very_long_string), very_long_string, empty_va_list.get()), diff --git a/tests/unit/linear-memory-aot/linear_memory_aot_test.cc b/tests/unit/linear-memory-aot/linear_memory_aot_test.cc index dafdbb791..198dfbc91 100644 --- a/tests/unit/linear-memory-aot/linear_memory_aot_test.cc +++ b/tests/unit/linear-memory-aot/linear_memory_aot_test.cc @@ -41,7 +41,7 @@ class TEST_SUITE_NAME : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/linear-memory-wasm/linear_memory_wasm_test.cc b/tests/unit/linear-memory-wasm/linear_memory_wasm_test.cc index 77eb53d7e..a5db0e033 100644 --- a/tests/unit/linear-memory-wasm/linear_memory_wasm_test.cc +++ b/tests/unit/linear-memory-wasm/linear_memory_wasm_test.cc @@ -41,7 +41,7 @@ class TEST_SUITE_NAME : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/memory64/memory64_test.cc b/tests/unit/memory64/memory64_test.cc index 67315a594..af36f308c 100644 --- a/tests/unit/memory64/memory64_test.cc +++ b/tests/unit/memory64/memory64_test.cc @@ -73,7 +73,7 @@ class memory64_test_suite : public testing::TestWithParam // TEST_P. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() { diff --git a/tests/unit/running-modes/wasm_running_modes_test.cc b/tests/unit/running-modes/wasm_running_modes_test.cc index 9d6a9379c..e18e64fb1 100644 --- a/tests/unit/running-modes/wasm_running_modes_test.cc +++ b/tests/unit/running-modes/wasm_running_modes_test.cc @@ -193,7 +193,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam // TEST_P. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() { diff --git a/tests/unit/runtime-common/wasm_exec_env_test.cc b/tests/unit/runtime-common/wasm_exec_env_test.cc index 06c162b62..5c5b46499 100644 --- a/tests/unit/runtime-common/wasm_exec_env_test.cc +++ b/tests/unit/runtime-common/wasm_exec_env_test.cc @@ -15,7 +15,7 @@ class wasm_exec_env_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/runtime-common/wasm_runtime_common_test.cc b/tests/unit/runtime-common/wasm_runtime_common_test.cc index 978b54022..15a02673b 100644 --- a/tests/unit/runtime-common/wasm_runtime_common_test.cc +++ b/tests/unit/runtime-common/wasm_runtime_common_test.cc @@ -60,7 +60,7 @@ class wasm_runtime_common_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/runtime-common/wasm_runtime_init_test.cc b/tests/unit/runtime-common/wasm_runtime_init_test.cc index 30e44cea3..f7ff26ae4 100644 --- a/tests/unit/runtime-common/wasm_runtime_init_test.cc +++ b/tests/unit/runtime-common/wasm_runtime_init_test.cc @@ -72,7 +72,7 @@ class wasm_runtime_init_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/bh_assert_test.cc b/tests/unit/shared-utils/bh_assert_test.cc index faa7a807b..bd0861dcf 100644 --- a/tests/unit/shared-utils/bh_assert_test.cc +++ b/tests/unit/shared-utils/bh_assert_test.cc @@ -15,7 +15,7 @@ class bh_assert_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/bh_common_test.cc b/tests/unit/shared-utils/bh_common_test.cc index 1d1cb528d..7f7d574c3 100644 --- a/tests/unit/shared-utils/bh_common_test.cc +++ b/tests/unit/shared-utils/bh_common_test.cc @@ -15,7 +15,7 @@ class bh_common_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/bh_hashmap_test.cc b/tests/unit/shared-utils/bh_hashmap_test.cc index 4b651ef17..496170226 100644 --- a/tests/unit/shared-utils/bh_hashmap_test.cc +++ b/tests/unit/shared-utils/bh_hashmap_test.cc @@ -44,7 +44,7 @@ class bh_hashmap_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/bh_list_test.cc b/tests/unit/shared-utils/bh_list_test.cc index 981c52f25..de8b83505 100644 --- a/tests/unit/shared-utils/bh_list_test.cc +++ b/tests/unit/shared-utils/bh_list_test.cc @@ -15,7 +15,7 @@ class bh_list_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} @@ -70,7 +70,7 @@ TEST_F(bh_list_test_suite, bh_list_remove) bh_list_insert(&list_test, &elem_insert_4); EXPECT_EQ(BH_LIST_SUCCESS, bh_list_remove(&list_test, &elem_insert_1)); - // The elem specified by prameter is not in the list. + // The elem specified by parameter is not in the list. EXPECT_EQ(BH_LIST_ERROR, bh_list_remove(&list_test, &elem_insert_1)); // Illegal parameters. diff --git a/tests/unit/shared-utils/bh_log_test.cc b/tests/unit/shared-utils/bh_log_test.cc index 250fb7926..cb76b89e0 100644 --- a/tests/unit/shared-utils/bh_log_test.cc +++ b/tests/unit/shared-utils/bh_log_test.cc @@ -16,7 +16,7 @@ class bh_log_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/bh_queue_test.cc b/tests/unit/shared-utils/bh_queue_test.cc index c540d8f36..e808aea31 100644 --- a/tests/unit/shared-utils/bh_queue_test.cc +++ b/tests/unit/shared-utils/bh_queue_test.cc @@ -15,7 +15,7 @@ class bh_queue_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/bh_vector_test.cc b/tests/unit/shared-utils/bh_vector_test.cc index 3da9fba5d..fae7c8c48 100644 --- a/tests/unit/shared-utils/bh_vector_test.cc +++ b/tests/unit/shared-utils/bh_vector_test.cc @@ -16,7 +16,7 @@ class bh_vector_test_suite : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/shared-utils/shared_utils_test.cc b/tests/unit/shared-utils/shared_utils_test.cc index 82bedf32f..41fe9f927 100644 --- a/tests/unit/shared-utils/shared_utils_test.cc +++ b/tests/unit/shared-utils/shared_utils_test.cc @@ -16,7 +16,7 @@ class SharedUtilsTest : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() {} diff --git a/tests/unit/wasm-vm/wasm_vm.cc b/tests/unit/wasm-vm/wasm_vm.cc index 73c2c761f..670fa599b 100644 --- a/tests/unit/wasm-vm/wasm_vm.cc +++ b/tests/unit/wasm-vm/wasm_vm.cc @@ -24,7 +24,7 @@ class WasmVMTest : public testing::Test // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. void SetUp() { From 48a87dc8bf63b4bd6ca17f3e0148f78ef53bae54 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Fri, 7 Mar 2025 08:22:12 +0800 Subject: [PATCH 077/198] avoid Windows perform newline translation (#4128) --- test-tools/binarydump-tool/binarydump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-tools/binarydump-tool/binarydump.c b/test-tools/binarydump-tool/binarydump.c index 050de6dfa..9070dd521 100644 --- a/test-tools/binarydump-tool/binarydump.c +++ b/test-tools/binarydump-tool/binarydump.c @@ -15,7 +15,7 @@ read_file_to_buffer(const char *filename, int *ret_size) FILE *file; int file_size, read_size; - if (!(file = fopen(filename, "r"))) + if (!(file = fopen(filename, "rb"))) return NULL; fseek(file, 0, SEEK_END); From d1cf3566f638f6c623a924453c6bd08dabcf285f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 10:47:38 +0000 Subject: [PATCH 078/198] build(deps): Bump github/codeql-action from 3.28.10 to 3.28.11 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.10 to 3.28.11. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.10...v3.28.11) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 302b27274..dae8190f1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.10 + uses: github/codeql-action/init@v3.28.11 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.10 + uses: github/codeql-action/analyze@v3.28.11 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.10 + uses: github/codeql-action/upload-sarif@v3.28.11 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 768b0eff4..2a378c879 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@ff79de67cc25c7617163ae1e4b8aa23b902fdf15 + uses: github/codeql-action/upload-sarif@b2e6519679e446e7bb7c3466d70f13a6b5461fcd with: sarif_file: results.sarif From dde6477fa5a77ea8466b97675b3b64a75e840ea1 Mon Sep 17 00:00:00 2001 From: Zhen Kong Date: Thu, 13 Mar 2025 17:07:03 +0000 Subject: [PATCH 079/198] Fix iwasm build error when WAMR_BUILD_WASI_NN enabled A recent change on ./product-mini/platforms/linux/CMakeLists.txt renamed libiwasm to vmlib, but wasi-nn.cmake still wants to link libiwasm.so. Replace libiwasm with vmlib in wasi-nn.cmake to resolve iwasm build error when WAMR_BUILD_WASI_NN enabled. --- core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake b/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake index c6deab6fc..b771b1c40 100644 --- a/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake +++ b/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake @@ -39,7 +39,7 @@ if(WAMR_BUILD_WASI_NN_TFLITE EQUAL 1) target_link_libraries( wasi_nn_tflite PUBLIC - libiwasm + vmlib tensorflow-lite ) @@ -71,7 +71,7 @@ if(WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1) target_link_libraries( wasi_nn_openvino PUBLIC - libiwasm + vmlib openvino::runtime openvino::runtime::c ) @@ -100,7 +100,7 @@ if(WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1) target_link_libraries( wasi_nn_llamacpp PUBLIC - libiwasm + vmlib cjson common ggml From c30e65ba5d2bb4c1b96e23dfaa74e498fc3ac3a3 Mon Sep 17 00:00:00 2001 From: James Ring Date: Sun, 16 Mar 2025 23:22:46 -0700 Subject: [PATCH 080/198] include bh_platform.h (#4135) This should guarantee that the various macros required by wasm_proposal.c are defined even if the build system does not supply them to the compiler command. --- product-mini/platforms/common/wasm_proposal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/product-mini/platforms/common/wasm_proposal.c b/product-mini/platforms/common/wasm_proposal.c index 4bf6ab3e9..12bbf79bc 100644 --- a/product-mini/platforms/common/wasm_proposal.c +++ b/product-mini/platforms/common/wasm_proposal.c @@ -5,6 +5,8 @@ #include +#include "bh_platform.h" + void wasm_proposal_print_status(void) { From efa8019bdba89de121f14d84484cecbf023df879 Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Thu, 20 Mar 2025 06:23:20 +0000 Subject: [PATCH 081/198] Merge dev/simd for fast-interp (#4131) * Implement the first few SIMD opcodes for fast interpreter (v128.const, v128.any_true) (#3818) Tested on the following code: ``` (module (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32))) (memory (export "memory") 1) ;; WASI entry point (func $main (export "_start") v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 v128.any_true if unreachable end v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v128.any_true i32.const 0 i32.eq if unreachable end i32.const 0 call $proc_exit ) ) ``` * implement POP_V128() This is to simplify the simd implementation for fast interpreter * Add all SIMD operations into wasm_interp_fast switch * Add V128 comparison operations Tested using ``` (module (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32))) (memory (export "memory") 1) (func $assert_true (param v128) local.get 0 v128.any_true i32.eqz if unreachable end ) (func $main (export "_start") ;; Test v128.not v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 v128.not v128.const i8x16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 i8x16.eq call $assert_true ;; Test v128.and v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 v128.and v128.const i8x16 255 255 0 0 0 0 0 0 255 255 0 0 0 0 0 0 i8x16.eq call $assert_true ;; Test v128.andnot v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 v128.andnot v128.const i8x16 0 0 255 255 0 0 0 0 0 0 255 255 0 0 0 0 i8x16.eq call $assert_true ;; Test v128.or v128.const i8x16 255 255 0 0 0 0 255 255 255 255 0 0 0 0 255 0 v128.const i8x16 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 v128.or v128.const i8x16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 i8x16.eq call $assert_true ;; Test v128.xor v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 v128.xor v128.const i8x16 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 i8x16.eq call $assert_true i32.const 0 call $proc_exit ) ) ``` * Add first NEON SIMD opcode implementations to fast interpreter (#3859) Add some implementations of SIMD opcodes using NEON instructions. Tested using: ```wast (module (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32))) (memory (export "memory") 1) (func $assert_true (param v128) local.get 0 v128.any_true i32.eqz if unreachable end ) (func $main (export "_start") i32.const 0 i32.const 32 memory.grow drop i32.const 0 v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v128.store i32.const 0 v128.load v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i8x16.eq call $assert_true i32.const 16 v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 v128.store i32.const 16 v128.load v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 i8x16.eq call $assert_true i32.const 0 v128.load v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i8x16.eq call $assert_true drop i32.const 0 i32.const 1 memory.grow drop i32.const 0 i64.const 0x7F80FF017E02FE80 i64.store i32.const 0 v128.load8x8_s v128.const i16x8 127 -128 -1 1 126 2 -2 -128 i16x8.eq call $assert_true i32.const 0 i64.const 0x80FE027E01FF807F i64.store i32.const 0 v128.load8x8_u v128.const i16x8 128 254 2 126 1 255 128 127 i16x8.eq call $assert_true i32.const 0 i64.const 0x8000FFFE7FFF0001 i64.store i32.const 0 v128.load16x4_s v128.const i32x4 -32768 -2 32767 1 i32x4.eq call $assert_true i32.const 0 i64.const 0x8000FFFE7FFF0001 i64.store i32.const 0 v128.load16x4_u v128.const i32x4 32768 65534 32767 1 i32x4.eq call $assert_true i32.const 0 i64.const 0x8000000000000001 i64.store i32.const 0 v128.load32x2_s v128.const i64x2 -2147483648 1 i64x2.eq call $assert_true i32.const 0 i64.const 0x8000000000000001 i64.store i32.const 0 v128.load32x2_u v128.const i64x2 2147483648 1 i64x2.eq call $assert_true call $proc_exit ) ) ``` * Emit imm for lane extract and replace (#3906) * Fix replacement value not being correct (#3919) * Implement load lanes opcodes for wasm (#3942) * Implement final SIMD opcodes: store lane (#4001) * Fix load/store (#4054) * Correctly use unsigned functions (#4055) * implement local and function calls for v128 in the fast interpreter * Fix splat opcodes, add V128 handling in preserve_referenced_local and reserve_block_ret * Fix incorrect memory overflow values + SIMD ifdefs * Fix load/load_splat macros * correct endif wasm loader * Update core/iwasm/interpreter/wasm_opcode.h * Fix spec tests when WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS is 0 * Resolve merge conflicts arising from main -> dev/simd_for_interp and implement fast interpreter const offset loader support for V128 * Enable SIMDe tests on CI * Document WAMR_BUILD_LIB_SIMDE --------- Co-authored-by: James Marsh Co-authored-by: jammar1 <108334558+jammar1@users.noreply.github.com> Co-authored-by: Maks Litskevich Co-authored-by: Marcin Kolny Co-authored-by: Wenyong Huang --- .../compilation_on_android_ubuntu.yml | 9 +- .github/workflows/compilation_on_sgx.yml | 4 +- build-scripts/config_common.cmake | 15 +- build-scripts/runtime_lib.cmake | 10 + core/config.h | 6 + core/iwasm/common/wasm_loader_common.c | 3 +- core/iwasm/common/wasm_runtime_common.h | 119 ++ core/iwasm/interpreter/wasm_interp_fast.c | 1657 ++++++++++++++++- core/iwasm/interpreter/wasm_loader.c | 373 +++- core/iwasm/interpreter/wasm_opcode.h | 26 +- core/iwasm/libraries/simde/simde.cmake | 21 + doc/build_wamr.md | 15 +- tests/wamr-test-suites/test_wamr.sh | 4 +- 13 files changed, 2189 insertions(+), 73 deletions(-) create mode 100644 core/iwasm/libraries/simde/simde.cmake diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 057082ebc..83cd154af 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -158,6 +158,7 @@ jobs: "-DWAMR_BUILD_PERF_PROFILING=1", "-DWAMR_BUILD_REF_TYPES=1", "-DWAMR_BUILD_SIMD=1", + "-DWAMR_BUILD_LIB_SIMDE=1", "-DWAMR_BUILD_TAIL_CALL=1", "-DWAMR_DISABLE_HW_BOUND_CHECK=1", "-DWAMR_BUILD_MEMORY64=1", @@ -178,11 +179,9 @@ jobs: make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1" - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1" - # SIMD only on JIT/AOT mode + # SIMD only on JIT/AOT/fast interpreter mode - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS make_options_feature: "-DWAMR_BUILD_SIMD=1" - - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS - make_options_feature: "-DWAMR_BUILD_SIMD=1" # DEBUG_INTERP only on CLASSIC INTERP mode - make_options_run_mode: $AOT_BUILD_OPTIONS make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1" @@ -649,11 +648,9 @@ jobs: test_option: $WAMR_COMPILER_TEST_OPTIONS exclude: # incompatible modes and features - # classic-interp and fast-interp don't support simd + # classic-interp doesn't support simd - running_mode: "classic-interp" test_option: $SIMD_TEST_OPTIONS - - running_mode: "fast-interp" - test_option: $SIMD_TEST_OPTIONS # llvm jit doesn't support multi module - running_mode: "jit" test_option: $MULTI_MODULES_TEST_OPTIONS diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index 70597c366..b865a59fe 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -49,7 +49,7 @@ env: # ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_REF_TYPES=1" CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" - FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" + FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_SIMD=0" FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1" LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1" LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0" @@ -97,7 +97,7 @@ jobs: "-DWAMR_BUILD_PERF_PROFILING=1", "-DWAMR_BUILD_REF_TYPES=1", # doesn't support - # "-DWAMR_BUILD_SIMD=1", + "-DWAMR_BUILD_SIMD=0", "-DWAMR_BUILD_TAIL_CALL=1", "-DWAMR_DISABLE_HW_BOUND_CHECK=1", "-DWAMR_BUILD_SGX_IPFS=1", diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 312944be5..2c0bf3c7c 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -300,6 +300,9 @@ endif () if (WAMR_BUILD_LIB_RATS EQUAL 1) message (" Lib rats enabled") endif() +if ((WAMR_BUILD_LIB_SIMDE EQUAL 1)) + message (" Lib simde enabled") +endif() ################## WAMR features ################## if (WAMR_BUILD_MULTI_MODULE EQUAL 1) add_definitions (-DWASM_ENABLE_MULTI_MODULE=1) @@ -371,11 +374,17 @@ else () message (" Wakeup of blocking operations enabled") endif () if (WAMR_BUILD_SIMD EQUAL 1) - if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*") - add_definitions (-DWASM_ENABLE_SIMD=1) - else () + if (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0) + set(SIMD_ENABLED 0) + message(" SIMD disabled for fast-interp as simde is not being built") + elseif (WAMR_BUILD_TARGET MATCHES "RISCV64.*") + set(SIMD_ENABLED 0) message (" SIMD disabled due to not supported on target RISCV64") + else() + set(SIMD_ENABLED 1) + message (" SIMD enabled") endif () + add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED}) endif () if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1) add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1) diff --git a/build-scripts/runtime_lib.cmake b/build-scripts/runtime_lib.cmake index c3edfe503..994414ffa 100644 --- a/build-scripts/runtime_lib.cmake +++ b/build-scripts/runtime_lib.cmake @@ -155,6 +155,16 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1) include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake) endif () +if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1) + if (WAMR_BUILD_PLATFORM STREQUAL "windows") + message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM}) + set(WAMR_BUILD_SIMDE 0) + else() + include (${IWASM_DIR}/libraries/simde/simde.cmake) + set (WAMR_BUILD_SIMDE 1) + endif() +endif () + if (WAMR_BUILD_WASM_CACHE EQUAL 1) include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake) endif () diff --git a/core/config.h b/core/config.h index d71aaca39..cb1189c96 100644 --- a/core/config.h +++ b/core/config.h @@ -322,6 +322,12 @@ #define WASM_ENABLE_SIMD 0 #endif +/* Disable SIMDe (used in the fast interpreter for SIMD opcodes) +unless used elsewhere */ +#ifndef WASM_ENABLE_SIMDE +#define WASM_ENABLE_SIMDE 0 +#endif + /* GC performance profiling */ #ifndef WASM_ENABLE_GC_PERF_PROFILING #define WASM_ENABLE_GC_PERF_PROFILING 0 diff --git a/core/iwasm/common/wasm_loader_common.c b/core/iwasm/common/wasm_loader_common.c index 97ea5efd1..6018f90a6 100644 --- a/core/iwasm/common/wasm_loader_common.c +++ b/core/iwasm/common/wasm_loader_common.c @@ -151,7 +151,8 @@ is_valid_value_type(uint8 type) bool is_valid_value_type_for_interpreter(uint8 value_type) { -#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) +#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \ + && (WASM_ENABLE_FAST_INTERP == 0) /* * Note: regardless of WASM_ENABLE_SIMD, our interpreters don't have * SIMD implemented. It's safer to reject v128, especially for the diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index c6425af20..8ac032bf8 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -37,6 +37,10 @@ extern "C" { do { \ *(int64 *)(addr) = (int64)(value); \ } while (0) +#define PUT_V128_TO_ADDR(addr, value) \ + do { \ + *(V128 *)(addr) = (value); \ + } while (0) #define PUT_F64_TO_ADDR(addr, value) \ do { \ *(float64 *)(addr) = (float64)(value); \ @@ -49,6 +53,7 @@ extern "C" { #define GET_I64_FROM_ADDR(addr) (*(int64 *)(addr)) #define GET_F64_FROM_ADDR(addr) (*(float64 *)(addr)) #define GET_REF_FROM_ADDR(addr) (*(void **)(addr)) +#define GET_V128_FROM_ADDR(addr) (*(V128 *)(addr)) /* For STORE opcodes */ #define STORE_I64 PUT_I64_TO_ADDR @@ -68,6 +73,12 @@ STORE_U8(void *addr, uint8_t value) *(uint8 *)addr = value; } +static inline void +STORE_V128(void *addr, V128 value) +{ + *(V128 *)addr = value; +} + /* For LOAD opcodes */ #define LOAD_I64(addr) (*(int64 *)(addr)) #define LOAD_F64(addr) (*(float64 *)(addr)) @@ -75,6 +86,7 @@ STORE_U8(void *addr, uint8_t value) #define LOAD_U32(addr) (*(uint32 *)(addr)) #define LOAD_I16(addr) (*(int16 *)(addr)) #define LOAD_U16(addr) (*(uint16 *)(addr)) +#define LOAD_V128(addr) (*(V128 *)(addr)) #define STORE_PTR(addr, ptr) \ do { \ @@ -83,6 +95,15 @@ STORE_U8(void *addr, uint8_t value) #else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */ +#define PUT_V128_TO_ADDR(addr, value) \ + do { \ + uint32 *addr_u32 = (uint32 *)(addr); \ + addr_u32[0] = (value).i32x4[0]; \ + addr_u32[1] = (value).i32x4[1]; \ + addr_u32[2] = (value).i32x4[2]; \ + addr_u32[3] = (value).i32x4[3]; \ + } while (0) + #define PUT_I64_TO_ADDR(addr, value) \ do { \ uint32 *addr_u32 = (uint32 *)(addr); \ @@ -124,6 +145,17 @@ STORE_U8(void *addr, uint8_t value) } while (0) #endif +static inline V128 +GET_V128_FROM_ADDR(uint32 *addr) +{ + V128 ret; + ret.i32x4[0] = addr[0]; + ret.i32x4[1] = addr[1]; + ret.i32x4[2] = addr[2]; + ret.i32x4[3] = addr[3]; + return ret; +} + static inline int64 GET_I64_FROM_ADDR(uint32 *addr) { @@ -239,7 +271,94 @@ STORE_U16(void *addr, uint16_t value) ((uint8_t *)(addr))[0] = u.u8[0]; ((uint8_t *)(addr))[1] = u.u8[1]; } + +static inline void +STORE_V128(void *addr, V128 value) +{ + uintptr_t addr_ = (uintptr_t)(addr); + union { + V128 val; + uint64 u64[2]; + uint32 u32[4]; + uint16 u16[8]; + uint8 u8[16]; + } u; + + if ((addr_ & (uintptr_t)15) == 0) { + *(V128 *)addr = value; + } + else if ((addr_ & (uintptr_t)7) == 0) { + u.val = value; + ((uint64 *)(addr))[0] = u.u64[0]; + ((uint64 *)(addr))[1] = u.u64[1]; + } + else if ((addr_ & (uintptr_t)3) == 0) { + u.val = value; + ((uint32 *)addr)[0] = u.u32[0]; + ((uint32 *)addr)[1] = u.u32[1]; + ((uint32 *)addr)[2] = u.u32[2]; + ((uint32 *)addr)[3] = u.u32[3]; + } + else if ((addr_ & (uintptr_t)1) == 0) { + u.val = value; + ((uint16 *)addr)[0] = u.u16[0]; + ((uint16 *)addr)[1] = u.u16[1]; + ((uint16 *)addr)[2] = u.u16[2]; + ((uint16 *)addr)[3] = u.u16[3]; + ((uint16 *)addr)[4] = u.u16[4]; + ((uint16 *)addr)[5] = u.u16[5]; + ((uint16 *)addr)[6] = u.u16[6]; + ((uint16 *)addr)[7] = u.u16[7]; + } + else { + u.val = value; + for (int i = 0; i < 16; i++) + ((uint8 *)addr)[i] = u.u8[i]; + } +} + /* For LOAD opcodes */ +static inline V128 +LOAD_V128(void *addr) +{ + uintptr_t addr1 = (uintptr_t)addr; + union { + V128 val; + uint64 u64[2]; + uint32 u32[4]; + uint16 u16[8]; + uint8 u8[16]; + } u; + if ((addr1 & (uintptr_t)15) == 0) + return *(V128 *)addr; + + if ((addr1 & (uintptr_t)7) == 0) { + u.u64[0] = ((uint64 *)addr)[0]; + u.u64[1] = ((uint64 *)addr)[1]; + } + else if ((addr1 & (uintptr_t)3) == 0) { + u.u32[0] = ((uint32 *)addr)[0]; + u.u32[1] = ((uint32 *)addr)[1]; + u.u32[2] = ((uint32 *)addr)[2]; + u.u32[3] = ((uint32 *)addr)[3]; + } + else if ((addr1 & (uintptr_t)1) == 0) { + u.u16[0] = ((uint16 *)addr)[0]; + u.u16[1] = ((uint16 *)addr)[1]; + u.u16[2] = ((uint16 *)addr)[2]; + u.u16[3] = ((uint16 *)addr)[3]; + u.u16[4] = ((uint16 *)addr)[4]; + u.u16[5] = ((uint16 *)addr)[5]; + u.u16[6] = ((uint16 *)addr)[6]; + u.u16[7] = ((uint16 *)addr)[7]; + } + else { + for (int i = 0; i < 16; i++) + u.u8[i] = ((uint8 *)addr)[i]; + } + return u.val; +} + static inline int64 LOAD_I64(void *addr) { diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 96b9ba2b2..21554953d 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -21,6 +21,10 @@ #include "../common/wasm_shared_memory.h" #endif +#if WASM_ENABLE_SIMDE != 0 +#include "simde/wasm/simd128.h" +#endif + typedef int32 CellType_I32; typedef int64 CellType_I64; typedef float32 CellType_F32; @@ -454,6 +458,8 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame) (type) GET_I64_FROM_ADDR(frame_lp + *(int16 *)(frame_ip + off)) #define GET_OPERAND_F64(type, off) \ (type) GET_F64_FROM_ADDR(frame_lp + *(int16 *)(frame_ip + off)) +#define GET_OPERAND_V128(off) \ + GET_V128_FROM_ADDR(frame_lp + *(int16 *)(frame_ip + off)) #define GET_OPERAND_REF(type, off) \ (type) GET_REF_FROM_ADDR(frame_lp + *(int16 *)(frame_ip + off)) @@ -504,6 +510,8 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame) #define POP_I64() (GET_I64_FROM_ADDR(frame_lp + GET_OFFSET())) +#define POP_V128() (GET_V128_FROM_ADDR(frame_lp + GET_OFFSET())) + #define POP_F64() (GET_F64_FROM_ADDR(frame_lp + GET_OFFSET())) #define POP_REF() \ @@ -1692,6 +1700,11 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, GET_OPERAND(uint64, I64, off)); ret_offset += 2; } + else if (ret_types[ret_idx] == VALUE_TYPE_V128) { + PUT_V128_TO_ADDR(prev_frame->lp + ret_offset, + GET_OPERAND_V128(off)); + ret_offset += 4; + } #if WASM_ENABLE_GC != 0 else if (wasm_is_type_reftype(ret_types[ret_idx])) { PUT_REF_TO_ADDR(prev_frame->lp + ret_offset, @@ -3531,6 +3544,24 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } +#if WASM_ENABLE_SIMD != 0 + HANDLE_OP(EXT_OP_SET_LOCAL_FAST_V128) + HANDLE_OP(EXT_OP_TEE_LOCAL_FAST_V128) + { + /* clang-format off */ +#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 + local_offset = *frame_ip++; +#else + local_offset = *frame_ip; + frame_ip += 2; +#endif + /* clang-format on */ + PUT_V128_TO_ADDR((uint32 *)(frame_lp + local_offset), + GET_OPERAND_V128(0)); + frame_ip += 2; + HANDLE_OP_END(); + } +#endif HANDLE_OP(WASM_OP_GET_GLOBAL) { global_idx = read_uint32(frame_ip); @@ -3567,7 +3598,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, GET_I64_FROM_ADDR((uint32 *)global_addr)); HANDLE_OP_END(); } - +#if WASM_ENABLE_SIMD != 0 + HANDLE_OP(WASM_OP_GET_GLOBAL_V128) + { + global_idx = read_uint32(frame_ip); + bh_assert(global_idx < module->e->global_count); + global = globals + global_idx; + global_addr = get_global_addr(global_data, global); + addr_ret = GET_OFFSET(); + PUT_V128_TO_ADDR(frame_lp + addr_ret, + GET_V128_FROM_ADDR((uint32 *)global_addr)); + HANDLE_OP_END(); + } +#endif HANDLE_OP(WASM_OP_SET_GLOBAL) { global_idx = read_uint32(frame_ip); @@ -3634,6 +3677,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, GET_I64_FROM_ADDR(frame_lp + addr1)); HANDLE_OP_END(); } +#if WASM_ENABLE_SIMDE != 0 + HANDLE_OP(WASM_OP_SET_GLOBAL_V128) + { + global_idx = read_uint32(frame_ip); + bh_assert(global_idx < module->e->global_count); + global = globals + global_idx; + global_addr = get_global_addr(global_data, global); + addr1 = GET_OFFSET(); + PUT_V128_TO_ADDR((uint32 *)global_addr, + GET_V128_FROM_ADDR(frame_lp + addr1)); + HANDLE_OP_END(); + } +#endif /* memory load instructions */ HANDLE_OP(WASM_OP_I32_LOAD) @@ -4879,6 +4935,28 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } +#if WASM_ENABLE_SIMD != 0 + HANDLE_OP(EXT_OP_COPY_STACK_TOP_V128) + { + addr1 = GET_OFFSET(); + addr2 = GET_OFFSET(); + + PUT_V128_TO_ADDR(frame_lp + addr2, + GET_V128_FROM_ADDR(frame_lp + addr1)); + +#if WASM_ENABLE_GC != 0 + /* Ignore constants because they are not reference */ + if (addr1 >= 0) { + if (*FRAME_REF(addr1)) { + CLEAR_FRAME_REF(addr1); + SET_FRAME_REF(addr2); + } + } +#endif + + HANDLE_OP_END(); + } +#endif HANDLE_OP(EXT_OP_COPY_STACK_VALUES) { @@ -5737,6 +5815,1571 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #endif goto call_func_from_entry; } +#if WASM_ENABLE_SIMDE != 0 +#define SIMD_V128_TO_SIMDE_V128(v) \ + ({ \ + bh_assert(sizeof(V128) == sizeof(simde_v128_t)); \ + simde_v128_t result; \ + bh_memcpy_s(&result, sizeof(simde_v128_t), &(v), sizeof(V128)); \ + result; \ + }) + +#define SIMDE_V128_TO_SIMD_V128(sv, v) \ + do { \ + bh_assert(sizeof(V128) == sizeof(simde_v128_t)); \ + bh_memcpy_s(&(v), sizeof(V128), &(sv), sizeof(simde_v128_t)); \ + } while (0) + + HANDLE_OP(WASM_OP_SIMD_PREFIX) + { + GET_OPCODE(); + + switch (opcode) { + /* Memory */ + case SIMD_v128_load: + { + uint32 offset, addr; + offset = read_uint32(frame_ip); + addr = POP_I32(); + addr_ret = GET_OFFSET(); + CHECK_MEMORY_OVERFLOW(16); + PUT_V128_TO_ADDR(frame_lp + addr_ret, LOAD_V128(maddr)); + break; + } +#define SIMD_LOAD_OP(simde_func) \ + do { \ + uint32 offset, addr; \ + offset = read_uint32(frame_ip); \ + addr = POP_I32(); \ + addr_ret = GET_OFFSET(); \ + CHECK_MEMORY_OVERFLOW(8); \ + \ + simde_v128_t simde_result = simde_func(maddr); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + \ + } while (0) + case SIMD_v128_load8x8_s: + { + SIMD_LOAD_OP(simde_wasm_i16x8_load8x8); + break; + } + case SIMD_v128_load8x8_u: + { + SIMD_LOAD_OP(simde_wasm_u16x8_load8x8); + break; + } + case SIMD_v128_load16x4_s: + { + SIMD_LOAD_OP(simde_wasm_i32x4_load16x4); + break; + } + case SIMD_v128_load16x4_u: + { + SIMD_LOAD_OP(simde_wasm_u32x4_load16x4); + break; + } + case SIMD_v128_load32x2_s: + { + SIMD_LOAD_OP(simde_wasm_i64x2_load32x2); + break; + } + case SIMD_v128_load32x2_u: + { + SIMD_LOAD_OP(simde_wasm_u64x2_load32x2); + break; + } +#define SIMD_LOAD_SPLAT_OP(simde_func, width) \ + do { \ + uint32 offset, addr; \ + offset = read_uint32(frame_ip); \ + addr = POP_I32(); \ + addr_ret = GET_OFFSET(); \ + CHECK_MEMORY_OVERFLOW(width / 8); \ + \ + simde_v128_t simde_result = simde_func(maddr); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + } while (0) + + case SIMD_v128_load8_splat: + { + SIMD_LOAD_SPLAT_OP(simde_wasm_v128_load8_splat, 8); + break; + } + case SIMD_v128_load16_splat: + { + SIMD_LOAD_SPLAT_OP(simde_wasm_v128_load16_splat, 16); + break; + } + case SIMD_v128_load32_splat: + { + SIMD_LOAD_SPLAT_OP(simde_wasm_v128_load32_splat, 32); + break; + } + case SIMD_v128_load64_splat: + { + SIMD_LOAD_SPLAT_OP(simde_wasm_v128_load64_splat, 64); + break; + } + case SIMD_v128_store: + { + uint32 offset, addr; + offset = read_uint32(frame_ip); + V128 data = POP_V128(); + addr = POP_I32(); + + CHECK_MEMORY_OVERFLOW(16); + STORE_V128(maddr, data); + break; + } + + /* Basic */ + case SIMD_v128_const: + { + uint8 *orig_ip = frame_ip; + + frame_ip += sizeof(V128); + addr_ret = GET_OFFSET(); + + PUT_V128_TO_ADDR(frame_lp + addr_ret, *(V128 *)orig_ip); + break; + } + /* TODO: Add a faster SIMD implementation */ + case SIMD_v8x16_shuffle: + { + V128 indices; + bh_memcpy_s(&indices, sizeof(V128), frame_ip, + sizeof(V128)); + frame_ip += sizeof(V128); + + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + addr_ret = GET_OFFSET(); + + V128 result; + for (int i = 0; i < 16; i++) { + uint8_t index = indices.i8x16[i]; + if (index < 16) { + result.i8x16[i] = v1.i8x16[index]; + } + else { + result.i8x16[i] = v2.i8x16[index - 16]; + } + } + + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); + break; + } + case SIMD_v8x16_swizzle: + { + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + addr_ret = GET_OFFSET(); + simde_v128_t simde_result = simde_wasm_i8x16_swizzle( + SIMD_V128_TO_SIMDE_V128(v1), + SIMD_V128_TO_SIMDE_V128(v2)); + + V128 result; + SIMDE_V128_TO_SIMD_V128(simde_result, result); + + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); + break; + } + + /* Splat */ +#define SIMD_SPLAT_OP(simde_func, pop_func, val_type) \ + do { \ + val_type val = pop_func(); \ + addr_ret = GET_OFFSET(); \ + \ + simde_v128_t simde_result = simde_func(val); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + } while (0) + +#define SIMD_SPLAT_OP_I32(simde_func) SIMD_SPLAT_OP(simde_func, POP_I32, uint32) +#define SIMD_SPLAT_OP_I64(simde_func) SIMD_SPLAT_OP(simde_func, POP_I64, uint64) +#define SIMD_SPLAT_OP_F32(simde_func) \ + SIMD_SPLAT_OP(simde_func, POP_F32, float32) +#define SIMD_SPLAT_OP_F64(simde_func) \ + SIMD_SPLAT_OP(simde_func, POP_F64, float64) + + case SIMD_i8x16_splat: + { + uint32 val = POP_I32(); + addr_ret = GET_OFFSET(); + + simde_v128_t simde_result = simde_wasm_i8x16_splat(val); + + V128 result; + SIMDE_V128_TO_SIMD_V128(simde_result, result); + + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); + break; + } + case SIMD_i16x8_splat: + { + SIMD_SPLAT_OP_I32(simde_wasm_i16x8_splat); + break; + } + case SIMD_i32x4_splat: + { + SIMD_SPLAT_OP_I32(simde_wasm_i32x4_splat); + break; + } + case SIMD_i64x2_splat: + { + SIMD_SPLAT_OP_I64(simde_wasm_i64x2_splat); + break; + } + case SIMD_f32x4_splat: + { + SIMD_SPLAT_OP_F32(simde_wasm_f32x4_splat); + break; + } + case SIMD_f64x2_splat: + { + SIMD_SPLAT_OP_F64(simde_wasm_f64x2_splat); + break; + } +#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 +#define SIMD_LANE_HANDLE_UNALIGNED_ACCESS() +#else +#define SIMD_LANE_HANDLE_UNALIGNED_ACCESS() *frame_ip++; +#endif +#define SIMD_EXTRACT_LANE_OP(register, return_type, push_elem) \ + do { \ + uint8 lane = *frame_ip++; \ + SIMD_LANE_HANDLE_UNALIGNED_ACCESS(); \ + V128 v = POP_V128(); \ + push_elem((return_type)(v.register[lane])); \ + } while (0) +#define SIMD_REPLACE_LANE_OP(register, return_type, pop_elem) \ + do { \ + uint8 lane = *frame_ip++; \ + SIMD_LANE_HANDLE_UNALIGNED_ACCESS(); \ + return_type replacement = pop_elem(); \ + V128 v = POP_V128(); \ + v.register[lane] = replacement; \ + addr_ret = GET_OFFSET(); \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, v); \ + } while (0) + case SIMD_i8x16_extract_lane_s: + { + SIMD_EXTRACT_LANE_OP(i8x16, int8, PUSH_I32); + break; + } + case SIMD_i8x16_extract_lane_u: + { + SIMD_EXTRACT_LANE_OP(i8x16, uint8, PUSH_I32); + break; + } + case SIMD_i8x16_replace_lane: + { + SIMD_REPLACE_LANE_OP(i8x16, int8, POP_I32); + break; + } + case SIMD_i16x8_extract_lane_s: + { + SIMD_EXTRACT_LANE_OP(i16x8, int16, PUSH_I32); + break; + } + case SIMD_i16x8_extract_lane_u: + { + SIMD_EXTRACT_LANE_OP(i16x8, uint16, PUSH_I32); + break; + } + case SIMD_i16x8_replace_lane: + { + SIMD_REPLACE_LANE_OP(i16x8, int16, POP_I32); + break; + } + case SIMD_i32x4_extract_lane: + { + SIMD_EXTRACT_LANE_OP(i32x4, int32, PUSH_I32); + break; + } + case SIMD_i32x4_replace_lane: + { + SIMD_REPLACE_LANE_OP(i32x4, int32, POP_I32); + break; + } + case SIMD_i64x2_extract_lane: + { + SIMD_EXTRACT_LANE_OP(i64x2, int64, PUSH_I64); + break; + } + case SIMD_i64x2_replace_lane: + { + SIMD_REPLACE_LANE_OP(i64x2, int64, POP_I64); + break; + } + case SIMD_f32x4_extract_lane: + { + SIMD_EXTRACT_LANE_OP(f32x4, float32, PUSH_F32); + break; + } + case SIMD_f32x4_replace_lane: + { + SIMD_REPLACE_LANE_OP(f32x4, float32, POP_F32); + break; + } + case SIMD_f64x2_extract_lane: + { + SIMD_EXTRACT_LANE_OP(f64x2, float64, PUSH_F64); + break; + } + case SIMD_f64x2_replace_lane: + { + SIMD_REPLACE_LANE_OP(f64x2, float64, POP_F64); + break; + } + +#define SIMD_DOUBLE_OP(simde_func) \ + do { \ + V128 v2 = POP_V128(); \ + V128 v1 = POP_V128(); \ + addr_ret = GET_OFFSET(); \ + \ + simde_v128_t simde_result = simde_func(SIMD_V128_TO_SIMDE_V128(v1), \ + SIMD_V128_TO_SIMDE_V128(v2)); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + } while (0) + + /* i8x16 comparison operations */ + case SIMD_i8x16_eq: + { + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + addr_ret = GET_OFFSET(); + + simde_v128_t simde_result = + simde_wasm_i8x16_eq(SIMD_V128_TO_SIMDE_V128(v1), + SIMD_V128_TO_SIMDE_V128(v2)); + + V128 result; + SIMDE_V128_TO_SIMD_V128(simde_result, result); + + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); + break; + } + case SIMD_i8x16_ne: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_ne); + break; + } + case SIMD_i8x16_lt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_lt); + break; + } + case SIMD_i8x16_lt_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_lt); + break; + } + case SIMD_i8x16_gt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_gt); + break; + } + case SIMD_i8x16_gt_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_gt); + break; + } + case SIMD_i8x16_le_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_le); + break; + } + case SIMD_i8x16_le_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_le); + break; + } + case SIMD_i8x16_ge_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_ge); + break; + } + case SIMD_i8x16_ge_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_ge); + break; + } + + /* i16x8 comparison operations */ + case SIMD_i16x8_eq: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_eq); + break; + } + case SIMD_i16x8_ne: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_ne); + break; + } + case SIMD_i16x8_lt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_lt); + break; + } + case SIMD_i16x8_lt_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_lt); + break; + } + case SIMD_i16x8_gt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_gt); + break; + } + case SIMD_i16x8_gt_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_gt); + break; + } + case SIMD_i16x8_le_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_le); + break; + } + case SIMD_i16x8_le_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_le); + break; + } + case SIMD_i16x8_ge_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_ge); + break; + } + case SIMD_i16x8_ge_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_ge); + break; + } + + /* i32x4 comparison operations */ + case SIMD_i32x4_eq: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_eq); + break; + } + case SIMD_i32x4_ne: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_ne); + break; + } + case SIMD_i32x4_lt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_lt); + break; + } + case SIMD_i32x4_lt_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_lt); + break; + } + case SIMD_i32x4_gt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_gt); + break; + } + case SIMD_i32x4_gt_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_gt); + break; + } + case SIMD_i32x4_le_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_le); + break; + } + case SIMD_i32x4_le_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_le); + break; + } + case SIMD_i32x4_ge_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_ge); + break; + } + case SIMD_i32x4_ge_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_ge); + break; + } + + /* f32x4 comparison operations */ + case SIMD_f32x4_eq: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_eq); + break; + } + case SIMD_f32x4_ne: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_ne); + break; + } + case SIMD_f32x4_lt: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_lt); + break; + } + case SIMD_f32x4_gt: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_gt); + break; + } + case SIMD_f32x4_le: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_le); + break; + } + case SIMD_f32x4_ge: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_ge); + break; + } + + /* f64x2 comparison operations */ + case SIMD_f64x2_eq: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_eq); + break; + } + case SIMD_f64x2_ne: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_ne); + break; + } + case SIMD_f64x2_lt: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_lt); + break; + } + case SIMD_f64x2_gt: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_gt); + break; + } + case SIMD_f64x2_le: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_le); + break; + } + case SIMD_f64x2_ge: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_ge); + break; + } + + /* v128 bitwise operations */ +#define SIMD_V128_BITWISE_OP_COMMON(result_expr_0, result_expr_1) \ + do { \ + V128 result; \ + result.i64x2[0] = (result_expr_0); \ + result.i64x2[1] = (result_expr_1); \ + addr_ret = GET_OFFSET(); \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + } while (0) + + case SIMD_v128_not: + { + V128 value = POP_V128(); + SIMD_V128_BITWISE_OP_COMMON(~value.i64x2[0], + ~value.i64x2[1]); + break; + } + case SIMD_v128_and: + { + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + SIMD_V128_BITWISE_OP_COMMON(v1.i64x2[0] & v2.i64x2[0], + v1.i64x2[1] & v2.i64x2[1]); + break; + } + case SIMD_v128_andnot: + { + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + SIMD_V128_BITWISE_OP_COMMON( + v1.i64x2[0] & (~v2.i64x2[0]), + v1.i64x2[1] & (~v2.i64x2[1])); + break; + } + case SIMD_v128_or: + { + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + SIMD_V128_BITWISE_OP_COMMON(v1.i64x2[0] | v2.i64x2[0], + v1.i64x2[1] | v2.i64x2[1]); + break; + } + case SIMD_v128_xor: + { + V128 v2 = POP_V128(); + V128 v1 = POP_V128(); + SIMD_V128_BITWISE_OP_COMMON(v1.i64x2[0] ^ v2.i64x2[0], + v1.i64x2[1] ^ v2.i64x2[1]); + break; + } + case SIMD_v128_bitselect: + { + V128 v1 = POP_V128(); + V128 v2 = POP_V128(); + V128 v3 = POP_V128(); + addr_ret = GET_OFFSET(); + + simde_v128_t simde_result = simde_wasm_v128_bitselect( + SIMD_V128_TO_SIMDE_V128(v3), + SIMD_V128_TO_SIMDE_V128(v2), + SIMD_V128_TO_SIMDE_V128(v1)); + + V128 result; + SIMDE_V128_TO_SIMD_V128(simde_result, result); + + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); + break; + } + case SIMD_v128_any_true: + { + V128 value = POP_V128(); + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = + value.i64x2[0] != 0 || value.i64x2[1] != 0; + break; + } + +#define SIMD_LOAD_LANE_COMMON(vec, register, lane, width) \ + do { \ + addr_ret = GET_OFFSET(); \ + CHECK_MEMORY_OVERFLOW(width / 8); \ + if (width == 64) { \ + vec.register[lane] = GET_I64_FROM_ADDR(maddr); \ + } \ + else { \ + vec.register[lane] = *(uint##width *)(maddr); \ + } \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, vec); \ + } while (0) + +#define SIMD_LOAD_LANE_OP(register, width) \ + do { \ + uint32 offset, addr; \ + offset = read_uint32(frame_ip); \ + V128 vec = POP_V128(); \ + addr = POP_I32(); \ + int lane = *frame_ip++; \ + SIMD_LANE_HANDLE_UNALIGNED_ACCESS(); \ + SIMD_LOAD_LANE_COMMON(vec, register, lane, width); \ + } while (0) + + case SIMD_v128_load8_lane: + { + SIMD_LOAD_LANE_OP(i8x16, 8); + break; + } + case SIMD_v128_load16_lane: + { + SIMD_LOAD_LANE_OP(i16x8, 16); + break; + } + case SIMD_v128_load32_lane: + { + SIMD_LOAD_LANE_OP(i32x4, 32); + break; + } + case SIMD_v128_load64_lane: + { + SIMD_LOAD_LANE_OP(i64x2, 64); + break; + } +#define SIMD_STORE_LANE_OP(register, width) \ + do { \ + uint32 offset, addr; \ + offset = read_uint32(frame_ip); \ + V128 vec = POP_V128(); \ + addr = POP_I32(); \ + int lane = *frame_ip++; \ + SIMD_LANE_HANDLE_UNALIGNED_ACCESS(); \ + CHECK_MEMORY_OVERFLOW(width / 8); \ + if (width == 64) { \ + STORE_I64(maddr, vec.register[lane]); \ + } \ + else { \ + *(uint##width *)(maddr) = vec.register[lane]; \ + } \ + } while (0) + + case SIMD_v128_store8_lane: + { + SIMD_STORE_LANE_OP(i8x16, 8); + break; + } + + case SIMD_v128_store16_lane: + { + SIMD_STORE_LANE_OP(i16x8, 16); + break; + } + + case SIMD_v128_store32_lane: + { + SIMD_STORE_LANE_OP(i32x4, 32); + break; + } + + case SIMD_v128_store64_lane: + { + SIMD_STORE_LANE_OP(i64x2, 64); + break; + } +#define SIMD_LOAD_ZERO_OP(register, width) \ + do { \ + uint32 offset, addr; \ + offset = read_uint32(frame_ip); \ + addr = POP_I32(); \ + int32 lane = 0; \ + V128 vec = { 0 }; \ + SIMD_LOAD_LANE_COMMON(vec, register, lane, width); \ + } while (0) + + case SIMD_v128_load32_zero: + { + SIMD_LOAD_ZERO_OP(i32x4, 32); + break; + } + case SIMD_v128_load64_zero: + { + SIMD_LOAD_ZERO_OP(i64x2, 64); + break; + } + +#define SIMD_SINGLE_OP(simde_func) \ + do { \ + V128 v1 = POP_V128(); \ + addr_ret = GET_OFFSET(); \ + \ + simde_v128_t simde_result = simde_func(SIMD_V128_TO_SIMDE_V128(v1)); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + } while (0) + + /* Float conversion */ + case SIMD_f32x4_demote_f64x2_zero: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_demote_f64x2_zero); + break; + } + case SIMD_f64x2_promote_low_f32x4_zero: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_promote_low_f32x4); + break; + } + + /* i8x16 operations */ + case SIMD_i8x16_abs: + { + SIMD_SINGLE_OP(simde_wasm_i8x16_abs); + break; + } + case SIMD_i8x16_neg: + { + SIMD_SINGLE_OP(simde_wasm_i8x16_neg); + break; + } + case SIMD_i8x16_popcnt: + { + SIMD_SINGLE_OP(simde_wasm_i8x16_popcnt); + break; + } + case SIMD_i8x16_all_true: + { + V128 v1 = POP_V128(); + + bool result = simde_wasm_i8x16_all_true( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + + case SIMD_i8x16_bitmask: + { + V128 v1 = POP_V128(); + + uint32_t result = simde_wasm_i8x16_bitmask( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i8x16_narrow_i16x8_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_narrow_i16x8); + break; + } + case SIMD_i8x16_narrow_i16x8_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_narrow_i16x8); + break; + } + case SIMD_f32x4_ceil: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_ceil); + break; + } + case SIMD_f32x4_floor: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_floor); + break; + } + case SIMD_f32x4_trunc: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_trunc); + break; + } + case SIMD_f32x4_nearest: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_nearest); + break; + } +#define SIMD_LANE_SHIFT(simde_func) \ + do { \ + int32 count = POP_I32(); \ + V128 v1 = POP_V128(); \ + addr_ret = GET_OFFSET(); \ + \ + simde_v128_t simde_result = \ + simde_func(SIMD_V128_TO_SIMDE_V128(v1), count); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ + } while (0) + case SIMD_i8x16_shl: + { + SIMD_LANE_SHIFT(simde_wasm_i8x16_shl); + break; + } + case SIMD_i8x16_shr_s: + { + SIMD_LANE_SHIFT(simde_wasm_i8x16_shr); + break; + } + case SIMD_i8x16_shr_u: + { + SIMD_LANE_SHIFT(simde_wasm_u8x16_shr); + break; + } + case SIMD_i8x16_add: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_add); + break; + } + case SIMD_i8x16_add_sat_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_add_sat); + break; + } + case SIMD_i8x16_add_sat_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_add_sat); + break; + } + case SIMD_i8x16_sub: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_sub); + break; + } + case SIMD_i8x16_sub_sat_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_sub_sat); + break; + } + case SIMD_i8x16_sub_sat_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_sub_sat); + break; + } + case SIMD_f64x2_ceil: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_ceil); + break; + } + case SIMD_f64x2_floor: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_floor); + break; + } + case SIMD_i8x16_min_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_min); + break; + } + case SIMD_i8x16_min_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_min); + break; + } + case SIMD_i8x16_max_s: + { + SIMD_DOUBLE_OP(simde_wasm_i8x16_max); + break; + } + case SIMD_i8x16_max_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_max); + break; + } + case SIMD_f64x2_trunc: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_trunc); + break; + } + case SIMD_i8x16_avgr_u: + { + SIMD_DOUBLE_OP(simde_wasm_u8x16_avgr); + break; + } + case SIMD_i16x8_extadd_pairwise_i8x16_s: + { + SIMD_SINGLE_OP(simde_wasm_i16x8_extadd_pairwise_i8x16); + break; + } + case SIMD_i16x8_extadd_pairwise_i8x16_u: + { + SIMD_SINGLE_OP(simde_wasm_u16x8_extadd_pairwise_u8x16); + break; + } + case SIMD_i32x4_extadd_pairwise_i16x8_s: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_extadd_pairwise_i16x8); + break; + } + case SIMD_i32x4_extadd_pairwise_i16x8_u: + { + SIMD_SINGLE_OP(simde_wasm_u32x4_extadd_pairwise_u16x8); + break; + } + + /* i16x8 operations */ + case SIMD_i16x8_abs: + { + SIMD_SINGLE_OP(simde_wasm_i16x8_abs); + break; + } + case SIMD_i16x8_neg: + { + SIMD_SINGLE_OP(simde_wasm_i16x8_neg); + break; + } + case SIMD_i16x8_q15mulr_sat_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_q15mulr_sat); + break; + } + case SIMD_i16x8_all_true: + { + V128 v1 = POP_V128(); + + bool result = simde_wasm_i16x8_all_true( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i16x8_bitmask: + { + V128 v1 = POP_V128(); + + uint32_t result = simde_wasm_i16x8_bitmask( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i16x8_narrow_i32x4_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_narrow_i32x4); + break; + } + case SIMD_i16x8_narrow_i32x4_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_narrow_i32x4); + break; + } + case SIMD_i16x8_extend_low_i8x16_s: + { + SIMD_SINGLE_OP(simde_wasm_i16x8_extend_low_i8x16); + break; + } + case SIMD_i16x8_extend_high_i8x16_s: + { + SIMD_SINGLE_OP(simde_wasm_i16x8_extend_high_i8x16); + break; + } + case SIMD_i16x8_extend_low_i8x16_u: + { + SIMD_SINGLE_OP(simde_wasm_u16x8_extend_low_u8x16); + break; + } + case SIMD_i16x8_extend_high_i8x16_u: + { + SIMD_SINGLE_OP(simde_wasm_u16x8_extend_high_u8x16); + break; + } + case SIMD_i16x8_shl: + { + SIMD_LANE_SHIFT(simde_wasm_i16x8_shl); + break; + } + case SIMD_i16x8_shr_s: + { + SIMD_LANE_SHIFT(simde_wasm_i16x8_shr); + break; + } + case SIMD_i16x8_shr_u: + { + SIMD_LANE_SHIFT(simde_wasm_u16x8_shr); + break; + } + case SIMD_i16x8_add: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_add); + break; + } + case SIMD_i16x8_add_sat_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_add_sat); + break; + } + case SIMD_i16x8_add_sat_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_add_sat); + break; + } + case SIMD_i16x8_sub: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_sub); + break; + } + case SIMD_i16x8_sub_sat_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_sub_sat); + break; + } + case SIMD_i16x8_sub_sat_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_sub_sat); + break; + } + case SIMD_f64x2_nearest: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_nearest); + break; + } + case SIMD_i16x8_mul: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_mul); + break; + } + case SIMD_i16x8_min_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_min); + break; + } + case SIMD_i16x8_min_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_min); + break; + } + case SIMD_i16x8_max_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_max); + break; + } + case SIMD_i16x8_max_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_max); + break; + } + case SIMD_i16x8_avgr_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_avgr); + break; + } + case SIMD_i16x8_extmul_low_i8x16_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_extmul_low_i8x16); + break; + } + case SIMD_i16x8_extmul_high_i8x16_s: + { + SIMD_DOUBLE_OP(simde_wasm_i16x8_extmul_high_i8x16); + break; + } + case SIMD_i16x8_extmul_low_i8x16_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_extmul_low_u8x16); + break; + } + case SIMD_i16x8_extmul_high_i8x16_u: + { + SIMD_DOUBLE_OP(simde_wasm_u16x8_extmul_high_u8x16); + break; + } + + /* i32x4 operations */ + case SIMD_i32x4_abs: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_abs); + break; + } + case SIMD_i32x4_neg: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_neg); + break; + } + case SIMD_i32x4_all_true: + { + V128 v1 = POP_V128(); + + bool result = simde_wasm_i32x4_all_true( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i32x4_bitmask: + { + V128 v1 = POP_V128(); + + uint32_t result = simde_wasm_i32x4_bitmask( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i32x4_extend_low_i16x8_s: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_extend_low_i16x8); + break; + } + case SIMD_i32x4_extend_high_i16x8_s: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_extend_high_i16x8); + break; + } + case SIMD_i32x4_extend_low_i16x8_u: + { + SIMD_SINGLE_OP(simde_wasm_u32x4_extend_low_u16x8); + break; + } + case SIMD_i32x4_extend_high_i16x8_u: + { + SIMD_SINGLE_OP(simde_wasm_u32x4_extend_high_u16x8); + break; + } + case SIMD_i32x4_shl: + { + SIMD_LANE_SHIFT(simde_wasm_i32x4_shl); + break; + } + case SIMD_i32x4_shr_s: + { + SIMD_LANE_SHIFT(simde_wasm_i32x4_shr); + break; + } + case SIMD_i32x4_shr_u: + { + SIMD_LANE_SHIFT(simde_wasm_u32x4_shr); + break; + } + case SIMD_i32x4_add: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_add); + break; + } + case SIMD_i32x4_sub: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_sub); + break; + } + case SIMD_i32x4_mul: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_mul); + break; + } + case SIMD_i32x4_min_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_min); + break; + } + case SIMD_i32x4_min_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_min); + break; + } + case SIMD_i32x4_max_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_max); + break; + } + case SIMD_i32x4_max_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_max); + break; + } + case SIMD_i32x4_dot_i16x8_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_dot_i16x8); + break; + } + case SIMD_i32x4_extmul_low_i16x8_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_extmul_low_i16x8); + break; + } + case SIMD_i32x4_extmul_high_i16x8_s: + { + SIMD_DOUBLE_OP(simde_wasm_i32x4_extmul_high_i16x8); + break; + } + case SIMD_i32x4_extmul_low_i16x8_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_extmul_low_u16x8); + break; + } + case SIMD_i32x4_extmul_high_i16x8_u: + { + SIMD_DOUBLE_OP(simde_wasm_u32x4_extmul_high_u16x8); + break; + } + + /* i64x2 operations */ + case SIMD_i64x2_abs: + { + SIMD_SINGLE_OP(simde_wasm_i64x2_abs); + break; + } + case SIMD_i64x2_neg: + { + SIMD_SINGLE_OP(simde_wasm_i64x2_neg); + break; + } + case SIMD_i64x2_all_true: + { + V128 v1 = POP_V128(); + + bool result = simde_wasm_i64x2_all_true( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i64x2_bitmask: + { + V128 v1 = POP_V128(); + + uint32_t result = simde_wasm_i64x2_bitmask( + SIMD_V128_TO_SIMDE_V128(v1)); + + addr_ret = GET_OFFSET(); + frame_lp[addr_ret] = result; + break; + } + case SIMD_i64x2_extend_low_i32x4_s: + { + SIMD_SINGLE_OP(simde_wasm_i64x2_extend_low_i32x4); + break; + } + case SIMD_i64x2_extend_high_i32x4_s: + { + SIMD_SINGLE_OP(simde_wasm_i64x2_extend_high_i32x4); + break; + } + case SIMD_i64x2_extend_low_i32x4_u: + { + SIMD_SINGLE_OP(simde_wasm_u64x2_extend_low_u32x4); + break; + } + case SIMD_i64x2_extend_high_i32x4_u: + { + SIMD_SINGLE_OP(simde_wasm_u64x2_extend_high_u32x4); + break; + } + case SIMD_i64x2_shl: + { + SIMD_LANE_SHIFT(simde_wasm_i64x2_shl); + break; + } + case SIMD_i64x2_shr_s: + { + SIMD_LANE_SHIFT(simde_wasm_i64x2_shr); + break; + } + case SIMD_i64x2_shr_u: + { + SIMD_LANE_SHIFT(simde_wasm_u64x2_shr); + break; + } + case SIMD_i64x2_add: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_add); + break; + } + case SIMD_i64x2_sub: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_sub); + break; + } + case SIMD_i64x2_mul: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_mul); + break; + } + case SIMD_i64x2_eq: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_eq); + break; + } + case SIMD_i64x2_ne: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_ne); + break; + } + case SIMD_i64x2_lt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_lt); + break; + } + case SIMD_i64x2_gt_s: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_gt); + break; + } + case SIMD_i64x2_le_s: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_le); + break; + } + case SIMD_i64x2_ge_s: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_ge); + break; + } + case SIMD_i64x2_extmul_low_i32x4_s: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_extmul_low_i32x4); + break; + } + case SIMD_i64x2_extmul_high_i32x4_s: + { + SIMD_DOUBLE_OP(simde_wasm_i64x2_extmul_high_i32x4); + break; + } + case SIMD_i64x2_extmul_low_i32x4_u: + { + SIMD_DOUBLE_OP(simde_wasm_u64x2_extmul_low_u32x4); + break; + } + case SIMD_i64x2_extmul_high_i32x4_u: + { + SIMD_DOUBLE_OP(simde_wasm_u64x2_extmul_high_u32x4); + break; + } + + /* f32x4 opertions */ + case SIMD_f32x4_abs: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_abs); + break; + } + case SIMD_f32x4_neg: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_neg); + break; + } + case SIMD_f32x4_sqrt: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_sqrt); + break; + } + case SIMD_f32x4_add: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_add); + break; + } + case SIMD_f32x4_sub: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_sub); + break; + } + case SIMD_f32x4_mul: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_mul); + break; + } + case SIMD_f32x4_div: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_div); + break; + } + case SIMD_f32x4_min: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_min); + break; + } + case SIMD_f32x4_max: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_max); + break; + } + case SIMD_f32x4_pmin: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_pmin); + break; + } + case SIMD_f32x4_pmax: + { + SIMD_DOUBLE_OP(simde_wasm_f32x4_pmax); + break; + } + + /* f64x2 operations */ + case SIMD_f64x2_abs: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_abs); + break; + } + case SIMD_f64x2_neg: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_neg); + break; + } + case SIMD_f64x2_sqrt: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_sqrt); + break; + } + case SIMD_f64x2_add: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_add); + break; + } + case SIMD_f64x2_sub: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_sub); + break; + } + case SIMD_f64x2_mul: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_mul); + break; + } + case SIMD_f64x2_div: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_div); + break; + } + case SIMD_f64x2_min: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_min); + break; + } + case SIMD_f64x2_max: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_max); + break; + } + case SIMD_f64x2_pmin: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_pmin); + break; + } + case SIMD_f64x2_pmax: + { + SIMD_DOUBLE_OP(simde_wasm_f64x2_pmax); + break; + } + + /* Conversion operations */ + case SIMD_i32x4_trunc_sat_f32x4_s: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_trunc_sat_f32x4); + break; + } + case SIMD_i32x4_trunc_sat_f32x4_u: + { + SIMD_SINGLE_OP(simde_wasm_u32x4_trunc_sat_f32x4); + break; + } + case SIMD_f32x4_convert_i32x4_s: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_convert_i32x4); + break; + } + case SIMD_f32x4_convert_i32x4_u: + { + SIMD_SINGLE_OP(simde_wasm_f32x4_convert_u32x4); + break; + } + case SIMD_i32x4_trunc_sat_f64x2_s_zero: + { + SIMD_SINGLE_OP(simde_wasm_i32x4_trunc_sat_f64x2_zero); + break; + } + case SIMD_i32x4_trunc_sat_f64x2_u_zero: + { + SIMD_SINGLE_OP(simde_wasm_u32x4_trunc_sat_f64x2_zero); + break; + } + case SIMD_f64x2_convert_low_i32x4_s: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_convert_low_i32x4); + break; + } + case SIMD_f64x2_convert_low_i32x4_u: + { + SIMD_SINGLE_OP(simde_wasm_f64x2_convert_low_u32x4); + break; + } + + default: + wasm_set_exception(module, "unsupported SIMD opcode"); + } + HANDLE_OP_END(); + } +#endif HANDLE_OP(WASM_OP_CALL) { @@ -5845,7 +7488,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if WASM_ENABLE_LABELS_AS_VALUES == 0 continue; #else - FETCH_OPCODE_AND_DISPATCH(); + FETCH_OPCODE_AND_DISPATCH(); #endif #if WASM_ENABLE_TAIL_CALL != 0 || WASM_ENABLE_GC != 0 @@ -5914,8 +7557,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, } for (i = 0; i < cur_func->param_count; i++) { - if (cur_func->param_types[i] == VALUE_TYPE_I64 - || cur_func->param_types[i] == VALUE_TYPE_F64) { + if (cur_func->param_types[i] == VALUE_TYPE_V128) { + PUT_V128_TO_ADDR( + outs_area->lp, + GET_OPERAND_V128(2 * (cur_func->param_count - i - 1))); + outs_area->lp += 4; + } + else if (cur_func->param_types[i] == VALUE_TYPE_I64 + || cur_func->param_types[i] == VALUE_TYPE_F64) { PUT_I64_TO_ADDR( outs_area->lp, GET_OPERAND(uint64, I64, diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 31424d21e..29813d875 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -319,7 +319,8 @@ is_byte_a_type(uint8 type) } #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) static V128 read_i8x16(uint8 *p_buf, char *error_buf, uint32 error_buf_size) { @@ -332,7 +333,8 @@ read_i8x16(uint8 *p_buf, char *error_buf, uint32 error_buf_size) return result; } -#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) */ +#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ + (WASM_ENABLE_FAST_INTERP != 0) */ #endif /* end of WASM_ENABLE_SIMD */ static void * @@ -725,7 +727,8 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, goto fail; break; #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) /* v128.const */ case INIT_EXPR_TYPE_V128_CONST: { @@ -754,7 +757,8 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, #endif break; } -#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) */ +#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ + (WASM_ENABLE_FAST_INTERP != 0) */ #endif /* end of WASM_ENABLE_SIMD */ #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 @@ -4174,7 +4178,8 @@ load_export_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, return false; } #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) /* TODO: check func type, if it has v128 param or result, report error */ #endif @@ -7347,6 +7352,10 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, case WASM_OP_SET_GLOBAL: case WASM_OP_GET_GLOBAL_64: case WASM_OP_SET_GLOBAL_64: +#if WASM_ENABLE_SIMDE != 0 + case WASM_OP_GET_GLOBAL_V128: + case WASM_OP_SET_GLOBAL_V128: +#endif case WASM_OP_SET_GLOBAL_AUX_STACK: skip_leb_uint32(p, p_end); /* local index */ break; @@ -7723,7 +7732,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, } #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) case WASM_OP_SIMD_PREFIX: { uint32 opcode1; @@ -7816,7 +7826,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, } break; } -#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) */ +#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ + (WASM_ENABLE_FAST_INTERP != 0) */ #endif /* end of WASM_ENABLE_SIMD */ #if WASM_ENABLE_SHARED_MEMORY != 0 @@ -7991,6 +8002,10 @@ typedef struct WASMLoaderContext { int32 *i32_consts; uint32 i32_const_max_num; uint32 i32_const_num; + /* const buffer for V128 */ + V128 *v128_consts; + uint32 v128_const_max_num; + uint32 v128_const_num; /* processed code */ uint8 *p_code_compiled; @@ -8224,6 +8239,8 @@ wasm_loader_ctx_destroy(WASMLoaderContext *ctx) wasm_runtime_free(ctx->i64_consts); if (ctx->i32_consts) wasm_runtime_free(ctx->i32_consts); + if (ctx->v128_consts) + wasm_runtime_free(ctx->v128_consts); #endif wasm_runtime_free(ctx); } @@ -8281,6 +8298,11 @@ wasm_loader_ctx_init(WASMFunction *func, char *error_buf, uint32 error_buf_size) loader_malloc(sizeof(int32) * loader_ctx->i32_const_max_num, error_buf, error_buf_size))) goto fail; + loader_ctx->v128_const_max_num = 8; + if (!(loader_ctx->v128_consts = + loader_malloc(sizeof(V128) * loader_ctx->v128_const_max_num, + error_buf, error_buf_size))) + goto fail; if (func->param_cell_num >= (int32)INT16_MAX - func->local_cell_num) { set_error_buf(error_buf, error_buf_size, @@ -9139,6 +9161,7 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode, bool *preserved, char *error_buf, uint32 error_buf_size) { + uint32 i = 0; int16 preserved_offset = (int16)local_index; @@ -9162,6 +9185,13 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode, loader_ctx->preserved_local_offset++; emit_label(EXT_OP_COPY_STACK_TOP); } +#if WASM_ENABLE_SIMDE != 0 + else if (local_type == VALUE_TYPE_V128) { + if (loader_ctx->p_code_compiled) + loader_ctx->preserved_local_offset += 4; + emit_label(EXT_OP_COPY_STACK_TOP_V128); + } +#endif else { if (loader_ctx->p_code_compiled) loader_ctx->preserved_local_offset += 2; @@ -9174,10 +9204,15 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode, loader_ctx->frame_offset_bottom[i] = preserved_offset; } - if (is_32bit_type(cur_type)) + if (cur_type == VALUE_TYPE_V128) { + i += 4; + } + else if (is_32bit_type(cur_type)) { i++; - else + } + else { i += 2; + } } (void)error_buf; @@ -9206,7 +9241,10 @@ preserve_local_for_block(WASMLoaderContext *loader_ctx, uint8 opcode, return false; } - if (is_32bit_type(cur_type)) { + if (cur_type == VALUE_TYPE_V128) { + i += 4; + } + else if (is_32bit_type(cur_type)) { i++; } else { @@ -9545,6 +9583,15 @@ cmp_i32_const(const void *p_i32_const1, const void *p_i32_const2) return (i32_const1 < i32_const2) ? -1 : (i32_const1 > i32_const2) ? 1 : 0; } +static int +cmp_v128_const(const void *p_v128_const1, const void *p_v128_const2) +{ + V128 v128_const1 = *(V128 *)p_v128_const1; + V128 v128_const2 = *(V128 *)p_v128_const2; + + return memcmp(&v128_const1, &v128_const2, sizeof(V128)); +} + static bool wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, int16 *offset, char *error_buf, @@ -9578,6 +9625,32 @@ wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, } ctx->i64_consts[ctx->i64_const_num++] = *(int64 *)value; } + else if (type == VALUE_TYPE_V128) { + /* No slot left, emit const instead */ + if (ctx->v128_const_num * 4 > INT16_MAX - 2) { + *offset = 0; + return true; + } + + /* Traverse the list if the const num is small */ + if (ctx->v128_const_num < 10) { + for (uint32 i = 0; i < ctx->v128_const_num; i++) { + if (memcmp(&ctx->v128_consts[i], value, sizeof(V128)) + == 0) { + *offset = -1; + return true; + } + } + } + + if (ctx->v128_const_num >= ctx->v128_const_max_num) { + MEM_REALLOC(ctx->v128_consts, + sizeof(V128) * ctx->v128_const_max_num, + sizeof(V128) * (ctx->v128_const_max_num * 2)); + ctx->v128_const_max_num *= 2; + } + ctx->v128_consts[ctx->v128_const_num++] = *(V128 *)value; + } else { /* Treat i32 and f32 as the same by reading i32 value from the raw bytes */ @@ -9623,6 +9696,17 @@ wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, *offset = -(uint32)(ctx->i64_const_num * 2 + ctx->i32_const_num) + (uint32)(i64_const - ctx->i64_consts) * 2; } + else if (type == VALUE_TYPE_V128) { + V128 key = *(V128 *)value, *v128_const; + v128_const = bsearch(&key, ctx->v128_consts, ctx->v128_const_num, + sizeof(V128), cmp_v128_const); + if (!v128_const) { /* not found, emit const instead */ + *offset = 0; + return true; + } + *offset = -(uint32)(ctx->v128_const_num) + + (uint32)(v128_const - ctx->v128_consts); + } else { int32 key = *(int32 *)value, *i32_const; i32_const = bsearch(&key, ctx->i32_consts, ctx->i32_const_num, @@ -9819,17 +9903,23 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, block_type, &return_types, &reftype_maps, &reftype_map_count); #endif - /* If there is only one return value, use EXT_OP_COPY_STACK_TOP/_I64 instead - * of EXT_OP_COPY_STACK_VALUES for interpreter performance. */ + /* If there is only one return value, use EXT_OP_COPY_STACK_TOP/_I64/V128 + * instead of EXT_OP_COPY_STACK_VALUES for interpreter performance. */ if (return_count == 1) { uint8 cell = (uint8)wasm_value_type_cell_num(return_types[0]); - if (cell <= 2 /* V128 isn't supported whose cell num is 4 */ - && block->dynamic_offset != *(loader_ctx->frame_offset - cell)) { + if (block->dynamic_offset != *(loader_ctx->frame_offset - cell)) { /* insert op_copy before else opcode */ if (opcode == WASM_OP_ELSE) skip_label(); - emit_label(cell == 1 ? EXT_OP_COPY_STACK_TOP - : EXT_OP_COPY_STACK_TOP_I64); +#if WASM_ENABLE_SIMDE != 0 + if (cell == 4) { + emit_label(EXT_OP_COPY_STACK_TOP_V128); + } +#endif + if (cell <= 2) { + emit_label(cell == 1 ? EXT_OP_COPY_STACK_TOP + : EXT_OP_COPY_STACK_TOP_I64); + } emit_operand(loader_ctx, *(loader_ctx->frame_offset - cell)); emit_operand(loader_ctx, block->dynamic_offset); @@ -9864,11 +9954,37 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, for (i = (int32)return_count - 1; i >= 0; i--) { uint8 cells = (uint8)wasm_value_type_cell_num(return_types[i]); - frame_offset -= cells; - dynamic_offset -= cells; - if (dynamic_offset != *frame_offset) { - value_count++; - total_cel_num += cells; + if (frame_offset - cells < loader_ctx->frame_offset_bottom) { + set_error_buf(error_buf, error_buf_size, "frame offset underflow"); + goto fail; + } + + if (cells == 4) { + bool needs_copy = false; + int16 v128_dynamic = dynamic_offset - cells; + + for (int j = 0; j < 4; j++) { + if (*(frame_offset - j - 1) != (v128_dynamic + j)) { + needs_copy = true; + break; + } + } + + if (needs_copy) { + value_count++; + total_cel_num += cells; + } + + frame_offset -= cells; + dynamic_offset = v128_dynamic; + } + else { + frame_offset -= cells; + dynamic_offset -= cells; + if (dynamic_offset != *frame_offset) { + value_count++; + total_cel_num += cells; + } } } @@ -9904,19 +10020,50 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, dynamic_offset = dynamic_offset_org; for (i = (int32)return_count - 1, j = 0; i >= 0; i--) { uint8 cell = (uint8)wasm_value_type_cell_num(return_types[i]); - frame_offset -= cell; - dynamic_offset -= cell; - if (dynamic_offset != *frame_offset) { - /* cell num */ - cells[j] = cell; - /* src offset */ - src_offsets[j] = *frame_offset; - /* dst offset */ - dst_offsets[j] = dynamic_offset; - j++; + + if (cell == 4) { + bool needs_copy = false; + int16 v128_dynamic = dynamic_offset - cell; + + for (int k = 0; k < 4; k++) { + if (*(frame_offset - k - 1) != (v128_dynamic + k)) { + needs_copy = true; + break; + } + } + + if (needs_copy) { + cells[j] = cell; + src_offsets[j] = *(frame_offset - cell); + dst_offsets[j] = v128_dynamic; + j++; + } + + frame_offset -= cell; + dynamic_offset = v128_dynamic; } + else { + frame_offset -= cell; + dynamic_offset -= cell; + if (dynamic_offset != *frame_offset) { + cells[j] = cell; + /* src offset */ + src_offsets[j] = *frame_offset; + /* dst offset */ + dst_offsets[j] = dynamic_offset; + j++; + } + } + if (opcode == WASM_OP_ELSE) { - *frame_offset = dynamic_offset; + if (cell == 4) { + for (int k = 0; k < cell; k++) { + *(frame_offset + k) = dynamic_offset + k; + } + } + else { + *frame_offset = dynamic_offset; + } } else { loader_ctx->frame_offset = frame_offset; @@ -10075,7 +10222,8 @@ check_memory_access_align(uint8 opcode, uint32 align, char *error_buf, } #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) static bool check_simd_memory_access_align(uint8 opcode, uint32 align, char *error_buf, uint32 error_buf_size) @@ -11172,6 +11320,39 @@ re_scan: } } + if (loader_ctx->v128_const_num > 0) { + V128 *v128_consts_old = loader_ctx->v128_consts; + + /* Sort the v128 consts */ + qsort(v128_consts_old, loader_ctx->v128_const_num, sizeof(V128), + cmp_v128_const); + + /* Remove the duplicated v128 consts */ + uint32 k = 1; + for (i = 1; i < loader_ctx->v128_const_num; i++) { + if (!(memcmp(&v128_consts_old[i], &v128_consts_old[i - 1], + sizeof(V128)) + == 0)) { + v128_consts_old[k++] = v128_consts_old[i]; + } + } + + if (k < loader_ctx->v128_const_num) { + V128 *v128_consts_new; + /* Try to reallocate memory with a smaller size */ + if ((v128_consts_new = + wasm_runtime_malloc((uint32)sizeof(V128) * k))) { + bh_memcpy_s(v128_consts_new, (uint32)sizeof(V128) * k, + v128_consts_old, (uint32)sizeof(V128) * k); + /* Free the old memory */ + wasm_runtime_free(v128_consts_old); + loader_ctx->v128_consts = v128_consts_new; + loader_ctx->v128_const_max_num = k; + } + loader_ctx->v128_const_num = k; + } + } + if (loader_ctx->i32_const_num > 0) { int32 *i32_consts_old = loader_ctx->i32_consts; @@ -12492,10 +12673,20 @@ re_scan: #endif } #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) else if (*(loader_ctx->frame_ref - 1) == VALUE_TYPE_V128) { loader_ctx->frame_ref -= 4; loader_ctx->stack_cell_num -= 4; +#if WASM_ENABLE_FAST_INTERP != 0 + skip_label(); + loader_ctx->frame_offset -= 4; + if ((*(loader_ctx->frame_offset) + > loader_ctx->start_dynamic_offset) + && (*(loader_ctx->frame_offset) + < loader_ctx->max_dynamic_offset)) + loader_ctx->dynamic_offset -= 4; +#endif } #endif #endif @@ -12582,10 +12773,12 @@ re_scan: #endif /* end of WASM_ENABLE_FAST_INTERP */ break; #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) case VALUE_TYPE_V128: break; -#endif /* (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) */ +#endif /* (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ + (WASM_ENABLE_FAST_INTERP != 0) */ #endif /* WASM_ENABLE_SIMD != 0 */ default: { @@ -12680,8 +12873,9 @@ re_scan: uint8 opcode_tmp = WASM_OP_SELECT; if (type == VALUE_TYPE_V128) { -#if (WASM_ENABLE_SIMD == 0) \ - || ((WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0)) +#if (WASM_ENABLE_SIMD == 0) \ + || ((WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \ + && (WASM_ENABLE_FAST_INTERP == 0)) set_error_buf(error_buf, error_buf_size, "SIMD v128 type isn't supported"); goto fail; @@ -13177,10 +13371,21 @@ re_scan: emit_label(EXT_OP_SET_LOCAL_FAST); emit_byte(loader_ctx, (uint8)local_offset); } - else { + else if (is_64bit_type(local_type)) { emit_label(EXT_OP_SET_LOCAL_FAST_I64); emit_byte(loader_ctx, (uint8)local_offset); } +#if WASM_ENABLE_SIMDE != 0 + else if (local_type == VALUE_TYPE_V128) { + emit_label(EXT_OP_SET_LOCAL_FAST_V128); + emit_byte(loader_ctx, (uint8)local_offset); + } +#endif + else { + set_error_buf(error_buf, error_buf_size, + "unknown local type"); + goto fail; + } POP_OFFSET_TYPE(local_type); } } @@ -13253,6 +13458,12 @@ re_scan: emit_label(EXT_OP_TEE_LOCAL_FAST); emit_byte(loader_ctx, (uint8)local_offset); } +#if WASM_ENABLE_SIMDE != 0 + else if (local_type == VALUE_TYPE_V128) { + emit_label(EXT_OP_TEE_LOCAL_FAST_V128); + emit_byte(loader_ctx, (uint8)local_offset); + } +#endif else { emit_label(EXT_OP_TEE_LOCAL_FAST_I64); emit_byte(loader_ctx, (uint8)local_offset); @@ -13341,12 +13552,18 @@ re_scan: #endif *p_org = WASM_OP_GET_GLOBAL_64; } -#else /* else of WASM_ENABLE_FAST_INTERP */ +#else /* else of WASM_ENABLE_FAST_INTERP */ if (global_type == VALUE_TYPE_I64 || global_type == VALUE_TYPE_F64) { skip_label(); emit_label(WASM_OP_GET_GLOBAL_64); } +#if WASM_ENABLE_SIMDE != 0 + if (global_type == VALUE_TYPE_V128) { + skip_label(); + emit_label(WASM_OP_GET_GLOBAL_V128); + } +#endif /* end of WASM_ENABLE_SIMDE */ emit_uint32(loader_ctx, global_idx); PUSH_OFFSET_TYPE(global_type); #endif /* end of WASM_ENABLE_FAST_INTERP */ @@ -13430,7 +13647,7 @@ re_scan: func->has_op_set_global_aux_stack = true; #endif } -#else /* else of WASM_ENABLE_FAST_INTERP */ +#else /* else of WASM_ENABLE_FAST_INTERP */ if (global_type == VALUE_TYPE_I64 || global_type == VALUE_TYPE_F64) { skip_label(); @@ -13441,6 +13658,12 @@ re_scan: skip_label(); emit_label(WASM_OP_SET_GLOBAL_AUX_STACK); } +#if WASM_ENABLE_SIMDE != 0 + else if (global_type == VALUE_TYPE_V128) { + skip_label(); + emit_label(WASM_OP_SET_GLOBAL_V128); + } +#endif /* end of WASM_ENABLE_SIMDE */ emit_uint32(loader_ctx, global_idx); POP_OFFSET_TYPE(global_type); #endif /* end of WASM_ENABLE_FAST_INTERP */ @@ -15285,7 +15508,8 @@ re_scan: } #if WASM_ENABLE_SIMD != 0 -#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) +#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ + || (WASM_ENABLE_FAST_INTERP != 0) case WASM_OP_SIMD_PREFIX: { uint32 opcode1; @@ -15297,6 +15521,10 @@ re_scan: pb_read_leb_uint32(p, p_end, opcode1); +#if WASM_ENABLE_FAST_INTERP != 0 + emit_byte(loader_ctx, opcode1); +#endif + /* follow the order of enum WASMSimdEXTOpcode in wasm_opcode.h */ switch (opcode1) { @@ -15324,6 +15552,10 @@ re_scan: pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ +#if WASM_ENABLE_FAST_INTERP != 0 + emit_uint32(loader_ctx, mem_offset); +#endif + POP_AND_PUSH(mem_offset_type, VALUE_TYPE_V128); #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; @@ -15344,6 +15576,10 @@ re_scan: pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ +#if WASM_ENABLE_FAST_INTERP != 0 + emit_uint32(loader_ctx, mem_offset); +#endif + POP_V128(); POP_MEM_OFFSET(); #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 @@ -15355,7 +15591,13 @@ re_scan: /* basic operation */ case SIMD_v128_const: { + uint64 high, low; CHECK_BUF1(p, p_end, 16); +#if WASM_ENABLE_FAST_INTERP != 0 + wasm_runtime_read_v128(p, &high, &low); + emit_uint64(loader_ctx, high); + emit_uint64(loader_ctx, low); +#endif p += 16; PUSH_V128(); break; @@ -15367,12 +15609,17 @@ re_scan: CHECK_BUF1(p, p_end, 16); mask = read_i8x16(p, error_buf, error_buf_size); - p += 16; if (!check_simd_shuffle_mask(mask, error_buf, error_buf_size)) { goto fail; } - +#if WASM_ENABLE_FAST_INTERP != 0 + uint64 high, low; + wasm_runtime_read_v128(p, &high, &low); + emit_uint64(loader_ctx, high); + emit_uint64(loader_ctx, low); +#endif + p += 16; POP2_AND_PUSH(VALUE_TYPE_V128, VALUE_TYPE_V128); break; } @@ -15443,14 +15690,25 @@ re_scan: error_buf_size)) { goto fail; } - +#if WASM_ENABLE_FAST_INTERP != 0 + emit_byte(loader_ctx, lane); +#endif if (replace[opcode1 - SIMD_i8x16_extract_lane_s]) { +#if WASM_ENABLE_FAST_INTERP != 0 + if (!(wasm_loader_pop_frame_ref_offset( + loader_ctx, + replace[opcode1 + - SIMD_i8x16_extract_lane_s], + error_buf, error_buf_size))) + goto fail; +#else if (!(wasm_loader_pop_frame_ref( loader_ctx, replace[opcode1 - SIMD_i8x16_extract_lane_s], error_buf, error_buf_size))) goto fail; +#endif /* end of WASM_ENABLE_FAST_INTERP != 0 */ } POP_AND_PUSH( @@ -15569,9 +15827,14 @@ re_scan: error_buf_size)) { goto fail; } - +#if WASM_ENABLE_FAST_INTERP != 0 + emit_uint32(loader_ctx, mem_offset); +#endif POP_V128(); POP_MEM_OFFSET(); +#if WASM_ENABLE_FAST_INTERP != 0 + emit_byte(loader_ctx, lane); +#endif if (opcode1 < SIMD_v128_store8_lane) { PUSH_V128(); } @@ -15594,7 +15857,9 @@ re_scan: pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */ - +#if WASM_ENABLE_FAST_INTERP != 0 + emit_uint32(loader_ctx, mem_offset); +#endif POP_AND_PUSH(mem_offset_type, VALUE_TYPE_V128); #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; @@ -15943,7 +16208,8 @@ re_scan: } break; } -#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) */ +#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ + (WASM_ENABLE_FAST_INTERP != 0) */ #endif /* end of WASM_ENABLE_SIMD */ #if WASM_ENABLE_SHARED_MEMORY != 0 @@ -16123,8 +16389,9 @@ re_scan: if (loader_ctx->p_code_compiled == NULL) goto re_scan; - func->const_cell_num = - loader_ctx->i64_const_num * 2 + loader_ctx->i32_const_num; + func->const_cell_num = loader_ctx->i64_const_num * 2 + + loader_ctx->v128_const_num * 4 + + loader_ctx->i32_const_num; if (func->const_cell_num > 0) { if (!(func->consts = loader_malloc((uint64)sizeof(uint32) * func->const_cell_num, @@ -16143,6 +16410,12 @@ re_scan: loader_ctx->i32_consts, (uint32)sizeof(int32) * loader_ctx->i32_const_num); } + if (loader_ctx->v128_const_num > 0) { + bh_memcpy_s(func->consts, + (uint32)sizeof(V128) * loader_ctx->v128_const_num, + loader_ctx->v128_consts, + (uint32)sizeof(V128) * loader_ctx->v128_const_num); + } } func->max_stack_cell_num = loader_ctx->preserved_local_offset diff --git a/core/iwasm/interpreter/wasm_opcode.h b/core/iwasm/interpreter/wasm_opcode.h index 76647454b..9660bb123 100644 --- a/core/iwasm/interpreter/wasm_opcode.h +++ b/core/iwasm/interpreter/wasm_opcode.h @@ -278,6 +278,15 @@ typedef enum WASMOpcode { DEBUG_OP_BREAK = 0xdc, /* debug break point */ #endif +#if WASM_ENABLE_JIT != 0 \ + || WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0 + EXT_OP_SET_LOCAL_FAST_V128 = 0xdd, + EXT_OP_TEE_LOCAL_FAST_V128 = 0xde, + EXT_OP_COPY_STACK_TOP_V128 = 0xdf, + WASM_OP_GET_GLOBAL_V128 = 0xe0, + WASM_OP_SET_GLOBAL_V128 = 0xe1, +#endif + /* Post-MVP extend op prefix */ WASM_OP_GC_PREFIX = 0xfb, WASM_OP_MISC_PREFIX = 0xfc, @@ -779,16 +788,27 @@ typedef enum WASMAtomicEXTOpcode { #else #define DEF_DEBUG_BREAK_HANDLE() #endif - #define SET_GOTO_TABLE_ELEM(opcode) [opcode] = HANDLE_OPCODE(opcode) -#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SIMD != 0 +#if (WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0) \ + && WASM_ENABLE_SIMD != 0 #define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() \ SET_GOTO_TABLE_ELEM(WASM_OP_SIMD_PREFIX), #else #define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() #endif +#if (WASM_ENABLE_FAST_INTERP != 0) && WASM_ENABLE_SIMD != 0 +#define DEF_EXT_V128_HANDLE() \ + SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \ + SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \ + SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), /* 0xdf */ \ + SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), /* 0xe0 */ \ + SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128), /* 0xe1 */ + +#else +#define DEF_EXT_V128_HANDLE() +#endif /* * Macro used to generate computed goto tables for the C interpreter. */ @@ -1020,7 +1040,7 @@ typedef enum WASMAtomicEXTOpcode { SET_GOTO_TABLE_ELEM(WASM_OP_MISC_PREFIX), /* 0xfc */ \ SET_GOTO_TABLE_SIMD_PREFIX_ELEM() /* 0xfd */ \ SET_GOTO_TABLE_ELEM(WASM_OP_ATOMIC_PREFIX), /* 0xfe */ \ - DEF_DEBUG_BREAK_HANDLE() \ + DEF_DEBUG_BREAK_HANDLE() DEF_EXT_V128_HANDLE() \ }; #ifdef __cplusplus diff --git a/core/iwasm/libraries/simde/simde.cmake b/core/iwasm/libraries/simde/simde.cmake new file mode 100644 index 000000000..eeb0e8d1f --- /dev/null +++ b/core/iwasm/libraries/simde/simde.cmake @@ -0,0 +1,21 @@ +# Copyright (C) 2024 Amazon Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# simde is a header only library + +set (LIB_SIMDE_DIR ${CMAKE_CURRENT_LIST_DIR}) + +add_definitions (-DWASM_ENABLE_SIMDE=1) + +include_directories(${LIB_SIMDE_DIR} ${LIB_SIMDE_DIR}/simde) + +include(FetchContent) + +FetchContent_Declare( + simde + GIT_REPOSITORY https://github.com/simd-everywhere/simde + GIT_TAG v0.8.2 +) + +message("-- Fetching simde ..") +FetchContent_MakeAvailable(simde) +include_directories("${simde_SOURCE_DIR}") diff --git a/doc/build_wamr.md b/doc/build_wamr.md index b8cfcc989..36b15e568 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -132,7 +132,11 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM ### **Enable 128-bit SIMD feature** - **WAMR_BUILD_SIMD**=1/0, default to enable if not set -> Note: only supported in AOT mode x86-64 target. +> Note: supported in AOT mode, JIT mode, and fast-interpreter mode with SIMDe library. + +### **Enable SIMDe library for SIMD in fast interpreter** +- **WAMR_BUILD_LIB_SIMDE**=1/0, default to disable if not set +> Note: If enabled, SIMDe (SIMD Everywhere) library will be used to implement SIMD operations in fast interpreter mode. ### **Enable Exception Handling** - **WAMR_BUILD_EXCE_HANDLING**=1/0, default to disable if not set @@ -335,4 +339,11 @@ Or if we want to enable interpreter, disable AOT and WASI, and build as X86_32, ``` Bash cmake .. -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_LIBC_WASI=0 -DWAMR_BUILD_TARGET=X86_32 -``` \ No newline at end of file +``` + +When enabling SIMD for fast interpreter mode, you'll need to enable both SIMD and the SIMDe library: + +``` Bash + +cmake .. -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_SIMD=1 -DWAMR_BUILD_LIB_SIMDE=1 +``` diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 31f8b3746..183033751 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -913,8 +913,8 @@ function do_execute_in_running_mode() fi if [[ ${ENABLE_SIMD} -eq 1 ]]; then - if [[ "${RUNNING_MODE}" != "jit" && "${RUNNING_MODE}" != "aot" ]]; then - echo "support simd in llvm-jit mode and aot mode" + if [[ "${RUNNING_MODE}" != "jit" && "${RUNNING_MODE}" != "aot" && "${RUNNING_MODE}" != "fast-interp" ]]; then + echo "support simd in llvm-jit, aot and fast-interp mode" return 0; fi fi From 1f14f4ec0ab68c0919cd7207ee8b583857d87243 Mon Sep 17 00:00:00 2001 From: peter-tatrai Date: Thu, 20 Mar 2025 07:24:30 +0100 Subject: [PATCH 082/198] Fix build issues when compiling WAMRC as a cross-compiler (#4112) * Use CMAKE_INSTALL_BINDIR for wamrc installation * Fix wamrc build failure for 32bit non-x86 targets * Handle PIC flags by cmake in wamrc * Use dummy AOT reloc functions when building wamrc AOT reloc functions are used only when loading AOT WebAssembly modules on target, not during AOT compilation. Original code led to build issues when building wamrc as cross-compiler, using arm header on x86 build. * Add option to turn off SIMD support in wamrc --- core/iwasm/aot/arch/aot_reloc_dummy.c | 39 +++++++++++++++++++++++++++ core/iwasm/aot/iwasm_aot.cmake | 5 +++- wamr-compiler/CMakeLists.txt | 35 ++++++++++++------------ 3 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 core/iwasm/aot/arch/aot_reloc_dummy.c diff --git a/core/iwasm/aot/arch/aot_reloc_dummy.c b/core/iwasm/aot/arch/aot_reloc_dummy.c new file mode 100644 index 000000000..bc05d7b78 --- /dev/null +++ b/core/iwasm/aot/arch/aot_reloc_dummy.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "aot_reloc.h" + +SymbolMap * +get_target_symbol_map(uint32 *sym_num) +{ + abort(); +} + +uint32 +get_plt_table_size(void) +{ + abort(); +} + +void +init_plt_table(uint8 *plt) +{ + abort(); +} + +void +get_current_target(char *target_buf, uint32 target_buf_size) +{ + abort(); +} + +bool +apply_relocation(AOTModule *module, uint8 *target_section_addr, + uint32 target_section_size, uint64 reloc_offset, + int64 reloc_addend, uint32 reloc_type, void *symbol_addr, + int32 symbol_index, char *error_buf, uint32 error_buf_size) +{ + abort(); +} diff --git a/core/iwasm/aot/iwasm_aot.cmake b/core/iwasm/aot/iwasm_aot.cmake index c82501fad..bb9004bc6 100644 --- a/core/iwasm/aot/iwasm_aot.cmake +++ b/core/iwasm/aot/iwasm_aot.cmake @@ -21,7 +21,10 @@ if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1) list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_validator.c) endif () -if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") +if (WAMR_BUILD_WAMR_COMPILER EQUAL 1) + # AOT reloc functions are not used during AOT compilation + set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_dummy.c) +elseif (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_64.c) elseif (WAMR_BUILD_TARGET STREQUAL "X86_32") set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_32.c) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index 9975dab7b..bbe83cc64 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -31,6 +31,13 @@ endif() set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") +# Turn on SIMD by default, can be turned off by setting WAMR_BUILD_SIMD to 0 +if (WAMR_BUILD_SIMD EQUAL 0) + add_definitions(-DWASM_ENABLE_SIMD=0) +else() + add_definitions(-DWASM_ENABLE_SIMD=1) +endif() + add_definitions(-DWASM_ENABLE_INTERP=1) add_definitions(-DWASM_ENABLE_WAMR_COMPILER=1) add_definitions(-DWASM_ENABLE_BULK_MEMORY=1) @@ -38,7 +45,6 @@ add_definitions(-DWASM_DISABLE_HW_BOUND_CHECK=1) add_definitions(-DWASM_ENABLE_SHARED_MEMORY=1) add_definitions(-DWASM_ENABLE_THREAD_MGR=1) add_definitions(-DWASM_ENABLE_TAIL_CALL=1) -add_definitions(-DWASM_ENABLE_SIMD=1) add_definitions(-DWASM_ENABLE_REF_TYPES=1) add_definitions(-DWASM_ENABLE_CUSTOM_NAME_SECTION=1) add_definitions(-DWASM_ENABLE_AOT_STACK_FRAME=1) @@ -132,21 +138,11 @@ endif () message ("-- Build as target ${WAMR_BUILD_TARGET}") -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64" - OR WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR WAMR_BUILD_TARGET MATCHES "RISCV64.*") - if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows") - # Add -fPIC flag if build as 64-bit - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC") - set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -fPIC") - endif () - else () - add_definitions (-m32) - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") - set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") - endif () +# Add -m32 flag if compiling on 64-bit system for 32-bit x86 target +if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND WAMR_BUILD_TARGET STREQUAL "X86_32") + add_definitions (-m32) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") endif () if (NOT CMAKE_BUILD_TYPE) @@ -275,6 +271,8 @@ else () message ("-- Lib wasi-threads disabled") endif () +set (WAMR_BUILD_WAMR_COMPILER 1) + include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake) include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake) include (${SHARED_DIR}/utils/shared_utils.cmake) @@ -376,7 +374,7 @@ add_library (aotclib ${IWASM_COMPL_SOURCE}) add_executable (wamrc main.c) check_pie_supported() -set_target_properties (wamrc PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties (wamrc vmlib aotclib PROPERTIES POSITION_INDEPENDENT_CODE ON) set_version_info (wamrc) if (LLVM_LINK_LLVM_DYLIB) @@ -398,4 +396,5 @@ else() ${UV_A_LIBS}) endif() -install (TARGETS wamrc DESTINATION bin) +include (GNUInstallDirs) +install (TARGETS wamrc) From 06ea960e76d49fcab7342541bde2329e25287520 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 20 Mar 2025 14:25:13 +0800 Subject: [PATCH 083/198] fix(runtest.py): A workaround to bypass errors that occur when deleting temporary files (#4093) - Replace sys.exit with exceptions for better error handling in test assertions - Update exception handling in compile_wast_to_wasm to catch all exceptions - Improve error messages and logging - Use `--ignore-whitespace` option for git apply in spec_test function - Use raw string notation for regex patterns. *The "SyntaxWarning: invalid escape sequence" in Python The warning has been upgraded to SyntaxWarning since Python 3.12, and it is expected to become a SyntaxError in future versions.* - Add early return for non-loadable AOT compilation to prevent unnecessary assertions - Redirect stderr to stdout in test_case for unified output - Update `create_tmpfiles()` to improve clarity and handling of temporary files --- ci/coding_guidelines_check.py | 2 +- test-tools/addr2line/addr2line.py | 2 +- .../wamr-test-suites/spec-test-script/all.py | 6 +- .../spec-test-script/runtest.py | 306 ++++++++++-------- tests/wamr-test-suites/test_wamr.sh | 26 +- 5 files changed, 191 insertions(+), 151 deletions(-) diff --git a/ci/coding_guidelines_check.py b/ci/coding_guidelines_check.py index a0b4535f9..919a1f56c 100644 --- a/ci/coding_guidelines_check.py +++ b/ci/coding_guidelines_check.py @@ -145,7 +145,7 @@ def run_clang_format_diff(root: Path, commits: str) -> bool: found = False for summary in [x for x in diff_content if x.startswith("diff --git")]: # b/path/to/file -> path/to/file - with_invalid_format = re.split("\s+", summary)[-1][2:] + with_invalid_format = re.split(r"\s+", summary)[-1][2:] if not is_excluded(with_invalid_format): print(f"--- {with_invalid_format} failed on code style checking.") found = True diff --git a/test-tools/addr2line/addr2line.py b/test-tools/addr2line/addr2line.py index 421b0bdb2..800ba3750 100644 --- a/test-tools/addr2line/addr2line.py +++ b/test-tools/addr2line/addr2line.py @@ -206,7 +206,7 @@ def get_line_info_from_function_addr_sourcemapping( if not line: continue - m = re.match("(.*):(\d+):(\d+)", line) + m = re.match(r"(.*):(\d+):(\d+)", line) if m: function_file, function_line, function_column = m.groups() continue diff --git a/tests/wamr-test-suites/spec-test-script/all.py b/tests/wamr-test-suites/spec-test-script/all.py index fe694124a..91f9e5649 100644 --- a/tests/wamr-test-suites/spec-test-script/all.py +++ b/tests/wamr-test-suites/spec-test-script/all.py @@ -247,7 +247,7 @@ def test_case( CMD, bufsize=1, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stderr=subprocess.STDOUT, universal_newlines=True, ) as p: try: @@ -285,7 +285,9 @@ def test_case( except subprocess.TimeoutExpired: print("failed with TimeoutExpired") raise Exception(case_name) - + except Exception as e: + print(f"An unexpected error occurred: {e}") + raise e def test_suite( target, diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index 6e963bdc7..427da3996 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -7,6 +7,7 @@ import array import atexit import math import os +import pathlib import re import shutil import struct @@ -81,9 +82,8 @@ def log(data, end='\n'): print(data, end=end) sys.stdout.flush() -def create_tmp_file(suffix: str) -> str: - with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as tmp_file: - return tmp_file.name +def create_tmp_file(prefix: str, suffix: str) -> str: + return tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, delete=False).name # TODO: do we need to support '\n' too import platform @@ -181,7 +181,16 @@ class Runner(): # queue, so we keep it for non-windows platforms. [outs,_,_] = select([self.stdout], [], [], 1) if self.stdout in outs: - return True, self.stdout.read(1) + try: + stdout_byte = self.stdout.read(1) + except ValueError: + return True, None + except OSError: + return True, None + except Exception as e: + print("Exception: ", e) + return False, None + return True, stdout_byte else: return False, None @@ -212,6 +221,8 @@ class Runner(): buf = self.buf[0:end-len(prompt)] self.buf = self.buf[end:] return buf + + log("left read_to_prompt() because of timeout") return None def writeline(self, str): @@ -249,14 +260,14 @@ def assert_prompt(runner, prompts, timeout, is_need_execute_result): header = runner.read_to_prompt(prompts, timeout=timeout) if not header and is_need_execute_result: log(" ---------- will terminate cause the case needs result while there is none inside of buf. ----------") - sys.exit(1) + raise Exception("get nothing from Runner") if not header == None: if header: log("Started with:\n%s" % header) else: log("Did not one of following prompt(s): %s" % repr(prompts)) log(" Got : %s" % repr(r.buf)) - sys.exit(1) + raise Exception("Did not one of following prompt(s)") ### WebAssembly specific @@ -551,7 +562,7 @@ def parse_assertion_value(val): if not val: return None, "" - splitted = re.split('\s+', val) + splitted = re.split(r'\s+', val) splitted = [s for s in splitted if s] type = splitted[0].split(".")[0] lane_type = splitted[1] if len(splitted) > 2 else "" @@ -790,8 +801,8 @@ def test_assert(r, opts, mode, cmd, expected): return True ## 0x9:i32,-0x1:i32 -> ['0x9:i32', '-0x1:i32'] - expected_list = re.split(',', expected) - out_list = re.split(',', out) + expected_list = re.split(r',', expected) + out_list = re.split(r',', out) if len(expected_list) != len(out_list): raise Exception("Failed:\n Results count incorrect:\n expected: '%s'\n got: '%s'" % (expected, out)) for i in range(len(expected_list)): @@ -806,34 +817,34 @@ def test_assert_return(r, opts, form): n. to search a pattern like (assert_return (invoke $module_name function_name ... ) ...) """ # params, return - m = re.search('^\(assert_return\s+\(invoke\s+"((?:[^"]|\\\")*)"\s+(\(.*\))\s*\)\s*(\(.*\))\s*\)\s*$', form, re.S) + m = re.search(r'^\(assert_return\s+\(invoke\s+"((?:[^"]|\\\")*)"\s+(\(.*\))\s*\)\s*(\(.*\))\s*\)\s*$', form, re.S) # judge if assert_return cmd includes the module name - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"((?:[^"]|\\\")*)"\s+(\(.*\))\s*\)\s*(\(.*\))\s*\)\s*$', form, re.S) + n = re.search(r'^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"((?:[^"]|\\\")*)"\s+(\(.*\))\s*\)\s*(\(.*\))\s*\)\s*$', form, re.S) # print("assert_return with {}".format(form)) if not m: # no params, return - m = re.search('^\(assert_return\s+\(invoke\s+"((?:[^"]|\\\")*)"\s*\)\s+()(\(.*\))\s*\)\s*$', form, re.S) + m = re.search(r'^\(assert_return\s+\(invoke\s+"((?:[^"]|\\\")*)"\s*\)\s+()(\(.*\))\s*\)\s*$', form, re.S) if not m: # params, no return - m = re.search('^\(assert_return\s+\(invoke\s+"([^"]*)"\s+(\(.*\))()\s*\)\s*\)\s*$', form, re.S) + m = re.search(r'^\(assert_return\s+\(invoke\s+"([^"]*)"\s+(\(.*\))()\s*\)\s*\)\s*$', form, re.S) if not m: # no params, no return - m = re.search('^\(assert_return\s+\(invoke\s+"([^"]*)"\s*()()\)\s*\)\s*$', form, re.S) + m = re.search(r'^\(assert_return\s+\(invoke\s+"([^"]*)"\s*()()\)\s*\)\s*$', form, re.S) if not m: # params, return if not n: # no params, return - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"((?:[^"]|\\\")*)"\s*\)\s+()(\(.*\))\s*\)\s*$', form, re.S) + n = re.search(r'^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"((?:[^"]|\\\")*)"\s*\)\s+()(\(.*\))\s*\)\s*$', form, re.S) if not n: # params, no return - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s+(\(.*\))()\s*\)\s*\)\s*$', form, re.S) + n = re.search(r'^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s+(\(.*\))()\s*\)\s*\)\s*$', form, re.S) if not n: # no params, no return - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"*()()\)\s*\)\s*$', form, re.S) + n = re.search(r'^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"*()()\)\s*\)\s*$', form, re.S) if not m and not n: - if re.search('^\(assert_return\s+\(get.*\).*\)$', form, re.S): + if re.search(r'^\(assert_return\s+\(get.*\).*\)$', form, re.S): log("ignoring assert_return get") return else: @@ -852,7 +863,7 @@ def test_assert_return(r, opts, form): if m.group(2) == '': args = [] else: - #args = [re.split(' +', v)[1].replace('_', "") for v in re.split("\)\s*\(", m.group(2)[1:-1])] + #args = [re.split(r' +', v)[1].replace('_', "") for v in re.split(r"\)\s*\(", m.group(2)[1:-1])] # split arguments with ')spaces(', remove leading and tailing ) and ( args_type_and_value = re.split(r'\)\s+\(', m.group(2)[1:-1]) args_type_and_value = [s.replace('_', '') for s in args_type_and_value] @@ -863,7 +874,7 @@ def test_assert_return(r, opts, form): for arg in args_type_and_value: # remove leading and tailing spaces, it might confuse following assertions arg = arg.strip() - splitted = re.split('\s+', arg) + splitted = re.split(r'\s+', arg) splitted = [s for s in splitted if s] if splitted[0] in ["i32.const", "i64.const"]: @@ -881,7 +892,7 @@ def test_assert_return(r, opts, form): numbers, _ = cast_v128_to_i64x2(splitted[2:], 'v128', splitted[1]) assert(len(numbers) == 2), "has to reform arguments into i64x2" - args.append(f"{numbers[0]:#x}\{numbers[1]:#x}") + args.append(f"{numbers[0]:#x}\\{numbers[1]:#x}") elif "ref.null" == splitted[0]: args.append("null") elif "ref.extern" == splitted[0]: @@ -896,7 +907,7 @@ def test_assert_return(r, opts, form): if m.group(3) == '': returns= [] else: - returns = re.split("\)\s*\(", m.group(3)[1:-1]) + returns = re.split(r"\)\s*\(", m.group(3)[1:-1]) # processed numbers in strings if len(returns) == 1 and returns[0] in ["ref.array", "ref.struct", "ref.i31", "ref.eq", "ref.any", "ref.extern", @@ -921,8 +932,7 @@ def test_assert_return(r, opts, form): except: _, exc, _ = sys.exc_info() log("Run wamrc failed:\n got: '%s'" % r.buf) - ret_code = 1 - sys.exit(1) + raise Exception("Run wamrc failed 1") r = run_wasm_with_repl(module+".wasm", module+".aot" if test_aot else module, opts, r) # Wait for the initial prompt try: @@ -941,23 +951,23 @@ def test_assert_return(r, opts, form): # convert (ref.null extern/func) into (ref.null null) n1 = n.group(3).replace("(ref.null extern)", "(ref.null null)") n1 = n1.replace("ref.null func)", "(ref.null null)") - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", n1[1:-1])] + args = [re.split(r' +', v)[1] for v in re.split(r"\)\s*\(", n1[1:-1])] _, expected = parse_assertion_value(n.group(4)[1:-1]) test_assert(r, opts, "return", "%s %s" % (func, " ".join(args)), expected) def test_assert_trap(r, opts, form): # params - m = re.search('^\(assert_trap\s+\(invoke\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form) + m = re.search(r'^\(assert_trap\s+\(invoke\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form) # judge if assert_return cmd includes the module name - n = re.search('^\(assert_trap\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form, re.S) + n = re.search(r'^\(assert_trap\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form, re.S) if not m: # no params - m = re.search('^\(assert_trap\s+\(invoke\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form) + m = re.search(r'^\(assert_trap\s+\(invoke\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form) if not m: if not n: # no params - n = re.search('^\(assert_trap\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form, re.S) + n = re.search(r'^\(assert_trap\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form, re.S) if not m and not n: raise Exception("unparsed assert_trap: '%s'" % form) @@ -969,7 +979,7 @@ def test_assert_trap(r, opts, form): # convert (ref.null extern/func) into (ref.null null) m1 = m.group(2).replace("(ref.null extern)", "(ref.null null)") m1 = m1.replace("ref.null func)", "(ref.null null)") - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m1[1:-1])] + args = [re.split(r' +', v)[1] for v in re.split(r"\)\s*\(", m1[1:-1])] expected = "Exception: %s" % m.group(3) test_assert(r, opts, "trap", "%s %s" % (func, " ".join(args)), expected) @@ -987,8 +997,7 @@ def test_assert_trap(r, opts, form): except: _, exc, _ = sys.exc_info() log("Run wamrc failed:\n got: '%s'" % r.buf) - ret_code = 1 - sys.exit(1) + raise Exception("Run wamrc failed 2") r = run_wasm_with_repl(module+".wasm", module+".aot" if test_aot else module, opts, r) # Wait for the initial prompt try: @@ -1002,23 +1011,23 @@ def test_assert_trap(r, opts, form): if n.group(3) == '': args = [] else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", n.group(3)[1:-1])] + args = [re.split(r' +', v)[1] for v in re.split(r"\)\s*\(", n.group(3)[1:-1])] expected = "Exception: %s" % n.group(4) test_assert(r, opts, "trap", "%s %s" % (func, " ".join(args)), expected) def test_assert_exhaustion(r,opts,form): # params - m = re.search('^\(assert_exhaustion\s+\(invoke\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form) + m = re.search(r'^\(assert_exhaustion\s+\(invoke\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form) if not m: # no params - m = re.search('^\(assert_exhaustion\s+\(invoke\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form) + m = re.search(r'^\(assert_exhaustion\s+\(invoke\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form) if not m: raise Exception("unparsed assert_exhaustion: '%s'" % form) func = m.group(1) if m.group(2) == '': args = [] else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m.group(2)[1:-1])] + args = [re.split(r' +', v)[1] for v in re.split(r"\)\s*\(", m.group(2)[1:-1])] expected = "Exception: %s\n" % m.group(3) test_assert(r, opts, "exhaustion", "%s %s" % (func, " ".join(args)), expected) @@ -1035,7 +1044,7 @@ def test_assert_wasmexception(r,opts,form): # \)\s* # \)\s* # $ - m = re.search('^\(assert_exception\s+\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*\)\s*$', form) + m = re.search(r'^\(assert_exception\s+\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*\)\s*$', form) if not m: # no params @@ -1046,24 +1055,24 @@ def test_assert_wasmexception(r,opts,form): # \)\s* # \)\s* # $ - m = re.search('^\(assert_exception\s+\(invoke\s+"([^"]+)"\s*()\)\s*\)\s*$', form) + m = re.search(r'^\(assert_exception\s+\(invoke\s+"([^"]+)"\s*()\)\s*\)\s*$', form) if not m: raise Exception("unparsed assert_exception: '%s'" % form) func = m.group(1) # function name if m.group(2) == '': # arguments args = [] else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m.group(2)[1:-1])] + args = [re.split(r' +', v)[1] for v in re.split(r"\)\s*\(", m.group(2)[1:-1])] expected = "Exception: uncaught wasm exception\n" test_assert(r, opts, "wasmexception", "%s %s" % (func, " ".join(args)), expected) def do_invoke(r, opts, form): # params - m = re.search('^\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*$', form) + m = re.search(r'^\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*$', form) if not m: # no params - m = re.search('^\(invoke\s+"([^"]+)"\s*()\)\s*$', form) + m = re.search(r'^\(invoke\s+"([^"]+)"\s*()\)\s*$', form) if not m: raise Exception("unparsed invoke: '%s'" % form) func = m.group(1) @@ -1074,7 +1083,7 @@ def do_invoke(r, opts, form): if m.group(2) == '': args = [] else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m.group(2)[1:-1])] + args = [re.split(r' +', v)[1] for v in re.split(r"\)\s*\(", m.group(2)[1:-1])] log("Invoking %s(%s)" % ( func, ", ".join([str(a) for a in args]))) @@ -1114,8 +1123,8 @@ def compile_wast_to_wasm(form, wast_tempfile, wasm_tempfile, opts): log("Running: %s" % " ".join(cmd)) try: subprocess.check_call(cmd) - except subprocess.CalledProcessError as e: - print(str(e)) + except Exception as e: + print(e) return False return True @@ -1238,13 +1247,17 @@ def run_wasm_with_repl(wasm_tempfile, aot_tempfile, opts, r): return r -def create_tmpfiles(wast_name): +def create_tmpfiles(file_name, test_aot, temp_file_repo): tempfiles = [] - tempfiles.append(create_tmp_file(".wast")) - tempfiles.append(create_tmp_file(".wasm")) + tempfiles.append(create_tmp_file(file_name, ".wast")) + tempfiles.append(create_tmp_file(file_name, ".wasm")) if test_aot: - tempfiles.append(create_tmp_file(".aot")) + tempfiles.append(create_tmp_file(file_name, ".aot")) + else: + tempfiles.append(None) + + assert len(tempfiles) == 3, "tempfiles should have 3 elements" # add these temp file to temporal repo, will be deleted when finishing the test temp_file_repo.extend(tempfiles) @@ -1263,6 +1276,9 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, if test_aot: r = compile_wasm_to_aot(wasm_tempfile, aot_tempfile, True, opts, r) + if not loadable: + return + try: assert_prompt(r, ['Compile success'], opts.start_fail_timeout, True) except: @@ -1275,8 +1291,7 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, else: log("Run wamrc failed:\n expected: '%s'\n got: '%s'" % \ (expected, r.buf)) - ret_code = 1 - sys.exit(1) + raise Exception("Run wamrc failed 3") r = run_wasm_with_repl(wasm_tempfile, aot_tempfile if test_aot else None, opts, r) @@ -1296,6 +1311,20 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, raise Exception("Failed:\n expected: '%s'\n got: '%s'" % \ (expected, r.buf)) +def recently_added_wasm(temp_file_repo): + for f in reversed(temp_file_repo): + if not f: + continue + + assert os.path.exists(f), f"temp file {f} should exist" + + if os.path.getsize(f) == 0: + continue + + if f.endswith(".wasm"): + return f + + if __name__ == "__main__": opts = parser.parse_args(sys.argv[1:]) # print('Input param :',opts) @@ -1314,16 +1343,10 @@ if __name__ == "__main__": else: SKIP_TESTS = C_SKIP_TESTS - wast_tempfile = create_tmp_file(".wast") - wasm_tempfile = create_tmp_file(".wasm") - if test_aot: - aot_tempfile = create_tmp_file(".aot") - # could be potientially compiled to aot - # with the future following call test_assert_xxx, - # add them to temp_file_repo now even if no actual following file, - # it will be simple ignore during final deletion if not exist - prefix = wasm_tempfile.split(".wasm")[0] - temp_file_repo.append(prefix + ".aot") + case_file = pathlib.Path(opts.test_file.name) + assert(case_file.exists()), f"Test file {case_file} doesn't exist" + + tmpfile_stem = case_file.stem + "_" ret_code = 0 try: @@ -1335,22 +1358,26 @@ if __name__ == "__main__": for form in forms: # log("\n### Current Case is " + form + "\n") + + wast_tempfile, wasm_tempfile, aot_tempfile = create_tmpfiles( + tmpfile_stem, test_aot, temp_file_repo) + if ";;" == form[0:2]: log(form) elif skip_test(form, SKIP_TESTS): log("Skipping test: %s" % form[0:60]) - elif re.match("^\(assert_trap\s+\(module", form): + elif re.match(r"^\(assert_trap\s+\(module", form): test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - elif re.match("^\(assert_exhaustion\\b.*", form): + elif re.match(r"^\(assert_exhaustion\b.*", form): test_assert_exhaustion(r, opts, form) - elif re.match("^\(assert_exception\\b.*", form): + elif re.match(r"^\(assert_exception\b.*", form): test_assert_wasmexception(r, opts, form) - elif re.match("^\(assert_unlinkable\\b.*", form): + elif re.match(r"^\(assert_unlinkable\b.*", form): test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r, False) - elif re.match("^\(assert_malformed\\b.*", form): + elif re.match(r"^\(assert_malformed\b.*", form): # remove comments in wast form,n = re.subn(";;.*\n", "", form) - m = re.match("^\(assert_malformed\s*\(module binary\s*(\".*\").*\)\s*\"(.*)\"\s*\)$", form, re.DOTALL) + m = re.match(r"^\(assert_malformed\s*\(module binary\s*(\".*\").*\)\s*\"(.*)\"\s*\)$", form, re.DOTALL) if m: # workaround: spec test changes error message to "malformed" while iwasm still use "invalid" @@ -1359,7 +1386,7 @@ if __name__ == "__main__": with open(wasm_tempfile, 'wb') as f: s = m.group(1) while s: - res = re.match("[^\"]*\"([^\"]*)\"(.*)", s, re.DOTALL) + res = re.match(r"[^\"]*\"([^\"]*)\"(.*)", s, re.DOTALL) if IS_PY_3: context = res.group(1).replace("\\", "\\x").encode("latin1").decode("unicode-escape").encode("latin1") f.write(context) @@ -1414,51 +1441,43 @@ if __name__ == "__main__": else: log("Run wamrc failed:\n expected: '%s'\n got: '%s'" % \ (error_msg, r.buf)) - ret_code = 1 - sys.exit(1) + raise Exception("Run wamrc failed 4") r = run_wasm_with_repl(wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - elif re.match("^\(assert_malformed\s*\(module quote", form): + elif re.match(r"^\(assert_malformed\s*\(module quote", form): log("ignoring assert_malformed module quote") else: log("unrecognized assert_malformed") - elif re.match("^\(assert_return[_a-z]*_nan\\b.*", form): + elif re.match(r"^\(assert_return[_a-z]*_nan\b.*", form): log("ignoring assert_return_.*_nan") pass - elif re.match(".*\(invoke\s+\$\\b.*", form): + elif re.match(r".*\(invoke\s+\$\b.*", form): # invoke a particular named module's function if form.startswith("(assert_return"): test_assert_return(r,opts,form) elif form.startswith("(assert_trap"): test_assert_trap(r,opts,form) - elif re.match("^\(module\\b.*", form): + elif re.match(r"^\(module\b.*", form): # if the module includes the particular name startswith $ - m = re.search("^\(module\s+\$.\S+", form) + m = re.search(r"^\(module\s+\$.\S+", form) if m: # get module name - module_name = re.split('\$', m.group(0).strip())[1] + module_name = re.split(r'\$', m.group(0).strip())[1] if module_name: # create temporal files - temp_files = create_tmpfiles(module_name) + temp_files = create_tmpfiles(module_name, test_aot, temp_file_repo) if not compile_wast_to_wasm(form, temp_files[0], temp_files[1], opts): raise Exception("compile wast to wasm failed") if test_aot: r = compile_wasm_to_aot(temp_files[1], temp_files[2], True, opts, r) - # could be potientially compiled to aot - # with the future following call test_assert_xxx, - # add them to temp_file_repo now even if no actual following file, - # it will be simple ignore during final deletion if not exist - prefix = temp_files[1].split(".wasm")[0] - temp_file_repo.append(prefix + ".aot") try: assert_prompt(r, ['Compile success'], opts.start_timeout, False) except: _, exc, _ = sys.exc_info() log("Run wamrc failed:\n got: '%s'" % r.buf) - ret_code = 1 - sys.exit(1) + raise Exception("Run wamrc failed 5") temp_module_table[module_name] = temp_files[1] r = run_wasm_with_repl(temp_files[1], temp_files[2] if test_aot else None, opts, r) else: @@ -1472,8 +1491,7 @@ if __name__ == "__main__": except: _, exc, _ = sys.exc_info() log("Run wamrc failed:\n got: '%s'" % r.buf) - ret_code = 1 - sys.exit(1) + raise Exception("Run wamrc failed 6") r = run_wasm_with_repl(wasm_tempfile, aot_tempfile if test_aot else None, opts, r) @@ -1485,38 +1503,51 @@ if __name__ == "__main__": raise Exception("Failed:\n expected: '%s'\n got: '%s'" % \ (repr(exc), r.buf)) - elif re.match("^\(assert_return\\b.*", form): + elif re.match(r"^\(assert_return\b.*", form): assert(r), "iwasm repl runtime should be not null" test_assert_return(r, opts, form) - elif re.match("^\(assert_trap\\b.*", form): + elif re.match(r"^\(assert_trap\b.*", form): test_assert_trap(r, opts, form) - elif re.match("^\(invoke\\b.*", form): + elif re.match(r"^\(invoke\b.*", form): assert(r), "iwasm repl runtime should be not null" do_invoke(r, opts, form) - elif re.match("^\(assert_invalid\\b.*", form): - test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - elif re.match("^\(register\\b.*", form): + elif re.match(r"^\(assert_invalid\b.*", form): + # loading invalid module will raise an error directly, so shell prompt won't show here + test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r, False) + elif re.match(r"^\(register\b.*", form): # get module's new name from the register cmd - name_new =re.split('\"',re.search('\".*\"',form).group(0))[1] - if name_new: - new_module = os.path.join(tempfile.gettempdir(), name_new + ".wasm") - shutil.copyfile(temp_module_table.get(name_new, wasm_tempfile), new_module) - - # add new_module copied from the old into temp_file_repo[] - temp_file_repo.append(new_module) - - if test_aot: - new_module_aot = os.path.join(tempfile.gettempdir(), name_new + ".aot") - r = compile_wasm_to_aot(new_module, new_module_aot, True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, True) - except: - raise Exception("compile wasm to aot failed") - # add aot module into temp_file_repo[] - temp_file_repo.append(new_module_aot) - else: + name_new =re.split(r'\"',re.search(r'\".*\"',form).group(0))[1] + if not name_new: # there is no name defined in register cmd - raise Exception("can not find module name from the register") + raise Exception(f"Not following register cmd pattern {form}") + + # assumption + # - There exists a module in the form of (module $name). + # - The nearest module in the form of (module), without $name, is the candidate for registration. + recently_wasm = recently_added_wasm(temp_file_repo) + if not name_new in temp_module_table: + print(temp_file_repo) + print(f"Module {name_new} is not found in temp_module_table. use the nearest module {recently_wasm}") + + for_registration = temp_module_table.get(name_new, recently_wasm) + assert os.path.exists(for_registration), f"module {for_registration} is not found" + + new_module = os.path.join(tempfile.gettempdir(), name_new + ".wasm") + # for_registration(tmpfile) --copy-> name_new.wasm + shutil.copyfile(for_registration, new_module) + + # add new_module copied from the old into temp_file_repo[] + temp_file_repo.append(new_module) + + if test_aot: + new_module_aot = os.path.join(tempfile.gettempdir(), name_new + ".aot") + r = compile_wasm_to_aot(new_module, new_module_aot, True, opts, r) + try: + assert_prompt(r, ['Compile success'], opts.start_timeout, True) + except: + raise Exception("compile wasm to aot failed") + # add aot module into temp_file_repo[] + temp_file_repo.append(new_module_aot) else: raise Exception("unrecognized form '%s...'" % form[0:40]) except Exception as e: @@ -1524,35 +1555,42 @@ if __name__ == "__main__": print("THE FINAL EXCEPTION IS {}".format(e)) ret_code = 101 - shutil.copyfile(wasm_tempfile, os.path.join(opts.log_dir, os.path.basename(wasm_tempfile))) - - if opts.aot or opts.xip: - shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile))) - if "indirect-mode" in str(e): - compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "object") - shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+'.o')) - subprocess.check_call(["llvm-objdump", "-r", aot_tempfile]) - compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "ir") - shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+".ir")) + try: + shutil.copyfile(wasm_tempfile, os.path.join(opts.log_dir, os.path.basename(wasm_tempfile))) + if opts.aot or opts.xip: + shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile))) + if "indirect-mode" in str(e): + compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "object") + shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+'.o')) + subprocess.check_call(["llvm-objdump", "-r", aot_tempfile]) + compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "ir") + shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+".ir")) + except Exception as e: + print("Failed to copy files to log directory: %s" % e) + ret_code = 102 else: ret_code = 0 finally: - if not opts.no_cleanup: - log("Removing tempfiles") - os.remove(wast_tempfile) - os.remove(wasm_tempfile) - if test_aot: - os.remove(aot_tempfile) + try: + if not opts.no_cleanup: + # remove the files under /tempfiles/ and copy of .wasm files + log(f"Removing {temp_file_repo}") - # remove the files under /tempfiles/ and copy of .wasm files - if temp_file_repo: for t in temp_file_repo: - if(len(str(t))!=0 and os.path.exists(t)): + # None and empty + if not t: + continue + + if os.path.exists(t): os.remove(t) + else: + log(f"Leaving {temp_file_repo}") + + except Exception as e: + print("Failed to remove tempfiles: %s" % e) + # ignore the exception + ret_code = 0 - log("### End testing %s" % opts.test_file.name) - else: - log("Leaving tempfiles: %s" % ([wast_tempfile, wasm_tempfile])) - + log(f"### End testing {opts.test_file.name} with {ret_code}") sys.exit(ret_code) diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 183033751..7a4ca08b5 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -448,9 +448,9 @@ function spec_test() # May 31, 2012 [interpreter] implement atomic.wait and atomic.notify (#194) git reset --hard 09f2831349bf409187abb6f7868482a8079f2264 - git apply ../../spec-test-script/thread_proposal_ignore_cases.patch || exit 1 - git apply ../../spec-test-script/thread_proposal_fix_atomic_case.patch || exit 1 - git apply ../../spec-test-script/thread_proposal_remove_memory64_flag_case.patch + git apply --ignore-whitespace ../../spec-test-script/thread_proposal_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/thread_proposal_fix_atomic_case.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/thread_proposal_remove_memory64_flag_case.patch elif [ ${ENABLE_EH} == 1 ]; then echo "checkout exception-handling test cases" @@ -459,7 +459,7 @@ function spec_test() # Jun 6, 2023 Merge branch 'upstream' into merge-upstream git reset --hard 51c721661b671bb7dc4b3a3acb9e079b49778d36 - git apply ../../spec-test-script/exception_handling.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/exception_handling.patch || exit 1 elif [[ ${ENABLE_GC} == 1 ]]; then echo "checkout spec for GC proposal" @@ -469,12 +469,12 @@ function spec_test() # Dec 9, 2024. Merge branch 'funcref' git reset --hard 756060f5816c7e2159f4817fbdee76cf52f9c923 - git apply ../../spec-test-script/gc_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/gc_ignore_cases.patch || exit 1 if [[ ${ENABLE_QEMU} == 1 ]]; then # Decrease the recursive count for tail call cases as nuttx qemu's # native stack size is much smaller - git apply ../../spec-test-script/gc_nuttx_tail_call.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/gc_nuttx_tail_call.patch || exit 1 fi # As of version 1.0.36, wabt is still unable to correctly handle the GC proposal. @@ -497,7 +497,7 @@ function spec_test() git checkout 044d0d2e77bdcbe891f7e0b9dd2ac01d56435f0b -- test/core/elem.wast test/core/data.wast # Patch table64 extension git checkout 940398cd4823522a9b36bec4984be4b153dedb81 -- test/core/call_indirect.wast test/core/table.wast test/core/table_copy.wast test/core/table_copy_mixed.wast test/core/table_fill.wast test/core/table_get.wast test/core/table_grow.wast test/core/table_init.wast test/core/table_set.wast test/core/table_size.wast - git apply ../../spec-test-script/memory64_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/memory64_ignore_cases.patch || exit 1 elif [[ ${ENABLE_MULTI_MEMORY} == 1 ]]; then echo "checkout spec for multi memory proposal" @@ -508,9 +508,9 @@ function spec_test() # Reset to commit: "Merge pull request #48 from backes/specify-memcpy-immediate-order" git reset --hard fbc99efd7a788db300aec3dd62a14577ec404f1b git checkout 044d0d2e77bdcbe891f7e0b9dd2ac01d56435f0b -- test/core/elem.wast - git apply ../../spec-test-script/multi_memory_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/multi_memory_ignore_cases.patch || exit 1 if [[ ${RUNNING_MODE} == "aot" ]]; then - git apply ../../spec-test-script/multi_module_aot_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/multi_module_aot_ignore_cases.patch || exit 1 fi else echo "checkout spec for default proposal" @@ -520,15 +520,15 @@ function spec_test() # Dec 20, 2024. Use WPT version of test harness for HTML core test conversion (#1859) git reset --hard f3a0e06235d2d84bb0f3b5014da4370613886965 - git apply ../../spec-test-script/ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/ignore_cases.patch || exit 1 if [[ ${ENABLE_SIMD} == 1 ]]; then - git apply ../../spec-test-script/simd_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/simd_ignore_cases.patch || exit 1 fi if [[ ${ENABLE_MULTI_MODULE} == 1 ]]; then - git apply ../../spec-test-script/multi_module_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/multi_module_ignore_cases.patch || exit 1 if [[ ${RUNNING_MODE} == "aot" ]]; then - git apply ../../spec-test-script/multi_module_aot_ignore_cases.patch || exit 1 + git apply --ignore-whitespace ../../spec-test-script/multi_module_aot_ignore_cases.patch || exit 1 fi fi fi From 913c2227bad6cbcf06835b0648aca24ac235ff76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 20:07:13 +0800 Subject: [PATCH 084/198] build(deps): Bump esbuild, @vitejs/plugin-react and vite (#4149) Bumps [esbuild](https://github.com/evanw/esbuild) to 0.25.1 and updates ancestor dependencies [esbuild](https://github.com/evanw/esbuild), [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) and [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite). These dependencies need to be updated together. Updates `esbuild` from 0.14.54 to 0.25.1 - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2022.md) - [Commits](https://github.com/evanw/esbuild/compare/v0.14.54...v0.25.1) Updates `@vitejs/plugin-react` from 2.0.1 to 4.3.4 - [Release notes](https://github.com/vitejs/vite-plugin-react/releases) - [Changelog](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite-plugin-react/commits/v4.3.4/packages/plugin-react) Updates `vite` from 3.0.9 to 6.2.2 - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.2/packages/vite) --- updated-dependencies: - dependency-name: esbuild dependency-type: indirect - dependency-name: "@vitejs/plugin-react" dependency-type: direct:development - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../portal/package-lock.json | 3282 +++++++++-------- .../wasm-mutator-fuzz/portal/package.json | 4 +- 2 files changed, 1760 insertions(+), 1526 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/portal/package-lock.json b/tests/fuzz/wasm-mutator-fuzz/portal/package-lock.json index 3abb540a2..87dc143d0 100644 --- a/tests/fuzz/wasm-mutator-fuzz/portal/package-lock.json +++ b/tests/fuzz/wasm-mutator-fuzz/portal/package-lock.json @@ -19,19 +19,20 @@ "devDependencies": { "@types/react": "^18.0.17", "@types/react-dom": "^18.0.6", - "@vitejs/plugin-react": "^2.0.1", + "@vitejs/plugin-react": "^4.3.4", "typescript": "^4.6.4", - "vite": "^3.0.7" + "vite": "^6.2.2" } }, "node_modules/@ampproject/remapping": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", - "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "@jridgewell/gen-mapping": "^0.1.0", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" @@ -85,47 +86,52 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/compat-data": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.13.tgz", - "integrity": "sha512-5yUzC5LqyTFp2HLmDoxGQelcdYgSpP9xsnMWBphAscOdFrHSAVbLNzWiy32sVNDqJRDiJK6klfDnAgu6PAGSHw==", + "version": "7.26.8", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.8.tgz", + "integrity": "sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.13.tgz", - "integrity": "sha512-ZisbOvRRusFktksHSG6pjj1CSvkPkcZq/KHD45LAkVP/oiHJkNBZWfpvlLmX8OtHDG8IuzsFlVRWo08w7Qxn0A==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.10.tgz", + "integrity": "sha512-vMqyb7XCDMPvJFFOaT9kxtiRh42GwlZEg1/uIgtZshS5a/8OaduUfCi7kynKgc3Tw/6Uo2D+db9qBttghhmxwQ==", "dev": true, + "license": "MIT", "dependencies": { - "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.18.13", - "@babel/helper-compilation-targets": "^7.18.9", - "@babel/helper-module-transforms": "^7.18.9", - "@babel/helpers": "^7.18.9", - "@babel/parser": "^7.18.13", - "@babel/template": "^7.18.10", - "@babel/traverse": "^7.18.13", - "@babel/types": "^7.18.13", - "convert-source-map": "^1.7.0", + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.10", + "@babel/helper-compilation-targets": "^7.26.5", + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helpers": "^7.26.10", + "@babel/parser": "^7.26.10", + "@babel/template": "^7.26.9", + "@babel/traverse": "^7.26.10", + "@babel/types": "^7.26.10", + "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.2.1", - "semver": "^6.3.0" + "json5": "^2.2.3", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -136,55 +142,63 @@ } }, "node_modules/@babel/generator": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.13.tgz", - "integrity": "sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.10.tgz", + "integrity": "sha512-rRHT8siFIXQrAYOYqZQVsAr8vJ+cBNqcVAY6m5V8/4QqzaPl+zDBe6cLEPRDuNOUf3ww8RfJVlOyQMoSI+5Ang==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.18.13", - "@jridgewell/gen-mapping": "^0.3.2", - "jsesc": "^2.5.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dev": true, - "dependencies": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz", - "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.18.6" + "@babel/parser": "^7.26.10", + "@babel/types": "^7.26.10", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz", - "integrity": "sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz", + "integrity": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.18.8", - "@babel/helper-validator-option": "^7.18.6", - "browserslist": "^4.20.2", - "semver": "^6.3.0" + "@babel/compat-data": "^7.26.5", + "@babel/helper-validator-option": "^7.25.9", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -193,164 +207,69 @@ "@babel/core": "^7.0.0" } }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz", - "integrity": "sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==", - "dev": true, - "dependencies": { - "@babel/template": "^7.18.6", - "@babel/types": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", - "dev": true, - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", - "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz", - "integrity": "sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g==", - "dev": true, - "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-simple-access": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.18.6", - "@babel/template": "^7.18.6", - "@babel/traverse": "^7.18.9", - "@babel/types": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.18.9.tgz", - "integrity": "sha512-aBXPT3bmtLryXaoJLyYPXPlSD4p1ld9aYeR+sJNOZjJJGiOpb+fKfh3NkcCu7J54nUJwCERPBExCCpyCOHnu/w==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.26.5.tgz", + "integrity": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==", "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz", - "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==", - "dev": true, - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.18.6" - }, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz", - "integrity": "sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz", - "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", - "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz", - "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz", + "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/template": "^7.18.6", - "@babel/traverse": "^7.18.9", - "@babel/types": "^7.18.9" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.13.tgz", - "integrity": "sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.10.tgz", + "integrity": "sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==", "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.26.10" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -358,62 +277,14 @@ "node": ">=6.0.0" } }, - "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", - "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-jsx": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.18.10.tgz", - "integrity": "sha512-gCy7Iikrpu3IZjYZolFE4M1Sm+nrh1/6za2Ewj77Z+XirT4TsbJcvOFOyF+fRPwU6AKKK136CZxx6L8AbSFG6A==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.9", - "@babel/plugin-syntax-jsx": "^7.18.6", - "@babel/types": "^7.18.10" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-react-jsx-development": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.18.6.tgz", - "integrity": "sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA==", - "dev": true, - "dependencies": { - "@babel/plugin-transform-react-jsx": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, "node_modules/@babel/plugin-transform-react-jsx-self": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.18.6.tgz", - "integrity": "sha512-A0LQGx4+4Jv7u/tWzoJF7alZwnBDQd6cGLh9P+Ttk4dpiL+J5p7NSNv/9tlEFFJDq3kjxOavWmbm6t0Gk+A3Ig==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.25.9.tgz", + "integrity": "sha512-y8quW6p0WHkEhmErnfe58r7x0A70uKphQm8Sp8cV7tjNQwK56sNVK0M73LK3WuYmsuyrftut4xAkjjgU0twaMg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -423,12 +294,13 @@ } }, "node_modules/@babel/plugin-transform-react-jsx-source": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.18.6.tgz", - "integrity": "sha512-utZmlASneDfdaMh0m/WausbjUjEdGrQJz0vFK93d7wD3xf5wBtX219+q6IlCNZeguIcxS2f/CvLZrlLSvSHQXw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.25.9.tgz", + "integrity": "sha512-+iqjT8xmXhhYv4/uiYd8FNQsraMFZIfxVSqxxVSZP0WbbSAWvBXAul0m/zu+7Vv4O/3WtApy9pmaTMiumEZgfg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -449,34 +321,33 @@ } }, "node_modules/@babel/template": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", - "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz", + "integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.18.10", - "@babel/types": "^7.18.10" + "@babel/code-frame": "^7.26.2", + "@babel/parser": "^7.26.9", + "@babel/types": "^7.26.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.13.tgz", - "integrity": "sha512-N6kt9X1jRMLPxxxPYWi7tgvJRH/rtoU+dbKAPDM44RFHiMH8igdsaSBgFeskhSl/kLWLDUvIh1RXCrTmg0/zvA==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.10.tgz", + "integrity": "sha512-k8NuDrxr0WrPH5Aupqb2LCVURP/S0vBEn5mK6iH+GIYob66U5EtoZvcdudR2jQ4cmTwhEwW1DLB+Yyas9zjF6A==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.18.13", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.18.9", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.18.13", - "@babel/types": "^7.18.13", - "debug": "^4.1.0", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.10", + "@babel/parser": "^7.26.10", + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10", + "debug": "^4.3.1", "globals": "^11.1.0" }, "engines": { @@ -484,14 +355,14 @@ } }, "node_modules/@babel/types": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.13.tgz", - "integrity": "sha512-ePqfTihzW0W6XAU+aMw2ykilisStJfDnsejDCXRchCcMJ4O0+8DhPXf2YUbZ6wjBlsEmZwLK/sPweWtu8hcJYQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.10.tgz", + "integrity": "sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.18.10", - "@babel/helper-validator-identifier": "^7.18.6", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -505,69 +376,802 @@ "node": ">=10" } }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz", - "integrity": "sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==", + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.1.tgz", + "integrity": "sha512-kfYGy8IdzTGy+z0vFGvExZtxkFlA4zAxgKEahG9KE1ScBjpQnFsNOX8KTU5ojNru5ed5CVoJYXFtoxaq5nFbjQ==", "cpu": [ - "loong64" + "ppc64" ], "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.1.tgz", + "integrity": "sha512-dp+MshLYux6j/JjdqVLnMglQlFu+MuVeNrmT5nk6q07wNhCdSnB7QZj+7G8VMUGh1q+vj2Bq8kRsuyA00I/k+Q==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.1.tgz", + "integrity": "sha512-50tM0zCJW5kGqgG7fQ7IHvQOcAn9TKiVRuQ/lN0xR+T2lzEFvAi1ZcS8DiksFcEpf1t/GYOeOfCAgDHFpkiSmA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.1.tgz", + "integrity": "sha512-GCj6WfUtNldqUzYkN/ITtlhwQqGWu9S45vUXs7EIYf+7rCiiqH9bCloatO9VhxsL0Pji+PF4Lz2XXCES+Q8hDw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.1.tgz", + "integrity": "sha512-5hEZKPf+nQjYoSr/elb62U19/l1mZDdqidGfmFutVUjjUZrOazAtwK+Kr+3y0C/oeJfLlxo9fXb1w7L+P7E4FQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.1.tgz", + "integrity": "sha512-hxVnwL2Dqs3fM1IWq8Iezh0cX7ZGdVhbTfnOy5uURtao5OIVCEyj9xIzemDi7sRvKsuSdtCAhMKarxqtlyVyfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.1.tgz", + "integrity": "sha512-1MrCZs0fZa2g8E+FUo2ipw6jw5qqQiH+tERoS5fAfKnRx6NXH31tXBKI3VpmLijLH6yriMZsxJtaXUyFt/8Y4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.1.tgz", + "integrity": "sha512-0IZWLiTyz7nm0xuIs0q1Y3QWJC52R8aSXxe40VUxm6BB1RNmkODtW6LHvWRrGiICulcX7ZvyH6h5fqdLu4gkww==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.1.tgz", + "integrity": "sha512-NdKOhS4u7JhDKw9G3cY6sWqFcnLITn6SqivVArbzIaf3cemShqfLGHYMx8Xlm/lBit3/5d7kXvriTUGa5YViuQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.1.tgz", + "integrity": "sha512-jaN3dHi0/DDPelk0nLcXRm1q7DNJpjXy7yWaWvbfkPvI+7XNSc/lDOnCLN7gzsyzgu6qSAmgSvP9oXAhP973uQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.1.tgz", + "integrity": "sha512-OJykPaF4v8JidKNGz8c/q1lBO44sQNUQtq1KktJXdBLn1hPod5rE/Hko5ugKKZd+D2+o1a9MFGUEIUwO2YfgkQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.1.tgz", + "integrity": "sha512-nGfornQj4dzcq5Vp835oM/o21UMlXzn79KobKlcs3Wz9smwiifknLy4xDCLUU0BWp7b/houtdrgUz7nOGnfIYg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.1.tgz", + "integrity": "sha512-1osBbPEFYwIE5IVB/0g2X6i1qInZa1aIoj1TdL4AaAb55xIIgbg8Doq6a5BzYWgr+tEcDzYH67XVnTmUzL+nXg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.1.tgz", + "integrity": "sha512-/6VBJOwUf3TdTvJZ82qF3tbLuWsscd7/1w+D9LH0W/SqUgM5/JJD0lrJ1fVIfZsqB6RFmLCe0Xz3fmZc3WtyVg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.1.tgz", + "integrity": "sha512-nSut/Mx5gnilhcq2yIMLMe3Wl4FK5wx/o0QuuCLMtmJn+WeWYoEGDN1ipcN72g1WHsnIbxGXd4i/MF0gTcuAjQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.1.tgz", + "integrity": "sha512-cEECeLlJNfT8kZHqLarDBQso9a27o2Zd2AQ8USAEoGtejOrCYHNtKP8XQhMDJMtthdF4GBmjR2au3x1udADQQQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.1.tgz", + "integrity": "sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.1.tgz", + "integrity": "sha512-O96poM2XGhLtpTh+s4+nP7YCCAfb4tJNRVZHfIE7dgmax+yMP2WgMd2OecBuaATHKTHsLWHQeuaxMRnCsH8+5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.1.tgz", + "integrity": "sha512-X53z6uXip6KFXBQ+Krbx25XHV/NCbzryM6ehOAeAil7X7oa4XIq+394PWGnwaSQ2WRA0KI6PUO6hTO5zeF5ijA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.1.tgz", + "integrity": "sha512-Na9T3szbXezdzM/Kfs3GcRQNjHzM6GzFBeU1/6IV/npKP5ORtp9zbQjvkDJ47s6BCgaAZnnnu/cY1x342+MvZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.1.tgz", + "integrity": "sha512-T3H78X2h1tszfRSf+txbt5aOp/e7TAz3ptVKu9Oyir3IAOFPGV6O9c2naym5TOriy1l0nNf6a4X5UXRZSGX/dw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.1.tgz", + "integrity": "sha512-2H3RUvcmULO7dIE5EWJH8eubZAI4xw54H1ilJnRNZdeo8dTADEZ21w6J22XBkXqGJbe0+wnNJtw3UXRoLJnFEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.1.tgz", + "integrity": "sha512-GE7XvrdOzrb+yVKB9KsRMq+7a2U/K5Cf/8grVFRAGJmfADr/e/ODQ134RK2/eeHqYV5eQRFxb1hY7Nr15fv1NQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.1.tgz", + "integrity": "sha512-uOxSJCIcavSiT6UnBhBzE8wy3n0hOkJsBOzy7HDAuTDE++1DJMRRVCPGisULScHL+a/ZwdXPpXD3IyFKjA7K8A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.1.tgz", + "integrity": "sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", - "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, + "license": "MIT", "dependencies": { - "@jridgewell/set-array": "^1.0.0", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.15", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz", - "integrity": "sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==", + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, + "license": "MIT", "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.36.0.tgz", + "integrity": "sha512-jgrXjjcEwN6XpZXL0HUeOVGfjXhPyxAbbhD0BlXUB+abTOpbPiN5Wb3kOT7yb+uEtATNYF5x5gIfwutmuBA26w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.36.0.tgz", + "integrity": "sha512-NyfuLvdPdNUfUNeYKUwPwKsE5SXa2J6bCt2LdB/N+AxShnkpiczi3tcLJrm5mA+eqpy0HmaIY9F6XCa32N5yzg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.36.0.tgz", + "integrity": "sha512-JQ1Jk5G4bGrD4pWJQzWsD8I1n1mgPXq33+/vP4sk8j/z/C2siRuxZtaUA7yMTf71TCZTZl/4e1bfzwUmFb3+rw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.36.0.tgz", + "integrity": "sha512-6c6wMZa1lrtiRsbDziCmjE53YbTkxMYhhnWnSW8R/yqsM7a6mSJ3uAVT0t8Y/DGt7gxUWYuFM4bwWk9XCJrFKA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.36.0.tgz", + "integrity": "sha512-KXVsijKeJXOl8QzXTsA+sHVDsFOmMCdBRgFmBb+mfEb/7geR7+C8ypAml4fquUt14ZyVXaw2o1FWhqAfOvA4sg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.36.0.tgz", + "integrity": "sha512-dVeWq1ebbvByI+ndz4IJcD4a09RJgRYmLccwlQ8bPd4olz3Y213uf1iwvc7ZaxNn2ab7bjc08PrtBgMu6nb4pQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.36.0.tgz", + "integrity": "sha512-bvXVU42mOVcF4le6XSjscdXjqx8okv4n5vmwgzcmtvFdifQ5U4dXFYaCB87namDRKlUL9ybVtLQ9ztnawaSzvg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.36.0.tgz", + "integrity": "sha512-JFIQrDJYrxOnyDQGYkqnNBtjDwTgbasdbUiQvcU8JmGDfValfH1lNpng+4FWlhaVIR4KPkeddYjsVVbmJYvDcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.36.0.tgz", + "integrity": "sha512-KqjYVh3oM1bj//5X7k79PSCZ6CvaVzb7Qs7VMWS+SlWB5M8p3FqufLP9VNp4CazJ0CsPDLwVD9r3vX7Ci4J56A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.36.0.tgz", + "integrity": "sha512-QiGnhScND+mAAtfHqeT+cB1S9yFnNQ/EwCg5yE3MzoaZZnIV0RV9O5alJAoJKX/sBONVKeZdMfO8QSaWEygMhw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.36.0.tgz", + "integrity": "sha512-1ZPyEDWF8phd4FQtTzMh8FQwqzvIjLsl6/84gzUxnMNFBtExBtpL51H67mV9xipuxl1AEAerRBgBwFNpkw8+Lg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.36.0.tgz", + "integrity": "sha512-VMPMEIUpPFKpPI9GZMhJrtu8rxnp6mJR3ZzQPykq4xc2GmdHj3Q4cA+7avMyegXy4n1v+Qynr9fR88BmyO74tg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.36.0.tgz", + "integrity": "sha512-ttE6ayb/kHwNRJGYLpuAvB7SMtOeQnVXEIpMtAvx3kepFQeowVED0n1K9nAdraHUPJ5hydEMxBpIR7o4nrm8uA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.36.0.tgz", + "integrity": "sha512-4a5gf2jpS0AIe7uBjxDeUMNcFmaRTbNv7NxI5xOCs4lhzsVyGR/0qBXduPnoWf6dGC365saTiwag8hP1imTgag==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.36.0.tgz", + "integrity": "sha512-5KtoW8UWmwFKQ96aQL3LlRXX16IMwyzMq/jSSVIIyAANiE1doaQsx/KRyhAvpHlPjPiSU/AYX/8m+lQ9VToxFQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.36.0.tgz", + "integrity": "sha512-sycrYZPrv2ag4OCvaN5js+f01eoZ2U+RmT5as8vhxiFz+kxwlHrsxOwKPSA8WyS+Wc6Epid9QeI/IkQ9NkgYyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.36.0.tgz", + "integrity": "sha512-qbqt4N7tokFwwSVlWDsjfoHgviS3n/vZ8LK0h1uLG9TYIRuUTJC88E1xb3LM2iqZ/WTqNQjYrtmtGmrmmawB6A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.36.0.tgz", + "integrity": "sha512-t+RY0JuRamIocMuQcfwYSOkmdX9dtkr1PbhKW42AMvaDQa+jOdpUYysroTF/nuPpAaQMWp7ye+ndlmmthieJrQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.36.0.tgz", + "integrity": "sha512-aRXd7tRZkWLqGbChgcMMDEHjOKudo1kChb1Jt1IfR8cY/KIpgNviLeJy5FUb9IpSuQj8dU2fAYNMPW/hLKOSTw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.6.tgz", + "integrity": "sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", @@ -601,36 +1205,23 @@ "dev": true }, "node_modules/@vitejs/plugin-react": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-2.0.1.tgz", - "integrity": "sha512-uINzNHmjrbunlFtyVkST6lY1ewSfz/XwLufG0PIqvLGnpk2nOIOa/1CACTDNcKi1/RwaCzJLmsXwm1NsUVV/NA==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.4.tgz", + "integrity": "sha512-SCCPBJtYLdE8PX/7ZQAs1QAZ8Jqwih+0VBLum1EGqmCCQal+MIUqLCzj3ZUy8ufbC0cAM4LRlSTm7IQJwWT4ug==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/core": "^7.18.10", - "@babel/plugin-transform-react-jsx": "^7.18.10", - "@babel/plugin-transform-react-jsx-development": "^7.18.6", - "@babel/plugin-transform-react-jsx-self": "^7.18.6", - "@babel/plugin-transform-react-jsx-source": "^7.18.6", - "magic-string": "^0.26.2", - "react-refresh": "^0.14.0" + "@babel/core": "^7.26.0", + "@babel/plugin-transform-react-jsx-self": "^7.25.9", + "@babel/plugin-transform-react-jsx-source": "^7.25.9", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.14.2" }, "engines": { "node": "^14.18.0 || >=16.0.0" }, "peerDependencies": { - "vite": "^3.0.0" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0" } }, "node_modules/antd": { @@ -703,9 +1294,9 @@ "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" }, "node_modules/browserslist": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz", - "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==", + "version": "4.24.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz", + "integrity": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==", "dev": true, "funding": [ { @@ -715,13 +1306,18 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001370", - "electron-to-chromium": "^1.4.202", - "node-releases": "^2.0.6", - "update-browserslist-db": "^1.0.5" + "caniuse-lite": "^1.0.30001688", + "electron-to-chromium": "^1.5.73", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -731,9 +1327,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001384", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001384.tgz", - "integrity": "sha512-BBWt57kqWbc0GYZXb47wTXpmAgqr5LSibPzNjk/AWMdmJMQhLqOl3c/Kd4OAU/tu4NLfYkMx8Tlq3RVBkOBolQ==", + "version": "1.0.30001706", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001706.tgz", + "integrity": "sha512-3ZczoTApMAZwPKYWmwVbQMFpXBDds3/0VciVoUwPUbldlYyVLmRVuRs/PcUZtHpbLRpzzDvrvnFuREsGt6lUug==", "dev": true, "funding": [ { @@ -743,56 +1339,30 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } - ] - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } + ], + "license": "CC-BY-4.0" }, "node_modules/classnames": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, "node_modules/compute-scroll-into-view": { "version": "1.0.17", "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.17.tgz", "integrity": "sha512-j4dx+Fb0URmzbwwMUrhqWM2BEWHdFGx+qZ9qqASHRPqvTYdqvWnHg0H1hIbcyLnvgnoNAVMlwkepyqM3DaIFUg==" }, "node_modules/convert-source-map": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", - "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true, - "dependencies": { - "safe-buffer": "~5.1.1" - } + "license": "MIT" }, "node_modules/copy-to-clipboard": { "version": "3.3.2", @@ -826,12 +1396,13 @@ "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==" }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dev": true, + "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -848,391 +1419,70 @@ "integrity": "sha512-Gj9hZN3a07cbR6zviMUBOMPdWxYhbMI+x+WS0NAIu2zFZmbK8ys9R79g+iG9qLnlCwpFoaB+fKy8Pdv470GsPA==" }, "node_modules/electron-to-chromium": { - "version": "1.4.233", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.233.tgz", - "integrity": "sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==", - "dev": true + "version": "1.5.121", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.121.tgz", + "integrity": "sha512-gpIEzIb3uvm6V8IK452TvzOvZ3EAF8D5i11SMUG7BjpF2aalh5KyKX5dO+GDW5m9Qdia1ejLm6WM5NOIOd7sbQ==", + "dev": true, + "license": "ISC" }, "node_modules/esbuild": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz", - "integrity": "sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==", + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", + "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", "dev": true, "hasInstallScript": true, + "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, "engines": { - "node": ">=12" + "node": ">=18" }, "optionalDependencies": { - "@esbuild/linux-loong64": "0.14.54", - "esbuild-android-64": "0.14.54", - "esbuild-android-arm64": "0.14.54", - "esbuild-darwin-64": "0.14.54", - "esbuild-darwin-arm64": "0.14.54", - "esbuild-freebsd-64": "0.14.54", - "esbuild-freebsd-arm64": "0.14.54", - "esbuild-linux-32": "0.14.54", - "esbuild-linux-64": "0.14.54", - "esbuild-linux-arm": "0.14.54", - "esbuild-linux-arm64": "0.14.54", - "esbuild-linux-mips64le": "0.14.54", - "esbuild-linux-ppc64le": "0.14.54", - "esbuild-linux-riscv64": "0.14.54", - "esbuild-linux-s390x": "0.14.54", - "esbuild-netbsd-64": "0.14.54", - "esbuild-openbsd-64": "0.14.54", - "esbuild-sunos-64": "0.14.54", - "esbuild-windows-32": "0.14.54", - "esbuild-windows-64": "0.14.54", - "esbuild-windows-arm64": "0.14.54" - } - }, - "node_modules/esbuild-android-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.54.tgz", - "integrity": "sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-android-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.54.tgz", - "integrity": "sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-darwin-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz", - "integrity": "sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-darwin-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.54.tgz", - "integrity": "sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-freebsd-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.54.tgz", - "integrity": "sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-freebsd-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.54.tgz", - "integrity": "sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-32": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.54.tgz", - "integrity": "sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz", - "integrity": "sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-arm": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.54.tgz", - "integrity": "sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.54.tgz", - "integrity": "sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-mips64le": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.54.tgz", - "integrity": "sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-ppc64le": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.54.tgz", - "integrity": "sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-riscv64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.54.tgz", - "integrity": "sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-linux-s390x": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.54.tgz", - "integrity": "sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-netbsd-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.54.tgz", - "integrity": "sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-openbsd-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.54.tgz", - "integrity": "sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-sunos-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz", - "integrity": "sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-windows-32": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.54.tgz", - "integrity": "sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-windows-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.54.tgz", - "integrity": "sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-windows-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz", - "integrity": "sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" + "@esbuild/aix-ppc64": "0.25.1", + "@esbuild/android-arm": "0.25.1", + "@esbuild/android-arm64": "0.25.1", + "@esbuild/android-x64": "0.25.1", + "@esbuild/darwin-arm64": "0.25.1", + "@esbuild/darwin-x64": "0.25.1", + "@esbuild/freebsd-arm64": "0.25.1", + "@esbuild/freebsd-x64": "0.25.1", + "@esbuild/linux-arm": "0.25.1", + "@esbuild/linux-arm64": "0.25.1", + "@esbuild/linux-ia32": "0.25.1", + "@esbuild/linux-loong64": "0.25.1", + "@esbuild/linux-mips64el": "0.25.1", + "@esbuild/linux-ppc64": "0.25.1", + "@esbuild/linux-riscv64": "0.25.1", + "@esbuild/linux-s390x": "0.25.1", + "@esbuild/linux-x64": "0.25.1", + "@esbuild/netbsd-arm64": "0.25.1", + "@esbuild/netbsd-x64": "0.25.1", + "@esbuild/openbsd-arm64": "0.25.1", + "@esbuild/openbsd-x64": "0.25.1", + "@esbuild/sunos-x64": "0.25.1", + "@esbuild/win32-arm64": "0.25.1", + "@esbuild/win32-ia32": "0.25.1", + "@esbuild/win32-x64": "0.25.1" } }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -1241,17 +1491,12 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -1261,27 +1506,7 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, + "license": "MIT", "engines": { "node": ">=4" } @@ -1299,33 +1524,22 @@ "@babel/runtime": "^7.7.6" } }, - "node_modules/is-core-module": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", - "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", - "dev": true, - "dependencies": { - "has": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true, + "license": "MIT", "bin": { "jsesc": "bin/jsesc" }, "engines": { - "node": ">=4" + "node": ">=6" } }, "node_modules/json2mq": { @@ -1337,10 +1551,11 @@ } }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, + "license": "MIT", "bin": { "json5": "lib/cli.js" }, @@ -1364,16 +1579,14 @@ "loose-envify": "cli.js" } }, - "node_modules/magic-string": { - "version": "0.26.2", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz", - "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==", + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "dev": true, + "license": "ISC", "dependencies": { - "sourcemap-codec": "^1.4.8" - }, - "engines": { - "node": ">=12" + "yallist": "^3.0.2" } }, "node_modules/memoize-one": { @@ -1390,16 +1603,24 @@ } }, "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" }, "node_modules/nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -1408,10 +1629,11 @@ } }, "node_modules/node-releases": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", - "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", - "dev": true + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", + "dev": true, + "license": "MIT" }, "node_modules/object-assign": { "version": "4.1.1", @@ -1421,22 +1643,17 @@ "node": ">=0.10.0" } }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" }, "node_modules/postcss": { - "version": "8.4.16", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", - "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", + "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", "dev": true, "funding": [ { @@ -1446,12 +1663,17 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "nanoid": "^3.3.4", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12 || >=14" @@ -2098,10 +2320,11 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/react-refresh": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", - "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==", + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", + "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -2140,44 +2363,45 @@ "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==" }, - "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", - "dev": true, - "dependencies": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/rollup": { - "version": "2.77.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.77.3.tgz", - "integrity": "sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==", + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.36.0.tgz", + "integrity": "sha512-zwATAXNQxUcd40zgtQG0ZafcRK4g004WtEl7kbuhTWPvf07PsfohXl39jVUvPF7jvNAIkKPQ2XrsDlWuxBd++Q==", "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.6" + }, "bin": { "rollup": "dist/bin/rollup" }, "engines": { - "node": ">=10.0.0" + "node": ">=18.0.0", + "npm": ">=8.0.0" }, "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.36.0", + "@rollup/rollup-android-arm64": "4.36.0", + "@rollup/rollup-darwin-arm64": "4.36.0", + "@rollup/rollup-darwin-x64": "4.36.0", + "@rollup/rollup-freebsd-arm64": "4.36.0", + "@rollup/rollup-freebsd-x64": "4.36.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.36.0", + "@rollup/rollup-linux-arm-musleabihf": "4.36.0", + "@rollup/rollup-linux-arm64-gnu": "4.36.0", + "@rollup/rollup-linux-arm64-musl": "4.36.0", + "@rollup/rollup-linux-loongarch64-gnu": "4.36.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.36.0", + "@rollup/rollup-linux-riscv64-gnu": "4.36.0", + "@rollup/rollup-linux-s390x-gnu": "4.36.0", + "@rollup/rollup-linux-x64-gnu": "4.36.0", + "@rollup/rollup-linux-x64-musl": "4.36.0", + "@rollup/rollup-win32-arm64-msvc": "4.36.0", + "@rollup/rollup-win32-ia32-msvc": "4.36.0", + "@rollup/rollup-win32-x64-msvc": "4.36.0", "fsevents": "~2.3.2" } }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, "node_modules/scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -2203,10 +2427,11 @@ } }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" } @@ -2217,58 +2442,20 @@ "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" }, "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } }, - "node_modules/sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, "node_modules/string-convert": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz", "integrity": "sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==" }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", @@ -2288,9 +2475,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", - "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", + "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", "dev": true, "funding": [ { @@ -2300,70 +2487,113 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.2.0", + "picocolors": "^1.1.1" }, "bin": { - "browserslist-lint": "cli.js" + "update-browserslist-db": "cli.js" }, "peerDependencies": { "browserslist": ">= 4.21.0" } }, "node_modules/vite": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.9.tgz", - "integrity": "sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.2.tgz", + "integrity": "sha512-yW7PeMM+LkDzc7CgJuRLMW2Jz0FxMOsVJ8Lv3gpgW9WLcb9cTW+121UEr1hvmfR7w3SegR5ItvYyzVz1vxNJgQ==", "dev": true, + "license": "MIT", "dependencies": { - "esbuild": "^0.14.47", - "postcss": "^8.4.16", - "resolve": "^1.22.1", - "rollup": ">=2.75.6 <2.77.0 || ~2.77.0" + "esbuild": "^0.25.0", + "postcss": "^8.5.3", + "rollup": "^4.30.1" }, "bin": { "vite": "bin/vite.js" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" }, "optionalDependencies": { - "fsevents": "~2.3.2" + "fsevents": "~2.3.3" }, "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", "less": "*", + "lightningcss": "^1.21.0", "sass": "*", + "sass-embedded": "*", "stylus": "*", - "terser": "^5.4.0" + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" }, "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, "less": { "optional": true }, + "lightningcss": { + "optional": true + }, "sass": { "optional": true }, + "sass-embedded": { + "optional": true + }, "stylus": { "optional": true }, + "sugarss": { + "optional": true + }, "terser": { "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true } } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" } }, "dependencies": { "@ampproject/remapping": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", - "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", "dev": true, "requires": { - "@jridgewell/gen-mapping": "^0.1.0", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" } }, "@ant-design/colors": { @@ -2404,255 +2634,151 @@ } }, "@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, "requires": { - "@babel/highlight": "^7.18.6" + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" } }, "@babel/compat-data": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.13.tgz", - "integrity": "sha512-5yUzC5LqyTFp2HLmDoxGQelcdYgSpP9xsnMWBphAscOdFrHSAVbLNzWiy32sVNDqJRDiJK6klfDnAgu6PAGSHw==", + "version": "7.26.8", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.8.tgz", + "integrity": "sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ==", "dev": true }, "@babel/core": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.13.tgz", - "integrity": "sha512-ZisbOvRRusFktksHSG6pjj1CSvkPkcZq/KHD45LAkVP/oiHJkNBZWfpvlLmX8OtHDG8IuzsFlVRWo08w7Qxn0A==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.10.tgz", + "integrity": "sha512-vMqyb7XCDMPvJFFOaT9kxtiRh42GwlZEg1/uIgtZshS5a/8OaduUfCi7kynKgc3Tw/6Uo2D+db9qBttghhmxwQ==", "dev": true, "requires": { - "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.18.13", - "@babel/helper-compilation-targets": "^7.18.9", - "@babel/helper-module-transforms": "^7.18.9", - "@babel/helpers": "^7.18.9", - "@babel/parser": "^7.18.13", - "@babel/template": "^7.18.10", - "@babel/traverse": "^7.18.13", - "@babel/types": "^7.18.13", - "convert-source-map": "^1.7.0", + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.10", + "@babel/helper-compilation-targets": "^7.26.5", + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helpers": "^7.26.10", + "@babel/parser": "^7.26.10", + "@babel/template": "^7.26.9", + "@babel/traverse": "^7.26.10", + "@babel/types": "^7.26.10", + "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.2.1", - "semver": "^6.3.0" + "json5": "^2.2.3", + "semver": "^6.3.1" } }, "@babel/generator": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.13.tgz", - "integrity": "sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.10.tgz", + "integrity": "sha512-rRHT8siFIXQrAYOYqZQVsAr8vJ+cBNqcVAY6m5V8/4QqzaPl+zDBe6cLEPRDuNOUf3ww8RfJVlOyQMoSI+5Ang==", "dev": true, "requires": { - "@babel/types": "^7.18.13", - "@jridgewell/gen-mapping": "^0.3.2", - "jsesc": "^2.5.1" - }, - "dependencies": { - "@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dev": true, - "requires": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - } - } - } - }, - "@babel/helper-annotate-as-pure": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz", - "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==", - "dev": true, - "requires": { - "@babel/types": "^7.18.6" + "@babel/parser": "^7.26.10", + "@babel/types": "^7.26.10", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" } }, "@babel/helper-compilation-targets": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz", - "integrity": "sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz", + "integrity": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==", "dev": true, "requires": { - "@babel/compat-data": "^7.18.8", - "@babel/helper-validator-option": "^7.18.6", - "browserslist": "^4.20.2", - "semver": "^6.3.0" - } - }, - "@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", - "dev": true - }, - "@babel/helper-function-name": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz", - "integrity": "sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==", - "dev": true, - "requires": { - "@babel/template": "^7.18.6", - "@babel/types": "^7.18.9" - } - }, - "@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", - "dev": true, - "requires": { - "@babel/types": "^7.18.6" + "@babel/compat-data": "^7.26.5", + "@babel/helper-validator-option": "^7.25.9", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" } }, "@babel/helper-module-imports": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", - "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" } }, "@babel/helper-module-transforms": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz", - "integrity": "sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", "dev": true, "requires": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-simple-access": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.18.6", - "@babel/template": "^7.18.6", - "@babel/traverse": "^7.18.9", - "@babel/types": "^7.18.9" + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" } }, "@babel/helper-plugin-utils": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.18.9.tgz", - "integrity": "sha512-aBXPT3bmtLryXaoJLyYPXPlSD4p1ld9aYeR+sJNOZjJJGiOpb+fKfh3NkcCu7J54nUJwCERPBExCCpyCOHnu/w==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.26.5.tgz", + "integrity": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==", "dev": true }, - "@babel/helper-simple-access": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz", - "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==", - "dev": true, - "requires": { - "@babel/types": "^7.18.6" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", - "dev": true, - "requires": { - "@babel/types": "^7.18.6" - } - }, "@babel/helper-string-parser": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz", - "integrity": "sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz", - "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true }, "@babel/helper-validator-option": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", - "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true }, "@babel/helpers": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz", - "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz", + "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==", "dev": true, "requires": { - "@babel/template": "^7.18.6", - "@babel/traverse": "^7.18.9", - "@babel/types": "^7.18.9" - } - }, - "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10" } }, "@babel/parser": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.13.tgz", - "integrity": "sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==", - "dev": true - }, - "@babel/plugin-syntax-jsx": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", - "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.10.tgz", + "integrity": "sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.18.6" - } - }, - "@babel/plugin-transform-react-jsx": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.18.10.tgz", - "integrity": "sha512-gCy7Iikrpu3IZjYZolFE4M1Sm+nrh1/6za2Ewj77Z+XirT4TsbJcvOFOyF+fRPwU6AKKK136CZxx6L8AbSFG6A==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.9", - "@babel/plugin-syntax-jsx": "^7.18.6", - "@babel/types": "^7.18.10" - } - }, - "@babel/plugin-transform-react-jsx-development": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.18.6.tgz", - "integrity": "sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA==", - "dev": true, - "requires": { - "@babel/plugin-transform-react-jsx": "^7.18.6" + "@babel/types": "^7.26.10" } }, "@babel/plugin-transform-react-jsx-self": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.18.6.tgz", - "integrity": "sha512-A0LQGx4+4Jv7u/tWzoJF7alZwnBDQd6cGLh9P+Ttk4dpiL+J5p7NSNv/9tlEFFJDq3kjxOavWmbm6t0Gk+A3Ig==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.25.9.tgz", + "integrity": "sha512-y8quW6p0WHkEhmErnfe58r7x0A70uKphQm8Sp8cV7tjNQwK56sNVK0M73LK3WuYmsuyrftut4xAkjjgU0twaMg==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.25.9" } }, "@babel/plugin-transform-react-jsx-source": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.18.6.tgz", - "integrity": "sha512-utZmlASneDfdaMh0m/WausbjUjEdGrQJz0vFK93d7wD3xf5wBtX219+q6IlCNZeguIcxS2f/CvLZrlLSvSHQXw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.25.9.tgz", + "integrity": "sha512-+iqjT8xmXhhYv4/uiYd8FNQsraMFZIfxVSqxxVSZP0WbbSAWvBXAul0m/zu+7Vv4O/3WtApy9pmaTMiumEZgfg==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.25.9" } }, "@babel/runtime": { @@ -2664,43 +2790,39 @@ } }, "@babel/template": { - "version": "7.18.10", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", - "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz", + "integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==", "dev": true, "requires": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.18.10", - "@babel/types": "^7.18.10" + "@babel/code-frame": "^7.26.2", + "@babel/parser": "^7.26.9", + "@babel/types": "^7.26.9" } }, "@babel/traverse": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.13.tgz", - "integrity": "sha512-N6kt9X1jRMLPxxxPYWi7tgvJRH/rtoU+dbKAPDM44RFHiMH8igdsaSBgFeskhSl/kLWLDUvIh1RXCrTmg0/zvA==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.10.tgz", + "integrity": "sha512-k8NuDrxr0WrPH5Aupqb2LCVURP/S0vBEn5mK6iH+GIYob66U5EtoZvcdudR2jQ4cmTwhEwW1DLB+Yyas9zjF6A==", "dev": true, "requires": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.18.13", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.18.9", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.18.13", - "@babel/types": "^7.18.13", - "debug": "^4.1.0", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.10", + "@babel/parser": "^7.26.10", + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10", + "debug": "^4.3.1", "globals": "^11.1.0" } }, "@babel/types": { - "version": "7.18.13", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.13.tgz", - "integrity": "sha512-ePqfTihzW0W6XAU+aMw2ykilisStJfDnsejDCXRchCcMJ4O0+8DhPXf2YUbZ6wjBlsEmZwLK/sPweWtu8hcJYQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.10.tgz", + "integrity": "sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.18.10", - "@babel/helper-validator-identifier": "^7.18.6", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" } }, "@ctrl/tinycolor": { @@ -2708,51 +2830,400 @@ "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.4.1.tgz", "integrity": "sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw==" }, + "@esbuild/aix-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.1.tgz", + "integrity": "sha512-kfYGy8IdzTGy+z0vFGvExZtxkFlA4zAxgKEahG9KE1ScBjpQnFsNOX8KTU5ojNru5ed5CVoJYXFtoxaq5nFbjQ==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.1.tgz", + "integrity": "sha512-dp+MshLYux6j/JjdqVLnMglQlFu+MuVeNrmT5nk6q07wNhCdSnB7QZj+7G8VMUGh1q+vj2Bq8kRsuyA00I/k+Q==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.1.tgz", + "integrity": "sha512-50tM0zCJW5kGqgG7fQ7IHvQOcAn9TKiVRuQ/lN0xR+T2lzEFvAi1ZcS8DiksFcEpf1t/GYOeOfCAgDHFpkiSmA==", + "dev": true, + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.1.tgz", + "integrity": "sha512-GCj6WfUtNldqUzYkN/ITtlhwQqGWu9S45vUXs7EIYf+7rCiiqH9bCloatO9VhxsL0Pji+PF4Lz2XXCES+Q8hDw==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.1.tgz", + "integrity": "sha512-5hEZKPf+nQjYoSr/elb62U19/l1mZDdqidGfmFutVUjjUZrOazAtwK+Kr+3y0C/oeJfLlxo9fXb1w7L+P7E4FQ==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.1.tgz", + "integrity": "sha512-hxVnwL2Dqs3fM1IWq8Iezh0cX7ZGdVhbTfnOy5uURtao5OIVCEyj9xIzemDi7sRvKsuSdtCAhMKarxqtlyVyfA==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.1.tgz", + "integrity": "sha512-1MrCZs0fZa2g8E+FUo2ipw6jw5qqQiH+tERoS5fAfKnRx6NXH31tXBKI3VpmLijLH6yriMZsxJtaXUyFt/8Y4A==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.1.tgz", + "integrity": "sha512-0IZWLiTyz7nm0xuIs0q1Y3QWJC52R8aSXxe40VUxm6BB1RNmkODtW6LHvWRrGiICulcX7ZvyH6h5fqdLu4gkww==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.1.tgz", + "integrity": "sha512-NdKOhS4u7JhDKw9G3cY6sWqFcnLITn6SqivVArbzIaf3cemShqfLGHYMx8Xlm/lBit3/5d7kXvriTUGa5YViuQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.1.tgz", + "integrity": "sha512-jaN3dHi0/DDPelk0nLcXRm1q7DNJpjXy7yWaWvbfkPvI+7XNSc/lDOnCLN7gzsyzgu6qSAmgSvP9oXAhP973uQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.1.tgz", + "integrity": "sha512-OJykPaF4v8JidKNGz8c/q1lBO44sQNUQtq1KktJXdBLn1hPod5rE/Hko5ugKKZd+D2+o1a9MFGUEIUwO2YfgkQ==", + "dev": true, + "optional": true + }, "@esbuild/linux-loong64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz", - "integrity": "sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==", + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.1.tgz", + "integrity": "sha512-nGfornQj4dzcq5Vp835oM/o21UMlXzn79KobKlcs3Wz9smwiifknLy4xDCLUU0BWp7b/houtdrgUz7nOGnfIYg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.1.tgz", + "integrity": "sha512-1osBbPEFYwIE5IVB/0g2X6i1qInZa1aIoj1TdL4AaAb55xIIgbg8Doq6a5BzYWgr+tEcDzYH67XVnTmUzL+nXg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.1.tgz", + "integrity": "sha512-/6VBJOwUf3TdTvJZ82qF3tbLuWsscd7/1w+D9LH0W/SqUgM5/JJD0lrJ1fVIfZsqB6RFmLCe0Xz3fmZc3WtyVg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.1.tgz", + "integrity": "sha512-nSut/Mx5gnilhcq2yIMLMe3Wl4FK5wx/o0QuuCLMtmJn+WeWYoEGDN1ipcN72g1WHsnIbxGXd4i/MF0gTcuAjQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.1.tgz", + "integrity": "sha512-cEECeLlJNfT8kZHqLarDBQso9a27o2Zd2AQ8USAEoGtejOrCYHNtKP8XQhMDJMtthdF4GBmjR2au3x1udADQQQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.1.tgz", + "integrity": "sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==", + "dev": true, + "optional": true + }, + "@esbuild/netbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.1.tgz", + "integrity": "sha512-O96poM2XGhLtpTh+s4+nP7YCCAfb4tJNRVZHfIE7dgmax+yMP2WgMd2OecBuaATHKTHsLWHQeuaxMRnCsH8+5g==", + "dev": true, + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.1.tgz", + "integrity": "sha512-X53z6uXip6KFXBQ+Krbx25XHV/NCbzryM6ehOAeAil7X7oa4XIq+394PWGnwaSQ2WRA0KI6PUO6hTO5zeF5ijA==", + "dev": true, + "optional": true + }, + "@esbuild/openbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.1.tgz", + "integrity": "sha512-Na9T3szbXezdzM/Kfs3GcRQNjHzM6GzFBeU1/6IV/npKP5ORtp9zbQjvkDJ47s6BCgaAZnnnu/cY1x342+MvZg==", + "dev": true, + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.1.tgz", + "integrity": "sha512-T3H78X2h1tszfRSf+txbt5aOp/e7TAz3ptVKu9Oyir3IAOFPGV6O9c2naym5TOriy1l0nNf6a4X5UXRZSGX/dw==", + "dev": true, + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.1.tgz", + "integrity": "sha512-2H3RUvcmULO7dIE5EWJH8eubZAI4xw54H1ilJnRNZdeo8dTADEZ21w6J22XBkXqGJbe0+wnNJtw3UXRoLJnFEg==", + "dev": true, + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.1.tgz", + "integrity": "sha512-GE7XvrdOzrb+yVKB9KsRMq+7a2U/K5Cf/8grVFRAGJmfADr/e/ODQ134RK2/eeHqYV5eQRFxb1hY7Nr15fv1NQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.1.tgz", + "integrity": "sha512-uOxSJCIcavSiT6UnBhBzE8wy3n0hOkJsBOzy7HDAuTDE++1DJMRRVCPGisULScHL+a/ZwdXPpXD3IyFKjA7K8A==", + "dev": true, + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.1.tgz", + "integrity": "sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg==", "dev": true, "optional": true }, "@jridgewell/gen-mapping": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", - "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, "requires": { - "@jridgewell/set-array": "^1.0.0", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" } }, "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true }, "@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "dev": true }, "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.15", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz", - "integrity": "sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==", + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "@rollup/rollup-android-arm-eabi": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.36.0.tgz", + "integrity": "sha512-jgrXjjcEwN6XpZXL0HUeOVGfjXhPyxAbbhD0BlXUB+abTOpbPiN5Wb3kOT7yb+uEtATNYF5x5gIfwutmuBA26w==", + "dev": true, + "optional": true + }, + "@rollup/rollup-android-arm64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.36.0.tgz", + "integrity": "sha512-NyfuLvdPdNUfUNeYKUwPwKsE5SXa2J6bCt2LdB/N+AxShnkpiczi3tcLJrm5mA+eqpy0HmaIY9F6XCa32N5yzg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-darwin-arm64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.36.0.tgz", + "integrity": "sha512-JQ1Jk5G4bGrD4pWJQzWsD8I1n1mgPXq33+/vP4sk8j/z/C2siRuxZtaUA7yMTf71TCZTZl/4e1bfzwUmFb3+rw==", + "dev": true, + "optional": true + }, + "@rollup/rollup-darwin-x64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.36.0.tgz", + "integrity": "sha512-6c6wMZa1lrtiRsbDziCmjE53YbTkxMYhhnWnSW8R/yqsM7a6mSJ3uAVT0t8Y/DGt7gxUWYuFM4bwWk9XCJrFKA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-freebsd-arm64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.36.0.tgz", + "integrity": "sha512-KXVsijKeJXOl8QzXTsA+sHVDsFOmMCdBRgFmBb+mfEb/7geR7+C8ypAml4fquUt14ZyVXaw2o1FWhqAfOvA4sg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-freebsd-x64": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.36.0.tgz", + "integrity": "sha512-dVeWq1ebbvByI+ndz4IJcD4a09RJgRYmLccwlQ8bPd4olz3Y213uf1iwvc7ZaxNn2ab7bjc08PrtBgMu6nb4pQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.36.0.tgz", + "integrity": "sha512-bvXVU42mOVcF4le6XSjscdXjqx8okv4n5vmwgzcmtvFdifQ5U4dXFYaCB87namDRKlUL9ybVtLQ9ztnawaSzvg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm-musleabihf": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.36.0.tgz", + "integrity": "sha512-JFIQrDJYrxOnyDQGYkqnNBtjDwTgbasdbUiQvcU8JmGDfValfH1lNpng+4FWlhaVIR4KPkeddYjsVVbmJYvDcg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.36.0.tgz", + "integrity": "sha512-KqjYVh3oM1bj//5X7k79PSCZ6CvaVzb7Qs7VMWS+SlWB5M8p3FqufLP9VNp4CazJ0CsPDLwVD9r3vX7Ci4J56A==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm64-musl": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.36.0.tgz", + "integrity": "sha512-QiGnhScND+mAAtfHqeT+cB1S9yFnNQ/EwCg5yE3MzoaZZnIV0RV9O5alJAoJKX/sBONVKeZdMfO8QSaWEygMhw==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.36.0.tgz", + "integrity": "sha512-1ZPyEDWF8phd4FQtTzMh8FQwqzvIjLsl6/84gzUxnMNFBtExBtpL51H67mV9xipuxl1AEAerRBgBwFNpkw8+Lg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.36.0.tgz", + "integrity": "sha512-VMPMEIUpPFKpPI9GZMhJrtu8rxnp6mJR3ZzQPykq4xc2GmdHj3Q4cA+7avMyegXy4n1v+Qynr9fR88BmyO74tg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-riscv64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.36.0.tgz", + "integrity": "sha512-ttE6ayb/kHwNRJGYLpuAvB7SMtOeQnVXEIpMtAvx3kepFQeowVED0n1K9nAdraHUPJ5hydEMxBpIR7o4nrm8uA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-s390x-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.36.0.tgz", + "integrity": "sha512-4a5gf2jpS0AIe7uBjxDeUMNcFmaRTbNv7NxI5xOCs4lhzsVyGR/0qBXduPnoWf6dGC365saTiwag8hP1imTgag==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-x64-gnu": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.36.0.tgz", + "integrity": "sha512-5KtoW8UWmwFKQ96aQL3LlRXX16IMwyzMq/jSSVIIyAANiE1doaQsx/KRyhAvpHlPjPiSU/AYX/8m+lQ9VToxFQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-x64-musl": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.36.0.tgz", + "integrity": "sha512-sycrYZPrv2ag4OCvaN5js+f01eoZ2U+RmT5as8vhxiFz+kxwlHrsxOwKPSA8WyS+Wc6Epid9QeI/IkQ9NkgYyQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-win32-arm64-msvc": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.36.0.tgz", + "integrity": "sha512-qbqt4N7tokFwwSVlWDsjfoHgviS3n/vZ8LK0h1uLG9TYIRuUTJC88E1xb3LM2iqZ/WTqNQjYrtmtGmrmmawB6A==", + "dev": true, + "optional": true + }, + "@rollup/rollup-win32-ia32-msvc": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.36.0.tgz", + "integrity": "sha512-t+RY0JuRamIocMuQcfwYSOkmdX9dtkr1PbhKW42AMvaDQa+jOdpUYysroTF/nuPpAaQMWp7ye+ndlmmthieJrQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-win32-x64-msvc": { + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.36.0.tgz", + "integrity": "sha512-aRXd7tRZkWLqGbChgcMMDEHjOKudo1kChb1Jt1IfR8cY/KIpgNviLeJy5FUb9IpSuQj8dU2fAYNMPW/hLKOSTw==", + "dev": true, + "optional": true + }, + "@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "requires": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@types/babel__traverse": { + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.6.tgz", + "integrity": "sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==", + "dev": true, + "requires": { + "@babel/types": "^7.20.7" + } + }, + "@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true + }, "@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", @@ -2786,27 +3257,16 @@ "dev": true }, "@vitejs/plugin-react": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-2.0.1.tgz", - "integrity": "sha512-uINzNHmjrbunlFtyVkST6lY1ewSfz/XwLufG0PIqvLGnpk2nOIOa/1CACTDNcKi1/RwaCzJLmsXwm1NsUVV/NA==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.4.tgz", + "integrity": "sha512-SCCPBJtYLdE8PX/7ZQAs1QAZ8Jqwih+0VBLum1EGqmCCQal+MIUqLCzj3ZUy8ufbC0cAM4LRlSTm7IQJwWT4ug==", "dev": true, "requires": { - "@babel/core": "^7.18.10", - "@babel/plugin-transform-react-jsx": "^7.18.10", - "@babel/plugin-transform-react-jsx-development": "^7.18.6", - "@babel/plugin-transform-react-jsx-self": "^7.18.6", - "@babel/plugin-transform-react-jsx-source": "^7.18.6", - "magic-string": "^0.26.2", - "react-refresh": "^0.14.0" - } - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" + "@babel/core": "^7.26.0", + "@babel/plugin-transform-react-jsx-self": "^7.25.9", + "@babel/plugin-transform-react-jsx-source": "^7.25.9", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.14.2" } }, "antd": { @@ -2871,67 +3331,38 @@ "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" }, "browserslist": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz", - "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==", + "version": "4.24.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz", + "integrity": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001370", - "electron-to-chromium": "^1.4.202", - "node-releases": "^2.0.6", - "update-browserslist-db": "^1.0.5" + "caniuse-lite": "^1.0.30001688", + "electron-to-chromium": "^1.5.73", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.1" } }, "caniuse-lite": { - "version": "1.0.30001384", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001384.tgz", - "integrity": "sha512-BBWt57kqWbc0GYZXb47wTXpmAgqr5LSibPzNjk/AWMdmJMQhLqOl3c/Kd4OAU/tu4NLfYkMx8Tlq3RVBkOBolQ==", + "version": "1.0.30001706", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001706.tgz", + "integrity": "sha512-3ZczoTApMAZwPKYWmwVbQMFpXBDds3/0VciVoUwPUbldlYyVLmRVuRs/PcUZtHpbLRpzzDvrvnFuREsGt6lUug==", "dev": true }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, "classnames": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, "compute-scroll-into-view": { "version": "1.0.17", "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-1.0.17.tgz", "integrity": "sha512-j4dx+Fb0URmzbwwMUrhqWM2BEWHdFGx+qZ9qqASHRPqvTYdqvWnHg0H1hIbcyLnvgnoNAVMlwkepyqM3DaIFUg==" }, "convert-source-map": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", - "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true }, "copy-to-clipboard": { "version": "3.3.2", @@ -2958,12 +3389,12 @@ "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==" }, "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dev": true, "requires": { - "ms": "2.1.2" + "ms": "^2.1.3" } }, "dom-align": { @@ -2972,205 +3403,57 @@ "integrity": "sha512-Gj9hZN3a07cbR6zviMUBOMPdWxYhbMI+x+WS0NAIu2zFZmbK8ys9R79g+iG9qLnlCwpFoaB+fKy8Pdv470GsPA==" }, "electron-to-chromium": { - "version": "1.4.233", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.233.tgz", - "integrity": "sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==", + "version": "1.5.121", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.121.tgz", + "integrity": "sha512-gpIEzIb3uvm6V8IK452TvzOvZ3EAF8D5i11SMUG7BjpF2aalh5KyKX5dO+GDW5m9Qdia1ejLm6WM5NOIOd7sbQ==", "dev": true }, "esbuild": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz", - "integrity": "sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==", + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", + "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", "dev": true, "requires": { - "@esbuild/linux-loong64": "0.14.54", - "esbuild-android-64": "0.14.54", - "esbuild-android-arm64": "0.14.54", - "esbuild-darwin-64": "0.14.54", - "esbuild-darwin-arm64": "0.14.54", - "esbuild-freebsd-64": "0.14.54", - "esbuild-freebsd-arm64": "0.14.54", - "esbuild-linux-32": "0.14.54", - "esbuild-linux-64": "0.14.54", - "esbuild-linux-arm": "0.14.54", - "esbuild-linux-arm64": "0.14.54", - "esbuild-linux-mips64le": "0.14.54", - "esbuild-linux-ppc64le": "0.14.54", - "esbuild-linux-riscv64": "0.14.54", - "esbuild-linux-s390x": "0.14.54", - "esbuild-netbsd-64": "0.14.54", - "esbuild-openbsd-64": "0.14.54", - "esbuild-sunos-64": "0.14.54", - "esbuild-windows-32": "0.14.54", - "esbuild-windows-64": "0.14.54", - "esbuild-windows-arm64": "0.14.54" + "@esbuild/aix-ppc64": "0.25.1", + "@esbuild/android-arm": "0.25.1", + "@esbuild/android-arm64": "0.25.1", + "@esbuild/android-x64": "0.25.1", + "@esbuild/darwin-arm64": "0.25.1", + "@esbuild/darwin-x64": "0.25.1", + "@esbuild/freebsd-arm64": "0.25.1", + "@esbuild/freebsd-x64": "0.25.1", + "@esbuild/linux-arm": "0.25.1", + "@esbuild/linux-arm64": "0.25.1", + "@esbuild/linux-ia32": "0.25.1", + "@esbuild/linux-loong64": "0.25.1", + "@esbuild/linux-mips64el": "0.25.1", + "@esbuild/linux-ppc64": "0.25.1", + "@esbuild/linux-riscv64": "0.25.1", + "@esbuild/linux-s390x": "0.25.1", + "@esbuild/linux-x64": "0.25.1", + "@esbuild/netbsd-arm64": "0.25.1", + "@esbuild/netbsd-x64": "0.25.1", + "@esbuild/openbsd-arm64": "0.25.1", + "@esbuild/openbsd-x64": "0.25.1", + "@esbuild/sunos-x64": "0.25.1", + "@esbuild/win32-arm64": "0.25.1", + "@esbuild/win32-ia32": "0.25.1", + "@esbuild/win32-x64": "0.25.1" } }, - "esbuild-android-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.54.tgz", - "integrity": "sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==", - "dev": true, - "optional": true - }, - "esbuild-android-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.54.tgz", - "integrity": "sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==", - "dev": true, - "optional": true - }, - "esbuild-darwin-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz", - "integrity": "sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==", - "dev": true, - "optional": true - }, - "esbuild-darwin-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.54.tgz", - "integrity": "sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==", - "dev": true, - "optional": true - }, - "esbuild-freebsd-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.54.tgz", - "integrity": "sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==", - "dev": true, - "optional": true - }, - "esbuild-freebsd-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.54.tgz", - "integrity": "sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==", - "dev": true, - "optional": true - }, - "esbuild-linux-32": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.54.tgz", - "integrity": "sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==", - "dev": true, - "optional": true - }, - "esbuild-linux-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz", - "integrity": "sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==", - "dev": true, - "optional": true - }, - "esbuild-linux-arm": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.54.tgz", - "integrity": "sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==", - "dev": true, - "optional": true - }, - "esbuild-linux-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.54.tgz", - "integrity": "sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==", - "dev": true, - "optional": true - }, - "esbuild-linux-mips64le": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.54.tgz", - "integrity": "sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==", - "dev": true, - "optional": true - }, - "esbuild-linux-ppc64le": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.54.tgz", - "integrity": "sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==", - "dev": true, - "optional": true - }, - "esbuild-linux-riscv64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.54.tgz", - "integrity": "sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==", - "dev": true, - "optional": true - }, - "esbuild-linux-s390x": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.54.tgz", - "integrity": "sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==", - "dev": true, - "optional": true - }, - "esbuild-netbsd-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.54.tgz", - "integrity": "sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==", - "dev": true, - "optional": true - }, - "esbuild-openbsd-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.54.tgz", - "integrity": "sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==", - "dev": true, - "optional": true - }, - "esbuild-sunos-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz", - "integrity": "sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==", - "dev": true, - "optional": true - }, - "esbuild-windows-32": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.54.tgz", - "integrity": "sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==", - "dev": true, - "optional": true - }, - "esbuild-windows-64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.54.tgz", - "integrity": "sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==", - "dev": true, - "optional": true - }, - "esbuild-windows-arm64": { - "version": "0.14.54", - "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz", - "integrity": "sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==", - "dev": true, - "optional": true - }, "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true }, "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "optional": true }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -3183,21 +3466,6 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true - }, "highlight-words-core": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/highlight-words-core/-/highlight-words-core-1.2.2.tgz", @@ -3211,24 +3479,15 @@ "@babel/runtime": "^7.7.6" } }, - "is-core-module": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", - "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true }, "json2mq": { @@ -3240,9 +3499,9 @@ } }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "lodash": { @@ -3258,13 +3517,13 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, - "magic-string": { - "version": "0.26.2", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz", - "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==", + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "dev": true, "requires": { - "sourcemap-codec": "^1.4.8" + "yallist": "^3.0.2" } }, "memoize-one": { @@ -3278,21 +3537,21 @@ "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" }, "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, "nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", "dev": true }, "node-releases": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", - "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", "dev": true }, "object-assign": { @@ -3300,27 +3559,21 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, "picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true }, "postcss": { - "version": "8.4.16", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", - "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", + "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", "dev": true, "requires": { - "nanoid": "^3.3.4", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" } }, "prop-types": { @@ -3777,9 +4030,9 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "react-refresh": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", - "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==", + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", + "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", "dev": true }, "react-router": { @@ -3809,32 +4062,35 @@ "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==" }, - "resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", - "dev": true, - "requires": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, "rollup": { - "version": "2.77.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.77.3.tgz", - "integrity": "sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==", + "version": "4.36.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.36.0.tgz", + "integrity": "sha512-zwATAXNQxUcd40zgtQG0ZafcRK4g004WtEl7kbuhTWPvf07PsfohXl39jVUvPF7jvNAIkKPQ2XrsDlWuxBd++Q==", "dev": true, "requires": { + "@rollup/rollup-android-arm-eabi": "4.36.0", + "@rollup/rollup-android-arm64": "4.36.0", + "@rollup/rollup-darwin-arm64": "4.36.0", + "@rollup/rollup-darwin-x64": "4.36.0", + "@rollup/rollup-freebsd-arm64": "4.36.0", + "@rollup/rollup-freebsd-x64": "4.36.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.36.0", + "@rollup/rollup-linux-arm-musleabihf": "4.36.0", + "@rollup/rollup-linux-arm64-gnu": "4.36.0", + "@rollup/rollup-linux-arm64-musl": "4.36.0", + "@rollup/rollup-linux-loongarch64-gnu": "4.36.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.36.0", + "@rollup/rollup-linux-riscv64-gnu": "4.36.0", + "@rollup/rollup-linux-s390x-gnu": "4.36.0", + "@rollup/rollup-linux-x64-gnu": "4.36.0", + "@rollup/rollup-linux-x64-musl": "4.36.0", + "@rollup/rollup-win32-arm64-msvc": "4.36.0", + "@rollup/rollup-win32-ia32-msvc": "4.36.0", + "@rollup/rollup-win32-x64-msvc": "4.36.0", + "@types/estree": "1.0.6", "fsevents": "~2.3.2" } }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, "scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -3857,9 +4113,9 @@ } }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true }, "shallowequal": { @@ -3868,15 +4124,9 @@ "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" }, "source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true - }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true }, "string-convert": { @@ -3884,27 +4134,6 @@ "resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz", "integrity": "sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==" }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true - }, "toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", @@ -3917,27 +4146,32 @@ "dev": true }, "update-browserslist-db": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", - "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", + "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", "dev": true, "requires": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.2.0", + "picocolors": "^1.1.1" } }, "vite": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.9.tgz", - "integrity": "sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.2.tgz", + "integrity": "sha512-yW7PeMM+LkDzc7CgJuRLMW2Jz0FxMOsVJ8Lv3gpgW9WLcb9cTW+121UEr1hvmfR7w3SegR5ItvYyzVz1vxNJgQ==", "dev": true, "requires": { - "esbuild": "^0.14.47", - "fsevents": "~2.3.2", - "postcss": "^8.4.16", - "resolve": "^1.22.1", - "rollup": ">=2.75.6 <2.77.0 || ~2.77.0" + "esbuild": "^0.25.0", + "fsevents": "~2.3.3", + "postcss": "^8.5.3", + "rollup": "^4.30.1" } + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true } } } diff --git a/tests/fuzz/wasm-mutator-fuzz/portal/package.json b/tests/fuzz/wasm-mutator-fuzz/portal/package.json index 01622ddf5..5019af623 100644 --- a/tests/fuzz/wasm-mutator-fuzz/portal/package.json +++ b/tests/fuzz/wasm-mutator-fuzz/portal/package.json @@ -20,8 +20,8 @@ "devDependencies": { "@types/react": "^18.0.17", "@types/react-dom": "^18.0.6", - "@vitejs/plugin-react": "^2.0.1", + "@vitejs/plugin-react": "^4.3.4", "typescript": "^4.6.4", - "vite": "^3.0.7" + "vite": "^6.2.2" } } From 3e20194ecd744e19982cd48e7f318ee9a352d064 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 24 Mar 2025 07:09:22 +0800 Subject: [PATCH 085/198] =?UTF-8?q?Update=20NuttX=20and=20NuttX=20Apps=20r?= =?UTF-8?q?eferences=20to=20releases/12.9=20in=20workflow=20f=E2=80=A6=20(?= =?UTF-8?q?#4148)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update NuttX and NuttX Apps references to releases/12.9 in workflow files * Remove Kconfig modification step for NuttX in spec test workflow --- .github/workflows/compilation_on_nuttx.yml | 4 ++-- .github/workflows/spec_test_on_nuttx.yml | 26 ++-------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/compilation_on_nuttx.yml b/.github/workflows/compilation_on_nuttx.yml index ef0799b42..5922f5e3a 100644 --- a/.github/workflows/compilation_on_nuttx.yml +++ b/.github/workflows/compilation_on_nuttx.yml @@ -88,14 +88,14 @@ jobs: uses: actions/checkout@v4 with: repository: apache/nuttx - ref: releases/12.6 + ref: releases/12.9 path: nuttx - name: Checkout NuttX Apps uses: actions/checkout@v4 with: repository: apache/nuttx-apps - ref: releases/12.6 + ref: releases/12.9 path: apps - name: Checkout WAMR diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index eabe01788..1c2dceadf 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -146,14 +146,14 @@ jobs: uses: actions/checkout@v4 with: repository: apache/nuttx - ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.6' }} + ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.9' }} path: nuttx - name: Checkout NuttX Apps uses: actions/checkout@v4 with: repository: apache/nuttx-apps - ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.6' }} + ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.9' }} path: apps - name: Checkout WAMR @@ -183,28 +183,6 @@ jobs: if: contains(matrix.wamr_test_option.mode, 'aot') run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm - # Inject the config option to NuttX - # TODO: Merge this into NuttX once GC is generally available - # - # Note: the version of nuttx-apps we use for xtensa does have - # an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is - # different though.) - - name: Modify Kconfig - if: matrix.target_config.target != 'xtensa' - run: | - echo "\n" >> apps/interpreters/wamr/Kconfig - echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig - echo "\tbool \"Enable GC\"" >> apps/interpreters/wamr/Kconfig - echo "\tdefault n" >> apps/interpreters/wamr/Kconfig - echo "\n" >> apps/interpreters/wamr/Kconfig - echo "config INTERPRETERS_WAMR_AOT_STACK_FRAME" >> apps/interpreters/wamr/Kconfig - echo "\tbool \"Enable AOT stack frame\"" >> apps/interpreters/wamr/Kconfig - echo "\tdefault n" >> apps/interpreters/wamr/Kconfig - echo "\n" >> apps/interpreters/wamr/Kconfig - echo "config INTERPRETERS_WAMR_TAIL_CALL" >> apps/interpreters/wamr/Kconfig - echo "\tbool \"Enable Tail Call\"" >> apps/interpreters/wamr/Kconfig - echo "\tdefault y" >> apps/interpreters/wamr/Kconfig - - name: Build wamrc if: contains(matrix.wamr_test_option.mode, 'aot') working-directory: apps/interpreters/wamr/wamr/wamr-compiler From 5d8fe5dcfd65031242f2af5d412643fed0f46e12 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 24 Mar 2025 07:09:57 +0800 Subject: [PATCH 086/198] platform/nuttx: Flush icache/dcache properly (#4147) Enhance the os_dcache_flush and os_icache_flush functions to ensure proper cache invalidation, improving memory management efficiency. * Added cache invalidation for data cache * Implemented cache invalidation for instruction cache Signed-off-by: Huang Qi --- core/shared/platform/nuttx/nuttx_platform.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/shared/platform/nuttx/nuttx_platform.c b/core/shared/platform/nuttx/nuttx_platform.c index dcefb7e84..171adb344 100644 --- a/core/shared/platform/nuttx/nuttx_platform.c +++ b/core/shared/platform/nuttx/nuttx_platform.c @@ -10,6 +10,8 @@ #include #endif +#include + int bh_platform_init() { @@ -115,11 +117,14 @@ os_dcache_flush() && defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) up_textheap_data_sync(); #endif + up_invalidate_dcache_all(); } void os_icache_flush(void *start, size_t len) -{} +{ + up_invalidate_icache((uintptr_t)start, (uintptr_t)start + len); +} #if (WASM_MEM_DUAL_BUS_MIRROR != 0) void * From c257692f55012d69c762e906050231bb6134d079 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:06:24 +0800 Subject: [PATCH 087/198] build(deps): Bump github/codeql-action from 3.28.11 to 3.28.12 (#4160) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.11 to 3.28.12. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.11...v3.28.12) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index dae8190f1..55a72f170 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.11 + uses: github/codeql-action/init@v3.28.12 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.11 + uses: github/codeql-action/analyze@v3.28.12 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.11 + uses: github/codeql-action/upload-sarif@v3.28.12 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 2a378c879..89a98f615 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@b2e6519679e446e7bb7c3466d70f13a6b5461fcd + uses: github/codeql-action/upload-sarif@e0ea141027937784e3c10ed1679e503fcc2245bc with: sarif_file: results.sarif From 8acaaa2892758eb309759a4ae760f2b9e25b9785 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:06:32 +0800 Subject: [PATCH 088/198] build(deps): Bump actions/upload-artifact from 4.6.1 to 4.6.2 (#4159) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.1...v4.6.2) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 2 +- .github/workflows/spec_test_on_nuttx.yml | 2 +- .github/workflows/supply_chain.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 55a72f170..c0dd58986 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -106,7 +106,7 @@ jobs: - name: Upload CodeQL results as an artifact if: success() || failure() - uses: actions/upload-artifact@v4.6.1 + uses: actions/upload-artifact@v4.6.2 with: name: codeql-results path: ${{ steps.step1.outputs.sarif-output }} diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index 1c2dceadf..6c36c45ca 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -329,7 +329,7 @@ jobs: - name: upload the log if: always() - uses: actions/upload-artifact@v4.6.1 + uses: actions/upload-artifact@v4.6.2 with: name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }} path: log diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 89a98f615..e2de61604 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -52,7 +52,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v3.1.0 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v3.1.0 with: name: SARIF file path: results.sarif From 4a177416702da053761fbb33282b9acef910c974 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 25 Mar 2025 10:38:34 +0800 Subject: [PATCH 089/198] test: temporarily skip 'skip-stack-guard-page' test case until issue is resolved --- tests/wamr-test-suites/spec-test-script/all.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/wamr-test-suites/spec-test-script/all.py b/tests/wamr-test-suites/spec-test-script/all.py index 91f9e5649..2c4725e89 100644 --- a/tests/wamr-test-suites/spec-test-script/all.py +++ b/tests/wamr-test-suites/spec-test-script/all.py @@ -134,6 +134,8 @@ def ignore_the_case( "float_misc", "select", "memory_grow", + # Skip the test case for now, restore it after fixing the issue + "skip-stack-guard-page", ]: return True From 1931f2e5d5de9cf0b9b093b99d2dea6547537ab8 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 27 Mar 2025 14:56:02 +0800 Subject: [PATCH 090/198] nuttx: remove the up_x API for kernel build (#4154) Signed-off-by: buxiasen Co-authored-by: buxiasen --- core/shared/platform/nuttx/nuttx_platform.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/shared/platform/nuttx/nuttx_platform.c b/core/shared/platform/nuttx/nuttx_platform.c index 171adb344..7a28005d4 100644 --- a/core/shared/platform/nuttx/nuttx_platform.c +++ b/core/shared/platform/nuttx/nuttx_platform.c @@ -117,13 +117,17 @@ os_dcache_flush() && defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) up_textheap_data_sync(); #endif +#ifndef CONFIG_BUILD_KERNEL up_invalidate_dcache_all(); +#endif } void os_icache_flush(void *start, size_t len) { +#ifndef CONFIG_BUILD_KERNEL up_invalidate_icache((uintptr_t)start, (uintptr_t)start + len); +#endif } #if (WASM_MEM_DUAL_BUS_MIRROR != 0) From 4082e53ddab184ae61ccae668cf96a122dfd084b Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 27 Mar 2025 15:01:54 +0800 Subject: [PATCH 091/198] docs: Update build instructions suggestions for using Valgrind (#4164) --- doc/build_wamr.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 36b15e568..6425450bd 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -347,3 +347,13 @@ When enabling SIMD for fast interpreter mode, you'll need to enable both SIMD an cmake .. -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_SIMD=1 -DWAMR_BUILD_LIB_SIMDE=1 ``` + +For Valgrind, begin with the following configurations and add additional ones as needed: + +``` Bash + #... + -DCMAKE_BUILD_TYPE=Debug \ + -DWAMR_DISABLE_HW_BOUND_CHECK=0 \ + -DWAMR_DISABLE_WRITE_GS_BASE=0 + #... +``` \ No newline at end of file From fb6969990973f858aef10f0810956eaf62da3c88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 10:39:31 +0800 Subject: [PATCH 092/198] build(deps): Bump github/codeql-action from 3.28.12 to 3.28.13 (#4170) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.12 to 3.28.13. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.12...v3.28.13) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c0dd58986..534f8e356 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.12 + uses: github/codeql-action/init@v3.28.13 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.12 + uses: github/codeql-action/analyze@v3.28.13 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.12 + uses: github/codeql-action/upload-sarif@v3.28.13 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index e2de61604..b691679b1 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@e0ea141027937784e3c10ed1679e503fcc2245bc + uses: github/codeql-action/upload-sarif@9f45e7498becbbc08084a122b4be9ab534ac6d88 with: sarif_file: results.sarif From b8dde7246d2ceebb80eea5aaea48316c19294b5d Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Tue, 1 Apr 2025 12:05:13 +0800 Subject: [PATCH 093/198] dwarf_extractor.cpp: use macro control to be compatible with lower version toolchain (#4169) --- core/iwasm/compilation/debug/dwarf_extractor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/iwasm/compilation/debug/dwarf_extractor.cpp b/core/iwasm/compilation/debug/dwarf_extractor.cpp index 334f4bb6c..f08f76616 100644 --- a/core/iwasm/compilation/debug/dwarf_extractor.cpp +++ b/core/iwasm/compilation/debug/dwarf_extractor.cpp @@ -311,14 +311,18 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx, case eLanguageTypeC: case eLanguageTypeC99: case eLanguageTypeC11: +#if LLVM_VERSION_MAJOR >= 17 case eLanguageTypeC17: +#endif break; case eLanguageTypeC_plus_plus: case eLanguageTypeC_plus_plus_03: case eLanguageTypeC_plus_plus_11: case eLanguageTypeC_plus_plus_14: +#if LLVM_VERSION_MAJOR >= 17 case eLanguageTypeC_plus_plus_17: case eLanguageTypeC_plus_plus_20: +#endif cplusplus = true; break; default: From 159b69da38e11bf5e8e22a04462f80dfd5fb39cf Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 2 Apr 2025 07:13:53 +0800 Subject: [PATCH 094/198] Update cmake min to 3.14 (#4175) 3.14 is used and tested by linux mini-product to fix ``` CMake Error at CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake. Update the VERSION argument value. Or, use the ... syntax to tell CMake that the project requires at least but has been updated to work with policies introduced by or earlier. Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. ``` --- CMakeLists.txt | 2 +- build-scripts/esp-idf/README.md | 2 +- core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake | 2 +- doc/build_wasm_app.md | 2 +- product-mini/app-samples/hello-world-cmake/CMakeLists.txt | 2 +- product-mini/platforms/esp-idf/CMakeLists.txt | 2 +- product-mini/platforms/freebsd/CMakeLists.txt | 2 +- product-mini/platforms/linux-sgx/CMakeLists.txt | 2 +- product-mini/platforms/linux-sgx/CMakeLists_minimal.txt | 2 +- product-mini/platforms/riot/CMakeLists.txt | 2 +- product-mini/platforms/vxworks/CMakeLists.txt | 2 +- product-mini/platforms/windows/CMakeLists.txt | 2 +- product-mini/platforms/zephyr/simple/CMakeLists.txt | 2 +- product-mini/platforms/zephyr/user-mode/CMakeLists.txt | 2 +- .../platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt | 2 +- samples/bh-atomic/CMakeLists.txt | 2 +- samples/file/CMakeLists.txt | 2 +- samples/file/wasm-app/CMakeLists.txt | 2 +- samples/mem-allocator/CMakeLists.txt | 2 +- samples/multi-module/wasm-apps/CMakeLists.txt | 2 +- samples/native-lib/wasm-app/CMakeLists.txt | 2 +- samples/sgx-ra/CMakeLists.txt | 2 +- samples/sgx-ra/wasm-app/CMakeLists.txt | 2 +- samples/socket-api/wasm-src/CMakeLists.txt | 2 +- test-tools/binarydump-tool/CMakeLists.txt | 2 +- .../wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6d1c840a..551991f89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required (VERSION 3.14) option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) diff --git a/build-scripts/esp-idf/README.md b/build-scripts/esp-idf/README.md index 6bec45d1e..25fe491ea 100644 --- a/build-scripts/esp-idf/README.md +++ b/build-scripts/esp-idf/README.md @@ -11,7 +11,7 @@ You can build an ESP-IDF project with wasm-micro-runtime as a component: - In the newly created project folder edit the `CMakeList.txt`: ``` - cmake_minimum_required(VERSION 3.5) + cmake_minimum_required(VERSION 3.14) include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake b/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake index 8ddddffeb..c6a4430f7 100644 --- a/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake +++ b/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.8...3.16) +cmake_minimum_required (VERSION 3.14) project(socket_wasi_ext LANGUAGES C) diff --git a/doc/build_wasm_app.md b/doc/build_wasm_app.md index ef9bea9e2..2cea78069 100644 --- a/doc/build_wasm_app.md +++ b/doc/build_wasm_app.md @@ -275,7 +275,7 @@ You can cross compile your project by using the toolchain provided by WAMR. Assume the original `CMakeLists.txt` for `test.c` likes below: ``` cmake -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.14) project(hello_world) add_executable(hello_world test.c) ``` diff --git a/product-mini/app-samples/hello-world-cmake/CMakeLists.txt b/product-mini/app-samples/hello-world-cmake/CMakeLists.txt index b41fe0a51..6131b6977 100644 --- a/product-mini/app-samples/hello-world-cmake/CMakeLists.txt +++ b/product-mini/app-samples/hello-world-cmake/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.14) project(hello_world) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-unused-command-line-argument") diff --git a/product-mini/platforms/esp-idf/CMakeLists.txt b/product-mini/platforms/esp-idf/CMakeLists.txt index 8472df8dd..309949a20 100644 --- a/product-mini/platforms/esp-idf/CMakeLists.txt +++ b/product-mini/platforms/esp-idf/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # from ESP-IDF 4.0 examples/build_system/cmake/idf_as_lib -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/product-mini/platforms/freebsd/CMakeLists.txt b/product-mini/platforms/freebsd/CMakeLists.txt index 5640a384a..fccc52323 100644 --- a/product-mini/platforms/freebsd/CMakeLists.txt +++ b/product-mini/platforms/freebsd/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (iwasm) diff --git a/product-mini/platforms/linux-sgx/CMakeLists.txt b/product-mini/platforms/linux-sgx/CMakeLists.txt index 927e6f459..bc3bde565 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (iwasm) diff --git a/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt b/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt index a29dbd69c..5104769d7 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (iwasm) diff --git a/product-mini/platforms/riot/CMakeLists.txt b/product-mini/platforms/riot/CMakeLists.txt index c32a0b977..cc98146c5 100644 --- a/product-mini/platforms/riot/CMakeLists.txt +++ b/product-mini/platforms/riot/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2020 TU Bergakademie Freiberg Karl Fessel # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.14) set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") diff --git a/product-mini/platforms/vxworks/CMakeLists.txt b/product-mini/platforms/vxworks/CMakeLists.txt index dd03cb356..3f08a72ad 100644 --- a/product-mini/platforms/vxworks/CMakeLists.txt +++ b/product-mini/platforms/vxworks/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (iwasm) diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index 5fcc276a1..9ec5d3415 100644 --- a/product-mini/platforms/windows/CMakeLists.txt +++ b/product-mini/platforms/windows/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (iwasm C ASM CXX) # set (CMAKE_VERBOSE_MAKEFILE 1) diff --git a/product-mini/platforms/zephyr/simple/CMakeLists.txt b/product-mini/platforms/zephyr/simple/CMakeLists.txt index 78dd32285..46dc3ea0c 100644 --- a/product-mini/platforms/zephyr/simple/CMakeLists.txt +++ b/product-mini/platforms/zephyr/simple/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.14) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(wamr) diff --git a/product-mini/platforms/zephyr/user-mode/CMakeLists.txt b/product-mini/platforms/zephyr/user-mode/CMakeLists.txt index 16c9b26dc..8e7b819b1 100644 --- a/product-mini/platforms/zephyr/user-mode/CMakeLists.txt +++ b/product-mini/platforms/zephyr/user-mode/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.13.1) +cmake_minimum_required(VERSION 3.14) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(wamr_user_mode LANGUAGES C) diff --git a/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt index 7c68a71ac..347fddf3e 100644 --- a/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt +++ b/product-mini/platforms/zephyr/user-mode/lib-wamr-zephyr/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.14) set (WAMR_BUILD_PLATFORM "zephyr") diff --git a/samples/bh-atomic/CMakeLists.txt b/samples/bh-atomic/CMakeLists.txt index f69052742..177cf2c5e 100644 --- a/samples/bh-atomic/CMakeLists.txt +++ b/samples/bh-atomic/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2023 Midokura Japan KK. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(bh_atomic) string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) diff --git a/samples/file/CMakeLists.txt b/samples/file/CMakeLists.txt index c3a69ccc8..fca200376 100644 --- a/samples/file/CMakeLists.txt +++ b/samples/file/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2022 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(file) ################ wasm application ############### diff --git a/samples/file/wasm-app/CMakeLists.txt b/samples/file/wasm-app/CMakeLists.txt index 4af87a3fd..f63485ca0 100644 --- a/samples/file/wasm-app/CMakeLists.txt +++ b/samples/file/wasm-app/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2022 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(wasm-app) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) diff --git a/samples/mem-allocator/CMakeLists.txt b/samples/mem-allocator/CMakeLists.txt index f157dfbde..9f3e49db9 100644 --- a/samples/mem-allocator/CMakeLists.txt +++ b/samples/mem-allocator/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2023 Midokura Japan KK. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(mem_allocator_create) string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) diff --git a/samples/multi-module/wasm-apps/CMakeLists.txt b/samples/multi-module/wasm-apps/CMakeLists.txt index 8dbb52686..6460a99e6 100644 --- a/samples/multi-module/wasm-apps/CMakeLists.txt +++ b/samples/multi-module/wasm-apps/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.8...3.16) +cmake_minimum_required (VERSION 3.14) project(wasm-apps) message(CHECK_START "Detecting WABT") diff --git a/samples/native-lib/wasm-app/CMakeLists.txt b/samples/native-lib/wasm-app/CMakeLists.txt index ffcd9005a..e5bea6010 100644 --- a/samples/native-lib/wasm-app/CMakeLists.txt +++ b/samples/native-lib/wasm-app/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(wasm-app) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) diff --git a/samples/sgx-ra/CMakeLists.txt b/samples/sgx-ra/CMakeLists.txt index 3f5f23e97..48ff9ee56 100644 --- a/samples/sgx-ra/CMakeLists.txt +++ b/samples/sgx-ra/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (c) 2020-2021 Alibaba Cloud # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.1.4) +cmake_minimum_required(VERSION 3.14) project(sgx-ra) ################ runtime settings ############## diff --git a/samples/sgx-ra/wasm-app/CMakeLists.txt b/samples/sgx-ra/wasm-app/CMakeLists.txt index afba7dfb6..93907b7f0 100644 --- a/samples/sgx-ra/wasm-app/CMakeLists.txt +++ b/samples/sgx-ra/wasm-app/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (c) 2020-2021 Alibaba Cloud # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(wasm-app) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) diff --git a/samples/socket-api/wasm-src/CMakeLists.txt b/samples/socket-api/wasm-src/CMakeLists.txt index 8f11e0a6b..38e813916 100644 --- a/samples/socket-api/wasm-src/CMakeLists.txt +++ b/samples/socket-api/wasm-src/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.8...3.18) +cmake_minimum_required(VERSION 3.14) project(socket_api_sample_wasm_app) message(CHECK_START "Detecting WABT") diff --git a/test-tools/binarydump-tool/CMakeLists.txt b/test-tools/binarydump-tool/CMakeLists.txt index d322b42b6..744f72c3c 100644 --- a/test-tools/binarydump-tool/CMakeLists.txt +++ b/test-tools/binarydump-tool/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project(binarydump) diff --git a/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt b/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt index 81d998bc8..a6298c5e1 100644 --- a/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt +++ b/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project(Main) From 6424122d6ba4df04b711aded13c884ec450161da Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 1 Apr 2025 21:30:45 -0700 Subject: [PATCH 095/198] fix format specifier warning on 32bit builds (#4177) --- core/iwasm/aot/aot_perf_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_perf_map.c b/core/iwasm/aot/aot_perf_map.c index b96bcd1bf..701929996 100644 --- a/core/iwasm/aot/aot_perf_map.c +++ b/core/iwasm/aot/aot_perf_map.c @@ -89,12 +89,12 @@ aot_create_perf_map(const AOTModule *module, char *error_buf, for (i = 0; i < module->func_count; i++) { memset(perf_map_info, 0, 128); if (strlen(module_name) > 0) - snprintf(perf_map_info, 128, "%lx %x [%s]#aot_func#%u\n", + snprintf(perf_map_info, 128, PRIxPTR " %x [%s]#aot_func#%u\n", (uintptr_t)sorted_func_ptrs[i].ptr, get_func_size(module, sorted_func_ptrs, i), module_name, sorted_func_ptrs[i].idx); else - snprintf(perf_map_info, 128, "%lx %x aot_func#%u\n", + snprintf(perf_map_info, 128, PRIxPTR " %x aot_func#%u\n", (uintptr_t)sorted_func_ptrs[i].ptr, get_func_size(module, sorted_func_ptrs, i), sorted_func_ptrs[i].idx); From 4e50d2191ca8f177ad03a9d80eebc44b59a932db Mon Sep 17 00:00:00 2001 From: dongsheng28849455 <68947925+dongsheng28849455@users.noreply.github.com> Date: Wed, 2 Apr 2025 14:39:03 +0800 Subject: [PATCH 096/198] Remove indirect-load for constants on Xtensa Target to improve performance (#4162) * Remove indirect-load for constants on Xtensa Target to improve performance * Remove const intrinsics flags for xtensa instead of adding too much #ifdef * Add AOT_INTRINSIC_FLAG_F32_CONST for xtensa frontend, because espressif xtensa llvm backend does not support float-point immediate for now --------- Co-authored-by: zhanheng1 --- core/iwasm/aot/aot_intrinsic.c | 3 - core/iwasm/compilation/aot_emit_conversion.c | 92 ++++++++++---------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/core/iwasm/aot/aot_intrinsic.c b/core/iwasm/aot/aot_intrinsic.c index 245c7a651..5f62abf24 100644 --- a/core/iwasm/aot/aot_intrinsic.c +++ b/core/iwasm/aot/aot_intrinsic.c @@ -878,9 +878,6 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx) add_i64_common_intrinsics(comp_ctx); add_common_float_integer_conversion(comp_ctx); add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F32_CONST); - add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F64_CONST); - add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CONST); - add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CONST); } else { /* diff --git a/core/iwasm/compilation/aot_emit_conversion.c b/core/iwasm/compilation/aot_emit_conversion.c index c3dfa6bf1..fa5c2ab95 100644 --- a/core/iwasm/compilation/aot_emit_conversion.c +++ b/core/iwasm/compilation/aot_emit_conversion.c @@ -347,17 +347,8 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F32(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F32_CONST(-2147483904.0f); - max_value = F32_CONST(2147483648.0f); - } - else { - min_value = F32_CONST(-1.0f); - max_value = F32_CONST(4294967296.0f); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f32.const")) { WASMValue wasm_value; if (sign) { wasm_value.f32 = -2147483904.0f; @@ -376,6 +367,16 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32); } } + else { + if (sign) { + min_value = F32_CONST(-2147483904.0f); + max_value = F32_CONST(2147483648.0f); + } + else { + min_value = F32_CONST(-1.0f); + max_value = F32_CONST(4294967296.0f); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); @@ -400,17 +401,8 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F64(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F64_CONST(-2147483649.0); - max_value = F64_CONST(2147483648.0); - } - else { - min_value = F64_CONST(-1.0); - max_value = F64_CONST(4294967296.0); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f64.const")) { WASMValue wasm_value; if (sign) { wasm_value.f64 = -2147483649.0; @@ -429,6 +421,16 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64); } } + else { + if (sign) { + min_value = F64_CONST(-2147483649.0); + max_value = F64_CONST(2147483648.0); + } + else { + min_value = F64_CONST(-1.0); + max_value = F64_CONST(4294967296.0); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); @@ -554,17 +556,8 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F32(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F32_CONST(-9223373136366403584.0f); - max_value = F32_CONST(9223372036854775808.0f); - } - else { - min_value = F32_CONST(-1.0f); - max_value = F32_CONST(18446744073709551616.0f); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f32.const")) { WASMValue wasm_value; if (sign) { wasm_value.f32 = -9223373136366403584.0f; @@ -583,6 +576,16 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32); } } + else { + if (sign) { + min_value = F32_CONST(-9223373136366403584.0f); + max_value = F32_CONST(9223372036854775808.0f); + } + else { + min_value = F32_CONST(-1.0f); + max_value = F32_CONST(18446744073709551616.0f); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); @@ -607,17 +610,8 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F64(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F64_CONST(-9223372036854777856.0); - max_value = F64_CONST(9223372036854775808.0); - } - else { - min_value = F64_CONST(-1.0); - max_value = F64_CONST(18446744073709551616.0); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f64.const")) { WASMValue wasm_value; if (sign) { wasm_value.f64 = -9223372036854777856.0; @@ -636,6 +630,16 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64); } } + else { + if (sign) { + min_value = F64_CONST(-9223372036854777856.0); + max_value = F64_CONST(9223372036854775808.0); + } + else { + min_value = F64_CONST(-1.0); + max_value = F64_CONST(18446744073709551616.0); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); From 79f26a96a47bbce8a9f17ba284be4625eca8e265 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 9 Apr 2025 10:26:53 +0800 Subject: [PATCH 097/198] cmake: Enhance target selection for ARM architectures with FPU (#4185) Improve the target selection logic for ARM architectures in the NuttX platform configuration. * Added support for FPU detection in THUMB and ARM targets * Ensured correct target is set based on architecture and configuration options Signed-off-by: Huang Qi --- product-mini/platforms/nuttx/CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/product-mini/platforms/nuttx/CMakeLists.txt b/product-mini/platforms/nuttx/CMakeLists.txt index edbfb62f7..997a82e41 100644 --- a/product-mini/platforms/nuttx/CMakeLists.txt +++ b/product-mini/platforms/nuttx/CMakeLists.txt @@ -7,7 +7,19 @@ set(WAMR_BUILD_PLATFORM nuttx) if(CONFIG_ARCH_ARMV6M) set(WAMR_BUILD_TARGET THUMBV6M) elseif(CONFIG_ARCH_ARMV7A) - set(WAMR_BUILD_TARGET THUMBV7) + if(CONFIG_ARM_THUMB) + if(CONFIG_ARCH_FPU) + set(WAMR_BUILD_TARGET THUMBV7_VFP) + else() + set(WAMR_BUILD_TARGET THUMBV7) + endif() + else() + if(CONFIG_ARCH_FPU) + set(WAMR_BUILD_TARGET ARMV7_VFP) + else() + set(WAMR_BUILD_TARGET ARMV7) + endif() + endif() elseif(CONFIG_ARCH_ARMV7M) set(WAMR_BUILD_TARGET THUMBV7EM) elseif(CONFIG_ARCH_ARMV8M) From 8f2fed4379d7b452e9aa1adaaf98362aedc16649 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 14:44:43 +0800 Subject: [PATCH 098/198] build(deps): Bump github/codeql-action from 3.28.13 to 3.28.14 (#4184) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.13 to 3.28.14. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.13...v3.28.14) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.14 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 534f8e356..098bd7f9c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.13 + uses: github/codeql-action/init@v3.28.14 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.13 + uses: github/codeql-action/analyze@v3.28.14 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.13 + uses: github/codeql-action/upload-sarif@v3.28.14 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index b691679b1..f0230c23e 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@9f45e7498becbbc08084a122b4be9ab534ac6d88 + uses: github/codeql-action/upload-sarif@362ef4ce205154842cd1d34794abd82bb8f12cd5 with: sarif_file: results.sarif From 8245aefc779931fb3672ec471d1d60d05a3efd1f Mon Sep 17 00:00:00 2001 From: Raul Hernandez Date: Wed, 9 Apr 2025 09:19:48 +0200 Subject: [PATCH 099/198] aot: add new u64 intrinsics (#4168) --- core/iwasm/aot/aot_intrinsic.c | 32 +++++++++++ core/iwasm/aot/aot_intrinsic.h | 16 ++++++ core/iwasm/aot/aot_reloc.h | 4 ++ core/iwasm/compilation/aot_emit_numberic.c | 64 +++++++++++++++------- 4 files changed, 96 insertions(+), 20 deletions(-) diff --git a/core/iwasm/aot/aot_intrinsic.c b/core/iwasm/aot/aot_intrinsic.c index 5f62abf24..252ef7056 100644 --- a/core/iwasm/aot/aot_intrinsic.c +++ b/core/iwasm/aot/aot_intrinsic.c @@ -485,6 +485,30 @@ aot_intrinsic_i64_bit_and(uint64 l, uint64 r) return l & r; } +uint64 +aot_intrinsic_i64_mul(uint64 l, uint64 r) +{ + return l * r; +} + +uint64 +aot_intrinsic_i64_shl(uint64 l, uint64 r) +{ + return l << r; +} + +uint64 +aot_intrinsic_i64_shr_s(uint64 l, uint64 r) +{ + return (int64)l >> r; +} + +uint64 +aot_intrinsic_i64_shr_u(uint64 l, uint64 r) +{ + return l >> r; +} + #if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 typedef struct { @@ -561,6 +585,10 @@ static const aot_intrinsic g_intrinsic_mapping[] = { { "i64.rem_u", "aot_intrinsic_i64_rem_u", AOT_INTRINSIC_FLAG_I64_REM_U}, { "i64.or", "aot_intrinsic_i64_bit_or", AOT_INTRINSIC_FLAG_I64_BIT_OR}, { "i64.and", "aot_intrinsic_i64_bit_and", AOT_INTRINSIC_FLAG_I64_BIT_AND}, + { "i64.mul", "aot_intrinsic_i64_mul", AOT_INTRINSIC_FLAG_I64_MUL}, + { "i64.shl", "aot_intrinsic_i64_shl", AOT_INTRINSIC_FLAG_I64_SHL}, + { "i64.shr_s", "aot_intrinsic_i64_shr_s", AOT_INTRINSIC_FLAG_I64_SHR_S}, + { "i64.shr_u", "aot_intrinsic_i64_shr_u", AOT_INTRINSIC_FLAG_I64_SHR_U}, }; /* clang-format on */ @@ -601,6 +629,10 @@ add_i64_common_intrinsics(AOTCompContext *comp_ctx) add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_REM_U); add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_BIT_OR); add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_BIT_AND); + add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_MUL); + add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_SHL); + add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_SHR_S); + add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_SHR_U); } static void diff --git a/core/iwasm/aot/aot_intrinsic.h b/core/iwasm/aot/aot_intrinsic.h index 6a456efda..f065a5ad2 100644 --- a/core/iwasm/aot/aot_intrinsic.h +++ b/core/iwasm/aot/aot_intrinsic.h @@ -98,6 +98,10 @@ extern "C" { #define AOT_INTRINSIC_FLAG_I64_REM_U AOT_INTRINSIC_FLAG(1, 31) #define AOT_INTRINSIC_FLAG_I64_BIT_OR AOT_INTRINSIC_FLAG(1, 32) #define AOT_INTRINSIC_FLAG_I64_BIT_AND AOT_INTRINSIC_FLAG(1, 33) +#define AOT_INTRINSIC_FLAG_I64_MUL AOT_INTRINSIC_FLAG(1, 34) +#define AOT_INTRINSIC_FLAG_I64_SHL AOT_INTRINSIC_FLAG(1, 35) +#define AOT_INTRINSIC_FLAG_I64_SHR_S AOT_INTRINSIC_FLAG(1, 36) +#define AOT_INTRINSIC_FLAG_I64_SHR_U AOT_INTRINSIC_FLAG(1, 37) /* clang-format on */ @@ -287,6 +291,18 @@ aot_intrinsic_i64_bit_or(uint64 l, uint64 r); uint64 aot_intrinsic_i64_bit_and(uint64 l, uint64 r); +uint64 +aot_intrinsic_i64_mul(uint64 l, uint64 r); + +uint64 +aot_intrinsic_i64_shl(uint64 l, uint64 r); + +uint64 +aot_intrinsic_i64_shr_s(uint64 l, uint64 r); + +uint64 +aot_intrinsic_i64_shr_u(uint64 l, uint64 r); + #if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 const char * aot_intrinsic_get_symbol(const char *llvm_intrinsic); diff --git a/core/iwasm/aot/aot_reloc.h b/core/iwasm/aot/aot_reloc.h index f7ada4d8d..ca9ba17f1 100644 --- a/core/iwasm/aot/aot_reloc.h +++ b/core/iwasm/aot/aot_reloc.h @@ -122,6 +122,10 @@ typedef struct { REG_SYM(aot_intrinsic_i64_rem_u), \ REG_SYM(aot_intrinsic_i64_bit_or), \ REG_SYM(aot_intrinsic_i64_bit_and), \ + REG_SYM(aot_intrinsic_i64_mul), \ + REG_SYM(aot_intrinsic_i64_shl), \ + REG_SYM(aot_intrinsic_i64_shr_s), \ + REG_SYM(aot_intrinsic_i64_shr_u), \ REG_SYM(aot_intrinsic_i32_div_s), \ REG_SYM(aot_intrinsic_i32_div_u), \ REG_SYM(aot_intrinsic_i32_rem_s), \ diff --git a/core/iwasm/compilation/aot_emit_numberic.c b/core/iwasm/compilation/aot_emit_numberic.c index 1f37060d9..492c3048c 100644 --- a/core/iwasm/compilation/aot_emit_numberic.c +++ b/core/iwasm/compilation/aot_emit_numberic.c @@ -653,15 +653,22 @@ compile_int_sub(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right, } static LLVMValueRef -compile_int_mul(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right, - bool is_i32) +compile_int_mul(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMValueRef left, LLVMValueRef right, bool is_i32) { /* If one of the operands is 0, just return constant 0 */ if (IS_CONST_ZERO(left) || IS_CONST_ZERO(right)) return is_i32 ? I32_ZERO : I64_ZERO; /* Build mul */ - return LLVMBuildMul(comp_ctx->builder, left, right, "mul"); + LLVMTypeRef param_types[2]; + param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE; + + LLVMValueRef res; + LLVM_BUILD_OP_OR_INTRINSIC(Mul, left, right, res, + is_i32 ? "i32.mul" : "i64.mul", "mul", false); + + return res; } static bool @@ -679,8 +686,9 @@ compile_op_int_arithmetic(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, "compile int sub fail."); return true; case INT_MUL: - DEF_INT_BINARY_OP(compile_int_mul(comp_ctx, left, right, is_i32), - "compile int mul fail."); + DEF_INT_BINARY_OP( + compile_int_mul(comp_ctx, func_ctx, left, right, is_i32), + "compile int mul fail."); return true; case INT_DIV_S: case INT_DIV_U: @@ -726,43 +734,57 @@ fail: } static LLVMValueRef -compile_int_shl(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right, - bool is_i32) +compile_int_shl(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMValueRef left, LLVMValueRef right, bool is_i32) { LLVMValueRef res; SHIFT_COUNT_MASK; /* Build shl */ - LLVM_BUILD_OP(Shl, left, right, res, "shl", NULL); + LLVMTypeRef param_types[2]; + param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE; + + LLVM_BUILD_OP_OR_INTRINSIC(Shl, left, right, res, + is_i32 ? "i32.shl" : "i64.shl", "shl", false); return res; } static LLVMValueRef -compile_int_shr_s(AOTCompContext *comp_ctx, LLVMValueRef left, - LLVMValueRef right, bool is_i32) +compile_int_shr_s(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMValueRef left, LLVMValueRef right, bool is_i32) { LLVMValueRef res; SHIFT_COUNT_MASK; /* Build shl */ - LLVM_BUILD_OP(AShr, left, right, res, "shr_s", NULL); + LLVMTypeRef param_types[2]; + param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE; + + LLVM_BUILD_OP_OR_INTRINSIC(AShr, left, right, res, + is_i32 ? "i32.shr_s" : "i64.shr_s", "shr_s", + false); return res; } static LLVMValueRef -compile_int_shr_u(AOTCompContext *comp_ctx, LLVMValueRef left, - LLVMValueRef right, bool is_i32) +compile_int_shr_u(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + LLVMValueRef left, LLVMValueRef right, bool is_i32) { LLVMValueRef res; SHIFT_COUNT_MASK; /* Build shl */ - LLVM_BUILD_OP(LShr, left, right, res, "shr_u", NULL); + LLVMTypeRef param_types[2]; + param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE; + + LLVM_BUILD_OP_OR_INTRINSIC(LShr, left, right, res, + is_i32 ? "i32.shr_u" : "i64.shr_u", "shr_u", + false); return res; } @@ -814,16 +836,18 @@ compile_op_int_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, { switch (shift_op) { case INT_SHL: - DEF_INT_BINARY_OP(compile_int_shl(comp_ctx, left, right, is_i32), - NULL); + DEF_INT_BINARY_OP( + compile_int_shl(comp_ctx, func_ctx, left, right, is_i32), NULL); return true; case INT_SHR_S: - DEF_INT_BINARY_OP(compile_int_shr_s(comp_ctx, left, right, is_i32), - NULL); + DEF_INT_BINARY_OP( + compile_int_shr_s(comp_ctx, func_ctx, left, right, is_i32), + NULL); return true; case INT_SHR_U: - DEF_INT_BINARY_OP(compile_int_shr_u(comp_ctx, left, right, is_i32), - NULL); + DEF_INT_BINARY_OP( + compile_int_shr_u(comp_ctx, func_ctx, left, right, is_i32), + NULL); return true; case INT_ROTL: DEF_INT_BINARY_OP( From 2a2632444b590a31e503fd50d4eedbbcb886bd54 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 11:59:59 +0800 Subject: [PATCH 100/198] Refactor Dockerfile and update .dockerignore for wasi-nn tests; adjust map-dir parameters in smoke test script (#4158) --- .dockerignore | 18 +++---- .../wasi-nn/test/Dockerfile.wasi-nn-smoke | 48 +++++++++++-------- .../libraries/wasi-nn/test/run_smoke_test.py | 8 ++-- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/.dockerignore b/.dockerignore index 20b1ad526..f322b3c1e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,16 +1,12 @@ # for now, it is used to speed up wasi-nn tests only. # you shall adapt below rules to incoming requirements -build -*/build -*/*/build -*/*/*/build -*/*/*/*/build -*/*/*/*/*/build -*/*/*/*/*/*/build +**/build +**/tmp.* .* +**/*.gguf -core/deps -!core/deps/tensorflow-src -samples -tests +/core/deps/ +!/core/deps/tensorflow-src +/samples +/tests diff --git a/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke b/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke index fdbe971d2..133b19185 100644 --- a/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke +++ b/core/iwasm/libraries/wasi-nn/test/Dockerfile.wasi-nn-smoke @@ -30,21 +30,23 @@ RUN apt-get update \ && apt-get upgrade -y \ && apt-get install --no-install-recommends -y openvino-2023.2.0 +# Activate after upgrading to wasi-nn 0.7.0 +# # +# # wasi-nn +# # compilation requirements +# WORKDIR /workspaces/wasi-nn +# RUN git clone https://github.com/bytecodealliance/wasi-nn.git . \ +# # update new wasmtime's cli (#100). Apr 27, 2024 +# && git checkout 556890b121dd1171665d835aba4d04a7e29e37dc # -# wasi-nn -# compilation requirements -WORKDIR /workspaces/wasi-nn -RUN git clone --depth 1 https://github.com/bytecodealliance/wasi-nn.git . - -WORKDIR /workspaces/wasi-nn/rust/examples/classification-example/ -RUN cargo build --target=wasm32-wasip1 - -WORKDIR /workspaces/wasi-nn/rust/examples/classification-example/build -RUN cp ../target/wasm32-wasip1/debug/wasi-nn-example.wasm . \ - && wget -q --no-clobber https://github.com/intel/openvino-rs/raw/main/crates/openvino/tests/fixtures/mobilenet/mobilenet.xml \ - && wget -q --no-clobber https://github.com/intel/openvino-rs/raw/main/crates/openvino/tests/fixtures/mobilenet/mobilenet.bin -# There are model files(mobilenet*) and wasm files(wasi-nn-example.wasm) in the directory, -# /workspaces/wasi-nn/rust/examples/classification-example/build +# WORKDIR /workspaces/wasi-nn/rust/examples/classification-example/ +# RUN cargo build --target=wasm32-wasip1 +# +# ARG FIXTURE=https://download.01.org/openvinotoolkit/fixtures/mobilenet +# RUN cp target/wasm32-wasip1/debug/wasi-nn-example.wasm . \ +# && wget -q --no-clobber $FIXTURE/mobilenet.xml \ +# && wget -q --no-clobber $FIXTURE/mobilenet.bin +# # There are model files(mobilenet*) and wasm files(wasi-nn-example.wasm) in the directory, # # wasmedge @@ -52,31 +54,34 @@ WORKDIR /tmp RUN wget -q https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh \ && chmod a+x ./install.sh # RUN ./install.sh -p /opt/wasmedge --plugins wasi_nn-tensorflowlite wasi_nn-openvino -RUN ./install.sh -r yes -D -p /opt/wasmedge --plugins wasi_nn-openvino --dist ubuntu20.04 \ +RUN ./install.sh -r yes -D -p /opt/wasmedge --plugins wasi_nn-openvino --dist ubuntu20.04 -v 0.14.0 \ && /opt/wasmedge/bin/wasmedge --version ENV PATH=/opt/wasmedge/bin:${PATH} # ENV WASMEDGE_LIB_DIR=/opt/wasmedge/lib # # wasmedge-wasinn-examples +# based on wasi-nn 0.6.0 WORKDIR /workspaces/wasmedge-wasinn-examples RUN git clone --depth 1 https://github.com/second-state/WasmEdge-WASINN-examples.git . -COPY core/iwasm/libraries/wasi-nn/test/bump_wasi_nn_to_0_6_0.patch . -RUN git apply ./bump_wasi_nn_to_0_6_0.patch -# recompile with wasi-nn 0.6.0 +# recompile with debug info +ARG FIXTURE=https://download.01.org/openvinotoolkit/fixtures/mobilenet WORKDIR /workspaces/wasmedge-wasinn-examples/openvino-mobilenet-image/ RUN pushd rust \ && cargo build --target=wasm32-wasip1 \ && popd \ - && ./download_mobilenet.sh . \ + && wget -q --no-clobber $FIXTURE/mobilenet.xml \ + && wget -q --no-clobber $FIXTURE/mobilenet.bin \ && ls -l mobilenet.xml mobilenet.bin WORKDIR /workspaces/wasmedge-wasinn-examples/openvino-mobilenet-raw/ RUN pushd rust \ && cargo build --target=wasm32-wasip1 \ && popd \ - && ./download_mobilenet.sh . \ + && wget -q --no-clobber $FIXTURE/mobilenet.xml \ + && wget -q --no-clobber $FIXTURE/mobilenet.bin \ + && wget -q --no-clobber $FIXTURE/tensor-1x224x224x3-f32.bgr \ && ls -l mobilenet.xml mobilenet.bin tensor-1x224x224x3-f32.bgr WORKDIR /workspaces/wasmedge-wasinn-examples/openvino-road-segmentation-adas/ @@ -91,7 +96,7 @@ RUN pushd rust \ WORKDIR /workspaces/wasmedge-wasinn-examples/wasmedge-ggml/qwen RUN wget --progress=dot:giga https://www.modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat-GGUF/resolve/master/qwen1_5-0_5b-chat-q2_k.gguf RUN cargo build --target=wasm32-wasip1 - +# # # iwasm. build from source WORKDIR /workspaces/wamr @@ -110,6 +115,7 @@ RUN OpenVINO_DIR=/usr/lib/openvino-2023.2.0 \ ENV LD_LIBRARY_PATH=/usr/local/lib + # add smoke test script COPY core/iwasm/libraries/wasi-nn/test/run_smoke_test.py / diff --git a/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py b/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py index 3637bc371..489e6e59f 100644 --- a/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py +++ b/core/iwasm/libraries/wasi-nn/test/run_smoke_test.py @@ -163,7 +163,7 @@ def execute_tflite_birds_v1_image(iwasm_bin: str, wasmedge_bin: str, cwd: Path): iwasm_output = execute_tflite_birds_v1_image_once( iwasm_bin, [ - "--map-dir=.:.", + "--map-dir=.::.", ], cwd, ) @@ -181,7 +181,7 @@ def execute_openvino_mobilenet_image(iwasm_bin: str, wasmedge_bin: str, cwd: Pat iwasm_output = execute_openvino_mobilenet_image_once( iwasm_bin, [ - "--map-dir=.:.", + "--map-dir=.::.", ], cwd, ) @@ -199,7 +199,7 @@ def execute_openvino_mobilenet_raw(iwasm_bin: str, wasmedge_bin: str, cwd: Path) iwasm_output = execute_openvino_mobilenet_raw_once( iwasm_bin, [ - "--map-dir=.:.", + "--map-dir=.::.", ], cwd, ) @@ -236,7 +236,7 @@ def execute_openvino_road_segmentation_adas( iwasm_output = execute_openvino_road_segmentation_adas_once( iwasm_bin, [ - "--map-dir=.:.", + "--map-dir=.::.", ], cwd, ) From 8fe98f64c197a9c0c9f1d6a34e237b63e074554f Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 10 Apr 2025 12:00:23 +0800 Subject: [PATCH 101/198] Add import memory/table flag assert check for miniloader (#4179) --- core/iwasm/interpreter/wasm_mini_loader.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index ecda490df..af9ea5046 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -665,7 +665,7 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end, const char *table_name, WASMTableImport *table, char *error_buf, uint32 error_buf_size) { - const uint8 *p = *p_buf, *p_end = buf_end; + const uint8 *p = *p_buf, *p_end = buf_end, *p_org; uint32 declare_elem_type = 0, table_flag = 0, declare_init_size = 0, declare_max_size = 0; @@ -678,7 +678,12 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end, #endif ); + /* the table flag can't exceed one byte, only check in debug build given + * the nature of mini-loader */ + p_org = p; read_leb_uint32(p, p_end, table_flag); + bh_assert(p - p_org <= 1); + (void)p_org; if (!wasm_table_check_flags(table_flag, error_buf, error_buf_size, false)) { return false; @@ -711,7 +716,7 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end, const char *memory_name, WASMMemoryImport *memory, char *error_buf, uint32 error_buf_size) { - const uint8 *p = *p_buf, *p_end = buf_end; + const uint8 *p = *p_buf, *p_end = buf_end, *p_org; #if WASM_ENABLE_APP_FRAMEWORK != 0 uint32 pool_size = wasm_runtime_memory_pool_size(); uint32 max_page_count = pool_size * APP_MEMORY_MAX_GLOBAL_HEAP_PERCENT @@ -724,7 +729,13 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end, uint32 declare_init_page_count = 0; uint32 declare_max_page_count = 0; + /* the memory flag can't exceed one byte, only check in debug build given + * the nature of mini-loader */ + p_org = p; read_leb_uint32(p, p_end, mem_flag); + bh_assert(p - p_org <= 1); + (void)p_org; + if (!wasm_memory_check_flags(mem_flag, error_buf, error_buf_size, false)) { return false; } @@ -815,6 +826,8 @@ load_table(const uint8 **p_buf, const uint8 *buf_end, WASMTable *table, #endif ); + /* the table flag can't exceed one byte, only check in debug build given + * the nature of mini-loader */ p_org = p; read_leb_uint32(p, p_end, table->table_type.flags); bh_assert(p - p_org <= 1); @@ -854,6 +867,8 @@ load_memory(const uint8 **p_buf, const uint8 *buf_end, WASMMemory *memory, bool is_memory64 = false; #endif + /* the memory flag can't exceed one byte, only check in debug build given + * the nature of mini-loader */ p_org = p; read_leb_uint32(p, p_end, memory->flags); bh_assert(p - p_org <= 1); From 793135b41c81cec489a8acb894bf46dcaa18913c Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 12:04:56 +0800 Subject: [PATCH 102/198] Fix few integer overflowing (#4161) - fix(interpreter): correct offset calculations in wasm_loader_get_const_offset function - fix(mem-alloc): update offset calculation in gc_migrate for memory migration - add pointer-overflow sanitizer --- build-scripts/config_common.cmake | 3 +++ core/iwasm/interpreter/wasm_loader.c | 19 ++++++++++----- core/shared/mem-alloc/ems/ems_kfc.c | 24 +++++++++++++++++-- .../spec-test-script/runtest.py | 6 +++-- tests/wamr-test-suites/test_wamr.sh | 7 +++++- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 2c0bf3c7c..1cb50235c 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -157,6 +157,9 @@ elseif (WAMR_BUILD_SANITIZER STREQUAL "asan") elseif (WAMR_BUILD_SANITIZER STREQUAL "tsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" ) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") +elseif (WAMR_BUILD_SANITIZER STREQUAL "posan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=pointer-overflow -fno-sanitize-recover=all" ) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=pointer-overflow") elseif (NOT (WAMR_BUILD_SANITIZER STREQUAL "") ) message(SEND_ERROR "Unsupported sanitizer: ${WAMR_BUILD_SANITIZER}") endif() diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 29813d875..8229c6f71 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -9693,8 +9693,10 @@ wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, *offset = 0; return true; } - *offset = -(uint32)(ctx->i64_const_num * 2 + ctx->i32_const_num) - + (uint32)(i64_const - ctx->i64_consts) * 2; + + /* constant index is encoded as negative value */ + *offset = -(int32)(ctx->i64_const_num * 2 + ctx->i32_const_num) + + (int32)(i64_const - ctx->i64_consts) * 2; } else if (type == VALUE_TYPE_V128) { V128 key = *(V128 *)value, *v128_const; @@ -9704,9 +9706,12 @@ wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, *offset = 0; return true; } - *offset = -(uint32)(ctx->v128_const_num) - + (uint32)(v128_const - ctx->v128_consts); + + /* constant index is encoded as negative value */ + *offset = -(int32)(ctx->v128_const_num) + + (int32)(v128_const - ctx->v128_consts); } + else { int32 key = *(int32 *)value, *i32_const; i32_const = bsearch(&key, ctx->i32_consts, ctx->i32_const_num, @@ -9715,8 +9720,10 @@ wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value, *offset = 0; return true; } - *offset = -(uint32)(ctx->i32_const_num) - + (uint32)(i32_const - ctx->i32_consts); + + /* constant index is encoded as negative value */ + *offset = -(int32)(ctx->i32_const_num) + + (int32)(i32_const - ctx->i32_consts); } return true; diff --git a/core/shared/mem-alloc/ems/ems_kfc.c b/core/shared/mem-alloc/ems/ems_kfc.c index 893dd5638..2d5a4b13e 100644 --- a/core/shared/mem-alloc/ems/ems_kfc.c +++ b/core/shared/mem-alloc/ems/ems_kfc.c @@ -208,8 +208,28 @@ gc_get_heap_struct_size() static void adjust_ptr(uint8 **p_ptr, intptr_t offset) { - if (*p_ptr) - *p_ptr = (uint8 *)((intptr_t)(*p_ptr) + offset); + if ((!*p_ptr)) { + return; + } + + /* + * to resolve a possible signed integer overflow issue + * when p_ptr is over 0x8000000000000000 by not using + * `(intptr_t)` + */ + uintptr_t offset_val = 0; +#if UINTPTR_MAX == UINT64_MAX + offset_val = labs(offset); +#else + offset_val = abs(offset); +#endif + + if (offset > 0) { + *p_ptr = (uint8 *)((uintptr_t)(*p_ptr) + offset_val); + } + else { + *p_ptr = (uint8 *)((uintptr_t)(*p_ptr) - offset_val); + } } int diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index 427da3996..ae418a60d 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -1575,7 +1575,8 @@ if __name__ == "__main__": try: if not opts.no_cleanup: # remove the files under /tempfiles/ and copy of .wasm files - log(f"Removing {temp_file_repo}") + log(f"Removing tmp*") + # log(f"Removing {temp_file_repo}") for t in temp_file_repo: # None and empty @@ -1585,7 +1586,8 @@ if __name__ == "__main__": if os.path.exists(t): os.remove(t) else: - log(f"Leaving {temp_file_repo}") + log(f"Leaving tmp*") + # log(f"Leaving {temp_file_repo}") except Exception as e: print("Failed to remove tempfiles: %s" % e) diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index 7a4ca08b5..b28b2bedb 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -39,7 +39,7 @@ function help() echo "-F set the firmware path used by qemu" echo "-C enable code coverage collect" echo "-j set the platform to test" - echo "-T set sanitizer to use in tests(ubsan|tsan|asan)" + echo "-T set sanitizer to use in tests(ubsan|tsan|asan|posan)" echo "-A use the specified wamrc command instead of building it" echo "-r [requirement name] [N [N ...]] specify a requirement name followed by one or more" echo " subrequirement IDs, if no subrequirement is specificed," @@ -1035,6 +1035,11 @@ function trigger() EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SANITIZER=tsan" fi + if [[ "$WAMR_BUILD_SANITIZER" == "posan" ]]; then + echo "Setting run with posan" + EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SANITIZER=posan" + fi + # Make sure we're using the builtin WASI libc implementation # if we're running the wasi certification tests. if [[ $TEST_CASE_ARR ]]; then From 9aaf3599ec69469f6ab3b4373bfb0d8e6b3345b9 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 12:06:06 +0800 Subject: [PATCH 103/198] prevent frame_offset underflow in wasm_loader (#4165) --- core/iwasm/interpreter/wasm_loader.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 8229c6f71..10a20e313 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -11234,6 +11234,13 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, bool disable_emit, preserve_local = false, if_condition_available = true; float32 f32_const; float64 f64_const; + /* + * It means that the fast interpreter detected an exception while preparing, + * typically near the block opcode, but it did not immediately trigger + * the exception. The loader should be capable of identifying it near + * the end opcode and then raising the exception. + */ + bool pending_exception = false; LOG_OP("\nProcessing func | [%d] params | [%d] locals | [%d] return\n", func->param_cell_num, func->local_cell_num, func->ret_cell_num); @@ -11584,6 +11591,16 @@ re_scan: cell_num = wasm_value_type_cell_num( wasm_type->types[wasm_type->param_count - i - 1]); loader_ctx->frame_offset -= cell_num; + + if (loader_ctx->frame_offset + < loader_ctx->frame_offset_bottom) { + LOG_DEBUG( + "frame_offset underflow, roll back and " + "let following stack checker report it\n"); + loader_ctx->frame_offset += cell_num; + pending_exception = true; + break; + } #endif } } @@ -12106,6 +12123,15 @@ re_scan: } } +#if WASM_ENABLE_FAST_INTERP != 0 + if (pending_exception) { + set_error_buf( + error_buf, error_buf_size, + "There is a pending exception needs to be handled"); + goto fail; + } +#endif + break; } From 751cdcf073f41fd3f2bff5e7ac0caddb7074cbf6 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 10 Apr 2025 14:36:20 +0800 Subject: [PATCH 104/198] improve variable naming and code clarity in SIMD operations (#4157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix compilation warning about shadow, like ```sh declaration of ‘val’ shadows a previous local [-Wshadow] ``` --- core/iwasm/interpreter/wasm_interp_fast.c | 40 +++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 21554953d..aa0330568 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -5816,12 +5816,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, goto call_func_from_entry; } #if WASM_ENABLE_SIMDE != 0 -#define SIMD_V128_TO_SIMDE_V128(v) \ +#define SIMD_V128_TO_SIMDE_V128(s_v) \ ({ \ bh_assert(sizeof(V128) == sizeof(simde_v128_t)); \ - simde_v128_t result; \ - bh_memcpy_s(&result, sizeof(simde_v128_t), &(v), sizeof(V128)); \ - result; \ + simde_v128_t se_v; \ + bh_memcpy_s(&se_v, sizeof(simde_v128_t), &(s_v), sizeof(V128)); \ + se_v; \ }) #define SIMDE_V128_TO_SIMD_V128(sv, v) \ @@ -5995,10 +5995,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, /* Splat */ #define SIMD_SPLAT_OP(simde_func, pop_func, val_type) \ do { \ - val_type val = pop_func(); \ + val_type v = pop_func(); \ addr_ret = GET_OFFSET(); \ \ - simde_v128_t simde_result = simde_func(val); \ + simde_v128_t simde_result = simde_func(v); \ \ V128 result; \ SIMDE_V128_TO_SIMD_V128(simde_result, result); \ @@ -6015,7 +6015,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, case SIMD_i8x16_splat: { - uint32 val = POP_I32(); + val = POP_I32(); addr_ret = GET_OFFSET(); simde_v128_t simde_result = simde_wasm_i8x16_splat(val); @@ -6666,19 +6666,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, SIMD_SINGLE_OP(simde_wasm_f32x4_nearest); break; } -#define SIMD_LANE_SHIFT(simde_func) \ - do { \ - int32 count = POP_I32(); \ - V128 v1 = POP_V128(); \ - addr_ret = GET_OFFSET(); \ - \ - simde_v128_t simde_result = \ - simde_func(SIMD_V128_TO_SIMDE_V128(v1), count); \ - \ - V128 result; \ - SIMDE_V128_TO_SIMD_V128(simde_result, result); \ - \ - PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ +#define SIMD_LANE_SHIFT(simde_func) \ + do { \ + int32 c = POP_I32(); \ + V128 v1 = POP_V128(); \ + addr_ret = GET_OFFSET(); \ + \ + simde_v128_t simde_result = \ + simde_func(SIMD_V128_TO_SIMDE_V128(v1), c); \ + \ + V128 result; \ + SIMDE_V128_TO_SIMD_V128(simde_result, result); \ + \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, result); \ } while (0) case SIMD_i8x16_shl: { From cc1903603d6d99f9bbe48f010e61ba954abdbf97 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 15 Apr 2025 09:47:18 +0800 Subject: [PATCH 105/198] fix: Remove unused variables in SIMD_v128_const case (#4197) Fix compiler warnings about unused variables `high` and `low` in the `SIMD_v128_const` case. These variables are only needed inside the `WASM_ENABLE_FAST_INTERP != 0` conditional block, but were incorrectly declared outside of it, causing unused variable warnings. Signed-off-by: Huang Qi --- core/iwasm/interpreter/wasm_loader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 10a20e313..fc68e5966 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -15624,7 +15624,9 @@ re_scan: /* basic operation */ case SIMD_v128_const: { +#if WASM_ENABLE_FAST_INTERP != 0 uint64 high, low; +#endif CHECK_BUF1(p, p_end, 16); #if WASM_ENABLE_FAST_INTERP != 0 wasm_runtime_read_v128(p, &high, &low); From 3bdec3c54b186f2d691e0078de2dadc25142828d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Apr 2025 09:59:20 +0800 Subject: [PATCH 106/198] build(deps): Bump github/codeql-action from 3.28.14 to 3.28.15 (#4198) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.14 to 3.28.15. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.14...v3.28.15) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.15 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 098bd7f9c..ab76a6b5d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.14 + uses: github/codeql-action/init@v3.28.15 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.14 + uses: github/codeql-action/analyze@v3.28.15 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.14 + uses: github/codeql-action/upload-sarif@v3.28.15 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index f0230c23e..39e868dd6 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@362ef4ce205154842cd1d34794abd82bb8f12cd5 + uses: github/codeql-action/upload-sarif@4c3e5362829f0b0bb62ff5f6c938d7f95574c306 with: sarif_file: results.sarif From 46ec863da3ebdf027ff83648f21753d321c3bd7d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 15 Apr 2025 12:48:48 +0900 Subject: [PATCH 107/198] fix false native stack overflow detections with HW_BOUND_CHECK (#4196) In call_wasm_with_hw_bound_check/call_native_with_hw_bound_check, ensure to set up the stack boundary (wasm_exec_env_set_thread_info) before checking the overflow. It seems that the problem was introduced by: https://github.com/bytecodealliance/wasm-micro-runtime/pull/2940 --- core/iwasm/aot/aot_runtime.c | 14 +++++++------- core/iwasm/interpreter/wasm_runtime.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index bf7f51964..55b680502 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -2315,13 +2315,6 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr, #endif bool ret; - /* Check native stack overflow firstly to ensure we have enough - native stack to run the following codes before actually calling - the aot function in invokeNative function. */ - if (!wasm_runtime_detect_native_stack_overflow(exec_env)) { - return false; - } - if (!exec_env_tls) { if (!os_thread_signal_inited()) { aot_set_exception(module_inst, "thread signal env not inited"); @@ -2340,6 +2333,13 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr, } } + /* Check native stack overflow firstly to ensure we have enough + native stack to run the following codes before actually calling + the aot function in invokeNative function. */ + if (!wasm_runtime_detect_native_stack_overflow(exec_env)) { + return false; + } + wasm_exec_env_push_jmpbuf(exec_env, &jmpbuf_node); if (os_setjmp(jmpbuf_node.jmpbuf) == 0) { diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 64719f7f5..3cc2afe04 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -3523,13 +3523,6 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst, #endif bool ret = true; - /* Check native stack overflow firstly to ensure we have enough - native stack to run the following codes before actually calling - the aot function in invokeNative function. */ - if (!wasm_runtime_detect_native_stack_overflow(exec_env)) { - return; - } - if (!exec_env_tls) { if (!os_thread_signal_inited()) { wasm_set_exception(module_inst, "thread signal env not inited"); @@ -3548,6 +3541,13 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst, } } + /* Check native stack overflow firstly to ensure we have enough + native stack to run the following codes before actually calling + the aot function in invokeNative function. */ + if (!wasm_runtime_detect_native_stack_overflow(exec_env)) { + return; + } + wasm_exec_env_push_jmpbuf(exec_env, &jmpbuf_node); if (os_setjmp(jmpbuf_node.jmpbuf) == 0) { From d085d1ccf77b289173d23d5fcab97b6e846fb350 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 15 Apr 2025 12:51:19 +0800 Subject: [PATCH 108/198] Keep fix the CMake compatibility issue (#4180) ``` CMake Error at CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake. Update the VERSION argument value. Or, use the ... syntax to tell CMake that the project requires at least but has been updated to work with policies introduced by or earlier. Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. ``` --- .github/workflows/compilation_on_android_ubuntu.yml | 12 ++++++------ core/iwasm/aot/iwasm_aot.cmake | 7 +++++++ core/iwasm/fast-jit/iwasm_fast_jit.cmake | 8 +++++++- core/iwasm/libraries/lib-rats/lib_rats.cmake | 7 +++++++ core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake | 7 +++++++ core/iwasm/libraries/simde/simde.cmake | 7 +++++++ core/iwasm/libraries/wasi-nn/cmake/Findcjson.cmake | 7 +++++++ .../iwasm/libraries/wasi-nn/cmake/Findllamacpp.cmake | 7 +++++++ .../wasi-nn/cmake/Findtensorflow_lite.cmake | 7 +++++++ samples/wasi-threads/CMakeLists.txt | 1 + tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 2 +- .../fuzz/wasm-mutator-fuzz/workspace/CMakeLists.txt | 2 +- .../test-module-malloc/wasm-app/CMakeLists.txt | 2 +- tests/unit/CMakeLists.txt | 9 ++++++++- tests/unit/aot-stack-frame/CMakeLists.txt | 2 +- tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt | 2 +- tests/unit/aot/CMakeLists.txt | 2 +- tests/unit/compilation/CMakeLists.txt | 2 +- tests/unit/custom-section/CMakeLists.txt | 2 +- tests/unit/custom-section/wasm-apps/CMakeLists.txt | 2 +- tests/unit/gc/CMakeLists.txt | 2 +- tests/unit/interpreter/CMakeLists.txt | 2 +- tests/unit/libc-builtin/CMakeLists.txt | 2 +- tests/unit/linear-memory-aot/CMakeLists.txt | 2 +- tests/unit/linear-memory-wasm/CMakeLists.txt | 2 +- tests/unit/runtime-common/CMakeLists.txt | 2 +- tests/unit/shared-utils/CMakeLists.txt | 2 +- tests/unit/unit_common.cmake | 7 +++++++ tests/unit/wasm-c-api/CMakeLists.txt | 10 +++++++++- tests/unit/wasm-vm/CMakeLists.txt | 2 +- 30 files changed, 104 insertions(+), 26 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 83cd154af..47f613ab2 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -317,7 +317,7 @@ jobs: os: [ubuntu-22.04] wasi_sdk_release: [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", + "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz" ] wabt_release: [ @@ -351,7 +351,7 @@ jobs: cd /opt sudo wget ${{ matrix.wasi_sdk_release }} sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-20.0 wasi-sdk + sudo ln -sf wasi-sdk-25.0-x86_64-linux wasi-sdk - name: download and install wabt run: | @@ -466,7 +466,7 @@ jobs: os: [ubuntu-22.04] wasi_sdk_release: [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", + "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz" ] wabt_release: [ @@ -484,7 +484,7 @@ jobs: cd /opt sudo wget ${{ matrix.wasi_sdk_release }} sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-20.0 wasi-sdk + sudo ln -sf wasi-sdk-25.0-x86_64-linux wasi-sdk - name: download and install wabt run: | @@ -636,7 +636,7 @@ jobs: ] wasi_sdk_release: [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", + "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz" ] include: - os: ubuntu-22.04 @@ -710,7 +710,7 @@ jobs: cd /opt sudo wget ${{ matrix.wasi_sdk_release }} sudo tar -xzf wasi-sdk-*.tar.gz - sudo mv wasi-sdk-20.0 wasi-sdk + sudo ln -sf wasi-sdk-25.0-x86_64-linux wasi-sdk # It is a temporary solution until new wasi-sdk that includes bug fixes is released - name: build wasi-libc from source diff --git a/core/iwasm/aot/iwasm_aot.cmake b/core/iwasm/aot/iwasm_aot.cmake index bb9004bc6..e6d56c43f 100644 --- a/core/iwasm/aot/iwasm_aot.cmake +++ b/core/iwasm/aot/iwasm_aot.cmake @@ -1,6 +1,13 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + set (IWASM_AOT_DIR ${CMAKE_CURRENT_LIST_DIR}) add_definitions (-DWASM_ENABLE_AOT=1) diff --git a/core/iwasm/fast-jit/iwasm_fast_jit.cmake b/core/iwasm/fast-jit/iwasm_fast_jit.cmake index c5012bd36..676258075 100644 --- a/core/iwasm/fast-jit/iwasm_fast_jit.cmake +++ b/core/iwasm/fast-jit/iwasm_fast_jit.cmake @@ -1,8 +1,14 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set (IWASM_FAST_JIT_DIR ${CMAKE_CURRENT_LIST_DIR}) +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) +set (IWASM_FAST_JIT_DIR ${CMAKE_CURRENT_LIST_DIR}) add_definitions(-DWASM_ENABLE_FAST_JIT=1) if (WAMR_BUILD_FAST_JIT_DUMP EQUAL 1) add_definitions(-DWASM_ENABLE_FAST_JIT_DUMP=1) diff --git a/core/iwasm/libraries/lib-rats/lib_rats.cmake b/core/iwasm/libraries/lib-rats/lib_rats.cmake index e17a6b25a..36bad1c51 100644 --- a/core/iwasm/libraries/lib-rats/lib_rats.cmake +++ b/core/iwasm/libraries/lib-rats/lib_rats.cmake @@ -2,6 +2,13 @@ # Copyright (c) 2020-2021 Alibaba Cloud # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + set (LIB_RATS_DIR ${CMAKE_CURRENT_LIST_DIR}) if ("$ENV{SGX_SSL_DIR}" STREQUAL "") diff --git a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake index 7a3bfbdce..fefe0fca2 100644 --- a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake +++ b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake @@ -1,6 +1,13 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR}) set (LIBUV_VERSION v1.46.0) diff --git a/core/iwasm/libraries/simde/simde.cmake b/core/iwasm/libraries/simde/simde.cmake index eeb0e8d1f..60fd6d975 100644 --- a/core/iwasm/libraries/simde/simde.cmake +++ b/core/iwasm/libraries/simde/simde.cmake @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # simde is a header only library +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + set (LIB_SIMDE_DIR ${CMAKE_CURRENT_LIST_DIR}) add_definitions (-DWASM_ENABLE_SIMDE=1) diff --git a/core/iwasm/libraries/wasi-nn/cmake/Findcjson.cmake b/core/iwasm/libraries/wasi-nn/cmake/Findcjson.cmake index 6c921bbc9..c698e8c5f 100644 --- a/core/iwasm/libraries/wasi-nn/cmake/Findcjson.cmake +++ b/core/iwasm/libraries/wasi-nn/cmake/Findcjson.cmake @@ -1,6 +1,13 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + include(FetchContent) set(CJSON_SOURCE_DIR "${WAMR_ROOT_DIR}/core/deps/cjson") diff --git a/core/iwasm/libraries/wasi-nn/cmake/Findllamacpp.cmake b/core/iwasm/libraries/wasi-nn/cmake/Findllamacpp.cmake index 8f4f8d1aa..29dd46390 100644 --- a/core/iwasm/libraries/wasi-nn/cmake/Findllamacpp.cmake +++ b/core/iwasm/libraries/wasi-nn/cmake/Findllamacpp.cmake @@ -1,6 +1,13 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + include(FetchContent) set(LLAMA_SOURCE_DIR "${WAMR_ROOT_DIR}/core/deps/llama.cpp") diff --git a/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake b/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake index d2b3f74e0..2561b5243 100644 --- a/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake +++ b/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake @@ -1,6 +1,13 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + include(FetchContent) set(TFLITE_SOURCE_DIR "${WAMR_ROOT_DIR}/core/deps/tensorflow-src") diff --git a/samples/wasi-threads/CMakeLists.txt b/samples/wasi-threads/CMakeLists.txt index 467f5fd1f..11b58d2ea 100644 --- a/samples/wasi-threads/CMakeLists.txt +++ b/samples/wasi-threads/CMakeLists.txt @@ -49,6 +49,7 @@ set(WAMR_BUILD_LIBC_BUILTIN 1) set(WAMR_BUILD_FAST_INTERP 1) set(WAMR_BUILD_LIBC_WASI 1) set(WAMR_BUILD_LIB_WASI_THREADS 1) +set(WAMR_BUILD_REF_TYPES 1) # compiling and linking flags if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index c0c7622c9..813afa21f 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.14) if (NOT DEFINED CMAKE_C_COMPILER) set (CMAKE_C_COMPILER "clang") diff --git a/tests/fuzz/wasm-mutator-fuzz/workspace/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/workspace/CMakeLists.txt index 5fa171a9c..610de6afe 100644 --- a/tests/fuzz/wasm-mutator-fuzz/workspace/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/workspace/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.14) project(wasm_mutator) diff --git a/tests/standalone/test-module-malloc/wasm-app/CMakeLists.txt b/tests/standalone/test-module-malloc/wasm-app/CMakeLists.txt index c87187709..e75a81b33 100644 --- a/tests/standalone/test-module-malloc/wasm-app/CMakeLists.txt +++ b/tests/standalone/test-module-malloc/wasm-app/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(wasm-app) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 9f7a69229..fa9b400fa 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,10 +1,17 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project(unit-test) +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5) + SET(CMAKE_BUILD_TYPE Debug) # add_definitions (-m32) diff --git a/tests/unit/aot-stack-frame/CMakeLists.txt b/tests/unit/aot-stack-frame/CMakeLists.txt index 9ff066f08..cbdc62f65 100644 --- a/tests/unit/aot-stack-frame/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-aot-stack-frame) diff --git a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt index 9dd9565a5..2becb77c9 100644 --- a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project(wasm-apps-aot-stack-frame) diff --git a/tests/unit/aot/CMakeLists.txt b/tests/unit/aot/CMakeLists.txt index 6b9c70c88..bb2216bdd 100644 --- a/tests/unit/aot/CMakeLists.txt +++ b/tests/unit/aot/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-aot) diff --git a/tests/unit/compilation/CMakeLists.txt b/tests/unit/compilation/CMakeLists.txt index 0941a39cc..65a9dfbda 100644 --- a/tests/unit/compilation/CMakeLists.txt +++ b/tests/unit/compilation/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-compilation) diff --git a/tests/unit/custom-section/CMakeLists.txt b/tests/unit/custom-section/CMakeLists.txt index 1529d0ea6..747a8b126 100644 --- a/tests/unit/custom-section/CMakeLists.txt +++ b/tests/unit/custom-section/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-custom-section) diff --git a/tests/unit/custom-section/wasm-apps/CMakeLists.txt b/tests/unit/custom-section/wasm-apps/CMakeLists.txt index a539dd236..6455db554 100644 --- a/tests/unit/custom-section/wasm-apps/CMakeLists.txt +++ b/tests/unit/custom-section/wasm-apps/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project(wasm-apps-custom-section) diff --git a/tests/unit/gc/CMakeLists.txt b/tests/unit/gc/CMakeLists.txt index e0f70d142..6d9670dfe 100644 --- a/tests/unit/gc/CMakeLists.txt +++ b/tests/unit/gc/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-wamr-gc) diff --git a/tests/unit/interpreter/CMakeLists.txt b/tests/unit/interpreter/CMakeLists.txt index c99908b2e..f0a1d5e22 100644 --- a/tests/unit/interpreter/CMakeLists.txt +++ b/tests/unit/interpreter/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-interpreter) diff --git a/tests/unit/libc-builtin/CMakeLists.txt b/tests/unit/libc-builtin/CMakeLists.txt index 4d88760e7..f39ed4444 100644 --- a/tests/unit/libc-builtin/CMakeLists.txt +++ b/tests/unit/libc-builtin/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-libc-builtin) diff --git a/tests/unit/linear-memory-aot/CMakeLists.txt b/tests/unit/linear-memory-aot/CMakeLists.txt index 549b70ad6..02e96c6d1 100644 --- a/tests/unit/linear-memory-aot/CMakeLists.txt +++ b/tests/unit/linear-memory-aot/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-linear-memory-aot) diff --git a/tests/unit/linear-memory-wasm/CMakeLists.txt b/tests/unit/linear-memory-wasm/CMakeLists.txt index 03e1616d7..a899b8fbe 100644 --- a/tests/unit/linear-memory-wasm/CMakeLists.txt +++ b/tests/unit/linear-memory-wasm/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-linear-memory-wasm) diff --git a/tests/unit/runtime-common/CMakeLists.txt b/tests/unit/runtime-common/CMakeLists.txt index f73756915..21e5a917f 100644 --- a/tests/unit/runtime-common/CMakeLists.txt +++ b/tests/unit/runtime-common/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project(test-runtime-common) diff --git a/tests/unit/shared-utils/CMakeLists.txt b/tests/unit/shared-utils/CMakeLists.txt index c5a43dd0e..47b6b835b 100644 --- a/tests/unit/shared-utils/CMakeLists.txt +++ b/tests/unit/shared-utils/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-shared-utils) diff --git a/tests/unit/unit_common.cmake b/tests/unit/unit_common.cmake index 90ea2eb7c..66c50b7e8 100644 --- a/tests/unit/unit_common.cmake +++ b/tests/unit/unit_common.cmake @@ -1,6 +1,13 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + if (NOT DEFINED WAMR_BUILD_PLATFORM) set (WAMR_BUILD_PLATFORM "linux") endif () diff --git a/tests/unit/wasm-c-api/CMakeLists.txt b/tests/unit/wasm-c-api/CMakeLists.txt index 3b8884e11..9448cd8c3 100644 --- a/tests/unit/wasm-c-api/CMakeLists.txt +++ b/tests/unit/wasm-c-api/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 2.9) +cmake_minimum_required (VERSION 3.14) project (wasm_c_api_test) ################ runtime settings ################ @@ -34,6 +34,14 @@ add_library(vmlib STATIC ${WAMR_RUNTIME_LIB_SOURCE}) ################################################ ################ unit test related ################ + +# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update +# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt +# from 3rd parties that we should not alter. Therefore, in addition to +# changing the `cmake_minimum_required()`, we should also add a configuration +# here that is compatible with earlier versions. +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) + # Add googletest directly to our build. This defines # the gtest and gtest_main targets. diff --git a/tests/unit/wasm-vm/CMakeLists.txt b/tests/unit/wasm-vm/CMakeLists.txt index d13d65aac..6242a48b9 100644 --- a/tests/unit/wasm-vm/CMakeLists.txt +++ b/tests/unit/wasm-vm/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 2.9) +cmake_minimum_required(VERSION 3.14) project (test-wasm-vm) From fc78d67e15e8ee7bdbc1f92f9026415eb1fc4890 Mon Sep 17 00:00:00 2001 From: a seven Date: Thu, 17 Apr 2025 00:04:27 +0800 Subject: [PATCH 109/198] Fix the error of AOT mode on the "i386-windows-msvc" platform (#4183) * Fix errors on the "i386-windows-msvc" platform * Refactor symbol name handling for AOT COFF32 binary format * Fix preprocessor directive placement for Windows compatibility in aot_reloc_x86_32.c --------- Co-authored-by: liang.he@intel.com --- core/iwasm/aot/aot_runtime.c | 34 +++++++++++++ core/iwasm/aot/arch/aot_reloc_x86_32.c | 31 +++++++----- core/iwasm/compilation/aot_emit_aot_file.c | 58 ++++++++++++++-------- 3 files changed, 89 insertions(+), 34 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 55b680502..b2c9ed628 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -3285,8 +3285,25 @@ aot_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 table_elem_idx, cell_num += wasm_value_type_cell_num(ext_ret_types[i]); } +#if WASM_ENABLE_AOT_STACK_FRAME != 0 + void *prev_frame = get_top_frame(exec_env); + if (!is_frame_per_function(exec_env) + && !aot_alloc_frame(exec_env, func_idx)) { + if (argv1 != argv1_buf) + wasm_runtime_free(argv1); + return false; + } +#endif ret = invoke_native_internal(exec_env, func_ptr, func_type, signature, attachment, argv1, argc, argv); +#if WASM_ENABLE_AOT_STACK_FRAME != 0 + /* Free all frames allocated, note that some frames + may be allocated in AOT code and haven't been + freed if exception occurred */ + while (get_top_frame(exec_env) != prev_frame) + aot_free_frame(exec_env); +#endif + if (!ret) { if (argv1 != argv1_buf) wasm_runtime_free(argv1); @@ -3327,8 +3344,25 @@ aot_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 table_elem_idx, return true; } else { +#if WASM_ENABLE_AOT_STACK_FRAME != 0 + void *prev_frame = get_top_frame(exec_env); + /* Only allocate frame for frame-per-call mode; in the + frame-per-function mode the frame is allocated at the + beginning of the function. */ + if (!is_frame_per_function(exec_env) + && !aot_alloc_frame(exec_env, func_idx)) { + return false; + } +#endif ret = invoke_native_internal(exec_env, func_ptr, func_type, signature, attachment, argv, argc, argv); +#if WASM_ENABLE_AOT_STACK_FRAME != 0 + /* Free all frames allocated, note that some frames + may be allocated in AOT code and haven't been + freed if exception occurred */ + while (get_top_frame(exec_env) != prev_frame) + aot_free_frame(exec_env); +#endif if (!ret) goto fail; diff --git a/core/iwasm/aot/arch/aot_reloc_x86_32.c b/core/iwasm/aot/arch/aot_reloc_x86_32.c index 0a423c398..f7f2421f4 100644 --- a/core/iwasm/aot/arch/aot_reloc_x86_32.c +++ b/core/iwasm/aot/arch/aot_reloc_x86_32.c @@ -30,36 +30,39 @@ void __umoddi3(); #pragma function(floor) #pragma function(ceil) -static int64 -__divdi3(int64 a, int64 b) +static int64 __stdcall __divdi3(int64 a, int64 b) { return a / b; } -static uint64 -__udivdi3(uint64 a, uint64 b) +static uint64 __stdcall __udivdi3(uint64 a, uint64 b) { return a / b; } -static int64 -__moddi3(int64 a, int64 b) +static int64 __stdcall __moddi3(int64 a, int64 b) { return a % b; } -static uint64 -__umoddi3(uint64 a, uint64 b) +static uint64 __stdcall __umoddi3(uint64 a, uint64 b) { return a % b; } -#endif -static uint64 -__aulldiv(uint64 a, uint64 b) +static uint64 __stdcall __aulldiv(uint64 a, uint64 b) { return a / b; } +static int64 __stdcall __alldiv(int64 a, int64 b) +{ + return a / b; +} +static int64 __stdcall __allrem(int64 a, int64 b) +{ + return a % b; +} +#endif /* !defined(_WIN32) && !defined(_WIN32_) */ /* clang-format off */ static SymbolMap target_sym_map[] = { @@ -69,7 +72,11 @@ static SymbolMap target_sym_map[] = { REG_SYM(__udivdi3), REG_SYM(__moddi3), REG_SYM(__umoddi3), - REG_SYM(__aulldiv) +#if defined(_WIN32) || defined(_WIN32_) + REG_SYM(__aulldiv), + REG_SYM(__alldiv), + REG_SYM(__allrem) +#endif /* defined(_WIN32) || defined(_WIN32_) */ }; /* clang-format on */ diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index ecb75968f..a41e0da33 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -920,9 +920,11 @@ get_relocations_size(AOTObjectData *obj_data, /* ignore the relocations to aot_func_internal#n in text section for windows platform since they will be applied in aot_emit_text_section */ + + const char *name = relocation->symbol_name; if ((!strcmp(relocation_group->section_name, ".text") || !strcmp(relocation_group->section_name, ".ltext")) - && !strncmp(relocation->symbol_name, AOT_FUNC_INTERNAL_PREFIX, + && !strncmp(name, AOT_FUNC_INTERNAL_PREFIX, strlen(AOT_FUNC_INTERNAL_PREFIX)) && ((!strncmp(obj_data->comp_ctx->target_arch, "x86_64", 6) /* Windows AOT_COFF64_BIN_TYPE */ @@ -2489,8 +2491,8 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset, relocation_count = relocation_group->relocation_count; for (j = 0; j < relocation_count; j++) { /* relocation to aot_func_internal#n */ - if (str_starts_with(relocation->symbol_name, - AOT_FUNC_INTERNAL_PREFIX) + const char *name = relocation->symbol_name; + if (str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX) && ((obj_data->target_info.bin_type == 6 /* AOT_COFF64_BIN_TYPE */ && relocation->relocation_type @@ -2500,8 +2502,7 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset, && relocation->relocation_type == 20 /* IMAGE_REL_I386_REL32 */))) { uint32 func_idx = - atoi(relocation->symbol_name - + strlen(AOT_FUNC_INTERNAL_PREFIX)); + atoi(name + strlen(AOT_FUNC_INTERNAL_PREFIX)); uint64 text_offset, reloc_offset, reloc_addend; bh_assert(func_idx < obj_data->func_count); @@ -3052,6 +3053,27 @@ typedef struct elf64_rela { #define SET_TARGET_INFO_FIELD(f, v, type, little) \ SET_TARGET_INFO_VALUE(f, elf_header->v, type, little) +/* in windows 32, the symbol name may start with '_' */ +static char * +LLVMGetSymbolNameAndUnDecorate(LLVMSymbolIteratorRef si, + AOTTargetInfo target_info) +{ + char *original_name = (char *)LLVMGetSymbolName(si); + if (!original_name) { + return NULL; + } + + if (target_info.bin_type != AOT_COFF32_BIN_TYPE) { + return original_name; + } + + if (*original_name == '_') { + return ++original_name; + } + + return original_name; +} + static bool aot_resolve_target_info(AOTCompContext *comp_ctx, AOTObjectData *obj_data) { @@ -3526,12 +3548,9 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data) } while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) { - if ((name = LLVMGetSymbolName(sym_itr)) - && (!strcmp(name, aot_stack_sizes_alias_name) - /* symbol of COFF32 starts with "_" */ - || (obj_data->target_info.bin_type == AOT_COFF32_BIN_TYPE - && !strncmp(name, "_", 1) - && !strcmp(name + 1, aot_stack_sizes_alias_name)))) { + if ((name = + LLVMGetSymbolNameAndUnDecorate(sym_itr, obj_data->target_info)) + && (!strcmp(name, aot_stack_sizes_alias_name))) { #if 0 /* cf. https://github.com/llvm/llvm-project/issues/67765 */ uint64 sz = LLVMGetSymbolSize(sym_itr); if (sz != sizeof(uint32) * obj_data->func_count @@ -3695,8 +3714,8 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data) } while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) { - if ((name = (char *)LLVMGetSymbolName(sym_itr)) - && str_starts_with(name, prefix)) { + name = LLVMGetSymbolNameAndUnDecorate(sym_itr, obj_data->target_info); + if (name && str_starts_with(name, prefix)) { /* symbol aot_func#n */ func_index = (uint32)atoi(name + strlen(prefix)); if (func_index < obj_data->func_count) { @@ -3734,8 +3753,7 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data) } } } - else if ((name = (char *)LLVMGetSymbolName(sym_itr)) - && str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)) { + else if (name && str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)) { /* symbol aot_func_internal#n */ func_index = (uint32)atoi(name + strlen(AOT_FUNC_INTERNAL_PREFIX)); if (func_index < obj_data->func_count) { @@ -3883,7 +3901,8 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, /* set relocation fields */ relocation->relocation_type = (uint32)type; - relocation->symbol_name = (char *)LLVMGetSymbolName(rel_sym); + relocation->symbol_name = + LLVMGetSymbolNameAndUnDecorate(rel_sym, obj_data->target_info); relocation->relocation_offset = offset; if (!strcmp(group->section_name, ".rela.text.unlikely.") || !strcmp(group->section_name, ".rel.text.unlikely.")) { @@ -3910,12 +3929,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, * Note: aot_stack_sizes_section_name section only contains * stack_sizes table. */ - if (!strcmp(relocation->symbol_name, aot_stack_sizes_name) - /* in windows 32, the symbol name may start with '_' */ - || (strlen(relocation->symbol_name) > 0 - && relocation->symbol_name[0] == '_' - && !strcmp(relocation->symbol_name + 1, - aot_stack_sizes_name))) { + if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)) { /* discard const */ relocation->symbol_name = (char *)aot_stack_sizes_section_name; } From 0ba65326366d6675dcb4fe42a3dc6c8e00703165 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 17 Apr 2025 01:07:08 +0900 Subject: [PATCH 110/198] debug-engine: fix a few type mismatches (#4189) - use strict prototypes complained by GCC `-Wstrict-prototypes` - use `int*` instead of `int32*` Note: on some targets, int32_t is a long. for example, GCC shipped with the recent ESP-IDF has such a configuration. - https://github.com/apache/nuttx/issues/15755#issuecomment-2635652808 - https://github.com/apache/nuttx/pull/16022 - https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/5.0/gcc.html#espressif-toolchain-changes --- .../iwasm/libraries/debug-engine/debug_engine.c | 6 +++--- .../iwasm/libraries/debug-engine/debug_engine.h | 2 +- core/iwasm/libraries/debug-engine/gdbserver.c | 2 +- core/iwasm/libraries/debug-engine/gdbserver.h | 2 +- core/iwasm/libraries/debug-engine/handler.c | 17 +++++++++-------- core/iwasm/libraries/debug-engine/handler.h | 4 ++-- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/iwasm/libraries/debug-engine/debug_engine.c b/core/iwasm/libraries/debug-engine/debug_engine.c index 0ffc78ad9..340e657e8 100644 --- a/core/iwasm/libraries/debug-engine/debug_engine.c +++ b/core/iwasm/libraries/debug-engine/debug_engine.c @@ -58,7 +58,7 @@ static WASMDebugEngine *g_debug_engine; static uint32 current_instance_id = 1; static uint32 -allocate_instance_id() +allocate_instance_id(void) { uint32 id; @@ -302,7 +302,7 @@ wasm_debug_control_thread_destroy(WASMDebugInstance *debug_instance) } static WASMDebugEngine * -wasm_debug_engine_create() +wasm_debug_engine_create(void) { WASMDebugEngine *engine; @@ -326,7 +326,7 @@ wasm_debug_engine_create() } void -wasm_debug_engine_destroy() +wasm_debug_engine_destroy(void) { if (g_debug_engine) { wasm_debug_handler_deinit(); diff --git a/core/iwasm/libraries/debug-engine/debug_engine.h b/core/iwasm/libraries/debug-engine/debug_engine.h index 68738213e..275eeaad1 100644 --- a/core/iwasm/libraries/debug-engine/debug_engine.h +++ b/core/iwasm/libraries/debug-engine/debug_engine.h @@ -133,7 +133,7 @@ bool wasm_debug_engine_init(char *ip_addr, int32 process_port); void -wasm_debug_engine_destroy(); +wasm_debug_engine_destroy(void); WASMExecEnv * wasm_debug_instance_get_current_env(WASMDebugInstance *instance); diff --git a/core/iwasm/libraries/debug-engine/gdbserver.c b/core/iwasm/libraries/debug-engine/gdbserver.c index fbd876ac3..2cf1e686a 100644 --- a/core/iwasm/libraries/debug-engine/gdbserver.c +++ b/core/iwasm/libraries/debug-engine/gdbserver.c @@ -38,7 +38,7 @@ static const struct packet_handler_elem packet_handler_table[255] = { }; WASMGDBServer * -wasm_create_gdbserver(const char *host, int32 *port) +wasm_create_gdbserver(const char *host, int *port) { bh_socket_t listen_fd = (bh_socket_t)-1; WASMGDBServer *server; diff --git a/core/iwasm/libraries/debug-engine/gdbserver.h b/core/iwasm/libraries/debug-engine/gdbserver.h index 9e279a2e6..41ed94dec 100644 --- a/core/iwasm/libraries/debug-engine/gdbserver.h +++ b/core/iwasm/libraries/debug-engine/gdbserver.h @@ -51,7 +51,7 @@ typedef struct WASMGDBServer { } WASMGDBServer; WASMGDBServer * -wasm_create_gdbserver(const char *host, int32 *port); +wasm_create_gdbserver(const char *host, int *port); bool wasm_gdbserver_listen(WASMGDBServer *server); diff --git a/core/iwasm/libraries/debug-engine/handler.c b/core/iwasm/libraries/debug-engine/handler.c index 905ca2f7c..a5267d770 100644 --- a/core/iwasm/libraries/debug-engine/handler.c +++ b/core/iwasm/libraries/debug-engine/handler.c @@ -34,7 +34,7 @@ static char *tmpbuf; static korp_mutex tmpbuf_lock; int -wasm_debug_handler_init() +wasm_debug_handler_init(void) { int ret; tmpbuf = wasm_runtime_malloc(MAX_PACKET_SIZE); @@ -51,7 +51,7 @@ wasm_debug_handler_init() } void -wasm_debug_handler_deinit() +wasm_debug_handler_deinit(void) { wasm_runtime_free(tmpbuf); tmpbuf = NULL; @@ -204,8 +204,7 @@ handle_general_query(WASMGDBServer *server, char *payload) if (!strcmp(name, "Supported")) { os_mutex_lock(&tmpbuf_lock); snprintf(tmpbuf, MAX_PACKET_SIZE, - "qXfer:libraries:read+;PacketSize=%" PRIx32 ";", - MAX_PACKET_SIZE); + "qXfer:libraries:read+;PacketSize=%x;", MAX_PACKET_SIZE); write_packet(server, tmpbuf); os_mutex_unlock(&tmpbuf_lock); } @@ -384,7 +383,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) if (status == 0) { os_mutex_lock(&tmpbuf_lock); - snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02x", status); + snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02" PRIx32, status); write_packet(server, tmpbuf); os_mutex_unlock(&tmpbuf_lock); return; @@ -400,8 +399,9 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) os_mutex_lock(&tmpbuf_lock); // TODO: how name a wasm thread? - len += snprintf(tmpbuf, MAX_PACKET_SIZE, "T%02xthread:%" PRIx64 ";name:%s;", - gdb_status, (uint64)(uintptr_t)tid, "nobody"); + len += snprintf(tmpbuf, MAX_PACKET_SIZE, + "T%02" PRIx32 "thread:%" PRIx64 ";name:%s;", gdb_status, + (uint64)(uintptr_t)tid, "nobody"); if (tids_count > 0) { len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "threads:"); while (i < tids_count) { @@ -624,7 +624,8 @@ void handle_get_write_memory(WASMGDBServer *server, char *payload) { size_t hex_len; - int32 offset, act_len; + int offset; + int32 act_len; uint64 maddr, mlen; char *buff; bool ret; diff --git a/core/iwasm/libraries/debug-engine/handler.h b/core/iwasm/libraries/debug-engine/handler.h index af2566da5..698663c7b 100644 --- a/core/iwasm/libraries/debug-engine/handler.h +++ b/core/iwasm/libraries/debug-engine/handler.h @@ -9,10 +9,10 @@ #include "gdbserver.h" int -wasm_debug_handler_init(); +wasm_debug_handler_init(void); void -wasm_debug_handler_deinit(); +wasm_debug_handler_deinit(void); void handle_interrupt(WASMGDBServer *server); From 955fce5664808d08d1e4c8fc8a282a06da1e3fb7 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 00:07:25 +0800 Subject: [PATCH 111/198] Replace CMAKE_CURRENT_FUNCTION_LIST_DIR (#4200) `CMAKE_CURRENT_FUNCTION_LIST_DIR` is added in version 3.17 and currently most of `cmake_minimum_required()` with 3.14. Refer to https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.html --- build-scripts/package.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-scripts/package.cmake b/build-scripts/package.cmake index 4ebb1d799..67cb8fc23 100644 --- a/build-scripts/package.cmake +++ b/build-scripts/package.cmake @@ -1,6 +1,8 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +set(_WAMR_BUILD_SCRIPTS_DIR "${CMAKE_CURRENT_LIST_DIR}") + function(install_iwasm_package) install (EXPORT iwasmTargets FILE iwasmTargets.cmake @@ -9,7 +11,7 @@ function(install_iwasm_package) ) include (CMakePackageConfigHelpers) - configure_package_config_file (${CMAKE_CURRENT_FUNCTION_LIST_DIR}/iwasmConfig.cmake.in + configure_package_config_file (${_WAMR_BUILD_SCRIPTS_DIR}/iwasmConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake" INSTALL_DESTINATION lib/cmake/iwasm ) From fc1527eacd75727d28eb9f769db6faadac543ead Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 15:07:46 +0800 Subject: [PATCH 112/198] Raise CI runner to ubuntu 22.04 (#4191) update workflows and scripts for Ubuntu 22.04 compatibility. It includes - install Intel SGX SDK 2.25 - use a reusable action to install sgx required - keep improve error handling in AOT compilation process in runtest.py add a workaround to fix receiving a shutdown signal problem. Refers to https://github.com/actions/runner-images/issues/6680 and https://github.com/actions/runner-images/discussions/7188 --- .github/actions/install-linux-sgx/action.yml | 47 ++++++++ .github/workflows/build_llvm_libraries.yml | 8 -- .github/workflows/coding_guidelines.yml | 2 +- .github/workflows/compilation_on_sgx.yml | 109 +++++++----------- .github/workflows/nightly_run.yml | 74 +++--------- .github/workflows/release_process.yml | 57 --------- ci/coding_guidelines_check.py | 17 ++- .../spec-test-script/runtest.py | 7 +- tests/wamr-test-suites/test_wamr.sh | 2 +- 9 files changed, 122 insertions(+), 201 deletions(-) create mode 100644 .github/actions/install-linux-sgx/action.yml diff --git a/.github/actions/install-linux-sgx/action.yml b/.github/actions/install-linux-sgx/action.yml new file mode 100644 index 000000000..17757573d --- /dev/null +++ b/.github/actions/install-linux-sgx/action.yml @@ -0,0 +1,47 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Always follow https://download.01.org/intel-sgx/latest/linux-latest/docs/ + +name: "Install Intel SGX SDK" +description: "Installs the Intel SGX SDK and necessary libraries for Ubuntu." +author: "Intel Corporation" +inputs: + os: + description: "Operating system to install on (ubuntu-22.04)" + required: true + +runs: + using: "composite" + steps: + - name: Check Runner OS + if: ${{ inputs.os != 'ubuntu-22.04' }} + shell: bash + run: | + echo "::error title=⛔ error hint::Only support ubuntu-22.04 for now" + exit 1 + + - name: Create installation directory + shell: bash + run: sudo mkdir -p /opt/intel + + - name: Download and install SGX SDK on ubuntu-22.04 + if: ${{ inputs.os == 'ubuntu-22.04' }} + shell: bash + run: | + sudo wget -O sgx_linux_x64_sdk.bin https://download.01.org/intel-sgx/sgx-linux/2.25/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.25.100.3.bin + sudo chmod +x sgx_linux_x64_sdk.bin + echo 'yes' | sudo ./sgx_linux_x64_sdk.bin + working-directory: /opt/intel + + - name: Add SGX repository and install libraries + shell: bash + run: | + echo "deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/intel-sgx.list + wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add - + sudo apt update + sudo apt install -y libsgx-launch libsgx-urts + + - name: Source SGX SDK environment + shell: bash + run: source /opt/intel/sgxsdk/environment diff --git a/.github/workflows/build_llvm_libraries.yml b/.github/workflows/build_llvm_libraries.yml index e4b7732bc..97e665c0b 100644 --- a/.github/workflows/build_llvm_libraries.yml +++ b/.github/workflows/build_llvm_libraries.yml @@ -89,14 +89,6 @@ jobs: ./core/deps/llvm/build/share key: ${{ steps.create_lib_cache_key.outputs.key}} - - uses: actions/cache@v4 - with: - path: ~/.ccache - key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }} - restore-keys: | - 0-ccache-${{ inputs.os }} - if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-20.04' - - uses: actions/cache@v4 with: path: ~/.cache/ccache diff --git a/.github/workflows/coding_guidelines.yml b/.github/workflows/coding_guidelines.yml index 569237778..b1f59ce3b 100644 --- a/.github/workflows/coding_guidelines.yml +++ b/.github/workflows/coding_guidelines.yml @@ -19,7 +19,7 @@ permissions: jobs: compliance_job: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: checkout uses: actions/checkout@v4 diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index b865a59fe..836f5c747 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -53,6 +53,10 @@ env: FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1" LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1" LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0" + # For Spec Test + DEFAULT_TEST_OPTIONS: "-s spec -x -p -b" + SIMD_TEST_OPTIONS: "-s spec -x -p -b -S" + XIP_TEST_OPTIONS: "-s spec -x -p -b -X" permissions: contents: read @@ -64,7 +68,7 @@ jobs: actions: write uses: ./.github/workflows/build_llvm_libraries.yml with: - os: "ubuntu-20.04" + os: ubuntu-22.04 arch: "X86" build_iwasm: @@ -102,7 +106,7 @@ jobs: "-DWAMR_DISABLE_HW_BOUND_CHECK=1", "-DWAMR_BUILD_SGX_IPFS=1", ] - os: [ubuntu-20.04] + os: [ubuntu-22.04] platform: [linux-sgx] exclude: # incompatible mode and feature @@ -110,22 +114,14 @@ jobs: - make_options_run_mode: $AOT_BUILD_OPTIONS make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1" steps: - - name: install SGX SDK and necessary libraries - run: | - mkdir -p /opt/intel - cd /opt/intel - wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin - chmod +x sgx_linux_x64_sdk_2.15.100.3.bin - echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin - echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list - wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add - - sudo apt update - sudo apt install -y libsgx-launch libsgx-urts - source /opt/intel/sgxsdk/environment - - name: checkout uses: actions/checkout@v4 + - name: install SGX SDK and necessary libraries + uses: ./.github/actions/install-linux-sgx + with: + os: ${{ matrix.os }} + - name: Build iwasm run: | mkdir build && cd build @@ -150,7 +146,7 @@ jobs: #$LLVM_LAZY_JIT_BUILD_OPTIONS, #$LLVM_EAGER_JIT_BUILD_OPTIONS, ] - os: [ubuntu-20.04] + os: [ubuntu-22.04] wasi_sdk_release: [ "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz", @@ -165,7 +161,7 @@ jobs: ] platform: [linux-sgx] include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }} steps: @@ -186,33 +182,10 @@ jobs: sudo tar -xzf wabt-1.0.31-*.tar.gz sudo mv wabt-1.0.31 wabt - - name: build wasi-libc (needed for wasi-threads) - run: | - mkdir wasi-libc - cd wasi-libc - git init - # "Fix a_store operation in atomic.h" commit on main branch - git fetch https://github.com/WebAssembly/wasi-libc \ - 1dfe5c302d1c5ab621f7abf04620fae92700fd22 - git checkout FETCH_HEAD - make \ - AR=/opt/wasi-sdk/bin/llvm-ar \ - NM=/opt/wasi-sdk/bin/llvm-nm \ - CC=/opt/wasi-sdk/bin/clang \ - THREAD_MODEL=posix - working-directory: core/deps - - name: install SGX SDK and necessary libraries - run: | - mkdir -p /opt/intel - cd /opt/intel - wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin - chmod +x sgx_linux_x64_sdk_2.15.100.3.bin - echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin - echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list - wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add - - sudo apt update - sudo apt install -y libsgx-launch libsgx-urts + uses: ./.github/actions/install-linux-sgx + with: + os: ${{ matrix.os }} - name: Build iwasm for testing samples run: | @@ -271,28 +244,32 @@ jobs: spec_test_default: needs: [build_iwasm, build_llvm_libraries] - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} strategy: matrix: - running_mode: ["classic-interp", "fast-interp", "aot", "fast-jit"] - # FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04 - test_option: ["-x -p -s spec -P", "-x -p -s spec -S -P", "-x -p -s spec -X -P"] - llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"] + #(workaround) disable "fast-interp" because of SIMDE + running_mode: ["classic-interp", "aot", "fast-jit"] + test_option: + [$DEFAULT_TEST_OPTIONS, $SIMD_TEST_OPTIONS, $XIP_TEST_OPTIONS] + os: [ubuntu-22.04] exclude: # classic-interp, fast-interp and fast-jit don't support simd - running_mode: "classic-interp" - test_option: "-x -p -s spec -S -P" + test_option: $SIMD_TEST_OPTIONS - running_mode: "fast-interp" - test_option: "-x -p -s spec -S -P" + test_option: $SIMD_TEST_OPTIONS - running_mode: "fast-jit" - test_option: "-x -p -s spec -S -P" + test_option: $SIMD_TEST_OPTIONS # classic-interp, fast-interp and fast jit don't support XIP - running_mode: "classic-interp" - test_option: "-x -p -s spec -X -P" + test_option: $XIP_TEST_OPTIONS - running_mode: "fast-interp" - test_option: "-x -p -s spec -X -P" + test_option: $XIP_TEST_OPTIONS - running_mode: "fast-jit" - test_option: "-x -p -s spec -X -P" + test_option: $XIP_TEST_OPTIONS + include: + - os: ubuntu-22.04 + llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }} steps: - name: checkout @@ -316,19 +293,19 @@ jobs: run: echo "::error::can not get prebuilt llvm libraries" && exit 1 - name: install SGX SDK and necessary libraries - run: | - mkdir -p /opt/intel - cd /opt/intel - wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin - chmod +x sgx_linux_x64_sdk_2.15.100.3.bin - echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin - echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list - wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add - - sudo apt update - sudo apt install -y libsgx-launch libsgx-urts + uses: ./.github/actions/install-linux-sgx + with: + os: ${{ matrix.os }} - - name: install for wabt compilation - run: sudo apt update && sudo apt install -y ninja-build + #workaround about a https://github.com/actions/runner-images/issues/6680#issuecomment-2640923706 + - name: Increase swapfile + run: | + sudo swapoff -a + sudo fallocate -l 15G /swapfile + sudo chmod 600 /swapfile + sudo mkswap /swapfile + sudo swapon /swapfile + sudo swapon --show - name: run spec tests run: | diff --git a/.github/workflows/nightly_run.yml b/.github/workflows/nightly_run.yml index dacdbc42d..dec06e327 100644 --- a/.github/workflows/nightly_run.yml +++ b/.github/workflows/nightly_run.yml @@ -48,15 +48,7 @@ permissions: contents: read jobs: - build_llvm_libraries_on_ubuntu_2004: - permissions: - contents: read - actions: write - uses: ./.github/workflows/build_llvm_libraries.yml - with: - os: "ubuntu-20.04" - arch: "X86" - build_llvm_libraries_on_ubuntu_2204: + build_llvm_libraries_on_ubuntu: permissions: contents: read actions: write @@ -66,16 +58,13 @@ jobs: arch: "X86" build_wamrc: - needs: - [ - build_llvm_libraries_on_ubuntu_2004, - ] + needs: build_llvm_libraries_on_ubuntu runs-on: ${{ matrix.os }} strategy: matrix: include: - - os: ubuntu-20.04 - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} + - os: ubuntu-22.04 + llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} steps: - name: checkout uses: actions/checkout@v4 @@ -106,10 +95,7 @@ jobs: working-directory: wamr-compiler build_iwasm: - needs: - [ - build_llvm_libraries_on_ubuntu_2004, - ] + needs: build_llvm_libraries_on_ubuntu runs-on: ${{ matrix.os }} strategy: matrix: @@ -144,7 +130,7 @@ jobs: "-DWAMR_BUILD_MULTI_MEMORY=1", "-DWAMR_BUILD_SHARED=1", ] - os: [ubuntu-20.04] + os: [ubuntu-22.04] platform: [android, linux] exclude: # incompatible feature and platform @@ -241,8 +227,8 @@ jobs: - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS platform: android include: - - os: ubuntu-20.04 - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} + - os: ubuntu-22.04 + llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} steps: - name: checkout @@ -375,12 +361,7 @@ jobs: working-directory: wamr/product-mini/platforms/linux build_samples_wasm_c_api: - needs: - [ - build_iwasm, - build_llvm_libraries_on_ubuntu_2004, - build_wamrc, - ] + needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc] runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -396,7 +377,7 @@ jobs: $LLVM_EAGER_JIT_BUILD_OPTIONS, $MULTI_TIER_JIT_BUILD_OPTIONS, ] - os: [ubuntu-20.04] + os: [ubuntu-22.04] wasi_sdk_release: [ "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", @@ -406,8 +387,8 @@ jobs: "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", ] include: - - os: ubuntu-20.04 - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} + - os: ubuntu-22.04 + llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} exclude: - make_options: $MULTI_TIER_JIT_BUILD_OPTIONS sanitizer: asan @@ -457,16 +438,11 @@ jobs: working-directory: samples/wasm-c-api build_samples_others: - needs: - [ - build_iwasm, - build_llvm_libraries_on_ubuntu_2004, - build_wamrc, - ] + needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc] runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04] + os: [ubuntu-22.04] wasi_sdk_release: [ "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", @@ -476,8 +452,8 @@ jobs: "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", ] include: - - os: ubuntu-20.04 - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} + - os: ubuntu-22.04 + llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} steps: - name: checkout uses: actions/checkout@v4 @@ -613,18 +589,12 @@ jobs: ./shared_heap_test --aot test: - needs: - [ - build_iwasm, - build_llvm_libraries_on_ubuntu_2004, - build_llvm_libraries_on_ubuntu_2204, - build_wamrc, - ] + needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc] runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-22.04] sanitizer: ["", "ubsan", "asan", "tsan"] running_mode: [ @@ -648,17 +618,11 @@ jobs: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", ] include: - - os: ubuntu-20.04 - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} - ubuntu_version: "20.04" - os: ubuntu-22.04 - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} + llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} ubuntu_version: "22.04" exclude: - # incompatible modes and features - - os: ubuntu-20.04 - sanitizer: tsan # asan works only for aot now - running_mode: "classic-interp" sanitizer: asan diff --git a/.github/workflows/release_process.yml b/.github/workflows/release_process.yml index 031d57884..ad751f870 100644 --- a/.github/workflows/release_process.yml +++ b/.github/workflows/release_process.yml @@ -58,16 +58,6 @@ jobs: # # LLVM_LIBRARIES - build_llvm_libraries_on_ubuntu_2004: - permissions: - contents: read - actions: write - needs: [create_tag, create_release] - uses: ./.github/workflows/build_llvm_libraries.yml - with: - os: "ubuntu-20.04" - arch: "AArch64 ARM Mips RISCV X86" - build_llvm_libraries_on_ubuntu_2204: permissions: contents: read @@ -100,18 +90,6 @@ jobs: # # WAMRC - release_wamrc_on_ubuntu_2004: - permissions: - contents: write # upload release artifact - needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2004] - uses: ./.github/workflows/build_wamrc.yml - with: - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} - release: true - runner: ubuntu-20.04 - upload_url: ${{ needs.create_release.outputs.upload_url }} - ver_num: ${{ needs.create_tag.outputs.new_ver}} - release_wamrc_on_ubuntu_2204: permissions: contents: write # upload release artifact @@ -150,18 +128,6 @@ jobs: # # IWASM - release_iwasm_on_ubuntu_2004: - permissions: - contents: write # upload release artifact - needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2004] - uses: ./.github/workflows/build_iwasm_release.yml - with: - cwd: product-mini/platforms/linux - llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} - runner: ubuntu-20.04 - upload_url: ${{ needs.create_release.outputs.upload_url }} - ver_num: ${{ needs.create_tag.outputs.new_ver}} - release_iwasm_on_ubuntu_2204: permissions: contents: write # upload release artifact @@ -200,19 +166,6 @@ jobs: # # WAMR_SDK - release_wamr_sdk_on_ubuntu_2004: - permissions: - contents: write # upload release artifact - needs: [create_tag, create_release] - uses: ./.github/workflows/build_wamr_sdk.yml - with: - config_file: wamr_config_ubuntu_release.cmake - runner: ubuntu-20.04 - upload_url: ${{ needs.create_release.outputs.upload_url }} - ver_num: ${{ needs.create_tag.outputs.new_ver}} - wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz - wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git - release_wamr_sdk_on_ubuntu_2204: permissions: contents: write # upload release artifact @@ -264,16 +217,6 @@ jobs: # # WAMR_LLDB - release_wamr_lldb_on_ubuntu_2004: - permissions: - contents: write # upload release artifact - needs: [create_tag, create_release] - uses: ./.github/workflows/build_wamr_lldb.yml - with: - runner: ubuntu-20.04 - upload_url: ${{ needs.create_release.outputs.upload_url }} - ver_num: ${{ needs.create_tag.outputs.new_ver}} - release_wamr_lldb_on_ubuntu_2204: permissions: contents: write # upload release artifact diff --git a/ci/coding_guidelines_check.py b/ci/coding_guidelines_check.py index 919a1f56c..5432080f1 100644 --- a/ci/coding_guidelines_check.py +++ b/ci/coding_guidelines_check.py @@ -13,8 +13,8 @@ import subprocess import sys import unittest -CLANG_FORMAT_CMD = "clang-format-12" -GIT_CLANG_FORMAT_CMD = "git-clang-format-12" +CLANG_FORMAT_CMD = "clang-format-14" +GIT_CLANG_FORMAT_CMD = "git-clang-format-14" # glob style patterns EXCLUDE_PATHS = [ @@ -32,7 +32,7 @@ EXCLUDE_PATHS = [ "**/tests/wamr-test-suites/workspace/*", ] -C_SUFFIXES = [".c", ".cpp", ".h"] +C_SUFFIXES = [".c", ".cc", ".cpp", ".h"] INVALID_DIR_NAME_SEGMENT = r"([a-zA-Z0-9]+\_[a-zA-Z0-9]+)" INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)" @@ -93,20 +93,19 @@ def run_clang_format(file_path: Path, root: Path) -> bool: def run_clang_format_diff(root: Path, commits: str) -> bool: """ - Use `clang-format-12` or `git-clang-format-12` to check code format of + Use `clang-format-14` or `git-clang-format-14` to check code format of the PR, with a commit range specified. It is required to format the code before committing the PR, or it might fail to pass the CI check: - 1. Install clang-format-12.0.0 - Normally we can install it by `sudo apt-get install clang-format-12`, - or download the `clang+llvm-12.0.0-xxx-tar.xz` package from - https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0 + 1. Install clang-format-14.0.0 + Normally we can install it by `sudo apt-get install clang-format-14`, + or download the package from https://github.com/llvm/llvm-project/releases and install it 2. Format the C/C++ source file ``` shell cd path/to/wamr/root - clang-format-12 --style file -i path/to/file + clang-format-14 --style file -i path/to/file ``` The code wrapped by `/* clang-format off */` and `/* clang-format on */` diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index ae418a60d..8de001af6 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -1541,11 +1541,10 @@ if __name__ == "__main__": if test_aot: new_module_aot = os.path.join(tempfile.gettempdir(), name_new + ".aot") - r = compile_wasm_to_aot(new_module, new_module_aot, True, opts, r) try: - assert_prompt(r, ['Compile success'], opts.start_timeout, True) - except: - raise Exception("compile wasm to aot failed") + compile_wasm_to_aot(new_module, new_module_aot, None, opts, r) + except Exception as e: + raise Exception(f"compile wasm to aot failed. {e}") # add aot module into temp_file_repo[] temp_file_repo.append(new_module_aot) else: diff --git a/tests/wamr-test-suites/test_wamr.sh b/tests/wamr-test-suites/test_wamr.sh index b28b2bedb..57cef635f 100755 --- a/tests/wamr-test-suites/test_wamr.sh +++ b/tests/wamr-test-suites/test_wamr.sh @@ -361,7 +361,7 @@ function sightglass_test() function setup_wabt() { - WABT_VERSION=1.0.36 + WABT_VERSION=1.0.37 if [ ${WABT_BINARY_RELEASE} == "YES" ]; then echo "download a binary release and install" local WAT2WASM=${WORK_DIR}/wabt/out/gcc/Release/wat2wasm From 996758cd4a32f5c5c04af4f6640ae1c510f0916d Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 15:21:02 +0800 Subject: [PATCH 113/198] Remove the dlen to optimize it. (#4193) There are two reasons for this optimization: - The value of dlen can equal 0x1_0000_0000, even in wasm32 mode, because it is derived from (4G-0). This results in a truncation when it is passed to b_memmove_s(). Consequently, s1max becomes 0 and n is greater than s1max. To correct this, a longer type is required. - The dlen is only used to check if there is enough space in b_memmove_s(). However, from a different angle, after confirming that both src+len and dst+len are within the memory range, we can be assured and there is no need for this explicit check. --- core/iwasm/interpreter/wasm_interp_classic.c | 35 ++++++++++---------- core/iwasm/interpreter/wasm_interp_fast.c | 27 +++++++++------ 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index d504e984c..41ac4c724 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -5784,7 +5784,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, { mem_offset_t dst, src, len; uint8 *mdst, *msrc; - uint64 dlen; len = POP_MEM_OFFSET(); src = POP_MEM_OFFSET(); @@ -5797,24 +5796,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, /* skip dst memidx */ frame_ip += 1; #endif + // TODO: apply memidx #if WASM_ENABLE_THREAD_MGR != 0 linear_mem_size = get_linear_mem_size(); #endif - - dlen = linear_mem_size - dst; - /* dst boundary check */ #ifndef OS_ENABLE_HW_BOUND_CHECK CHECK_BULK_MEMORY_OVERFLOW(dst, len, mdst); -#if WASM_ENABLE_SHARED_HEAP != 0 - if (app_addr_in_shared_heap((uint64)dst, len)) - dlen = shared_heap_end_off - dst + 1; -#endif #else /* else of OS_ENABLE_HW_BOUND_CHECK */ #if WASM_ENABLE_SHARED_HEAP != 0 if (app_addr_in_shared_heap((uint64)dst, len)) { shared_heap_addr_app_to_native((uint64)dst, mdst); - dlen = shared_heap_end_off - dst + 1; } else #endif @@ -5832,6 +5824,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, /* skip src memidx */ frame_ip += 1; #endif + // TODO: apply memidx #if WASM_ENABLE_THREAD_MGR != 0 linear_mem_size = get_linear_mem_size(); #endif @@ -5851,15 +5844,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, } #endif -#if WASM_ENABLE_MEMORY64 == 0 - /* allowing the destination and source to overlap */ - bh_memmove_s(mdst, (uint32)dlen, msrc, (uint32)len); -#else - /* use memmove when memory64 is enabled since len - may be larger than UINT32_MAX */ - memmove(mdst, msrc, len); - (void)dlen; -#endif + /* + * avoid unnecessary operations + * + * since dst and src both are valid indexes in the + * linear memory, mdst and msrc can't be NULL + * + * The spec. converts memory.copy into i32.load8 and + * i32.store8; the following are runtime-specific + * optimizations. + * + */ + if (len && mdst != msrc) { + /* allowing the destination and source to overlap */ + memmove(mdst, msrc, len); + } break; } case WASM_OP_MEMORY_FILL: diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index aa0330568..f02f3f2f0 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -5163,7 +5163,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, { uint32 dst, src, len; uint8 *mdst, *msrc; - uint64 dlen; len = POP_I32(); src = POP_I32(); @@ -5173,15 +5172,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, linear_mem_size = get_linear_mem_size(); #endif - dlen = linear_mem_size - dst; - #ifndef OS_ENABLE_HW_BOUND_CHECK CHECK_BULK_MEMORY_OVERFLOW(src, len, msrc); CHECK_BULK_MEMORY_OVERFLOW(dst, len, mdst); -#if WASM_ENABLE_SHARED_HEAP != 0 - if (app_addr_in_shared_heap((uint64)dst, len)) - dlen = shared_heap_end_off - dst + 1; -#endif #else /* else of OS_ENABLE_HW_BOUND_CHECK */ #if WASM_ENABLE_SHARED_HEAP != 0 if (app_addr_in_shared_heap((uint64)src, len)) @@ -5197,7 +5190,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if WASM_ENABLE_SHARED_HEAP != 0 if (app_addr_in_shared_heap((uint64)dst, len)) { shared_heap_addr_app_to_native((uint64)dst, mdst); - dlen = shared_heap_end_off - dst + 1; } else #endif @@ -5208,8 +5200,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, } #endif /* end of OS_ENABLE_HW_BOUND_CHECK */ - /* allowing the destination and source to overlap */ - bh_memmove_s(mdst, (uint32)dlen, msrc, len); + /* + * avoid unnecessary operations + * + * since dst and src both are valid indexes in the + * linear memory, mdst and msrc can't be NULL + * + * The spec. converts memory.copy into i32.load8 and + * i32.store8; the following are runtime-specific + * optimizations. + * + */ + if (len && mdst != msrc) { + /* allowing the destination and source to overlap */ + memmove(mdst, msrc, len); + } break; } case WASM_OP_MEMORY_FILL: @@ -7488,7 +7493,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if WASM_ENABLE_LABELS_AS_VALUES == 0 continue; #else - FETCH_OPCODE_AND_DISPATCH(); + FETCH_OPCODE_AND_DISPATCH(); #endif #if WASM_ENABLE_TAIL_CALL != 0 || WASM_ENABLE_GC != 0 From ecb47d9326ec70f7001ae71f515dbf481ea33171 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 15:22:23 +0800 Subject: [PATCH 114/198] Add missing casts and improve error handling in performance map functions (#4202) Wrong type of arguments to formatting function. --- core/iwasm/aot/aot_perf_map.c | 46 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/core/iwasm/aot/aot_perf_map.c b/core/iwasm/aot/aot_perf_map.c index 701929996..b072c9851 100644 --- a/core/iwasm/aot/aot_perf_map.c +++ b/core/iwasm/aot/aot_perf_map.c @@ -31,8 +31,15 @@ get_func_size(const AOTModule *module, struct func_info *sorted_func_ptrs, static int compare_func_ptrs(const void *f1, const void *f2) { - return (intptr_t)((struct func_info *)f1)->ptr - - (intptr_t)((struct func_info *)f2)->ptr; + uintptr_t ptr1 = (uintptr_t)((struct func_info *)f1)->ptr; + uintptr_t ptr2 = (uintptr_t)((struct func_info *)f2)->ptr; + + if (ptr1 < ptr2) + return -1; + else if (ptr1 > ptr2) + return 1; + else + return 0; } static struct func_info * @@ -45,8 +52,8 @@ sort_func_ptrs(const AOTModule *module, char *error_buf, uint32 error_buf_size) content_len = (uint64)sizeof(struct func_info) * module->func_count; sorted_func_ptrs = wasm_runtime_malloc(content_len); if (!sorted_func_ptrs) { - snprintf(error_buf, error_buf_size, - "allocate memory failed when creating perf map"); + (void)snprintf(error_buf, error_buf_size, + "allocate memory failed when creating perf map"); return NULL; } @@ -77,7 +84,8 @@ aot_create_perf_map(const AOTModule *module, char *error_buf, if (!sorted_func_ptrs) goto quit; - snprintf(perf_map_path, sizeof(perf_map_path) - 1, "/tmp/perf-%d.map", pid); + (void)snprintf(perf_map_path, sizeof(perf_map_path) - 1, "/tmp/perf-%d.map", + pid); perf_map = fopen(perf_map_path, "a"); if (!perf_map) { LOG_WARNING("warning: can't create /tmp/perf-%d.map, because %s", pid, @@ -88,19 +96,23 @@ aot_create_perf_map(const AOTModule *module, char *error_buf, const char *module_name = aot_get_module_name((AOTModule *)module); for (i = 0; i < module->func_count; i++) { memset(perf_map_info, 0, 128); - if (strlen(module_name) > 0) - snprintf(perf_map_info, 128, PRIxPTR " %x [%s]#aot_func#%u\n", - (uintptr_t)sorted_func_ptrs[i].ptr, - get_func_size(module, sorted_func_ptrs, i), module_name, - sorted_func_ptrs[i].idx); - else - snprintf(perf_map_info, 128, PRIxPTR " %x aot_func#%u\n", - (uintptr_t)sorted_func_ptrs[i].ptr, - get_func_size(module, sorted_func_ptrs, i), - sorted_func_ptrs[i].idx); + if (strlen(module_name) > 0) { + (void)snprintf(perf_map_info, 128, + "%" PRIxPTR " %x [%s]#aot_func#%u\n", + (uintptr_t)sorted_func_ptrs[i].ptr, + get_func_size(module, sorted_func_ptrs, i), + module_name, sorted_func_ptrs[i].idx); + } + else { + (void)snprintf(perf_map_info, 128, + "%" PRIxPTR " %x aot_func#%u\n", + (uintptr_t)sorted_func_ptrs[i].ptr, + get_func_size(module, sorted_func_ptrs, i), + sorted_func_ptrs[i].idx); + } /* fwrite() is thread safe */ - fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map); + (void)fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map); } LOG_VERBOSE("write map information from %s into /tmp/perf-%d.map", @@ -112,7 +124,7 @@ quit: wasm_runtime_free(sorted_func_ptrs); if (perf_map) - fclose(perf_map); + (void)fclose(perf_map); return ret; } From 8f8c5605e9239c3e5294300f34a5e4cee471b05b Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 17 Apr 2025 16:41:47 +0800 Subject: [PATCH 115/198] Raise wasi-sdk to 25 and wabt to 1.0.37 (#4187) Raise wasi-sdk to 25 and wabt to 1.0.37. It includes - Refactor CI workflow to install WASI-SDK and WABT from a composite action - Use ExternalProject to bring wasm-apps for few samples. file/ wasi-threads/ - Refactor sample build and test steps in SGX compilation workflow for improved clarity and efficiency (workaround) Add CMake support for EMSCRIPTEN and WAMRC, update module paths --- .../actions/install-wasi-sdk-wabt/action.yml | 80 +++++++++++++++++ .../compilation_on_android_ubuntu.yml | 85 +++++------------- .github/workflows/compilation_on_macos.yml | 46 +++------- .github/workflows/compilation_on_sgx.yml | 47 +++------- .github/workflows/nightly_run.yml | 86 +++++++------------ .../platforms/linux-sgx/CMakeLists.txt | 5 ++ .../cmake/FindEMSCRIPTEN.cmake | 0 .../{debug-tools => }/cmake/FindWAMRC.cmake | 0 .../{debug-tools => }/cmake/FindWASISDK.cmake | 11 +-- samples/debug-tools/CMakeLists.txt | 2 +- samples/debug-tools/wasm-apps/CMakeLists.txt | 2 +- samples/file/CMakeLists.txt | 18 +++- samples/file/wasm-app/CMakeLists.txt | 25 ++---- samples/linux-perf/CMakeLists.txt | 2 +- samples/linux-perf/cmake/FindWASISDK.cmake | 23 ----- samples/wasi-threads/CMakeLists.txt | 19 +++- samples/wasi-threads/wasm-apps/CMakeLists.txt | 28 ++---- 17 files changed, 213 insertions(+), 266 deletions(-) create mode 100644 .github/actions/install-wasi-sdk-wabt/action.yml rename samples/{debug-tools => }/cmake/FindEMSCRIPTEN.cmake (100%) rename samples/{debug-tools => }/cmake/FindWAMRC.cmake (100%) rename samples/{debug-tools => }/cmake/FindWASISDK.cmake (58%) delete mode 100644 samples/linux-perf/cmake/FindWASISDK.cmake diff --git a/.github/actions/install-wasi-sdk-wabt/action.yml b/.github/actions/install-wasi-sdk-wabt/action.yml new file mode 100644 index 000000000..c872e4252 --- /dev/null +++ b/.github/actions/install-wasi-sdk-wabt/action.yml @@ -0,0 +1,80 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Get URLs from: +# - https://github.com/WebAssembly/wasi-sdk/releases +# - https://github.com/WebAssembly/wabt/releases + +# Install WASI-SDK and WABT at /opt +# /opt is the assumed location widely used in the project +name: Install WASI-SDK and WABT + +description: A composite action to download and install wasi-sdk and wabt on Ubuntu, macOS. + +inputs: + os: + description: "Operating system to install on (ubuntu, macos)" + required: true + +runs: + using: "composite" + steps: + - name: Check Runner OS + if: ${{ !startsWith(inputs.os, 'ubuntu') && !startsWith(inputs.os, 'windows') && !startsWith(inputs.os, 'macos') }} + shell: bash + run: | + echo "::error title=⛔ error hint::Support Ubuntu, Windows, and macOS Only" + exit 1 + + - name: Set up wasi-sdk and wabt on Ubuntu + if: ${{ startsWith(inputs.os, 'ubuntu') }} + shell: bash + run: | + sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz + sudo tar -xf wasi-sdk.tar.gz + sudo ln -sf wasi-sdk-25.0-x86_64-linux/ wasi-sdk + sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz + sudo tar -xf wabt.tar.gz + sudo ln -sf wabt-1.0.37 wabt + /opt/wasi-sdk/bin/clang --version + /opt/wabt/bin/wasm-interp --version + echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on ubuntu" + working-directory: /opt + + - name: Set up wasi-sdk and wabt on macOS-13 (intel) + if: ${{ inputs.os == 'macos-13' }} + shell: bash + run: | + sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-macos.tar.gz + sudo tar -xf wasi-sdk.tar.gz + sudo ln -sf wasi-sdk-25.0-x86_64-macos wasi-sdk + sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz + sudo tar -xf wabt.tar.gz + sudo ln -sf wabt-1.0.36 wabt + /opt/wasi-sdk/bin/clang --version + /opt/wabt/bin/wasm-interp --version + echo "::notice::wasi-sdk-25 and wabt-1.0.36 installed on macos-13" + working-directory: /opt + + - name: Set up wasi-sdk and wabt on macOS-14 (arm64) + if: ${{ inputs.os == 'macos-14' }} + shell: bash + run: | + sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-arm64-macos.tar.gz + sudo tar -xf wasi-sdk.tar.gz + sudo ln -sf wasi-sdk-25.0-arm64-macos wasi-sdk + sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-macos-14.tar.gz + sudo tar -xf wabt.tar.gz + sudo ln -sf wabt-1.0.37 wabt + /opt/wasi-sdk/bin/clang --version + /opt/wabt/bin/wasm-interp --version + echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on macos-14" + working-directory: /opt + + #TODO: Add support for Windows + - name: Set up wasi-sdk and wabt on Windows + if: ${{ startsWith(inputs.os, 'windows') }} + shell: powershell + run: | + echo "::notice::Support for Windows is not implemented yet" + exit 1 diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 47f613ab2..dd6c096f1 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -315,17 +315,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz" - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} + steps: - name: checkout uses: actions/checkout@v4 @@ -346,19 +339,10 @@ jobs: if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true') run: echo "::error::can not get prebuilt llvm libraries" && exit 1 - - name: download and install wasi-sdk - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-25.0-x86_64-linux wasi-sdk - - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo mv wabt-1.0.31 wabt + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} - name: Build wamrc run: | @@ -397,14 +381,6 @@ jobs: $MULTI_TIER_JIT_BUILD_OPTIONS, ] os: [ubuntu-22.04] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} @@ -430,12 +406,10 @@ jobs: if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true') run: echo "::error::can not get prebuilt llvm libraries" && exit 1 - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo mv wabt-1.0.31 wabt + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} - name: Build wamrc if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) @@ -464,34 +438,14 @@ jobs: strategy: matrix: os: [ubuntu-22.04] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz" - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} + steps: - name: checkout uses: actions/checkout@v4 - - name: download and install wasi-sdk - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-25.0-x86_64-linux wasi-sdk - - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo ln -sf wabt-1.0.31 wabt - name: Get LLVM libraries id: retrieve_llvm_libs uses: actions/cache@v4 @@ -503,12 +457,19 @@ jobs: ./core/deps/llvm/build/libexec ./core/deps/llvm/build/share key: ${{ matrix.llvm_cache_key }} + + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} + - name: Build wamrc run: | mkdir build && cd build cmake .. cmake --build . --config Release --parallel 4 working-directory: wamr-compiler + - name: Build Sample [basic] run: | cd samples/basic @@ -634,10 +595,6 @@ jobs: $MEMORY64_TEST_OPTIONS, $MULTI_MEMORY_TEST_OPTIONS, ] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz" - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} @@ -706,11 +663,9 @@ jobs: - name: download and install wasi-sdk if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-25.0-x86_64-linux wasi-sdk + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} # It is a temporary solution until new wasi-sdk that includes bug fixes is released - name: build wasi-libc from source diff --git a/.github/workflows/compilation_on_macos.yml b/.github/workflows/compilation_on_macos.yml index 66938905c..cf5578cfb 100644 --- a/.github/workflows/compilation_on_macos.yml +++ b/.github/workflows/compilation_on_macos.yml @@ -228,24 +228,14 @@ jobs: #$AOT_BUILD_OPTIONS, ] os: [macos-13] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz", - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz", - ] steps: - name: checkout uses: actions/checkout@v4 - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo mv wabt-1.0.31 wabt + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} - name: Build Sample [wasm-c-api] run: | @@ -260,14 +250,6 @@ jobs: strategy: matrix: os: [macos-13, macos-14] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz", - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz", - ] include: - os: macos-13 llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }} @@ -277,19 +259,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: download and install wasi-sdk - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-20.0 wasi-sdk - - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo ln -sf wabt-1.0.31 wabt + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} - name: Build Sample [basic] run: | @@ -356,12 +329,13 @@ jobs: cmake --build . --config Release --parallel 4 working-directory: wamr-compiler + # cmake --build . --config Debug --parallel 4 - name: Build Sample [wasi-threads] run: | cd samples/wasi-threads mkdir build && cd build cmake .. - cmake --build . --config Debug --parallel 4 + cmake --build . --config Debug --verbose ./iwasm wasm-apps/no_pthread.wasm ../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index 836f5c747..541f7a284 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -147,14 +147,6 @@ jobs: #$LLVM_EAGER_JIT_BUILD_OPTIONS, ] os: [ubuntu-22.04] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz", - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", - ] iwasm_make_options_feature: [ # Features to be tested: IPFS "-DWAMR_BUILD_SGX_IPFS=1", @@ -168,19 +160,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: download and install wasi-sdk - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo mv wasi-sdk-19.0 wasi-sdk - - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo mv wabt-1.0.31 wabt + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} - name: install SGX SDK and necessary libraries uses: ./.github/actions/install-linux-sgx @@ -213,33 +196,31 @@ jobs: - name: Build wamrc only for testing samples in aot mode if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS' run: | - mkdir build && cd build - cmake .. - cmake --build . --config Release --parallel 4 - cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample + cmake -S . -B build + cmake --build build --config Release --parallel 4 + cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample working-directory: wamr-compiler - name: Build Sample [file] run: | - cd samples/file - mkdir build && cd build - cmake .. - cmake --build . --config Debug --parallel 4 - cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample + cmake -S . -B build + cmake --build build --config Debug --parallel 4 + cp build/wasm-app/file.wasm ../../product-mini/platforms/${{ matrix.platform }}/enclave-sample + working-directory: samples/file - name: Test Sample [file] in non-aot mode if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS' run: | source /opt/intel/sgxsdk/environment - ./iwasm --dir=. file.wasm + ./iwasm --dir=. ./file.wasm working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample - name: Test Sample [file] in aot mode if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS' run: | source /opt/intel/sgxsdk/environment - ./wamrc -sgx -o file.aot file.wasm - ./iwasm --dir=. file.aot + ./wamrc -sgx -o ./file.aot ./file.wasm + ./iwasm --dir=. ./file.aot working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample spec_test_default: diff --git a/.github/workflows/nightly_run.yml b/.github/workflows/nightly_run.yml index dec06e327..92b8f5519 100644 --- a/.github/workflows/nightly_run.yml +++ b/.github/workflows/nightly_run.yml @@ -378,14 +378,6 @@ jobs: $MULTI_TIER_JIT_BUILD_OPTIONS, ] os: [ubuntu-22.04] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} @@ -413,12 +405,11 @@ jobs: if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true') run: echo "::error::can not get prebuilt llvm libraries" && exit 1 - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo mv wabt-1.0.31 wabt + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} + - name: Build wamrc if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) run: | @@ -443,14 +434,6 @@ jobs: strategy: matrix: os: [ubuntu-22.04] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", - ] - wabt_release: - [ - "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz", - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} @@ -458,19 +441,11 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: download and install wasi-sdk - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo ln -sf wasi-sdk-20.0 wasi-sdk - - name: download and install wabt - run: | - cd /opt - sudo wget ${{ matrix.wabt_release }} - sudo tar -xzf wabt-1.0.31-*.tar.gz - sudo ln -sf wabt-1.0.31 wabt - + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} + - name: Get LLVM libraries id: retrieve_llvm_libs uses: actions/cache@v4 @@ -567,17 +542,21 @@ jobs: ./iwasm --native-lib=./libtest_add.so --native-lib=./libtest_sqrt.so --native-lib=./libtest_hello.so --native-lib=./libtest_hello2.so wasm-app/test.wasm working-directory: ./samples/native-lib - - name: checkout wamr-app-framework - run: git clone https://github.com/bytecodealliance/wamr-app-framework.git - - name: download wamr-app-framework dependencies - run: LVGL=0 LV_DRIVERS=0 ./download.sh - working-directory: ./wamr-app-framework/deps - - name: Build Sample [simple] - run: | - ./build.sh -p host-interp - python3 ./sample_test_run.py $(pwd)/out - exit $? - working-directory: ./wamr-app-framework/samples/simple + # FIXME: un-comment me after fix cmake minimum issue + # https://github.com/bytecodealliance/wamr-app-framework/pull/11 + # - name: checkout wamr-app-framework + # run: git clone https://github.com/bytecodealliance/wamr-app-framework.git + + # - name: download wamr-app-framework dependencies + # run: LVGL=0 LV_DRIVERS=0 ./download.sh + # working-directory: ./wamr-app-framework/deps + + # - name: Build Sample [simple] + # run: | + # ./build.sh -p host-interp + # python3 ./sample_test_run.py $(pwd)/out + # exit $? + # working-directory: ./wamr-app-framework/samples/simple - name: Build Sample [shared-heap] run: | @@ -613,10 +592,6 @@ jobs: $THREADS_TEST_OPTIONS, $WASI_TEST_OPTIONS, ] - wasi_sdk_release: - [ - "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz", - ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }} @@ -664,13 +639,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: download and install wasi-sdk - if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: | - cd /opt - sudo wget ${{ matrix.wasi_sdk_release }} - sudo tar -xzf wasi-sdk-*.tar.gz - sudo mv wasi-sdk-20.0 wasi-sdk + - name: install-wasi-sdk-wabt + uses: ./.github/actions/install-wasi-sdk-wabt + with: + os: ${{ matrix.os }} # It is a temporary solution until new wasi-sdk that includes bug fixes is released - name: build wasi-libc from source diff --git a/product-mini/platforms/linux-sgx/CMakeLists.txt b/product-mini/platforms/linux-sgx/CMakeLists.txt index bc3bde565..af911a0db 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists.txt @@ -98,6 +98,11 @@ if (NOT DEFINED WAMR_BUILD_STATIC_PGO) set (WAMR_BUILD_STATIC_PGO 0) endif () +if (NOT DEFINED WAMR_BUILD_REF_TYPES) + # Enable reference types by default + set (WAMR_BUILD_REF_TYPES 1) +endif () + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -ffunction-sections -fdata-sections \ -Wall -Wno-unused-parameter -Wno-pedantic \ diff --git a/samples/debug-tools/cmake/FindEMSCRIPTEN.cmake b/samples/cmake/FindEMSCRIPTEN.cmake similarity index 100% rename from samples/debug-tools/cmake/FindEMSCRIPTEN.cmake rename to samples/cmake/FindEMSCRIPTEN.cmake diff --git a/samples/debug-tools/cmake/FindWAMRC.cmake b/samples/cmake/FindWAMRC.cmake similarity index 100% rename from samples/debug-tools/cmake/FindWAMRC.cmake rename to samples/cmake/FindWAMRC.cmake diff --git a/samples/debug-tools/cmake/FindWASISDK.cmake b/samples/cmake/FindWASISDK.cmake similarity index 58% rename from samples/debug-tools/cmake/FindWASISDK.cmake rename to samples/cmake/FindWASISDK.cmake index 0caf374df..65b9647d9 100644 --- a/samples/debug-tools/cmake/FindWASISDK.cmake +++ b/samples/cmake/FindWASISDK.cmake @@ -16,9 +16,10 @@ string(REGEX MATCH [0-9]+\.[0-9]+\.*[0-9]* WASISDK_VERSION ${WASISDK_HOME}) find_package_handle_standard_args(WASISDK REQUIRED_VARS WASISDK_HOME VERSION_VAR WASISDK_VERSION) if(WASISDK_FOUND) - set(WASISDK_CC_COMMAND ${WASISDK_HOME}/bin/clang) - set(WASISDK_CXX_COMMAND ${WASISDK_HOME}/bin/clang++) - set(WASISDK_TOOLCHAIN ${WASISDK_HOME}/share/cmake/wasi-sdk.cmake) - set(WASISDK_SYSROOT ${WASISDK_HOME}/share/wasi-sysroot) + set(WASISDK_CC_COMMAND ${WASISDK_HOME}/bin/clang) + set(WASISDK_CXX_COMMAND ${WASISDK_HOME}/bin/clang++) + set(WASISDK_TOOLCHAIN ${WASISDK_HOME}/share/cmake/wasi-sdk.cmake) + set(WASISDK_PTHREAD_TOOLCHAIN ${WASISDK_HOME}/share/cmake/wasi-sdk-pthread.cmake) + set(WASISDK_SYSROOT ${WASISDK_HOME}/share/wasi-sysroot) endif() -mark_as_advanced(WASISDK_CC_COMMAND WASISDK_CXX_COMMAND WASISDK_TOOLCHAIN WASISDK_SYSROOT WASISDK_HOME) +mark_as_advanced(WASISDK_CC_COMMAND WASISDK_CXX_COMMAND WASISDK_TOOLCHAIN WASISDK_PTHREAD_TOOLCHAIN WASISDK_SYSROOT WASISDK_HOME) diff --git a/samples/debug-tools/CMakeLists.txt b/samples/debug-tools/CMakeLists.txt index 411106bb3..512507d6e 100644 --- a/samples/debug-tools/CMakeLists.txt +++ b/samples/debug-tools/CMakeLists.txt @@ -7,7 +7,7 @@ include(CheckPIESupported) project(debug_tools_sample) -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) find_package(WASISDK REQUIRED) option(SOURCE_MAP_DEMO "Enable source map demo" OFF) diff --git a/samples/debug-tools/wasm-apps/CMakeLists.txt b/samples/debug-tools/wasm-apps/CMakeLists.txt index 527b5f37a..9858b98da 100644 --- a/samples/debug-tools/wasm-apps/CMakeLists.txt +++ b/samples/debug-tools/wasm-apps/CMakeLists.txt @@ -7,7 +7,7 @@ project (debut_tools_wasm) set (CMAKE_BUILD_TYPE Debug) # Otherwise no debug symbols (addr2line) -list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) +list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake) find_package (WAMRC REQUIRED) option(SOURCE_MAP_DEMO "Enable source map demo" OFF) diff --git a/samples/file/CMakeLists.txt b/samples/file/CMakeLists.txt index fca200376..a5184718b 100644 --- a/samples/file/CMakeLists.txt +++ b/samples/file/CMakeLists.txt @@ -6,4 +6,20 @@ project(file) ################ wasm application ############### add_subdirectory(src) -add_subdirectory(wasm-app) + +# Use ExternalProject to avoid incorporating WAMR library compilation flags into the +# compilation of the wasm application, which could lead to compatibility +# issues due to different targets. +# Like: clang: error: unsupported option '-arch' for target 'wasm32-wasi' +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) +find_package(WASISDK REQUIRED) + +include(ExternalProject) +ExternalProject_Add(wasm-app + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/wasm-app" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-app -B build + -DWASI_SDK_PREFIX=${WASISDK_HOME} + -DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN} + BUILD_COMMAND ${CMAKE_COMMAND} --build build + INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR} +) diff --git a/samples/file/wasm-app/CMakeLists.txt b/samples/file/wasm-app/CMakeLists.txt index f63485ca0..a80f0c8f0 100644 --- a/samples/file/wasm-app/CMakeLists.txt +++ b/samples/file/wasm-app/CMakeLists.txt @@ -2,25 +2,10 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception cmake_minimum_required(VERSION 3.14) -project(wasm-app) +project(file_wasm) -set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set (CMAKE_BUILD_TYPE Debug) # Otherwise no debug symbols (addr2line) -if (APPLE) - set (HAVE_FLAG_SEARCH_PATHS_FIRST 0) - set (CMAKE_C_LINK_FLAGS "") - set (CMAKE_CXX_LINK_FLAGS "") -endif () - -set (CMAKE_SYSTEM_PROCESSOR wasm32) - -if (NOT DEFINED WASI_SDK_DIR) - set (WASI_SDK_DIR "/opt/wasi-sdk") -endif () - -set (CMAKE_C_COMPILER_TARGET "wasm32-wasi") -set (CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang") -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-unused-command-line-argument") - -add_executable(file.wasm main.c) -target_link_libraries(file.wasm) +add_executable(file main.c) +set_target_properties (file PROPERTIES SUFFIX .wasm) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/file.wasm DESTINATION wasm-app) diff --git a/samples/linux-perf/CMakeLists.txt b/samples/linux-perf/CMakeLists.txt index e9882c835..efcc8c07e 100644 --- a/samples/linux-perf/CMakeLists.txt +++ b/samples/linux-perf/CMakeLists.txt @@ -15,7 +15,7 @@ endif() set(CMAKE_CXX_STANDARD 17) -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) find_package(WASISDK REQUIRED) ################ runtime settings ################ diff --git a/samples/linux-perf/cmake/FindWASISDK.cmake b/samples/linux-perf/cmake/FindWASISDK.cmake deleted file mode 100644 index 5cdfea41e..000000000 --- a/samples/linux-perf/cmake/FindWASISDK.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -include(FindPackageHandleStandardArgs) - -file(GLOB WASISDK_SEARCH_PATH "/opt/wasi-sdk-*") -find_path(WASISDK_HOME - NAMES share/wasi-sysroot - PATHS ${WASISDK_SEARCH_PATH} - NO_DEFAULT_PATH - REQUIRED -) - -string(REGEX MATCH [0-9]+\.[0-9]+\.*[0-9]* WASISDK_VERSION ${WASISDK_HOME}) - -find_package_handle_standard_args(WASISDK REQUIRED_VARS WASISDK_HOME VERSION_VAR WASISDK_VERSION) - -if(WASISDK_FOUND) - set(WASISDK_CC_COMMAND ${WASISDK_HOME}/bin/clang) - set(WASISDK_CXX_COMMAND ${WASISDK_HOME}/bin/clang++) - set(WASISDK_TOOLCHAIN ${WASISDK_HOME}/share/cmake/wasi-sdk.cmake) - set(WASISDK_SYSROOT ${WASISDK_HOME}/share/wasi-sysroot) -endif() diff --git a/samples/wasi-threads/CMakeLists.txt b/samples/wasi-threads/CMakeLists.txt index 11b58d2ea..08cc3a7ff 100644 --- a/samples/wasi-threads/CMakeLists.txt +++ b/samples/wasi-threads/CMakeLists.txt @@ -66,7 +66,24 @@ add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) ################ wasm application ################ -add_subdirectory(wasm-apps) +# Use ExternalProject to avoid incorporating WAMR library compilation flags into the +# compilation of the wasm application, which could lead to compatibility +# issues due to different targets. +# Like: clang: error: unsupported option '-arch' for target 'wasm32-wasi' + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) +find_package(WASISDK REQUIRED) + +include(ExternalProject) +ExternalProject_Add(wasm-apps + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps -B build + -DWASI_SDK_PREFIX=${WASISDK_HOME} + -DCMAKE_TOOLCHAIN_FILE=${WASISDK_PTHREAD_TOOLCHAIN} + BUILD_COMMAND ${CMAKE_COMMAND} --build build + INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR} +) + ################ wamr runtime ################ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) diff --git a/samples/wasi-threads/wasm-apps/CMakeLists.txt b/samples/wasi-threads/wasm-apps/CMakeLists.txt index 87f21e9fd..27e06b634 100644 --- a/samples/wasi-threads/wasm-apps/CMakeLists.txt +++ b/samples/wasi-threads/wasm-apps/CMakeLists.txt @@ -1,28 +1,10 @@ # Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -if (APPLE) - set (HAVE_FLAG_SEARCH_PATHS_FIRST 0) - set (CMAKE_C_LINK_FLAGS "") - set (CMAKE_CXX_LINK_FLAGS "") -endif () +cmake_minimum_required (VERSION 3.14) +project (wasi_threads_wasm) -if (NOT DEFINED WASI_SDK_DIR) - set (WASI_SDK_DIR "/opt/wasi-sdk") -endif () - -if (DEFINED WASI_SYSROOT) - set (CMAKE_SYSROOT "${WASI_SYSROOT}") -endif () - -set (CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang") -set (CMAKE_ASM_COMPILER "${WASI_SDK_DIR}/bin/clang") -set (CMAKE_EXE_LINKER_FLAGS "-target wasm32-wasi-threads") - -if ("$ENV{COLLECT_CODE_COVERAGE}" STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1) - set (CMAKE_C_FLAGS "") - set (CMAKE_CXX_FLAGS "") -endif () +set (CMAKE_BUILD_TYPE Debug) # Otherwise no debug symbols (addr2line) function (compile_sample SOURCE_FILE) get_filename_component (FILE_NAME ${SOURCE_FILE} NAME_WLE) @@ -41,6 +23,8 @@ function (compile_sample SOURCE_FILE) LINKER:--export=malloc LINKER:--export=free ) + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${WASM_MODULE} DESTINATION wasm-apps) endfunction () -compile_sample(no_pthread.c wasi_thread_start.S) \ No newline at end of file +compile_sample(no_pthread.c wasi_thread_start.S) From 0702f788fdae71289a67ef102cd27b3131442d02 Mon Sep 17 00:00:00 2001 From: James Marsh Date: Wed, 16 Apr 2025 17:34:52 +0100 Subject: [PATCH 116/198] Add missing V128 handling in WASM_OP_BR, reported in #4173 --- core/iwasm/interpreter/wasm_interp_fast.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 21554953d..042a06da5 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1013,6 +1013,22 @@ fail: SET_FRAME_REF((unsigned)(dst_offsets[0] + 1)); \ } \ } \ + else if (cells[0] == 4) { \ + PUT_V128_TO_ADDR( \ + frame_lp + dst_offsets[0], \ + GET_V128_FROM_ADDR(frame_lp + src_offsets[0])); \ + /* Ignore constants because they are not reference */ \ + if (src_offsets[0] >= 0) { \ + CLEAR_FRAME_REF((unsigned)src_offsets[0]); \ + CLEAR_FRAME_REF((unsigned)(src_offsets[0] + 1)); \ + CLEAR_FRAME_REF((unsigned)(src_offsets[0] + 2)); \ + CLEAR_FRAME_REF((unsigned)(src_offsets[0] + 3)); \ + SET_FRAME_REF((unsigned)dst_offsets[0]); \ + SET_FRAME_REF((unsigned)(dst_offsets[0] + 1)); \ + SET_FRAME_REF((unsigned)(dst_offsets[0] + 2)); \ + SET_FRAME_REF((unsigned)(dst_offsets[0] + 3)); \ + } \ + } \ } \ else { \ if (!copy_stack_values(module, frame_lp, arity, frame_ref, \ @@ -1053,6 +1069,11 @@ fail: frame_lp + dst_offsets[0], \ GET_I64_FROM_ADDR(frame_lp + src_offsets[0])); \ } \ + else if (cells[0] == 4) { \ + PUT_V128_TO_ADDR( \ + frame_lp + dst_offsets[0], \ + GET_V128_FROM_ADDR(frame_lp + src_offsets[0])); \ + } \ } \ else { \ if (!copy_stack_values(module, frame_lp, arity, total_cell, \ From ff2768775c26337016f26aba6c395dcdfd5b30c7 Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Tue, 22 Apr 2025 12:08:25 +0800 Subject: [PATCH 117/198] fix potential memory leak (#4205) --- .../libc-wasi/sandboxed-system-primitives/src/posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c index d26c460fe..e48645d8c 100644 --- a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c +++ b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c @@ -3021,9 +3021,9 @@ fd_table_destroy(struct fd_table *ft) fd_object_release(NULL, ft->entries[i].object); } } - rwlock_destroy(&ft->lock); wasm_runtime_free(ft->entries); } + rwlock_destroy(&ft->lock); } void @@ -3035,9 +3035,9 @@ fd_prestats_destroy(struct fd_prestats *pt) wasm_runtime_free((void *)pt->prestats[i].dir); } } - rwlock_destroy(&pt->lock); wasm_runtime_free(pt->prestats); } + rwlock_destroy(&pt->lock); } bool From 6d61e72344bfc606304a3ef4b256539e3b216a14 Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:43:24 +0800 Subject: [PATCH 118/198] Update unit test cases (#4214) * Update gc unit test cases * Update aot stack frame unit test cases --- tests/unit/aot-stack-frame/CMakeLists.txt | 25 ++- .../aot-stack-frame/aot_stack_frame_test.cc | 69 +------ .../aot-stack-frame/wasm-apps/CMakeLists.txt | 2 +- tests/unit/gc/wasm-apps/func1.wasm | Bin 106 -> 71 bytes tests/unit/gc/wasm-apps/func1.wast | 4 +- tests/unit/gc/wasm-apps/func2.wasm | Bin 470 -> 8 bytes tests/unit/gc/wasm-apps/struct1.wasm | Bin 85 -> 8 bytes tests/unit/gc/wasm-apps/struct2.wasm | Bin 234 -> 302 bytes tests/unit/gc/wasm-apps/struct2.wast | 34 +++- tests/unit/gc/wasm-apps/struct3.wasm | Bin 118 -> 94 bytes tests/unit/gc/wasm-apps/test1.wasm | Bin 647 -> 8 bytes tests/unit/gc/wasm-apps/test2.wasm | Bin 626 -> 626 bytes tests/unit/gc/wasm-apps/test2.wast | 57 +++--- tests/unit/gc/wasm-apps/test3.wasm | Bin 976 -> 931 bytes tests/unit/gc/wasm-apps/test3.wast | 184 +++++++++--------- tests/unit/gc/wasm-apps/test4.wasm | Bin 299 -> 322 bytes tests/unit/gc/wasm-apps/test4.wast | 33 ++-- tests/unit/gc/wasm-apps/test5.wasm | Bin 512 -> 466 bytes tests/unit/gc/wasm-apps/test5.wast | 92 ++++----- tests/unit/gc/wasm-apps/test6.wasm | Bin 197 -> 139 bytes tests/unit/gc/wasm-apps/test6.wast | 14 +- 21 files changed, 237 insertions(+), 277 deletions(-) diff --git a/tests/unit/aot-stack-frame/CMakeLists.txt b/tests/unit/aot-stack-frame/CMakeLists.txt index cbdc62f65..90a61aea7 100644 --- a/tests/unit/aot-stack-frame/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/CMakeLists.txt @@ -17,6 +17,7 @@ set (WAMR_BUILD_LIBC_BUILTIN 0) set (WAMR_BUILD_MULTI_MODULE 0) set (WAMR_DISABLE_HW_BOUND_CHECK 1) set (WAMR_DISABLE_WRITE_GS_BASE 1) +set (WAMR_BUILD_GC 1) include (../unit_common.cmake) @@ -31,15 +32,21 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) set (UNIT_SOURCE ${source_all}) set (unit_test_sources - ${UNIT_SOURCE} - ${PLATFORM_SHARED_SOURCE} - ${UTILS_SHARED_SOURCE} - ${MEM_ALLOC_SHARED_SOURCE} - ${NATIVE_INTERFACE_SOURCE} - ${IWASM_COMMON_SOURCE} - ${IWASM_INTERP_SOURCE} - ${IWASM_AOT_SOURCE} - ${WASM_APP_LIB_SOURCE_ALL} + ${UNIT_SOURCE} + ${WAMR_RUNTIME_LIB_SOURCE} + ${UNCOMMON_SHARED_SOURCE} + ${SRC_LIST} + ${PLATFORM_SHARED_SOURCE} + ${UTILS_SHARED_SOURCE} + ${MEM_ALLOC_SHARED_SOURCE} + ${LIB_HOST_AGENT_SOURCE} + ${NATIVE_INTERFACE_SOURCE} + ${LIBC_BUILTIN_SOURCE} + ${IWASM_COMMON_SOURCE} + ${IWASM_INTERP_SOURCE} + ${IWASM_AOT_SOURCE} + ${IWASM_COMPL_SOURCE} + ${WASM_APP_LIB_SOURCE_ALL} ) # Automatically build wasm-apps for this test diff --git a/tests/unit/aot-stack-frame/aot_stack_frame_test.cc b/tests/unit/aot-stack-frame/aot_stack_frame_test.cc index 9bea2b2a0..bcc1e246c 100644 --- a/tests/unit/aot-stack-frame/aot_stack_frame_test.cc +++ b/tests/unit/aot-stack-frame/aot_stack_frame_test.cc @@ -162,57 +162,6 @@ TEST_F(AOTStackFrameTest, test1) exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024); ASSERT_TRUE(exec_env != NULL); - func_inst = wasm_runtime_lookup_function(module_inst, "test1"); - ASSERT_TRUE(func_inst != NULL); - - argv[0] = 33; - argv[1] = 44; - wasm_runtime_call_wasm(exec_env, func_inst, 2, argv); - ASSERT_TRUE(wasm_runtime_get_exception(module_inst)); - - frames = AOTStackFrameTest::my_frames; - frame_num = AOTStackFrameTest::my_frame_num; - - ASSERT_TRUE(frames != NULL); - ASSERT_TRUE(frame_num == 1); - - ASSERT_TRUE(frames[0]->lp[0] == 33); - ASSERT_TRUE(frames[0]->lp[1] == 44); - ASSERT_TRUE(frames[0]->lp[2] == 0x11223344); - ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL); - ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f); - ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322); - - wasm_runtime_destroy_exec_env(exec_env); - exec_env = NULL; - - wasm_runtime_deinstantiate(module_inst); - module_inst = NULL; - - wasm_runtime_unload(module); - module = NULL; -} - -TEST_F(AOTStackFrameTest, test2) -{ - MyAOTFrame *frame, **frames; - uint32 frame_num; - - aot_set_stack_frame_callback(aot_stack_frame_cb); - - bh_memcpy_s(test_aot_buf, sizeof(test_aot_buf), test_aot, sizeof(test_aot)); - - module = wasm_runtime_load(test_aot_buf, sizeof(test_aot), error_buf, - sizeof(error_buf)); - ASSERT_TRUE(module != NULL); - - module_inst = wasm_runtime_instantiate(module, 16384, 0, error_buf, - sizeof(error_buf)); - ASSERT_TRUE(module_inst != NULL); - - exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024); - ASSERT_TRUE(exec_env != NULL); - func_inst = wasm_runtime_lookup_function(module_inst, "test2"); ASSERT_TRUE(func_inst != NULL); @@ -233,11 +182,9 @@ TEST_F(AOTStackFrameTest, test2) ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL); ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f); ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322); - ASSERT_TRUE(frames[0]->lp[8] == 0x1234); - ASSERT_TRUE(frames[0]->lp[9] == 0x5678); } -TEST_F(AOTStackFrameTest, test3) +TEST_F(AOTStackFrameTest, test2) { MyAOTFrame *frame, **frames; uint32 frame_num; @@ -271,18 +218,14 @@ TEST_F(AOTStackFrameTest, test3) ASSERT_TRUE(frames != NULL); ASSERT_TRUE(frame_num == 2); - ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 5); - ASSERT_TRUE(frames[0]->ip_offset == 24); + // 5(i32) + 1(i64) local variables, occupied 7 * 4 bytes + ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 7); + + // offset of ip from module load address + ASSERT_TRUE(frames[0]->ip_offset == 163); ASSERT_TRUE(frames[0]->lp[0] == 1234); ASSERT_TRUE(frames[0]->lp[1] == 5678); ASSERT_TRUE(frames[0]->lp[2] == 0x11223344); ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL); - - ASSERT_TRUE(frames[1]->lp[0] == 0x1234); - ASSERT_TRUE(frames[1]->lp[1] == 0x5678); - ASSERT_TRUE(frames[1]->lp[2] == 0x11223344); - ASSERT_TRUE(*(uint64 *)(frames[1]->lp + 3) == 0x12345678ABCDEF99LL); - ASSERT_TRUE(*(float *)(frames[1]->lp + 5) == 5566.7788f); - ASSERT_TRUE(*(double *)(frames[1]->lp + 6) == 99887766.55443322); } diff --git a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt index 2becb77c9..6c43a4184 100644 --- a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt @@ -13,7 +13,7 @@ add_custom_target(aot-stack-frame-test-wasm ALL -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_LIST_DIR}/test.wast && ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc - --enable-dump-call-stack --bounds-checks=1 + --enable-dump-call-stack --bounds-checks=1 --enable-gc -o ${CMAKE_CURRENT_BINARY_DIR}/test.aot ${CMAKE_CURRENT_BINARY_DIR}/test.wasm && cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump diff --git a/tests/unit/gc/wasm-apps/func1.wasm b/tests/unit/gc/wasm-apps/func1.wasm index 51b316b54edacd385cb79b8d54e8ebe886eb0c20..1553dec75fd9882fce678c3a91f2e8d93aca3cfa 100644 GIT binary patch literal 71 zcmV~$yAFUL5Cp*8^Abf{V?jlXABG_|0zLwNPs0q(k_muDJm4iJ3_^|*wO*wH^TFNd Xr>{JcCGwV}0St6#>u(*~mh932hJ*}q literal 106 zcmZQbEY4+QU|?YEY-ng;U`k+MNMK6OVqk6paTyueJHRwcNosKk0|VD~FmEG>6ksl3 s&S%VH%wPq&S7B8VPq^|1kw=UEXH&NhTk4(QVNW}9kZmk0cPtN<^TWy diff --git a/tests/unit/gc/wasm-apps/func1.wast b/tests/unit/gc/wasm-apps/func1.wast index 1b4941787..adc9640e7 100644 --- a/tests/unit/gc/wasm-apps/func1.wast +++ b/tests/unit/gc/wasm-apps/func1.wast @@ -26,10 +26,10 @@ (local (ref null struct)) local.get 0 - ref.test null array + ref.test (ref array) drop local.get 1 - ref.cast i31 + ref.cast (ref i31) drop ) ) diff --git a/tests/unit/gc/wasm-apps/func2.wasm b/tests/unit/gc/wasm-apps/func2.wasm index e5d852ce4664d9109bc5ae6e0c5f7da48096d746..d8fc92d022fbf4d1072da17bc8e0840054b51ddc 100644 GIT binary patch literal 8 PcmZQbEY4+QU|;|M2ZjMd literal 470 zcmcJKO=`q23`U=l$)+dhsz>ON;iMMtn~{e0(kf z$k*e3=Y51xqA}r+RpHTk{>JMo6g)Z)`ut}Aj z8&@(bArn>-3lpA*jXmnE;+bvs@%k2s> diff --git a/tests/unit/gc/wasm-apps/struct1.wasm b/tests/unit/gc/wasm-apps/struct1.wasm index 513442f96f3d8e21005d6c4048092279380f9420..d8fc92d022fbf4d1072da17bc8e0840054b51ddc 100644 GIT binary patch literal 8 PcmZQbEY4+QU|;|M2ZjMd literal 85 zcmXAeNeX~K48T$uLHuO#>V_~Ui`xFqZ&{Tb0trK11dux-=#)eZEyj;Fj-$P?r!P(p SRyHP>1#RDEjM=pKcbx}0=@RMy diff --git a/tests/unit/gc/wasm-apps/struct2.wasm b/tests/unit/gc/wasm-apps/struct2.wasm index 497a96441938f39943904cfb416a6bcc60893952..7d22e80fdd4a6472e555f1576c30f258d9056529 100644 GIT binary patch literal 302 zcmZ{dK@Ng25JmsAlu{~&6BrUNfG3c|rH25c#FcC?8Wv6T+}$`uWI5 diff --git a/tests/unit/gc/wasm-apps/test1.wasm b/tests/unit/gc/wasm-apps/test1.wasm index d907e457f589c37ecdb58ceac4ac65fd12e46af4..d8fc92d022fbf4d1072da17bc8e0840054b51ddc 100644 GIT binary patch literal 8 PcmZQbEY4+QU|;|M2ZjMd literal 647 zcmd5%NlwE+5Uh3x2VTJ&P;x;$A}?s0L+r#g9$VsMEAiyOr@2vMgAgA;sMXb@nyOy# z`qmi$`*^?I@KOQQeE_kf(NH}NeeBw%KAulMFAnS(*|BBAnn#{_3J4a8FAYIs@msbT zdRkSaB-x)0Djz3|mTblq7YyjZ0qhacp+SvSry>-~Pv+W%CA2@d$(TK1tK(4SunFbe zgf+?{A)$QG4Apf;ltcck-)3%7&nQn?Hjw(?ZR8VtgeUk6zrru@2xp_L;VMF1@o{hUJ>MlCw6h{J@|zWK5n5e4$$nj4Yts`#qjPH#zniB7ujxEU~t|NKg;|B z%zt;Rc4CR)S(~c+k<<3|Ai=%}GMc$N{*TzBXZ0SYfx-HDQm-W`0bADQq7rkstXh-u zYD=oQrks-Nk})#Fg)})8gBj!%xmhK(qsr%ucBZ8K8>FbRIVX~k@)<}qcPOXwnksc# zT^N;6Zok#{&v1h;C33Qj?Dv*QM>JIQ>87EZK8+h1_vyN!>pqPd8b#d%OijS#BtJ7)%!Pm)|ExtwGtNiLnFp-E)_0={Xnd;kCd literal 626 zcmZ9HK~94}6o&s9ptMjmX*>WMyEk5-?0O0*sX!s^Kq*bEo1%#u6Jzu^o&r697nzN3 zz(A3N|9|hBe`emm-)$HG_EDB4j0ND~_5ll)(tl(}?N#wHG`;&?6w(B&3|0!u{CuR| z)?*PDV3Rxuy&~8Zp4hL~-ko3g;Nuqh;sDKV+h7a5Ta0h6VO+F}yCUB&3k=R%;^(=4 zfcfu^a4(h^p0%mEA6>S6JxFk01Ub#z9sft{(X)CF)4*W;JgL``lz=U3b5V&YTvkP- zyb4G)*OU&qE;%DJT*wKhV&Fh#Sh+_1UEl)l?yC>0{{9Se zV~Z<<6{4fHOfHkpRE#t?^QcRCjW;MSX*`=7lhYmJR0sYTr#dcKH)qu386{#biFiXI zI)3SL&&@>ap_PL*wQ}%|IEkkJJESsf^b=$!s6rQkAF(0m4uUiUY5b@ms0V^H1Zm1q rLy(4`gb~hb)E}mwEy@2im@1E`&a}*=>Zf6eq!URuoobZYBeAR>+}+;9 literal 976 zcmb7?F;2rk5JhKaZEWlyD7XUYxP!NdM420efRHOfkx(Z{h#OFF6&iY~+=C-*!=Jxv zo0jT*ujkL-8C%xdM<*ig>u@;8=~7m*bh2{$32vo(v1c8GOajLz>FHL)zgiPt*L6YV zdbzAV>`d$3!*+MQeZCXdP~NXMPaDzZ`^_w$RwO~9%3MN|;G#M_wNVw&s2-R_EdU?2 z1d6EDT-qPRiCl!5M^y~U5?oFokw7AWL;{Hf zW9m!AzI=xsKKCHegG3J!JxKI020D2HXPKQOoFtqioFtsazzKK)XO*2KoFtqioFtsa zz=^4BN1bhzvm|9VO3D(FGRL2~aprDPoQ4kGjt-{waN@H8F2N_12^GS54ZP({R>mt* z@D&{Cf+m<@f)OTIgLbLL1ZOb88WXIsEc+Qc6Ra`8h7jkiwC^v&|CSv8+D$WVsU6j9 ZR1DU|kW9ro?vQoUHVdocneEkX_6yM(<=+4R diff --git a/tests/unit/gc/wasm-apps/test3.wast b/tests/unit/gc/wasm-apps/test3.wast index 4df02ce8f..e551b14b4 100644 --- a/tests/unit/gc/wasm-apps/test3.wast +++ b/tests/unit/gc/wasm-apps/test3.wast @@ -11,105 +11,105 @@ (table 20 (ref null struct)) (func $init - (table.set (i32.const 0) (struct.new_canon_default $t0)) - (table.set (i32.const 10) (struct.new_canon_default $t0)) - (table.set (i32.const 1) (struct.new_canon_default $t1)) - (table.set (i32.const 11) (struct.new_canon_default $t1')) - (table.set (i32.const 2) (struct.new_canon_default $t2)) - (table.set (i32.const 12) (struct.new_canon_default $t2')) - (table.set (i32.const 3) (struct.new_canon_default $t3)) - (table.set (i32.const 4) (struct.new_canon_default $t4)) + (table.set (i32.const 0) (struct.new_default $t0)) + (table.set (i32.const 10) (struct.new_default $t0)) + (table.set (i32.const 1) (struct.new_default $t1)) + (table.set (i32.const 11) (struct.new_default $t1')) + (table.set (i32.const 2) (struct.new_default $t2)) + (table.set (i32.const 12) (struct.new_default $t2')) + (table.set (i32.const 3) (struct.new_default $t3)) + (table.set (i32.const 4) (struct.new_default $t4)) ) (func (export "test-sub") (call $init) (block $l ;; must hold - (br_if $l (i32.eqz (ref.test null $t0 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 0))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 1))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 3))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 4))))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 1))))) - (br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t2 (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t3 (table.get (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (table.get (i32.const 3))))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t4 (table.get (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (table.get (i32.const 4))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 4))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t2) (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t3 (table.get (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref $t3) (table.get (i32.const 3))))) - (br_if $l (i32.eqz (ref.test $t4 (table.get (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref $t4) (table.get (i32.const 4))))) ;; must not hold - (br_if $l (ref.test $t0 (ref.null struct))) - (br_if $l (ref.test $t1 (ref.null struct))) - (br_if $l (ref.test $t2 (ref.null struct))) - (br_if $l (ref.test $t3 (ref.null struct))) - (br_if $l (ref.test $t4 (ref.null struct))) + (br_if $l (ref.test (ref $t0) (ref.null struct))) + (br_if $l (ref.test (ref $t1) (ref.null struct))) + (br_if $l (ref.test (ref $t2) (ref.null struct))) + (br_if $l (ref.test (ref $t3) (ref.null struct))) + (br_if $l (ref.test (ref $t4) (ref.null struct))) - (br_if $l (ref.test $t1 (table.get (i32.const 0)))) - (br_if $l (ref.test $t1 (table.get (i32.const 3)))) - (br_if $l (ref.test $t1 (table.get (i32.const 4)))) + (br_if $l (ref.test (ref $t1) (table.get (i32.const 0)))) + (br_if $l (ref.test (ref $t1) (table.get (i32.const 3)))) + (br_if $l (ref.test (ref $t1) (table.get (i32.const 4)))) - (br_if $l (ref.test $t2 (table.get (i32.const 0)))) - (br_if $l (ref.test $t2 (table.get (i32.const 1)))) - (br_if $l (ref.test $t2 (table.get (i32.const 3)))) - (br_if $l (ref.test $t2 (table.get (i32.const 4)))) + (br_if $l (ref.test (ref $t2) (table.get (i32.const 0)))) + (br_if $l (ref.test (ref $t2) (table.get (i32.const 1)))) + (br_if $l (ref.test (ref $t2) (table.get (i32.const 3)))) + (br_if $l (ref.test (ref $t2) (table.get (i32.const 4)))) - (br_if $l (ref.test $t3 (table.get (i32.const 0)))) - (br_if $l (ref.test $t3 (table.get (i32.const 1)))) - (br_if $l (ref.test $t3 (table.get (i32.const 2)))) - (br_if $l (ref.test $t3 (table.get (i32.const 4)))) + (br_if $l (ref.test (ref $t3) (table.get (i32.const 0)))) + (br_if $l (ref.test (ref $t3) (table.get (i32.const 1)))) + (br_if $l (ref.test (ref $t3) (table.get (i32.const 2)))) + (br_if $l (ref.test (ref $t3) (table.get (i32.const 4)))) - (br_if $l (ref.test $t4 (table.get (i32.const 0)))) - (br_if $l (ref.test $t4 (table.get (i32.const 1)))) - (br_if $l (ref.test $t4 (table.get (i32.const 2)))) - (br_if $l (ref.test $t4 (table.get (i32.const 3)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 0)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 1)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 2)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 3)))) (return) ) @@ -119,25 +119,25 @@ (func (export "test-canon") (call $init) (block $l - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 4))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 10))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 11))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 10))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 11))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 12))))) - (br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 11))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 11))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 12))))) - (br_if $l (i32.eqz (ref.test $t2' (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t2') (table.get (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t2) (table.get (i32.const 12))))) (return) ) diff --git a/tests/unit/gc/wasm-apps/test4.wasm b/tests/unit/gc/wasm-apps/test4.wasm index b4841a82cb878091351cbe6e43bbcdef6e88341f..e7522e88fff5dd36390f91f31b6c6f17f8bc4868 100644 GIT binary patch literal 322 zcmYL>y$*sf6ot=)LXGu*(4=v2(ZS8Qx$zZE$j@@Vd%oUV zgxQ4v(AWv+g#ZZX3LpCi><%Z(JOPZ6LYMDd7OOZnyXoQRM`4!x>Z*KoPZC)D))n3E zH9g*Lz=loD^7J0%a0ZPD(=>d-?Y@ay5IcDI+*a_&<9cprX|fG$51KPGum!X!Z5?qq__ba>{DX^ diff --git a/tests/unit/gc/wasm-apps/test4.wast b/tests/unit/gc/wasm-apps/test4.wast index 8bf02e430..eeec11faa 100644 --- a/tests/unit/gc/wasm-apps/test4.wast +++ b/tests/unit/gc/wasm-apps/test4.wast @@ -10,10 +10,10 @@ (func (export "init") (param $x externref) (table.set (i32.const 0) (ref.null any)) - (table.set (i32.const 1) (i31.new (i32.const 7))) - (table.set (i32.const 2) (struct.new_canon_default $st)) - (table.set (i32.const 3) (array.new_canon_default $at (i32.const 0))) - (table.set (i32.const 4) (extern.internalize (local.get $x))) + (table.set (i32.const 1) (ref.i31 (i32.const 7))) + (table.set (i32.const 2) (struct.new_default $st)) + (table.set (i32.const 3) (array.new_default $at (i32.const 0))) + (table.set (i32.const 4) (any.convert_extern (local.get $x))) (table.set (i32.const 5) (ref.null i31)) (table.set (i32.const 6) (ref.null struct)) (table.set (i32.const 7) (ref.null none)) @@ -21,26 +21,25 @@ (func (export "ref_cast_non_null") (param $i i32) (drop (ref.as_non_null (table.get (local.get $i)))) - (drop (ref.cast null any (table.get (local.get $i)))) + (drop (ref.cast (ref null any) (table.get (local.get $i)))) ) (func (export "ref_cast_null") (param $i i32) - (drop (ref.cast null any (table.get (local.get $i)))) - (drop (ref.cast null struct (table.get (local.get $i)))) - (drop (ref.cast null array (table.get (local.get $i)))) - (drop (ref.cast null i31 (table.get (local.get $i)))) - (drop (ref.cast null none (table.get (local.get $i)))) + (drop (ref.cast anyref (table.get (local.get $i)))) + (drop (ref.cast structref (table.get (local.get $i)))) + (drop (ref.cast arrayref (table.get (local.get $i)))) + (drop (ref.cast i31ref (table.get (local.get $i)))) + (drop (ref.cast nullref (table.get (local.get $i)))) ) (func (export "ref_cast_i31") (param $i i32) - (drop (ref.cast i31 (table.get (local.get $i)))) - (drop (ref.cast null i31 (table.get (local.get $i)))) + (drop (ref.cast (ref i31) (table.get (local.get $i)))) + (drop (ref.cast i31ref (table.get (local.get $i)))) ) (func (export "ref_cast_struct") (param $i i32) - (drop (ref.cast struct (table.get (local.get $i)))) - (drop (ref.cast null struct (table.get (local.get $i)))) + (drop (ref.cast (ref struct) (table.get (local.get $i)))) + (drop (ref.cast structref (table.get (local.get $i)))) ) (func (export "ref_cast_array") (param $i i32) - (drop (ref.cast array (table.get (local.get $i)))) - (drop (ref.cast null array (table.get (local.get $i)))) + (drop (ref.cast (ref array) (table.get (local.get $i)))) + (drop (ref.cast arrayref (table.get (local.get $i)))) ) ) - diff --git a/tests/unit/gc/wasm-apps/test5.wasm b/tests/unit/gc/wasm-apps/test5.wasm index 050ead4ae9fde01db1690721be8f931206be8d43..e92d600d152d5087749beff4530eb73932b34672 100644 GIT binary patch literal 466 zcmaKmF-`+96hvpf%?7PgP@s))PdY?T=Nse(OF&eJplFwRFUBFb2?ub4{rwZsfSc#> z%>QHTr#AxN{c491J7VNgz)=<~c!WOby?RAmG{<>Yj`w`U_3B10=a*@|n?9bvUa!yl z!}|f!e~WuSLMFCIeFHODRA`V)DQex|GJR1#v)dwk5?A;-=FKrC+#+uf6OCeYM&D>@ zO)(}-G1{vtIVqj=G3jL28U|~qtm(>{tE{=RZ@Y&R#d5Z9=wg`5=k?p?p?{Y4wmcZu Qf0U_TO4a{Wu3BRF0l~sx=l}o! literal 512 zcmaKoF;c@o3`M`R4mREtDX6w5T@JA&U2b3k!=xe<4s}e1OK=s28Lq%#sMrQcmPsnA zr!W04t&L6pNC4<_7zSLf(P2&K=x_pce1K}63Y-dQUySM&2(P*%G)+@kMO$3eZ`$K# z|IqJO{qr5Dweo(md)k59pQA?J)r5?~SR%J0s4$6&g;~IbgJ52`5`@AtK~=b3B7VGR ze1WfRxk1XfhLN1?49;q#yUj%@n~RcnO@&EWa+b0s>+wRCOPW=xTd6*!`u^s=J5LPm n^L@Ea@!P(CA%EaJ_|M|jebG5T&#^y9XmdGi^XUPV>yY9vVfuIE diff --git a/tests/unit/gc/wasm-apps/test5.wast b/tests/unit/gc/wasm-apps/test5.wast index 895473ce3..f74da50e8 100644 --- a/tests/unit/gc/wasm-apps/test5.wast +++ b/tests/unit/gc/wasm-apps/test5.wast @@ -11,75 +11,75 @@ (table 20 (ref null struct)) (func $init - (table.set (i32.const 0) (struct.new_canon_default $t0)) - (table.set (i32.const 10) (struct.new_canon_default $t0)) - (table.set (i32.const 1) (struct.new_canon_default $t1)) - (table.set (i32.const 11) (struct.new_canon_default $t1')) - (table.set (i32.const 2) (struct.new_canon_default $t2)) - (table.set (i32.const 12) (struct.new_canon_default $t2')) - (table.set (i32.const 3) (struct.new_canon_default $t3)) - (table.set (i32.const 4) (struct.new_canon_default $t4)) + (table.set (i32.const 0) (struct.new_default $t0)) + (table.set (i32.const 10) (struct.new_default $t0)) + (table.set (i32.const 1) (struct.new_default $t1)) + (table.set (i32.const 11) (struct.new_default $t1')) + (table.set (i32.const 2) (struct.new_default $t2)) + (table.set (i32.const 12) (struct.new_default $t2')) + (table.set (i32.const 3) (struct.new_default $t3)) + (table.set (i32.const 4) (struct.new_default $t4)) ) (func (export "test-sub") (call $init) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t0 (table.get (i32.const 0)))) - (drop (ref.cast null $t0 (table.get (i32.const 1)))) - (drop (ref.cast null $t0 (table.get (i32.const 2)))) - (drop (ref.cast null $t0 (table.get (i32.const 3)))) - (drop (ref.cast null $t0 (table.get (i32.const 4)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 0)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 1)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 2)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 3)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 4)))) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t1 (table.get (i32.const 1)))) - (drop (ref.cast null $t1 (table.get (i32.const 2)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t1) (table.get (i32.const 1)))) + (drop (ref.cast (ref null $t1) (table.get (i32.const 2)))) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t2 (table.get (i32.const 2)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t2) (table.get (i32.const 2)))) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t3 (table.get (i32.const 3)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t3) (table.get (i32.const 3)))) - (drop (ref.cast null $t4 (table.get (i32.const 4)))) + (drop (ref.cast (ref null $t4) (table.get (i32.const 4)))) - (drop (ref.cast $t0 (table.get (i32.const 0)))) - (drop (ref.cast $t0 (table.get (i32.const 1)))) - (drop (ref.cast $t0 (table.get (i32.const 2)))) - (drop (ref.cast $t0 (table.get (i32.const 3)))) - (drop (ref.cast $t0 (table.get (i32.const 4)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 0)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 1)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 2)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 3)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 4)))) - (drop (ref.cast $t1 (table.get (i32.const 1)))) - (drop (ref.cast $t1 (table.get (i32.const 2)))) + (drop (ref.cast (ref $t1) (table.get (i32.const 1)))) + (drop (ref.cast (ref $t1) (table.get (i32.const 2)))) - (drop (ref.cast $t2 (table.get (i32.const 2)))) + (drop (ref.cast (ref $t2) (table.get (i32.const 2)))) - (drop (ref.cast $t3 (table.get (i32.const 3)))) + (drop (ref.cast (ref $t3) (table.get (i32.const 3)))) - (drop (ref.cast $t4 (table.get (i32.const 4)))) + (drop (ref.cast (ref $t4) (table.get (i32.const 4)))) ) (func (export "test-canon") (call $init) - (drop (ref.cast $t0 (table.get (i32.const 0)))) - (drop (ref.cast $t0 (table.get (i32.const 1)))) - (drop (ref.cast $t0 (table.get (i32.const 2)))) - (drop (ref.cast $t0 (table.get (i32.const 3)))) - (drop (ref.cast $t0 (table.get (i32.const 4)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 0)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 1)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 2)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 3)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 4)))) - (drop (ref.cast $t0 (table.get (i32.const 10)))) - (drop (ref.cast $t0 (table.get (i32.const 11)))) - (drop (ref.cast $t0 (table.get (i32.const 12)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 10)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 11)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 12)))) - (drop (ref.cast $t1' (table.get (i32.const 1)))) - (drop (ref.cast $t1' (table.get (i32.const 2)))) + (drop (ref.cast (ref $t1') (table.get (i32.const 1)))) + (drop (ref.cast (ref $t1') (table.get (i32.const 2)))) - (drop (ref.cast $t1 (table.get (i32.const 11)))) - (drop (ref.cast $t1 (table.get (i32.const 12)))) + (drop (ref.cast (ref $t1) (table.get (i32.const 11)))) + (drop (ref.cast (ref $t1) (table.get (i32.const 12)))) - (drop (ref.cast $t2' (table.get (i32.const 2)))) + (drop (ref.cast (ref $t2') (table.get (i32.const 2)))) - (drop (ref.cast $t2 (table.get (i32.const 12)))) + (drop (ref.cast (ref $t2) (table.get (i32.const 12)))) ) ) diff --git a/tests/unit/gc/wasm-apps/test6.wasm b/tests/unit/gc/wasm-apps/test6.wasm index b1abc14729ffe04acd72180963e77174e24912ab..f6b7a9e4a5fa88b46fbe2616c63b70d7077e64bf 100644 GIT binary patch literal 139 zcmXYlAr8Vo6b0x1UD$>Vf&_`EDfjpWjX*;Yh>DUlt*F~8l5m_gY)Z|WH^X!61(1Wk z^58zxLaQlBa!%EGFFnVwSKqz63G_7}yPIAxKEoN4Wz|AH6>}@SRf})3Q1bSVVB{dh OtM$Z4O+zgW-}nRFw;5yr literal 197 zcmXYpu?@m75Jmr83^t@g4B#g0;SD?ign}YSMnX{0*b;P6W?>8JG<0m@2HQz-|J{Gm z9ga6g0O%b;z{=u)G~}^=z*25gPFxlZuAud= us83E9jBW=*<2fZ88FgYcQy5kHA~KR*PLKw1!>Oxzsr&Luqk*Od-}( Date: Fri, 25 Apr 2025 16:46:37 +0800 Subject: [PATCH 119/198] fix print_help when libc wasi is enabled (#4218) --- product-mini/platforms/posix/main.c | 6 +++++- product-mini/platforms/windows/main.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/product-mini/platforms/posix/main.c b/product-mini/platforms/posix/main.c index fa5dcb2c3..2790a12eb 100644 --- a/product-mini/platforms/posix/main.c +++ b/product-mini/platforms/posix/main.c @@ -52,7 +52,11 @@ print_help(void) printf(" --multi-tier-jit Run the wasm app with multi-tier jit mode\n"); #endif printf(" --stack-size=n Set maximum stack size in bytes, default is 64 KB\n"); - printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB\n"); +#if WASM_ENABLE_LIBC_WASI !=0 + printf(" --heap-size=n Set maximum heap size in bytes, default is 0 KB when libc wasi is enabled\n"); +#else + printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n"); +#endif #if WASM_ENABLE_FAST_JIT != 0 printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n"); printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024); diff --git a/product-mini/platforms/windows/main.c b/product-mini/platforms/windows/main.c index e85e869c2..7537216dc 100644 --- a/product-mini/platforms/windows/main.c +++ b/product-mini/platforms/windows/main.c @@ -44,7 +44,11 @@ print_help() printf(" --multi-tier-jit Run the wasm app with multi-tier jit mode\n"); #endif printf(" --stack-size=n Set maximum stack size in bytes, default is 64 KB\n"); - printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB\n"); +#if WASM_ENABLE_LIBC_WASI !=0 + printf(" --heap-size=n Set maximum heap size in bytes, default is 0 KB when libc wasi is enabled\n"); +#else + printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n"); +#endif #if WASM_ENABLE_GC != 0 printf(" --gc-heap-size=n Set maximum gc heap size in bytes,\n"); printf(" default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024); From c2d7fa30df1e0923d8a64df7344e1de6ecec174d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 27 Apr 2025 12:30:35 +0900 Subject: [PATCH 120/198] LLVM: don't verify instcombine fixpoint (#4219) LLVM 18 and later, instcombine perfoms only one iteration. it performs extra "verify fixpoint" operation when instcombine is specified in certain ways, including how we do so here. a problem is that the verification raises a fatal error when it finds we didn't reach a fixpoint: LLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations while it should be rare, it's quite normal not to reach a fixpoint. this commit fixes the issue by simply disabing the verification. cf. https://github.com/llvm/llvm-project/commit/41895843b5915bb78e9d02aa711fa10f7174db43 --- core/iwasm/compilation/aot_llvm_extra.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/iwasm/compilation/aot_llvm_extra.cpp b/core/iwasm/compilation/aot_llvm_extra.cpp index e6770eb45..35b25c830 100644 --- a/core/iwasm/compilation/aot_llvm_extra.cpp +++ b/core/iwasm/compilation/aot_llvm_extra.cpp @@ -318,10 +318,15 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module) ModulePassManager MPM; if (comp_ctx->is_jit_mode) { +#if LLVM_VERSION_MAJOR >= 18 +#define INSTCOMBINE "instcombine" +#else +#define INSTCOMBINE "instcombine" +#endif const char *Passes = "loop-vectorize,slp-vectorizer," "load-store-vectorizer,vector-combine," - "mem2reg,instcombine,simplifycfg,jump-threading,indvars"; + "mem2reg," INSTCOMBINE ",simplifycfg,jump-threading,indvars"; ExitOnErr(PB.parsePassPipeline(MPM, Passes)); } else { From 6593b3f34784c0cca1176aec917ba38a22376d5c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 27 Apr 2025 12:48:57 +0900 Subject: [PATCH 121/198] LLVMCreateTargetMachineWithOpts: disable large data (#4220) for x86-64, llvm 17 and later sometimes uses "l" prefix for data sections. cf. https://github.com/llvm/llvm-project/commit/43249378da67319906cf04f2c6cd38df141f3bf6 because our aot file emitter/loader doesn't support such sections, it ends up with load-time errors solving symbols like ".lrodata". this commit fixes it by avoid placing data in the large data sections. references: https://groups.google.com/g/x86-64-abi/c/jnQdJeabxiU https://github.com/llvm/llvm-project/commit/1feb00a28c9fdab162da08a15fcc9d088a36c352 --- core/iwasm/compilation/aot_llvm_extra2.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/iwasm/compilation/aot_llvm_extra2.cpp b/core/iwasm/compilation/aot_llvm_extra2.cpp index ccbccd1e0..5e1fdf6ce 100644 --- a/core/iwasm/compilation/aot_llvm_extra2.cpp +++ b/core/iwasm/compilation/aot_llvm_extra2.cpp @@ -159,6 +159,17 @@ LLVMCreateTargetMachineWithOpts(LLVMTargetRef ctarget, const char *triple, auto cm = convert(code_model, &jit); auto targetmachine = target->createTargetMachine(triple, cpu, features, opts, rm, cm, ol, jit); +#if LLVM_VERSION_MAJOR >= 18 + // always place data in normal data section. + // + // note that: + // - our aot file emitter/loader doesn't support x86-64 large data + // sections. (eg .lrodata) + // - for our purposes, "data" is usually something the compiler + // generated. (eg. jump tables) we probably never benefit from + // large data sections. + targetmachine->setLargeDataThreshold(UINT64_MAX); +#endif return reinterpret_cast(targetmachine); } From 84767f91210611f36cecee6e6acbf434474d88b5 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 28 Apr 2025 17:43:53 +0900 Subject: [PATCH 122/198] wamrc: add --disable-llvm-jump-tables option (#4224) while ideally a user should not need to care this kind of optimization details, in reality i guess it's sometimes useful. both of clang and GCC expose a similar option. (-fno-jump-tables) --- core/iwasm/compilation/aot_llvm.c | 11 ++++++++--- core/iwasm/compilation/aot_llvm.h | 3 +++ core/iwasm/include/aot_comp_option.h | 3 ++- wamr-compiler/main.c | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index a9fd68c24..21e675bc7 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -711,8 +711,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module, prefix))) goto fail; - if (comp_ctx->is_indirect_mode) { - /* avoid LUT relocations ("switch-table") */ + if (comp_ctx->disable_llvm_jump_tables) { LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute( comp_ctx->context, "no-jump-tables", (uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true")); @@ -2664,12 +2663,18 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) if (option->enable_aux_stack_check) comp_ctx->enable_aux_stack_check = true; - if (option->is_indirect_mode) + if (option->is_indirect_mode) { comp_ctx->is_indirect_mode = true; + /* avoid LUT relocations ("switch-table") */ + comp_ctx->disable_llvm_jump_tables = true; + } if (option->disable_llvm_intrinsics) comp_ctx->disable_llvm_intrinsics = true; + if (option->disable_llvm_jump_tables) + comp_ctx->disable_llvm_jump_tables = true; + if (option->disable_llvm_lto) comp_ctx->disable_llvm_lto = true; diff --git a/core/iwasm/compilation/aot_llvm.h b/core/iwasm/compilation/aot_llvm.h index 9c608d301..6b1233c39 100644 --- a/core/iwasm/compilation/aot_llvm.h +++ b/core/iwasm/compilation/aot_llvm.h @@ -448,6 +448,9 @@ typedef struct AOTCompContext { /* Disable LLVM built-in intrinsics */ bool disable_llvm_intrinsics; + /* Disable LLVM jump tables */ + bool disable_llvm_jump_tables; + /* Disable LLVM link time optimization */ bool disable_llvm_lto; diff --git a/core/iwasm/include/aot_comp_option.h b/core/iwasm/include/aot_comp_option.h index fda17d5a7..839176623 100644 --- a/core/iwasm/include/aot_comp_option.h +++ b/core/iwasm/include/aot_comp_option.h @@ -73,6 +73,7 @@ typedef struct AOTCompOption { bool enable_perf_profiling; bool enable_memory_profiling; bool disable_llvm_intrinsics; + bool disable_llvm_jump_tables; bool disable_llvm_lto; bool enable_llvm_pgo; bool enable_stack_estimation; @@ -96,4 +97,4 @@ typedef struct AOTCompOption { } #endif -#endif /* end of __AOT_COMP_OPTION_H__ */ \ No newline at end of file +#endif /* end of __AOT_COMP_OPTION_H__ */ diff --git a/wamr-compiler/main.c b/wamr-compiler/main.c index 3efe344e6..312231619 100644 --- a/wamr-compiler/main.c +++ b/wamr-compiler/main.c @@ -180,6 +180,7 @@ print_help() printf(" Available flags: all, i32.common, i64.common, f32.common, f64.common,\n"); printf(" i32.clz, i32.ctz, etc, refer to doc/xip.md for full list\n"); printf(" Use comma to separate, please refer to doc/xip.md for full list.\n"); + printf(" --disable-llvm-jump-tables Disable the LLVM jump tables similarly to clang's -fno-jump-tables\n"); printf(" --disable-llvm-lto Disable the LLVM link time optimization\n"); printf(" --enable-llvm-pgo Enable LLVM PGO (Profile-Guided Optimization)\n"); printf(" --enable-llvm-passes=\n"); @@ -570,6 +571,9 @@ main(int argc, char *argv[]) PRINT_HELP_AND_EXIT(); option.builtin_intrinsics = argv[0] + 28; } + else if (!strcmp(argv[0], "--disable-llvm-jump-tables")) { + option.disable_llvm_jump_tables = true; + } else if (!strcmp(argv[0], "--disable-llvm-lto")) { option.disable_llvm_lto = true; } From 791e60f5335dc78537321943d6f58c7082974980 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 28 Apr 2025 21:44:04 +0800 Subject: [PATCH 123/198] feat(fuzz): add a new fuzzing target about aot compiler (#4121) support llvm-jit running mode as another fuzzing target --- build-scripts/version.cmake | 2 +- core/iwasm/compilation/aot_llvm.c | 3 +- tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 211 ++++++------------ tests/fuzz/wasm-mutator-fuzz/README.md | 57 +++-- .../aot-compiler/CMakeLists.txt | 164 ++++++++++++++ .../aot-compiler/aot_compiler_fuzz.cc | 85 +++++++ .../wasm-mutator-fuzz/clang_toolchain.cmake | 29 +++ .../wasm-mutator/CMakeLists.txt | 70 ++++++ .../{ => wasm-mutator}/wasm_mutator_fuzz.cc | 0 9 files changed, 455 insertions(+), 166 deletions(-) create mode 100644 tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt create mode 100644 tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc create mode 100644 tests/fuzz/wasm-mutator-fuzz/clang_toolchain.cmake create mode 100644 tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt rename tests/fuzz/wasm-mutator-fuzz/{ => wasm-mutator}/wasm_mutator_fuzz.cc (100%) diff --git a/build-scripts/version.cmake b/build-scripts/version.cmake index 04c4e1ccb..21eaedca8 100644 --- a/build-scripts/version.cmake +++ b/build-scripts/version.cmake @@ -3,7 +3,7 @@ if(NOT WAMR_ROOT_DIR) # if from wamr-compiler - set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) + set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..) endif() set(WAMR_VERSION_MAJOR 2) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index 21e675bc7..9270f0efe 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2520,7 +2520,8 @@ aot_compiler_init(void) LLVMInitializeCore(LLVMGetGlobalPassRegistry()); #endif -#if WASM_ENABLE_WAMR_COMPILER != 0 +/* fuzzing only use host targets for simple */ +#if WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_FUZZ_TEST == 0 /* Init environment of all targets for AOT compiler */ LLVMInitializeAllTargetInfos(); LLVMInitializeAllTargets(); diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index 813afa21f..8bb860788 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -1,170 +1,101 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required (VERSION 3.14) +cmake_minimum_required(VERSION 3.14) -if (NOT DEFINED CMAKE_C_COMPILER) -set (CMAKE_C_COMPILER "clang") -endif () -if (NOT DEFINED CMAKE_CXX_COMPILER) -set (CMAKE_CXX_COMPILER "clang++") -endif () +project(wamr_fuzzing LANGUAGES ASM C CXX) -project(wasm_mutator) +include(CMakePrintHelpers) -set (CMAKE_BUILD_TYPE Debug) - -string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) - -# Reset default linker flags -set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") -set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - -set (CMAKE_C_STANDARD 11) -set (CMAKE_CXX_STANDARD 17) - -# Set WAMR_BUILD_TARGET, currently values supported: -# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", -# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]" -if (NOT DEFINED WAMR_BUILD_TARGET) - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)") - set (WAMR_BUILD_TARGET "AARCH64") - elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64") - set (WAMR_BUILD_TARGET "RISCV64") - elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) - # Build as X86_64 by default in 64-bit platform - set (WAMR_BUILD_TARGET "X86_64") - elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) - # Build as X86_32 by default in 32-bit platform - set (WAMR_BUILD_TARGET "X86_32") - else () - message(SEND_ERROR "Unsupported build target platform!") - endif () -endif () - -if (APPLE) - add_definitions(-DBH_PLATFORM_DARWIN) -endif () - -if(CUSTOM_MUTATOR EQUAL 1) - add_compile_definitions(CUSTOM_MUTATOR) +# Ensure Clang is used as the compiler +if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR NOT CMAKE_ASM_COMPILER_ID STREQUAL "Clang") + message(FATAL_ERROR "Please use Clang as the C compiler for libFuzzer compatibility.") endif() -if (NOT DEFINED WAMR_BUILD_INTERP) - # Enable Interpreter by default - set (WAMR_BUILD_INTERP 1) -endif () +# +# Global settings +# +set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) -if (NOT DEFINED WAMR_BUILD_AOT) - # Enable AOT by default. - set (WAMR_BUILD_AOT 1) -endif () +string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) -if (NOT DEFINED WAMR_BUILD_JIT) - # Disable JIT by default. - set (WAMR_BUILD_JIT 0) -endif () +# Reset default linker flags +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") -if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) - # Disable libc builtin support by default - set (WAMR_BUILD_LIBC_BUILTIN 0) -endif () +# Check if the compiler supports the sanitizer flags +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-fsanitize=address" HAS_ADDRESS_SANITIZER) +check_cxx_compiler_flag("-fsanitize=memory" HAS_MEMORY_SANITIZER) +check_cxx_compiler_flag("-fsanitize=undefined" HAS_UNDEFINED_SANITIZER) -if (NOT DEFINED WAMR_BUILD_LIBC_WASI) - # Enable libc wasi support by default - set (WAMR_BUILD_LIBC_WASI 0) -endif () +# Determine WAMR_BUILD_TARGET based on system properties +if(NOT DEFINED WAMR_BUILD_TARGET) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)") + set(WAMR_BUILD_TARGET "AARCH64") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64") + set(WAMR_BUILD_TARGET "RISCV64") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(WAMR_BUILD_TARGET "X86_64") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(WAMR_BUILD_TARGET "X86_32") + else() + message(SEND_ERROR "Unsupported build target platform!") + endif() +endif() -if (NOT DEFINED WAMR_BUILD_FAST_INTERP) - # Enable fast interpreter - set (WAMR_BUILD_FAST_INTERP 1) -endif () +if(APPLE) + add_definitions(-DBH_PLATFORM_DARWIN) +endif() -if (NOT DEFINED WAMR_BUILD_MULTI_MODULE) - # Disable multiple modules - set (WAMR_BUILD_MULTI_MODULE 0) -endif () +# Disable hardware bound check and enable AOT validator +set(WAMR_DISABLE_HW_BOUND_CHECK 1) +set(WAMR_BUILD_AOT_VALIDATOR 1) -if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD) - # Disable pthread library by default - set (WAMR_BUILD_LIB_PTHREAD 0) -endif () +set(REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) +message(STATUS "REPO_ROOT_DIR: ${REPO_ROOT_DIR}") -if (NOT DEFINED WAMR_BUILD_MINI_LOADER) - # Disable wasm mini loader by default - set (WAMR_BUILD_MINI_LOADER 0) -endif () +# Use LLVM_DIR from command line if defined +# LLVM_DIR should be something like /path/to/llvm/build/lib/cmake/llvm +if(DEFINED LLVM_DIR) + set(LLVM_DIR $ENV{LLVM_DIR}) +else() + set(LLVM_SRC_ROOT ${REPO_ROOT_DIR}/core/deps/llvm) + set(LLVM_BUILD_ROOT ${LLVM_SRC_ROOT}/build) + set(LLVM_DIR ${LLVM_BUILD_ROOT}/lib/cmake/llvm) +endif() -if (NOT DEFINED WAMR_BUILD_SIMD) - # Enable SIMD by default - set (WAMR_BUILD_SIMD 1) -endif () +# if LLVM_DIR is an existing directory, use it +if(NOT EXISTS ${LLVM_DIR}) + message(FATAL_ERROR "LLVM_DIR not found: ${LLVM_DIR}") +endif() -if (NOT DEFINED WAMR_BUILD_REF_TYPES) - # Enable reference type by default - set (WAMR_BUILD_REF_TYPES 1) -endif () +find_package(LLVM REQUIRED CONFIG) -if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP) - # Disable Debug feature by default - set (WAMR_BUILD_DEBUG_INTERP 0) -endif () +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") -if (WAMR_BUILD_DEBUG_INTERP EQUAL 1) - set (WAMR_BUILD_FAST_INTERP 0) - set (WAMR_BUILD_MINI_LOADER 0) - set (WAMR_BUILD_SIMD 0) -endif () +include_directories(${LLVM_INCLUDE_DIRS}) +separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) +add_definitions(${LLVM_DEFINITIONS_LIST}) -# sanitizer may use kHandleSignalExclusive to handle SIGSEGV -# like `UBSAN_OPTIONS=handle_segv=2:...` -set (WAMR_DISABLE_HW_BOUND_CHECK 1) -# Enable aot validator -set (WAMR_BUILD_AOT_VALIDATOR 1) +set(SHARED_DIR ${REPO_ROOT_DIR}/core/shared) +set(IWASM_DIR ${REPO_ROOT_DIR}/core/iwasm) -set (REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) -message([ceith]:REPO_ROOT_DIR, ${REPO_ROOT_DIR}) - -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - -add_definitions(-DWAMR_USE_MEM_POOL=0 -DWASM_ENABLE_FUZZ_TEST=1) +# Global setting +add_compile_options(-Wno-unused-command-line-argument) # Enable fuzzer +add_definitions(-DWASM_ENABLE_FUZZ_TEST=1) add_compile_options(-fsanitize=fuzzer) add_link_options(-fsanitize=fuzzer) -# if not calling from oss-fuzz helper, enable all support sanitizers -# oss-fuzz will define FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in CFLAGS and CXXFLAGS +# Enable sanitizers if not in oss-fuzz environment set(CFLAGS_ENV $ENV{CFLAGS}) string(FIND "${CFLAGS_ENV}" "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" IN_OSS_FUZZ) -if (IN_OSS_FUZZ EQUAL -1) - message("[ceith]:Enable ASan and UBSan in non-oss-fuzz environment") - add_compile_options( - -fprofile-instr-generate -fcoverage-mapping - -fno-sanitize-recover=all - -fsanitize=address,undefined - # reference: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html - # -fsanitize=undefined: All of the checks listed above other than float-divide-by-zero, - # unsigned-integer-overflow, implicit-conversion, local-bounds and - # the nullability-* group of checks. - # - # for now, we disable below from UBSan - # -alignment - # -implicit-conversion - # - -fsanitize=float-divide-by-zero,unsigned-integer-overflow,local-bounds,nullability - -fno-sanitize=alignment - ) - add_link_options(-fsanitize=address -fprofile-instr-generate) -endif () -include(${REPO_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake) -include(${REPO_ROOT_DIR}/build-scripts/runtime_lib.cmake) - -add_library(vmlib - ${WAMR_RUNTIME_LIB_SOURCE} -) - -add_executable(wasm_mutator_fuzz wasm_mutator_fuzz.cc) -target_link_libraries(wasm_mutator_fuzz vmlib -lm) +add_subdirectory(aot-compiler) +add_subdirectory(wasm-mutator) diff --git a/tests/fuzz/wasm-mutator-fuzz/README.md b/tests/fuzz/wasm-mutator-fuzz/README.md index acf210ae4..09fd757be 100644 --- a/tests/fuzz/wasm-mutator-fuzz/README.md +++ b/tests/fuzz/wasm-mutator-fuzz/README.md @@ -1,44 +1,53 @@ # WAMR fuzz test framework -## install wasm-tools +## Install wasm-tools + +Download the release suitable for your specific platform from https://github.com/bytecodealliance/wasm-tools/releases/latest, unpack it, and add the executable wasm-tools to the `PATH`. Then, you should be able to verify that the installation was successful by using the following command: ```bash -1.git clone https://github.com/bytecodealliance/wasm-tools -$ cd wasm-tools -2.This project can be installed and compiled from source with this Cargo command: -$ cargo install wasm-tools -3.Installation can be confirmed with: $ wasm-tools --version -4.Subcommands can be explored with: +# Or learn subcommands with $ wasm-tools help ``` +## Install clang Toolchain + +Refer to: https://apt.llvm.org/ and ensure that you have clang installed. + +```bash +$ clang --version + +$ clang++ --version +``` + ## Build ```bash -mkdir build && cd build # Without custom mutator (libfuzzer modify the buffer randomly) -cmake .. -# TODO: TBC. `wasm-tools mutate` is not supported yet -# With custom mutator (wasm-tools mutate) -cmake .. -DCUSTOM_MUTATOR=1 -make -j$(nproc) +$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./clang_toolchain.cmake -DLLVM_DIR=/lib/cmake/llvm + +# TBC: if `wasm-tools mutate` is supported or not +# Or With custom mutator (wasm-tools mutate) +$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./clang_toolchain.cmake -DLLVM_DIR=/lib/cmake/llvm -DCUSTOM_MUTATOR=1 + +# Then +$ cmake --build build ``` ## Manually generate wasm file in build -```bash +````bash # wasm-tools smith generate some valid wasm file # The generated wasm file is in corpus_dir under build # N - Number of files to be generated -./smith_wasm.sh N +$ ./smith_wasm.sh N # running ``` bash -cd build -./wasm-mutate-fuzz CORPUS_DIR - -``` +$ ./build/wasm-mutator/wasm_mutator_fuzz ./build/CORPUS_DIR + +$ ./build/aot-compiler/aot_compiler_fuzz ./build/CORPUS_DIR +```` ## Fuzzing Server @@ -49,20 +58,20 @@ $ pip install -r requirements.txt 2. Database Migration $ python3 app/manager.py db init -$ python3 app/manager.py db migrate -$ python3 app/manager.py db upgrade +$ python3 app/manager.py db migrate +$ python3 app/manager.py db upgrade 3. Change localhost to your machine's IP address -$ cd ../portal +$ cd ../portal $ vim .env # Change localhost to your machine's IP address # http://:16667 4. Run Server and Portal $ cd .. # Switch to the original directory If you want to customize the front-end deployment port: # defaut 9999 - $ vim .env # Please change the portal_port to the port you want to use + $ vim .env # Please change the portal_port to the port you want to use The server is deployed on port 16667 by default, If you want to change the server deployment port: - $ vim .env # Please change the server_port to the port you want to use + $ vim .env # Please change the server_port to the port you want to use $ vim portal/.env # Please change the VITE_SERVER_URL to the port you want to use # http://ip: diff --git a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt new file mode 100644 index 000000000..cf3caa16d --- /dev/null +++ b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt @@ -0,0 +1,164 @@ +# Copyright (C) 2025 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Set default build options with the ability to override from the command line +if(NOT WAMR_BUILD_INTERP) + set(WAMR_BUILD_INTERP 1) +endif() + +set(WAMR_BUILD_WAMR_COMPILER 1) +set(WAMR_BUILD_AOT 1) +set(WAMR_BUILD_INTERP 1) +set(WAMR_BUILD_JIT 0) + +include(${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake) +include(${SHARED_DIR}/mem-alloc/mem_alloc.cmake) +include(${SHARED_DIR}/utils/shared_utils.cmake) +include(${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) +include(${IWASM_DIR}/compilation/iwasm_compl.cmake) +include(${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake) +include(${IWASM_DIR}/common/iwasm_common.cmake) +include(${IWASM_DIR}/common/gc/iwasm_gc.cmake) +include(${IWASM_DIR}/interpreter/iwasm_interp.cmake) +include(${IWASM_DIR}/aot/iwasm_aot.cmake) +include(${IWASM_DIR}/compilation/iwasm_compl.cmake) +include(${REPO_ROOT_DIR}/build-scripts/version.cmake) + +add_library(aotclib + ${PLATFORM_SHARED_SOURCE} + ${MEM_ALLOC_SHARED_SOURCE} + ${UTILS_SHARED_SOURCE} + ${UNCOMMON_SHARED_SOURCE} + ${THREAD_MGR_SOURCE} + ${IWASM_COMMON_SOURCE} + ${IWASM_INTERP_SOURCE} + ${IWASM_AOT_SOURCE} + ${IWASM_GC_SOURCE} + ${IWASM_COMPL_SOURCE} +) + +target_compile_definitions(aotclib + PUBLIC + -DWASM_ENABLE_WAMR_COMPILER=1 + -DWASM_ENABLE_FAST_INTERP=0 + -DWASM_ENABLE_INTERP=1 + -DWASM_ENABLE_BULK_MEMORY=1 + -DWASM_ENABLE_SHARED_MEMORY=1 + -DWASM_ENABLE_TAIL_CALL=1 + -DWASM_ENABLE_SIMD=1 + -DWASM_ENABLE_REF_TYPES=1 + -DWASM_ENABLE_MEMORY64=1 + -DWASM_ENABLE_GC=1 + -DWASM_ENABLE_CUSTOM_NAME_SECTION=1 + -DWASM_ENABLE_AOT_STACK_FRAME=1 + -DWASM_ENABLE_DUMP_CALL_STACK=1 + -DWASM_ENABLE_PERF_PROFILING=1 + -DWASM_ENABLE_LOAD_CUSTOM_SECTION=1 + -DWASM_ENABLE_THREAD_MGR=1 + ${LLVM_DEFINITIONS} +) + +target_include_directories(aotclib PUBLIC + ${IWASM_DIR}/include + ${SHARED_DIR}/include +) + +target_link_directories(aotclib PUBLIC ${LLVM_LIBRARY_DIR}) + +target_link_libraries(aotclib + PUBLIC + LLVMDemangle + LLVMSupport + LLVMTableGen + LLVMTableGenGlobalISel + LLVMCore + LLVMFuzzerCLI + LLVMFuzzMutate + LLVMFileCheck + LLVMInterfaceStub + LLVMIRReader + LLVMCodeGen + LLVMSelectionDAG + LLVMAsmPrinter + LLVMMIRParser + LLVMGlobalISel + LLVMBinaryFormat + LLVMBitReader + LLVMBitWriter + LLVMBitstreamReader + LLVMDWARFLinker + LLVMExtensions + LLVMFrontendOpenACC + LLVMFrontendOpenMP + LLVMTransformUtils + LLVMInstrumentation + LLVMAggressiveInstCombine + LLVMInstCombine + LLVMScalarOpts + LLVMipo + LLVMVectorize + LLVMObjCARCOpts + LLVMCoroutines + LLVMCFGuard + LLVMLinker + LLVMAnalysis + LLVMLTO + LLVMMC + LLVMMCParser + LLVMMCDisassembler + LLVMMCA + LLVMObjCopy + LLVMObject + LLVMObjectYAML + LLVMOption + LLVMRemarks + LLVMDebuginfod + LLVMDebugInfoDWARF + LLVMDebugInfoGSYM + LLVMDebugInfoMSF + LLVMDebugInfoCodeView + LLVMDebugInfoPDB + LLVMSymbolize + LLVMDWP + LLVMExecutionEngine + LLVMInterpreter + LLVMJITLink + LLVMMCJIT + LLVMOrcJIT + LLVMOrcShared + LLVMOrcTargetProcess + LLVMRuntimeDyld + LLVMTarget + LLVMX86CodeGen + LLVMX86AsmParser + LLVMX86Disassembler + LLVMX86TargetMCA + LLVMX86Desc + LLVMX86Info + LLVMAsmParser + LLVMLineEditor + LLVMProfileData + LLVMCoverage + LLVMPasses + LLVMTextAPI + LLVMDlltoolDriver + LLVMLibDriver + LLVMXRay + LLVMWindowsDriver + LLVMWindowsManifest +) + +if(NOT IN_OSS_FUZZ) + message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment") + target_compile_options(aotclib PUBLIC + -fprofile-instr-generate -fcoverage-mapping + -fno-sanitize-recover=all + -fsanitize=address,undefined + -fsanitize=float-divide-by-zero,unsigned-integer-overflow,local-bounds,nullability + -fno-sanitize=alignment + ) + target_link_options(aotclib PUBLIC -fsanitize=address,undefined -fprofile-instr-generate) +endif() + +add_executable(aot_compiler_fuzz aot_compiler_fuzz.cc) +target_link_libraries(aot_compiler_fuzz PRIVATE stdc++ aotclib) diff --git a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc new file mode 100644 index 000000000..e758cd974 --- /dev/null +++ b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2025 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +#include "aot_export.h" +#include "wasm_export.h" +#include "bh_read_file.h" + +static void +handle_aot_recent_error(const char *tag) +{ + const char *error = aot_get_last_error(); + if (strlen(error) == 0) { + error = "UNKNOWN ERROR"; + } + + std::cout << tag << " " << error << std::endl; +} + +extern "C" int +LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) +{ + wasm_module_t module = NULL; + char error_buf[128] = { 0 }; + AOTCompOption option = { 0 }; + aot_comp_data_t comp_data = NULL; + aot_comp_context_t comp_ctx = NULL; + + /* libfuzzer don't allow to modify the given Data, so make a copy here */ + std::vector myData(Data, Data + Size); + + wasm_runtime_init(); + + module = wasm_runtime_load((uint8_t *)myData.data(), Size, error_buf, 120); + if (!module) { + std::cout << "[LOADING] " << error_buf << std::endl; + goto DESTROY_RUNTIME; + } + + // TODO: target_arch and other fields + option.target_arch = "x86_64"; + option.target_abi = "gnu"; + option.enable_bulk_memory = true; + option.enable_thread_mgr = true; + option.enable_tail_call = true; + option.enable_simd = true; + option.enable_ref_types = true; + option.enable_gc = true; + + comp_data = + aot_create_comp_data(module, option.target_arch, option.enable_gc); + if (!comp_data) { + handle_aot_recent_error("[CREATING comp_data]"); + goto UNLOAD_MODULE; + } + + comp_ctx = aot_create_comp_context(comp_data, &option); + if (!comp_ctx) { + handle_aot_recent_error("[CREATING comp_context]"); + goto DESTROY_COMP_DATA; + } + + if (!aot_compile_wasm(comp_ctx)) { + handle_aot_recent_error("[COMPILING]"); + goto DESTROY_COMP_CTX; + } + +DESTROY_COMP_CTX: + aot_destroy_comp_context(comp_ctx); +DESTROY_COMP_DATA: + aot_destroy_comp_data(comp_data); +UNLOAD_MODULE: + wasm_runtime_unload(module); +DESTROY_RUNTIME: + wasm_runtime_destroy(); + + /* Values other than 0 and -1 are reserved for future use. */ + return 0; +} diff --git a/tests/fuzz/wasm-mutator-fuzz/clang_toolchain.cmake b/tests/fuzz/wasm-mutator-fuzz/clang_toolchain.cmake new file mode 100644 index 000000000..d16a0b207 --- /dev/null +++ b/tests/fuzz/wasm-mutator-fuzz/clang_toolchain.cmake @@ -0,0 +1,29 @@ +# Copyright (C) 2025 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Check for Clang C compiler +find_program(CLANG_C_COMPILER NAMES clang) +if(NOT CLANG_C_COMPILER) + message(FATAL_ERROR "Clang C compiler not found. Please install Clang.") +else() + message(STATUS "Clang C compiler found: ${CLANG_C_COMPILER}") + set(CMAKE_C_COMPILER ${CLANG_C_COMPILER}) +endif() + +# Check for Clang C++ compiler +find_program(CLANG_CXX_COMPILER NAMES clang++) +if(NOT CLANG_CXX_COMPILER) + message(FATAL_ERROR "Clang C++ compiler not found. Please install Clang.") +else() + message(STATUS "Clang C++ compiler found: ${CLANG_CXX_COMPILER}") + set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER}) +endif() + +# Check for Clang assembler +find_program(CLANG_ASM_COMPILER NAMES clang) +if(NOT CLANG_ASM_COMPILER) + message(FATAL_ERROR "Clang assembler not found. Please install Clang.") +else() + message(STATUS "Clang assembler found: ${CLANG_ASM_COMPILER}") + set(CMAKE_ASM_COMPILER ${CLANG_ASM_COMPILER}) +endif() diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt new file mode 100644 index 000000000..1e12be3a7 --- /dev/null +++ b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt @@ -0,0 +1,70 @@ +# Copyright (C) 2025 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +if(CUSTOM_MUTATOR EQUAL 1) + add_compile_definitions(CUSTOM_MUTATOR) +endif() + +# Set default build options with the ability to override from the command line +if(NOT WAMR_BUILD_INTERP) + set(WAMR_BUILD_INTERP 1) +endif() + +if(NOT WAMR_BUILD_AOT) + set(WAMR_BUILD_AOT 1) +endif() + +if(NOT WAMR_BUILD_JIT) + set(WAMR_BUILD_JIT 0) +endif() + +if(NOT WAMR_BUILD_LIBC_BUILTIN) + set(WAMR_BUILD_LIBC_BUILTIN 0) +endif() + +if(NOT WAMR_BUILD_LIBC_WASI) + set(WAMR_BUILD_LIBC_WASI 1) +endif() + +if(NOT WAMR_BUILD_FAST_INTERP) + set(WAMR_BUILD_FAST_INTERP 1) +endif() + +if(NOT WAMR_BUILD_MULTI_MODULE) + set(WAMR_BUILD_MULTI_MODULE 0) +endif() + +if(NOT WAMR_BUILD_LIB_PTHREAD) + set(WAMR_BUILD_LIB_PTHREAD 0) +endif() + +if(NOT WAMR_BUILD_MINI_LOADER) + set(WAMR_BUILD_MINI_LOADER 0) +endif() + +set(WAMR_BUILD_SIMD 1) +set(WAMR_BUILD_REF_TYPES 1) +set(WAMR_BUILD_GC 1) + +include(${REPO_ROOT_DIR}/build-scripts/runtime_lib.cmake) +include(${REPO_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake) + +add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) +target_include_directories(vmlib PUBLIC ${RUNTIME_LIB_HEADER_LIST}) +target_link_directories(vmlib PUBLIC ${RUNTIME_LIB_LINK_LIST}) +target_link_libraries(vmlib PUBLIC ${LLVM_AVAILABLE_LIBS}) + +add_executable(wasm_mutator_fuzz wasm_mutator_fuzz.cc) +target_link_libraries(wasm_mutator_fuzz PRIVATE vmlib m) + +if(NOT IN_OSS_FUZZ) + message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment") + target_compile_options(vmlib PUBLIC + -fprofile-instr-generate -fcoverage-mapping + -fno-sanitize-recover=all + -fsanitize=address,undefined + -fsanitize=float-divide-by-zero,unsigned-integer-overflow,local-bounds,nullability + -fno-sanitize=alignment + ) + target_link_options(vmlib PUBLIC -fsanitize=address,undefined -fprofile-instr-generate) +endif() diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/wasm_mutator_fuzz.cc similarity index 100% rename from tests/fuzz/wasm-mutator-fuzz/wasm_mutator_fuzz.cc rename to tests/fuzz/wasm-mutator-fuzz/wasm-mutator/wasm_mutator_fuzz.cc From 1d39b9c8343dd5393a4f31533cf5391af1bf6702 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 29 Apr 2025 10:05:02 +0800 Subject: [PATCH 124/198] bypass vptr santizier (#4231) LLVM, by default, disables the use of C++'s built-in Run-Time Type Information. This decision is primarily driven by concerns about code size and efficiency. But '-fsanitize=vptr' not allowed with '-fno-rtti'. --- tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index 8bb860788..60c6d92f2 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -90,8 +90,10 @@ add_compile_options(-Wno-unused-command-line-argument) # Enable fuzzer add_definitions(-DWASM_ENABLE_FUZZ_TEST=1) -add_compile_options(-fsanitize=fuzzer) -add_link_options(-fsanitize=fuzzer) +# '-fsanitize=vptr' not allowed with '-fno-rtti +# But, LLVM by default, disables the use of `rtti` in the compiler +add_compile_options(-fsanitize=fuzzer -fno-sanitize=vptr) +add_link_options(-fsanitize=fuzzer -fno-sanitize=vptr) # Enable sanitizers if not in oss-fuzz environment set(CFLAGS_ENV $ENV{CFLAGS}) From a9966897b65914362a6835c26a8bd20372ec6053 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 29 Apr 2025 11:41:34 +0800 Subject: [PATCH 125/198] use a selected llvm libs list to replace the full list (#4232) --- tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 84 +++++++++++++++++++ .../aot-compiler/CMakeLists.txt | 83 +----------------- .../wasm-mutator/CMakeLists.txt | 2 +- 3 files changed, 86 insertions(+), 83 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index 60c6d92f2..a6ff12d64 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -82,6 +82,90 @@ include_directories(${LLVM_INCLUDE_DIRS}) separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) add_definitions(${LLVM_DEFINITIONS_LIST}) +list( + APPEND + REQUIRED_LLVM_LIBS + LLVMDemangle + LLVMSupport + LLVMTableGen + LLVMTableGenGlobalISel + LLVMCore + LLVMFuzzerCLI + LLVMFuzzMutate + LLVMFileCheck + LLVMInterfaceStub + LLVMIRReader + LLVMCodeGen + LLVMSelectionDAG + LLVMAsmPrinter + LLVMMIRParser + LLVMGlobalISel + LLVMBinaryFormat + LLVMBitReader + LLVMBitWriter + LLVMBitstreamReader + LLVMDWARFLinker + LLVMExtensions + LLVMFrontendOpenACC + LLVMFrontendOpenMP + LLVMTransformUtils + LLVMInstrumentation + LLVMAggressiveInstCombine + LLVMInstCombine + LLVMScalarOpts + LLVMipo + LLVMVectorize + LLVMObjCARCOpts + LLVMCoroutines + LLVMCFGuard + LLVMLinker + LLVMAnalysis + LLVMLTO + LLVMMC + LLVMMCParser + LLVMMCDisassembler + LLVMMCA + LLVMObjCopy + LLVMObject + LLVMObjectYAML + LLVMOption + LLVMRemarks + LLVMDebuginfod + LLVMDebugInfoDWARF + LLVMDebugInfoGSYM + LLVMDebugInfoMSF + LLVMDebugInfoCodeView + LLVMDebugInfoPDB + LLVMSymbolize + LLVMDWP + LLVMExecutionEngine + LLVMInterpreter + LLVMJITLink + LLVMMCJIT + LLVMOrcJIT + LLVMOrcShared + LLVMOrcTargetProcess + LLVMRuntimeDyld + LLVMTarget + LLVMX86CodeGen + LLVMX86AsmParser + LLVMX86Disassembler + LLVMX86TargetMCA + LLVMX86Desc + LLVMX86Info + LLVMAsmParser + LLVMLineEditor + LLVMProfileData + LLVMCoverage + LLVMPasses + LLVMTextAPI + LLVMDlltoolDriver + LLVMLibDriver + LLVMXRay + LLVMWindowsDriver + LLVMWindowsManifest +) + set(SHARED_DIR ${REPO_ROOT_DIR}/core/shared) set(IWASM_DIR ${REPO_ROOT_DIR}/core/iwasm) diff --git a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt index cf3caa16d..82c0ab332 100644 --- a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt @@ -65,88 +65,7 @@ target_include_directories(aotclib PUBLIC target_link_directories(aotclib PUBLIC ${LLVM_LIBRARY_DIR}) -target_link_libraries(aotclib - PUBLIC - LLVMDemangle - LLVMSupport - LLVMTableGen - LLVMTableGenGlobalISel - LLVMCore - LLVMFuzzerCLI - LLVMFuzzMutate - LLVMFileCheck - LLVMInterfaceStub - LLVMIRReader - LLVMCodeGen - LLVMSelectionDAG - LLVMAsmPrinter - LLVMMIRParser - LLVMGlobalISel - LLVMBinaryFormat - LLVMBitReader - LLVMBitWriter - LLVMBitstreamReader - LLVMDWARFLinker - LLVMExtensions - LLVMFrontendOpenACC - LLVMFrontendOpenMP - LLVMTransformUtils - LLVMInstrumentation - LLVMAggressiveInstCombine - LLVMInstCombine - LLVMScalarOpts - LLVMipo - LLVMVectorize - LLVMObjCARCOpts - LLVMCoroutines - LLVMCFGuard - LLVMLinker - LLVMAnalysis - LLVMLTO - LLVMMC - LLVMMCParser - LLVMMCDisassembler - LLVMMCA - LLVMObjCopy - LLVMObject - LLVMObjectYAML - LLVMOption - LLVMRemarks - LLVMDebuginfod - LLVMDebugInfoDWARF - LLVMDebugInfoGSYM - LLVMDebugInfoMSF - LLVMDebugInfoCodeView - LLVMDebugInfoPDB - LLVMSymbolize - LLVMDWP - LLVMExecutionEngine - LLVMInterpreter - LLVMJITLink - LLVMMCJIT - LLVMOrcJIT - LLVMOrcShared - LLVMOrcTargetProcess - LLVMRuntimeDyld - LLVMTarget - LLVMX86CodeGen - LLVMX86AsmParser - LLVMX86Disassembler - LLVMX86TargetMCA - LLVMX86Desc - LLVMX86Info - LLVMAsmParser - LLVMLineEditor - LLVMProfileData - LLVMCoverage - LLVMPasses - LLVMTextAPI - LLVMDlltoolDriver - LLVMLibDriver - LLVMXRay - LLVMWindowsDriver - LLVMWindowsManifest -) +target_link_libraries(aotclib PUBLIC ${REQUIRED_LLVM_LIBS}) if(NOT IN_OSS_FUZZ) message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment") diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt index 1e12be3a7..4d6ae0fa4 100644 --- a/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt @@ -52,7 +52,7 @@ include(${REPO_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) target_include_directories(vmlib PUBLIC ${RUNTIME_LIB_HEADER_LIST}) target_link_directories(vmlib PUBLIC ${RUNTIME_LIB_LINK_LIST}) -target_link_libraries(vmlib PUBLIC ${LLVM_AVAILABLE_LIBS}) +target_link_libraries(vmlib PUBLIC ${REQUIRED_LLVM_LIBS}) add_executable(wasm_mutator_fuzz wasm_mutator_fuzz.cc) target_link_libraries(wasm_mutator_fuzz PRIVATE vmlib m) From 9773390537600314b375dcb55643cbf101acaa0e Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Wed, 30 Apr 2025 14:10:56 +0800 Subject: [PATCH 126/198] set default value of `WAMR_BUILD_REF_TYPES` to 1 in standalone cases (#4227) - set default value of WAMR_BUILD_REF_TYPES to 1 in CMakeLists.txt --- tests/standalone/test-invoke-native/CMakeLists.txt | 5 +++++ tests/standalone/test-module-malloc/CMakeLists.txt | 3 +++ tests/standalone/test-module-malloc/run.sh | 1 - .../test-pthread/threads-opcode-wasm-apps/CMakeLists.txt | 2 +- .../standalone/test-running-modes/c-embed/CMakeLists.txt | 9 +++++++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/standalone/test-invoke-native/CMakeLists.txt b/tests/standalone/test-invoke-native/CMakeLists.txt index 54cec530a..9ba585842 100644 --- a/tests/standalone/test-invoke-native/CMakeLists.txt +++ b/tests/standalone/test-invoke-native/CMakeLists.txt @@ -88,6 +88,11 @@ if (NOT DEFINED WAMR_BUILD_SIMD) set (WAMR_BUILD_SIMD 0) endif () +if (NOT DEFINED WAMR_BUILD_REF_TYPES) + # Enable reference types by default + set (WAMR_BUILD_REF_TYPES 1) +endif () + set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) diff --git a/tests/standalone/test-module-malloc/CMakeLists.txt b/tests/standalone/test-module-malloc/CMakeLists.txt index 8081f9fa4..bdaff6834 100644 --- a/tests/standalone/test-module-malloc/CMakeLists.txt +++ b/tests/standalone/test-module-malloc/CMakeLists.txt @@ -48,6 +48,9 @@ endif () if (NOT WAMR_BUILD_AOT) set (WAMR_BUILD_AOT 1) endif () +if (NOT WAMR_BUILD_REF_TYPES) + set (WAMR_BUILD_REF_TYPES 1) +endif () set (WAMR_BUILD_LIBC_BUILTIN 1) set (WAMR_BUILD_LIBC_WASI 1) diff --git a/tests/standalone/test-module-malloc/run.sh b/tests/standalone/test-module-malloc/run.sh index 644544f08..a89a11654 100755 --- a/tests/standalone/test-module-malloc/run.sh +++ b/tests/standalone/test-module-malloc/run.sh @@ -55,4 +55,3 @@ else ./iwasm --native-lib=./libtest_module_malloc.so wasm-app/test.aot fi fi - diff --git a/tests/standalone/test-pthread/threads-opcode-wasm-apps/CMakeLists.txt b/tests/standalone/test-pthread/threads-opcode-wasm-apps/CMakeLists.txt index 4f8e21ac8..fa5b59a1b 100644 --- a/tests/standalone/test-pthread/threads-opcode-wasm-apps/CMakeLists.txt +++ b/tests/standalone/test-pthread/threads-opcode-wasm-apps/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14) project(wasm-apps) -set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../wamr) +set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) if (APPLE) set (HAVE_FLAG_SEARCH_PATHS_FIRST 0) diff --git a/tests/standalone/test-running-modes/c-embed/CMakeLists.txt b/tests/standalone/test-running-modes/c-embed/CMakeLists.txt index 52064ac44..a79ca33b5 100644 --- a/tests/standalone/test-running-modes/c-embed/CMakeLists.txt +++ b/tests/standalone/test-running-modes/c-embed/CMakeLists.txt @@ -11,10 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -project(c_embed_test) - cmake_minimum_required(VERSION 3.14) +project(c_embed_test) + include(CheckPIESupported) string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) @@ -34,6 +34,11 @@ set(WAMR_BUILD_LIBC_WASI 1) set(WAMR_BUILD_SIMD 1) set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../..) +if (NOT DEFINED WAMR_BUILD_REF_TYPES) + # Enable reference types by default + set (WAMR_BUILD_REF_TYPES 1) +endif () + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") if (NOT WAMR_BUILD_PLATFORM STREQUAL "darwin") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE") From 3232bdf2f7317c76a3d0b8ac2966f6f3d72cd22c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 May 2025 07:55:35 +0900 Subject: [PATCH 127/198] teach aot emitter/loader about .srodata and .srodata.cst* sections (#4240) LLVM 19 and later started to use srodata ("small read only data") sections for RISCV. cf. https://github.com/llvm/llvm-project/pull/82214 this commit makes our aot emitter/loader deal with those sections. an alternative would be to disable small data sections completely by setting the "SmallDataLimit" module attribute to zero. however, i feel this commit is more straightforward and consisitent as we are already dealing with sdata sections. --- core/iwasm/aot/aot_loader.c | 6 ++++-- core/iwasm/compilation/aot_emit_aot_file.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 9ca64f9c8..ae66b3f70 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -3189,10 +3189,12 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group, symbol_addr = module->code; } else if (!strcmp(symbol, ".data") || !strcmp(symbol, ".sdata") - || !strcmp(symbol, ".rdata") - || !strcmp(symbol, ".rodata") + || !strcmp(symbol, ".rdata") || !strcmp(symbol, ".rodata") + || !strcmp(symbol, ".srodata") /* ".rodata.cst4/8/16/.." */ || !strncmp(symbol, ".rodata.cst", strlen(".rodata.cst")) + /* ".srodata.cst4/8/16/.." */ + || !strncmp(symbol, ".srodata.cst", strlen(".srodata.cst")) /* ".rodata.strn.m" */ || !strncmp(symbol, ".rodata.str", strlen(".rodata.str")) || !strcmp(symbol, AOT_STACK_SIZES_SECTION_NAME) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index a41e0da33..29c5828f4 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -3270,8 +3270,17 @@ is_data_section(AOTObjectData *obj_data, LLVMSectionIteratorRef sec_itr, return (!strcmp(section_name, ".data") || !strcmp(section_name, ".sdata") || !strcmp(section_name, ".rodata") +#if LLVM_VERSION_MAJOR >= 19 + /* https://github.com/llvm/llvm-project/pull/82214 */ + || !strcmp(section_name, ".srodata") +#endif /* ".rodata.cst4/8/16/.." */ || !strncmp(section_name, ".rodata.cst", strlen(".rodata.cst")) +#if LLVM_VERSION_MAJOR >= 19 + /* https://github.com/llvm/llvm-project/pull/82214 + * ".srodata.cst4/8/16/.." */ + || !strncmp(section_name, ".srodata.cst", strlen(".srodata.cst")) +#endif /* ".rodata.strn.m" */ || !strncmp(section_name, ".rodata.str", strlen(".rodata.str")) || (!strcmp(section_name, ".rdata") From 382aa9e6c35327df5ad405ffe61e9cd3e2bf2a86 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 May 2025 07:55:42 +0900 Subject: [PATCH 128/198] run_clang_format_diff: mention homebrew for clang-format installation (#4237) --- ci/coding_guidelines_check.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ci/coding_guidelines_check.py b/ci/coding_guidelines_check.py index 5432080f1..43c366259 100644 --- a/ci/coding_guidelines_check.py +++ b/ci/coding_guidelines_check.py @@ -98,9 +98,19 @@ def run_clang_format_diff(root: Path, commits: str) -> bool: code before committing the PR, or it might fail to pass the CI check: 1. Install clang-format-14.0.0 - Normally we can install it by `sudo apt-get install clang-format-14`, - or download the package from https://github.com/llvm/llvm-project/releases - and install it + + You can download the package from + https://github.com/llvm/llvm-project/releases + and install it. + + For Debian/Ubuntu, we can probably use + `sudo apt-get install clang-format-14`. + + Homebrew has it as a part of llvm@14. + ```shell + brew install llvm@14 + /usr/local/opt/llvm@14/bin/clang-format + ``` 2. Format the C/C++ source file ``` shell From 5bdbba0dbecea0e7da077a3c6fef462b51f8a1b6 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 6 May 2025 06:55:53 +0800 Subject: [PATCH 129/198] platform/nuttx: Fix dcache operation in os_dcache_flush (#4225) Replace up_invalidate_dcache_all() with up_flush_dcache_all() in os_dcache_flush() to properly flush the data cache instead of just invalidating it. This ensures that any modified data in the cache is written back to memory before execution. Signed-off-by: Huang Qi --- core/shared/platform/nuttx/nuttx_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/shared/platform/nuttx/nuttx_platform.c b/core/shared/platform/nuttx/nuttx_platform.c index 7a28005d4..da5bf8673 100644 --- a/core/shared/platform/nuttx/nuttx_platform.c +++ b/core/shared/platform/nuttx/nuttx_platform.c @@ -118,7 +118,7 @@ os_dcache_flush() up_textheap_data_sync(); #endif #ifndef CONFIG_BUILD_KERNEL - up_invalidate_dcache_all(); + up_flush_dcache_all(); #endif } From 5910e5cd2134b20d7c7a7fb8ff6d360760463148 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 6 May 2025 06:56:06 +0800 Subject: [PATCH 130/198] Use --target to pass a triple in wamrc (#4199) Provide a triple string in the format of --- via --target. --- core/iwasm/compilation/aot_llvm.c | 22 ++++++++++++++++++---- wamr-compiler/main.c | 3 +++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index 9270f0efe..c1708e3f9 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2742,10 +2742,23 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) } else { /* Create LLVM target machine */ - arch = option->target_arch; - abi = option->target_abi; - cpu = option->target_cpu; - features = option->cpu_features; + if (!option->target_arch || !strstr(option->target_arch, "-")) { + /* Retrieve the target triple based on user input */ + triple = NULL; + arch = option->target_arch; + abi = option->target_abi; + cpu = option->target_cpu; + features = option->cpu_features; + } + else { + /* Form a target triple */ + triple = option->target_arch; + arch = NULL; + abi = NULL; + cpu = NULL; + features = NULL; + } + opt_level = option->opt_level; size_level = option->size_level; @@ -2986,6 +2999,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) aot_set_last_error(buf); goto fail; } + LOG_VERBOSE("triple: %s => normailized: %s", triple, triple_norm); if (!cpu) cpu = ""; } diff --git a/wamr-compiler/main.c b/wamr-compiler/main.c index 312231619..4d1a24b54 100644 --- a/wamr-compiler/main.c +++ b/wamr-compiler/main.c @@ -116,6 +116,9 @@ print_help() printf(" Default is host arch, e.g. x86_64\n"); printf(" = for ex. on arm or thumb: v5, v6m, v7a, v7m, etc.\n"); printf(" Use --target=help to list supported targets\n"); + printf(" Or, provide a triple in the format of ---.\n"); + printf(" By doing this, --target-abi, --cpu, and --cpu-features will be ignored.\n"); + printf(" The triple will only be normalized without any further verification.\n"); printf(" --target-abi= Set the target ABI, e.g. gnu, eabi, gnueabihf, msvc, etc.\n"); printf(" Default is gnu if target isn't riscv64 or riscv32\n"); printf(" For target riscv64 and riscv32, default is lp64d and ilp32d\n"); From 4735956eeb7ea80f9298ca1a5367b0f8741de68d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 May 2025 11:15:00 +0900 Subject: [PATCH 131/198] fix return types of our 64-bit clz/ctz/popcount intrinsics (#4238) the corresponding LLVM intrinsics' return types are same as their first argument. eg. i64 for llvm.cttz.i64. cf. https://llvm.org/docs/LangRef.html#llvm-cttz-intrinsic this commit changes the return types of our versions of the intrinsics to match llvm versions as our aot compiler, specifically __call_llvm_intrinsic, assumes. strictly speaking, this is a potential AOT ABI change. however, I suppose it isn't a problem for many of 64-bit ABIs out there, where (lower half of) a 64-bit register is used to return a 32-bit value anyway. (for such ABIs, this commit would fix the upper 32-bit value of the register.) --- core/iwasm/aot/aot_intrinsic.c | 6 +++--- core/iwasm/aot/aot_intrinsic.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/iwasm/aot/aot_intrinsic.c b/core/iwasm/aot/aot_intrinsic.c index 252ef7056..fcc2fda9d 100644 --- a/core/iwasm/aot/aot_intrinsic.c +++ b/core/iwasm/aot/aot_intrinsic.c @@ -194,7 +194,7 @@ aot_intrinsic_clz_i32(uint32 type) return num; } -uint32 +uint64 aot_intrinsic_clz_i64(uint64 type) { uint32 num = 0; @@ -220,7 +220,7 @@ aot_intrinsic_ctz_i32(uint32 type) return num; } -uint32 +uint64 aot_intrinsic_ctz_i64(uint64 type) { uint32 num = 0; @@ -244,7 +244,7 @@ aot_intrinsic_popcnt_i32(uint32 u) return ret; } -uint32 +uint64 aot_intrinsic_popcnt_i64(uint64 u) { uint32 ret = 0; diff --git a/core/iwasm/aot/aot_intrinsic.h b/core/iwasm/aot/aot_intrinsic.h index f065a5ad2..e54c82516 100644 --- a/core/iwasm/aot/aot_intrinsic.h +++ b/core/iwasm/aot/aot_intrinsic.h @@ -186,19 +186,19 @@ aot_intrinsic_fmax_f64(float64 a, float64 b); uint32 aot_intrinsic_clz_i32(uint32 type); -uint32 +uint64 aot_intrinsic_clz_i64(uint64 type); uint32 aot_intrinsic_ctz_i32(uint32 type); -uint32 +uint64 aot_intrinsic_ctz_i64(uint64 type); uint32 aot_intrinsic_popcnt_i32(uint32 u); -uint32 +uint64 aot_intrinsic_popcnt_i64(uint64 u); float32 From d053f5534a479d9563580f941eb72e459cc05133 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 11:16:45 +0800 Subject: [PATCH 132/198] build(deps): Bump github/codeql-action from 3.28.15 to 3.28.17 (#4243) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.15 to 3.28.17. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.15...v3.28.17) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.17 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ab76a6b5d..7126e2d09 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.15 + uses: github/codeql-action/init@v3.28.17 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.15 + uses: github/codeql-action/analyze@v3.28.17 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.15 + uses: github/codeql-action/upload-sarif@v3.28.17 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 39e868dd6..acc123c77 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@4c3e5362829f0b0bb62ff5f6c938d7f95574c306 + uses: github/codeql-action/upload-sarif@5eb3ed6614230b1931d5c08df9e096e4ba524f21 with: sarif_file: results.sarif From 1996c18c4b796c343eb1e1410a2ccc58c9b7e518 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 08:09:44 +0900 Subject: [PATCH 133/198] samples/wasm-c-api: skip aot compilation unless necessary (#4239) --- samples/wasm-c-api/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/wasm-c-api/CMakeLists.txt b/samples/wasm-c-api/CMakeLists.txt index b8783f4ae..19c601889 100644 --- a/samples/wasm-c-api/CMakeLists.txt +++ b/samples/wasm-c-api/CMakeLists.txt @@ -129,7 +129,7 @@ if (${WAT2WASM_VERSION} VERSION_LESS 1.0.26) set(WAT2WASM_FLAGS "--enable-reference-types") endif () -if(${WAMR_BUILD_AOT} EQUAL 1) +if(${WAMR_BUILD_AOT} EQUAL 1 AND ${WAMR_BUILD_INTERP} EQUAL 0) ## locate wamrc find_program(WAMRC wamrc From bb36a43fa4558170f24aa6b172ab361c31ed54c6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 10:42:51 +0900 Subject: [PATCH 134/198] riscv: avoid llvm.cttz.i32/i64 for xip (#4248) LLVM 16 and later expands cttz intrinsic to a table lookup, which involves some relocations. (unless ZBB is available, in which case the native instructions are preferred over the table-based lowering.) cf. https://reviews.llvm.org/D128911 --- core/iwasm/aot/aot_intrinsic.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/iwasm/aot/aot_intrinsic.c b/core/iwasm/aot/aot_intrinsic.c index fcc2fda9d..a0e59e1d2 100644 --- a/core/iwasm/aot/aot_intrinsic.c +++ b/core/iwasm/aot/aot_intrinsic.c @@ -898,6 +898,17 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx) if (!strncmp(comp_ctx->target_arch, "riscv32", 7)) { add_i64_common_intrinsics(comp_ctx); } + /* + * LLVM 16 and later expands cttz intrinsic to a table lookup, + * which involves some relocations. (unless ZBB is available, + * in which case the native instructions are preferred over + * the table-based lowering.) + * https://reviews.llvm.org/D128911 + */ +#if LLVM_VERSION_MAJOR >= 16 + add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CTZ); + add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CTZ); +#endif } else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) { /* From ea417d7619db70ee79856d486e0b3cc3406155f9 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 7 May 2025 09:45:49 +0800 Subject: [PATCH 135/198] Add overflow check for preserved local offset in preserve_referenced_local (#4211) --- core/iwasm/interpreter/wasm_loader.c | 9 +++++++++ core/iwasm/interpreter/wasm_mini_loader.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index fc68e5966..ef4020a36 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -9197,6 +9197,15 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode, loader_ctx->preserved_local_offset += 2; emit_label(EXT_OP_COPY_STACK_TOP_I64); } + + /* overflow */ + if (preserved_offset > loader_ctx->preserved_local_offset) { + set_error_buf_v(error_buf, error_buf_size, + "too much local cells 0x%x", + loader_ctx->preserved_local_offset); + return false; + } + emit_operand(loader_ctx, local_index); emit_operand(loader_ctx, preserved_offset); emit_label(opcode); diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index af9ea5046..23fb76370 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -4778,6 +4778,11 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode, loader_ctx->preserved_local_offset += 2; emit_label(EXT_OP_COPY_STACK_TOP_I64); } + + /* overflow */ + bh_assert(preserved_offset + <= loader_ctx->preserved_local_offset); + emit_operand(loader_ctx, local_index); emit_operand(loader_ctx, preserved_offset); emit_label(opcode); From ac2fe552d518788c17e6a69fc83cfe223b44590e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 12:32:14 +0900 Subject: [PATCH 136/198] aot_resolve_object_relocation_group: adapt to LLVM 16 (#4250) cf. https://reviews.llvm.org/D123264 --- core/iwasm/compilation/aot_emit_aot_file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index 29c5828f4..5a7ba9e74 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -4007,8 +4007,12 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, && (str_starts_with(relocation->symbol_name, ".LCPI") || str_starts_with(relocation->symbol_name, ".LJTI") || str_starts_with(relocation->symbol_name, ".LBB") - || str_starts_with(relocation->symbol_name, - ".Lswitch.table."))) { + || str_starts_with(relocation->symbol_name, ".Lswitch.table.") +#if LLVM_VERSION_MAJOR >= 16 + /* cf. https://reviews.llvm.org/D123264 */ + || str_starts_with(relocation->symbol_name, ".Lpcrel_hi") +#endif + )) { /* change relocation->relocation_addend and relocation->symbol_name */ LLVMSectionIteratorRef contain_section; From 88b5f6a53568ab7b96b9277b281073e60735b71d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 May 2025 12:32:29 +0900 Subject: [PATCH 137/198] samples/wasm-c-api: remove unused valgrind detection (#4249) - it's unused - valgrind is basically a linux-only software. it isn't a good idea to make it a hard requirement. if we want to use valgrind, it's better to introduce a separate option to control it. --- samples/wasm-c-api/CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/samples/wasm-c-api/CMakeLists.txt b/samples/wasm-c-api/CMakeLists.txt index 19c601889..06dc92d5e 100644 --- a/samples/wasm-c-api/CMakeLists.txt +++ b/samples/wasm-c-api/CMakeLists.txt @@ -205,12 +205,3 @@ foreach(EX ${EXAMPLES}) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endforeach() - -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - find_program(VALGRIND - valgrind - REQUIRED - ) - - # run `ctest -T memcheck -V --test-dir build` -endif() From 0e8b57d8a8af644cc44bc3f0f44ed78d409c834c Mon Sep 17 00:00:00 2001 From: Chris Woods <6069113+woodsmc@users.noreply.github.com> Date: Tue, 6 May 2025 23:32:43 -0400 Subject: [PATCH 138/198] More detail to python setup, and fixed small typo (#4247) --- language-bindings/python/wamr-api/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/language-bindings/python/wamr-api/README.md b/language-bindings/python/wamr-api/README.md index 38a440144..b2ef1e105 100644 --- a/language-bindings/python/wamr-api/README.md +++ b/language-bindings/python/wamr-api/README.md @@ -1,14 +1,17 @@ -# WARM API +# WAMR API -* **Notice**: The python package `wamr.wamrapi.wamr` need python >= `3.10`. +* **Notice**: The python package `wamr.wamrapi.wamr` requires a python version >= `3.10`. ## Setup ### Pre-requisites +#### Install requirements +Before proceeding it is necessary to make sure your Python environment is correctly configured. To do ths open a terminal session in this directory and perfom the following: -Install requirements, ```shell +python3 -m venv venv +source venv/bin/activate pip install -r requirements.txt ``` From 216404d7cbaf02027fcf1f3fa5689c74624185ee Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 8 May 2025 08:47:07 +0800 Subject: [PATCH 139/198] initialize WASI stdio handles to invalid for better error handling (#4092) * initialize WASI stdio handles to invalid for better error handling * implement os_invalid_raw_handle function for consistent invalid handle representation --- core/iwasm/aot/aot_loader.c | 6 ++++++ core/iwasm/interpreter/wasm_loader.c | 6 ++++++ core/iwasm/interpreter/wasm_mini_loader.c | 6 ++++++ core/shared/platform/alios/alios_platform.c | 6 ++++++ core/shared/platform/common/posix/posix_file.c | 8 +++++++- core/shared/platform/esp-idf/espidf_file.c | 8 +++++++- core/shared/platform/include/platform_api_extension.h | 9 +++++++++ core/shared/platform/riot/riot_platform.c | 6 ++++++ core/shared/platform/rt-thread/rtt_file.c | 6 ++++++ core/shared/platform/windows/win_file.c | 6 ++++++ core/shared/platform/zephyr/zephyr_platform.c | 6 ++++++ 11 files changed, 71 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index ae66b3f70..13de3009d 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -4127,6 +4127,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) } #endif +#if WASM_ENABLE_LIBC_WASI != 0 + module->wasi_args.stdio[0] = os_invalid_raw_handle(); + module->wasi_args.stdio[1] = os_invalid_raw_handle(); + module->wasi_args.stdio[2] = os_invalid_raw_handle(); +#endif + return module; #if WASM_ENABLE_GC != 0 fail2: diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index ef4020a36..4cdf6ea5c 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -6376,6 +6376,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) } #endif +#if WASM_ENABLE_LIBC_WASI != 0 + module->wasi_args.stdio[0] = os_invalid_raw_handle(); + module->wasi_args.stdio[1] = os_invalid_raw_handle(); + module->wasi_args.stdio[2] = os_invalid_raw_handle(); +#endif + (void)ret; return module; diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 23fb76370..30d540d56 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -3137,6 +3137,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) } #endif +#if WASM_ENABLE_LIBC_WASI != 0 + module->wasi_args.stdio[0] = os_invalid_raw_handle(); + module->wasi_args.stdio[1] = os_invalid_raw_handle(); + module->wasi_args.stdio[2] = os_invalid_raw_handle(); +#endif + (void)ret; return module; } diff --git a/core/shared/platform/alios/alios_platform.c b/core/shared/platform/alios/alios_platform.c index b5663e3a2..a3752b439 100644 --- a/core/shared/platform/alios/alios_platform.c +++ b/core/shared/platform/alios/alios_platform.c @@ -79,3 +79,9 @@ os_dcache_flush() void os_icache_flush(void *start, size_t len) {} + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return -1; +} diff --git a/core/shared/platform/common/posix/posix_file.c b/core/shared/platform/common/posix/posix_file.c index 9ae0a03a2..d90f38ec5 100644 --- a/core/shared/platform/common/posix/posix_file.c +++ b/core/shared/platform/common/posix/posix_file.c @@ -1032,4 +1032,10 @@ char * os_realpath(const char *path, char *resolved_path) { return realpath(path, resolved_path); -} \ No newline at end of file +} + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return -1; +} diff --git a/core/shared/platform/esp-idf/espidf_file.c b/core/shared/platform/esp-idf/espidf_file.c index be50a2900..4d78df38a 100644 --- a/core/shared/platform/esp-idf/espidf_file.c +++ b/core/shared/platform/esp-idf/espidf_file.c @@ -1032,4 +1032,10 @@ char * os_realpath(const char *path, char *resolved_path) { return realpath(path, resolved_path); -} \ No newline at end of file +} + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return -1; +} diff --git a/core/shared/platform/include/platform_api_extension.h b/core/shared/platform/include/platform_api_extension.h index 12843b7c1..d57d0eac7 100644 --- a/core/shared/platform/include/platform_api_extension.h +++ b/core/shared/platform/include/platform_api_extension.h @@ -1607,6 +1607,15 @@ os_is_dir_stream_valid(os_dir_stream *dir_stream); os_file_handle os_get_invalid_handle(void); +/** + * Returns an invalid raw file handle that is guaranteed to cause failure when + * called with any filesystem operation. + * + * @return the invalid raw file handle + */ +os_raw_file_handle +os_invalid_raw_handle(void); + /** * Checks whether the given file handle is valid. An invalid handle is * guaranteed to cause failure when called with any filesystem operation. diff --git a/core/shared/platform/riot/riot_platform.c b/core/shared/platform/riot/riot_platform.c index 9accc5eb8..b48033247 100644 --- a/core/shared/platform/riot/riot_platform.c +++ b/core/shared/platform/riot/riot_platform.c @@ -95,3 +95,9 @@ os_dcache_flush(void) void os_icache_flush(void *start, size_t len) {} + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return -1; +} diff --git a/core/shared/platform/rt-thread/rtt_file.c b/core/shared/platform/rt-thread/rtt_file.c index b9fd1f9fa..f858f7eae 100644 --- a/core/shared/platform/rt-thread/rtt_file.c +++ b/core/shared/platform/rt-thread/rtt_file.c @@ -192,3 +192,9 @@ posix_fallocate(int __fd, off_t __offset, off_t __length) errno = ENOSYS; return -1; } + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return -1; +} diff --git a/core/shared/platform/windows/win_file.c b/core/shared/platform/windows/win_file.c index 770c5c741..55ea77ac7 100644 --- a/core/shared/platform/windows/win_file.c +++ b/core/shared/platform/windows/win_file.c @@ -1810,3 +1810,9 @@ os_realpath(const char *path, char *resolved_path) return resolved_path; } + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return INVALID_HANDLE_VALUE; +} diff --git a/core/shared/platform/zephyr/zephyr_platform.c b/core/shared/platform/zephyr/zephyr_platform.c index b383def67..3280e542f 100644 --- a/core/shared/platform/zephyr/zephyr_platform.c +++ b/core/shared/platform/zephyr/zephyr_platform.c @@ -255,3 +255,9 @@ set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func, exec_mem_alloc_func = alloc_func; exec_mem_free_func = free_func; } + +os_raw_file_handle +os_invalid_raw_handle(void) +{ + return -1; +} From ca5a2faf58f2fe86bbce7ce1168651069cea9898 Mon Sep 17 00:00:00 2001 From: Chris Woods <6069113+woodsmc@users.noreply.github.com> Date: Wed, 7 May 2025 22:13:09 -0400 Subject: [PATCH 140/198] Modifying build flags to ensure libiwasm.so is built (#4255) --- language-bindings/python/utils/create_lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/language-bindings/python/utils/create_lib.sh b/language-bindings/python/utils/create_lib.sh index 801186e97..157135880 100755 --- a/language-bindings/python/utils/create_lib.sh +++ b/language-bindings/python/utils/create_lib.sh @@ -17,6 +17,7 @@ cmake \ -DWAMR_BUILD_LIB_PTHREAD=1 \ -DWAMR_BUILD_LIB_WASI_THREADS=1 \ -DWAMR_BUILD_LIB_WASI=1 \ + -DBUILD_SHARED_LIBS=ON \ .. make -j From f88718d7053c35ba722f68e04ab83fca78173397 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 May 2025 11:24:55 +0900 Subject: [PATCH 141/198] JIT: don't join worker threads twice (#4252) in case of WASM_ENABLE_LAZY_JIT==0, compile_jit_functions should have already joined these threads. joining them again here is an undefined behavior. --- core/iwasm/interpreter/wasm_loader.c | 2 ++ core/iwasm/interpreter/wasm_mini_loader.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 4cdf6ea5c..13fd61e7c 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -5711,6 +5711,7 @@ orcjit_thread_callback(void *arg) static void orcjit_stop_compile_threads(WASMModule *module) { +#if WASM_ENABLE_LAZY_JIT != 0 uint32 i, thread_num = (uint32)(sizeof(module->orcjit_thread_args) / sizeof(OrcJitThreadArg)); @@ -5719,6 +5720,7 @@ orcjit_stop_compile_threads(WASMModule *module) if (module->orcjit_threads[i]) os_thread_join(module->orcjit_threads[i], NULL); } +#endif } static bool diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 30d540d56..1ed91230f 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -2493,6 +2493,7 @@ orcjit_thread_callback(void *arg) static void orcjit_stop_compile_threads(WASMModule *module) { +#if WASM_ENABLE_LAZY_JIT != 0 uint32 i, thread_num = (uint32)(sizeof(module->orcjit_thread_args) / sizeof(OrcJitThreadArg)); @@ -2501,6 +2502,7 @@ orcjit_stop_compile_threads(WASMModule *module) if (module->orcjit_threads[i]) os_thread_join(module->orcjit_threads[i], NULL); } +#endif } static bool From 0a8994a2d5174fb985b260159dcf0a3cd7d1a7b1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 May 2025 11:34:04 +0900 Subject: [PATCH 142/198] aot_resolve_object_relocation_group: adapt to LLVM 19 (#4254) cf. https://github.com/llvm/llvm-project/pull/95031 https://github.com/llvm/llvm-project/pull/89693 --- core/iwasm/compilation/aot_emit_aot_file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index 5a7ba9e74..097727d13 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -4011,6 +4011,15 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, #if LLVM_VERSION_MAJOR >= 16 /* cf. https://reviews.llvm.org/D123264 */ || str_starts_with(relocation->symbol_name, ".Lpcrel_hi") +#endif +#if LLVM_VERSION_MAJOR >= 19 + /* cf. + * https://github.com/llvm/llvm-project/pull/95031 + * https://github.com/llvm/llvm-project/pull/89693 + * + * note: the trailing space in ".L0 " is intentional. */ + || !strcmp(relocation->symbol_name, "") + || !strcmp(relocation->symbol_name, ".L0 ") #endif )) { /* change relocation->relocation_addend and From 6aa223dbf35dfd24910c153c1adec010c8e27e16 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 9 May 2025 10:29:06 +0900 Subject: [PATCH 143/198] Stop pretending to support extended-const proposal (#4258) As far as I know, we don't implement the proposal at all. ``` spacetanuki% wasm2wat --enable-all data.28.wasm (module (memory (;0;) 1) (data (;0;) (i32.const 42 i32.const 0 i32.sub) "")) spacetanuki% toywasm --load data.28.wasm spacetanuki% ~/git/wasm-micro-runtime/product-mini/platforms/darwin/b.classic/iwasm data.28.wasm WASM module load failed: illegal opcode or constant expression required or type mismatch spacetanuki% ``` data.28.wasm in the above example is a binary version of: https://github.com/WebAssembly/extended-const/blob/8d4f6aa2b00a8e7c0174410028625c6a176db8a1/test/core/data.wast#L184-L187 --- build-scripts/config_common.cmake | 2 +- doc/stability_wasm_proposals.md | 2 +- product-mini/platforms/common/wasm_proposal.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 1cb50235c..7ded52fd9 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -677,7 +677,6 @@ endif () message ( "-- About Wasm Proposals:\n" " Always-on:\n" -" \"Extended Constant Expressions\"\n" " \"Multi-value\"\n" " \"Non-trapping float-to-int conversions\"\n" " \"Sign-extension operators\"\n" @@ -698,6 +697,7 @@ message ( " \"Branch Hinting\"\n" " \"Custom Annotation Syntax in the Text Format\"\n" " \"Exception handling\"\n" +" \"Extended Constant Expressions\"\n" " \"Import/Export of Mutable Globals\"\n" " \"JS String Builtins\"\n" " \"Relaxed SIMD\"\n" diff --git a/doc/stability_wasm_proposals.md b/doc/stability_wasm_proposals.md index 715f2f3bd..e2bbe54e8 100644 --- a/doc/stability_wasm_proposals.md +++ b/doc/stability_wasm_proposals.md @@ -15,7 +15,6 @@ Users can turn those features on or off by using compilation options. If a relev | Proposal | >= Phase 4 | Compilation Option | | ------------------------------------- | ---------- | ------------------------ | | Bulk memory operations | Yes | `WAMR_BUILD_BULK_MEMORY` | -| Extended Constant Expressions | Yes | N/A | | Fixed-width SIMD[^1] | Yes | `WAMR_BUILD_SIMD` | | Multi-value | Yes | N/A | | Non-trapping float-to-int conversions | Yes | N/A | @@ -54,6 +53,7 @@ Users can turn those features on or off by using compilation options. If a relev | Branch Hinting | Yes | | Custom Annotation Syntax in the Text Format | Yes | | Exception handling[^5] | Yes | +| Extended Constant Expressions | Yes | | Import/Export of Mutable Globals | Yes | | JS String Builtins | Yes | | Relaxed SIMD | Yes | diff --git a/product-mini/platforms/common/wasm_proposal.c b/product-mini/platforms/common/wasm_proposal.c index 12bbf79bc..3c04d46ec 100644 --- a/product-mini/platforms/common/wasm_proposal.c +++ b/product-mini/platforms/common/wasm_proposal.c @@ -12,7 +12,6 @@ wasm_proposal_print_status(void) { printf("About Wasm Proposals:\n"); printf(" Always-on:\n"); - printf(" - Extended Constant Expressions\n"); printf(" - Multi-value\n"); printf(" - Non-trapping float-to-int conversions\n"); printf(" - Sign-extension operators\n"); @@ -44,6 +43,7 @@ wasm_proposal_print_status(void) printf(" - Branch Hinting\n"); printf(" - Custom Annotation Syntax in the Text Format\n"); printf(" - Exception handling\n"); + printf(" - Extended Constant Expressions\n"); printf(" - Import/Export of Mutable Globals\n"); printf(" - JS String Builtins\n"); printf(" - Relaxed SIMD\n"); From 1a72dcf34fc83b21f04163157c50ed834aa4270f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 9 May 2025 14:01:29 +0800 Subject: [PATCH 144/198] Improve readlinkat_dup() to handle symlink size correctly (#4229) * In readlinkat_dup(), use fstatat() to estimate size first. * Reduce additional space in samples/file --- .../sandboxed-system-primitives/src/posix.c | 57 ++++++++++++------- samples/file/wasm-app/main.c | 2 +- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c index e48645d8c..bef4c19f3 100644 --- a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c +++ b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c @@ -1222,43 +1222,56 @@ __wasi_errno_t readlinkat_dup(os_file_handle handle, const char *path, size_t *p_len, char **out_buf) { - char *buf = NULL; - size_t len = 32; - size_t len_org = len; + __wasi_errno_t error; + struct __wasi_filestat_t stat = { 0 }; + size_t buf_len; + /* + * use fstatat to get a better estimation + * If path is a symbolic link, do not dereference it: + * instead return information about the link itself, + * like lstat(). + */ + error = os_fstatat(handle, path, &stat, 0); + if (error != __WASI_ESUCCESS) { + stat.st_size = 0; + } + + /* + * Some magic symlinks report `st_size` as zero. In that case, take + * 32 as the initial buffer size. Otherwise, use `st_size + 1`. + */ + buf_len = stat.st_size ? stat.st_size + 1 : 32; for (;;) { - char *newbuf = wasm_runtime_malloc((uint32)len); + size_t bytes_read = 0; + char *buf; - if (newbuf == NULL) { - if (buf) - wasm_runtime_free(buf); + buf = wasm_runtime_malloc((uint32)buf_len); + if (buf == NULL) { *out_buf = NULL; return __WASI_ENOMEM; } - if (buf != NULL) { - bh_memcpy_s(newbuf, (uint32)len, buf, (uint32)len_org); - wasm_runtime_free(buf); - } - - buf = newbuf; - size_t bytes_read = 0; - __wasi_errno_t error = - os_readlinkat(handle, path, buf, len, &bytes_read); + error = os_readlinkat(handle, path, buf, buf_len, &bytes_read); if (error != __WASI_ESUCCESS) { wasm_runtime_free(buf); + *p_len = 0; *out_buf = NULL; return error; } - if ((size_t)bytes_read + 1 < len) { - buf[bytes_read] = '\0'; - *p_len = len; - *out_buf = buf; + /* not truncated */ + if (bytes_read < buf_len) { + buf[bytes_read] = '\0'; + *p_len = bytes_read + 1; + *out_buf = buf; return __WASI_ESUCCESS; } - len_org = len; - len *= 2; + + /* truncated, try again with a bigger buf */ + wasm_runtime_free(buf); + buf = NULL; + buf_len *= 2; } } diff --git a/samples/file/wasm-app/main.c b/samples/file/wasm-app/main.c index 6e6204cca..e794a273f 100644 --- a/samples/file/wasm-app/main.c +++ b/samples/file/wasm-app/main.c @@ -18,7 +18,7 @@ #define WORLD_OFFSET 7 #define NAME_REPLACMENT "James" #define NAME_REPLACMENT_LEN (sizeof(NAME_REPLACMENT) - 1) -#define ADDITIONAL_SPACE 1 * 1024 * 1024 +#define ADDITIONAL_SPACE 16 * 1024 int main(int argc, char **argv) From 908838a5b59f1994aac8f8fdee8c98f35b95b3a5 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 9 May 2025 18:14:02 +0900 Subject: [PATCH 145/198] build-scripts/build_llvm.py: bump to llvm 18 (#4259) * build-scripts/build_llvm.py: bump to llvm 18 cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4210 why not 20? because, as of writing this, 19 is the latest released version for the xtensa fork of llvm: https://github.com/espressif/llvm-project why not 19? because of a bug in the xtensa fork of llvm: https://github.com/espressif/llvm-project/issues/112 while we can use different versions for different targets, it's nicer to use the same version everywhere when possible. * spec-test-script/runtest.py: --size-level=0 for x86-64 with the recent version of LLVM, wamrc --size-level=1 often generates R_X86_64_32S relocations which fail on load with the infamous error: "relocation truncated to fit R_X86_64_32S failed" it seems that these relocations are often for jump tables. this commit workarounds it with --size-level=0. an alternative is to disable jump tables. (although it seems that jump tables are not the only source of these relocations.) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035 it might be better to do this in wamrc itself. however, currently target info is not available there in case of native compilation. related: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3356 * wamr-compiler: size_level=0 for sgx mode cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035 --- build-scripts/build_llvm.py | 6 +++--- tests/wamr-test-suites/spec-test-script/runtest.py | 3 ++- wamr-compiler/main.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index d8bcbd26c..3d241355b 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -294,17 +294,17 @@ def main(): "arc": { "repo": "https://github.com/llvm/llvm-project.git", "repo_ssh": "git@github.com:llvm/llvm-project.git", - "branch": "release/15.x", + "branch": "release/18.x", }, "xtensa": { "repo": "https://github.com/espressif/llvm-project.git", "repo_ssh": "git@github.com:espressif/llvm-project.git", - "branch": "xtensa_release_17.0.1", + "branch": "xtensa_release_18.1.2", }, "default": { "repo": "https://github.com/llvm/llvm-project.git", "repo_ssh": "git@github.com:llvm/llvm-project.git", - "branch": "release/15.x", + "branch": "release/18.x", }, } diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index 8de001af6..158d759ed 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -46,7 +46,8 @@ temp_module_table = {} aot_target_options_map = { "i386": ["--target=i386"], "x86_32": ["--target=i386"], - "x86_64": ["--target=x86_64", "--cpu=skylake"], + # cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035 + "x86_64": ["--target=x86_64", "--cpu=skylake", "--size-level=0"], "aarch64": ["--target=aarch64", "--target-abi=eabi", "--cpu=cortex-a53"], "aarch64_vfp": ["--target=aarch64", "--target-abi=gnueabihf", "--cpu=cortex-a53"], "armv7": ["--target=armv7", "--target-abi=eabi", "--cpu=cortex-a9", "--cpu-features=-neon"], diff --git a/wamr-compiler/main.c b/wamr-compiler/main.c index 4d1a24b54..f74b2fb15 100644 --- a/wamr-compiler/main.c +++ b/wamr-compiler/main.c @@ -712,7 +712,7 @@ main(int argc, char *argv[]) } if (sgx_mode) { - option.size_level = 1; + option.size_level = 0; option.is_sgx_platform = true; } From 8f3961026e96bcee8a5848dd5d9887141a7503d2 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 9 May 2025 17:14:20 +0800 Subject: [PATCH 146/198] fix: improve error handling of snprintf() in send_thread_stop_status() (#4234) Prevent `MAX_PACKET_SIZE - len` from overflowing. --- core/iwasm/libraries/debug-engine/handler.c | 81 +++++++++++++++------ 1 file changed, 57 insertions(+), 24 deletions(-) diff --git a/core/iwasm/libraries/debug-engine/handler.c b/core/iwasm/libraries/debug-engine/handler.c index a5267d770..743165dd9 100644 --- a/core/iwasm/libraries/debug-engine/handler.c +++ b/core/iwasm/libraries/debug-engine/handler.c @@ -383,7 +383,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) if (status == 0) { os_mutex_lock(&tmpbuf_lock); - snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02" PRIx32, status); + (void)snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02" PRIx32, status); write_packet(server, tmpbuf); os_mutex_unlock(&tmpbuf_lock); return; @@ -399,18 +399,38 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) os_mutex_lock(&tmpbuf_lock); // TODO: how name a wasm thread? - len += snprintf(tmpbuf, MAX_PACKET_SIZE, - "T%02" PRIx32 "thread:%" PRIx64 ";name:%s;", gdb_status, - (uint64)(uintptr_t)tid, "nobody"); + len = snprintf(tmpbuf, MAX_PACKET_SIZE, + "T%02" PRIx32 "thread:%" PRIx64 ";name:%s;", gdb_status, + (uint64)(uintptr_t)tid, "nobody"); + if (len < 0 || len >= MAX_PACKET_SIZE) { + os_mutex_unlock(&tmpbuf_lock); + return; + } + if (tids_count > 0) { - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "threads:"); + int n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "threads:"); + if (n < 0 || n >= MAX_PACKET_SIZE - len) { + os_mutex_unlock(&tmpbuf_lock); + return; + } + + len += n; while (i < tids_count) { - if (i == tids_count - 1) - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, - "%" PRIx64 ";", (uint64)(uintptr_t)tids[i]); - else - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, - "%" PRIx64 ",", (uint64)(uintptr_t)tids[i]); + if (i == tids_count - 1) { + n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, + "%" PRIx64 ";", (uint64)(uintptr_t)tids[i]); + } + else { + n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, + "%" PRIx64 ",", (uint64)(uintptr_t)tids[i]); + } + + if (n < 0 || n >= MAX_PACKET_SIZE - len) { + os_mutex_unlock(&tmpbuf_lock); + return; + } + + len += n; i++; } } @@ -427,32 +447,45 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) /* When exception occurs, use reason:exception so the description can be * correctly processed by LLDB */ uint32 exception_len = strlen(exception); - len += + int n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "thread-pcs:%" PRIx64 ";00:%s;reason:%s;description:", pc, pc_string, "exception"); + if (n < 0 || n >= MAX_PACKET_SIZE - len) { + os_mutex_unlock(&tmpbuf_lock); + return; + } + + len += n; /* The description should be encoded as HEX */ for (i = 0; i < exception_len; i++) { - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "%02x", - exception[i]); + n = snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "%02x", + exception[i]); + if (n < 0 || n >= MAX_PACKET_SIZE - len) { + os_mutex_unlock(&tmpbuf_lock); + return; + } + + len += n; } - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, ";"); + + (void)snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, ";"); } else { if (status == WAMR_SIG_TRAP) { - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, - "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, - pc_string, "breakpoint"); + (void)snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, + "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, + pc_string, "breakpoint"); } else if (status == WAMR_SIG_SINGSTEP) { - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, - "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, - pc_string, "trace"); + (void)snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, + "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, + pc_string, "trace"); } else { /* status > 0 (== 0 is checked at the function beginning) */ - len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, - "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, - pc_string, "signal"); + (void)snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, + "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, + pc_string, "signal"); } } write_packet(server, tmpbuf); From c48dd5ccd7eeddeae7622e835f6d15af9b62159d Mon Sep 17 00:00:00 2001 From: James Ring Date: Fri, 9 May 2025 02:14:33 -0700 Subject: [PATCH 147/198] Don't call os_thread_get_stack_boundary unless we actually use it (#4264) Previously, if the user sets their own stack boundary, we still compute the thread stack boundary (which is expensive), then immediately discard the result. This change makes the expensive call only if we need it for sure. --- core/iwasm/common/wasm_exec_env.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/iwasm/common/wasm_exec_env.c b/core/iwasm/common/wasm_exec_env.c index e33fd9f3a..27484dfc5 100644 --- a/core/iwasm/common/wasm_exec_env.c +++ b/core/iwasm/common/wasm_exec_env.c @@ -276,8 +276,6 @@ wasm_exec_env_restore_module_inst( void wasm_exec_env_set_thread_info(WASMExecEnv *exec_env) { - uint8 *stack_boundary = os_thread_get_stack_boundary(); - #if WASM_ENABLE_THREAD_MGR != 0 os_mutex_lock(&exec_env->wait_lock); #endif @@ -286,9 +284,11 @@ wasm_exec_env_set_thread_info(WASMExecEnv *exec_env) /* WASM_STACK_GUARD_SIZE isn't added for flexibility to developer, he must ensure that enough guard bytes are kept. */ exec_env->native_stack_boundary = exec_env->user_native_stack_boundary; - else + else { + uint8 *stack_boundary = os_thread_get_stack_boundary(); exec_env->native_stack_boundary = stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL; + } exec_env->native_stack_top_min = (void *)UINTPTR_MAX; #if WASM_ENABLE_THREAD_MGR != 0 os_mutex_unlock(&exec_env->wait_lock); From 510bb11f4acad6ecbf1c221b96af9317887770b2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 9 May 2025 18:38:48 +0900 Subject: [PATCH 148/198] CI: make macos' build_samples_wasm_c_api similar to ubuntu (#4253) --- .github/workflows/compilation_on_macos.yml | 62 +++++++++++++++++----- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/.github/workflows/compilation_on_macos.yml b/.github/workflows/compilation_on_macos.yml index cf5578cfb..b59f841c5 100644 --- a/.github/workflows/compilation_on_macos.yml +++ b/.github/workflows/compilation_on_macos.yml @@ -46,11 +46,14 @@ concurrency: cancel-in-progress: true env: - AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" - CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" - FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" - LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1" - LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0" + # For BUILD + AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" + CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" + FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" + FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0" + LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1" + LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0" + MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1" permissions: contents: read @@ -214,33 +217,68 @@ jobs: working-directory: product-mini/platforms/${{ matrix.platform }} build_samples_wasm_c_api: - needs: [build_iwasm] + needs: + [ + build_iwasm, + build_llvm_libraries_on_intel_macos, + build_wamrc, + ] runs-on: ${{ matrix.os }} strategy: matrix: make_options: [ - # Running modes supported + $AOT_BUILD_OPTIONS, $CLASSIC_INTERP_BUILD_OPTIONS, $FAST_INTERP_BUILD_OPTIONS, - # Running modes unsupported - #$LLVM_LAZY_JIT_BUILD_OPTIONS, - #$LLVM_EAGER_JIT_BUILD_OPTIONS, - #$AOT_BUILD_OPTIONS, + $FAST_JIT_BUILD_OPTIONS, + $LLVM_LAZY_JIT_BUILD_OPTIONS, + $LLVM_EAGER_JIT_BUILD_OPTIONS, + $MULTI_TIER_JIT_BUILD_OPTIONS, ] os: [macos-13] + include: + - os: macos-13 + llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }} + steps: - name: checkout uses: actions/checkout@v4 + - name: Get LLVM libraries + id: retrieve_llvm_libs + if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) + uses: actions/cache@v4 + with: + path: | + ./core/deps/llvm/build/bin + ./core/deps/llvm/build/include + ./core/deps/llvm/build/lib + ./core/deps/llvm/build/libexec + ./core/deps/llvm/build/share + key: ${{ matrix.llvm_cache_key }} + + - name: Quit if cache miss + if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true') + run: echo "::error::can not get prebuilt llvm libraries" && exit 1 + - name: install-wasi-sdk-wabt uses: ./.github/actions/install-wasi-sdk-wabt with: os: ${{ matrix.os }} + - name: Build wamrc + if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) + run: | + mkdir build && cd build + cmake .. + cmake --build . --config Release --parallel 4 + working-directory: wamr-compiler + - name: Build Sample [wasm-c-api] run: | + VERBOSE=1 cmake -S . -B build ${{ matrix.make_options }} - cmake --build build --config Release --parallel 4 + cmake --build build --config Debug --parallel 4 ctest --test-dir build --output-on-failure working-directory: samples/wasm-c-api From 3cce6fdaacfaee598707e2fc135b608cb6c453b8 Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Mon, 12 May 2025 10:21:45 +0800 Subject: [PATCH 149/198] avoid access null pointer (#4262) --- core/iwasm/interpreter/wasm_loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 13fd61e7c..8fbfea36b 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -820,7 +820,8 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, #else cur_value.gc_obj = NULL_REF; - if (!is_byte_a_type(type1)) { + if (!is_byte_a_type(type1) + || wasm_is_type_multi_byte_type(type1)) { p--; read_leb_uint32(p, p_end, type_idx); if (!check_type_index(module, module->type_count, type_idx, From 7446b088c9dc24656a068b6028039b35ad5296cb Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Tue, 13 May 2025 07:13:39 +0800 Subject: [PATCH 150/198] disable compiler to prevent get_current_target() crash (#4251) --- tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt | 4 ++-- .../wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt index 82c0ab332..a613ea4e2 100644 --- a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt @@ -7,7 +7,7 @@ if(NOT WAMR_BUILD_INTERP) endif() set(WAMR_BUILD_WAMR_COMPILER 1) -set(WAMR_BUILD_AOT 1) +set(WAMR_BUILD_AOT 0) set(WAMR_BUILD_INTERP 1) set(WAMR_BUILD_JIT 0) @@ -69,7 +69,7 @@ target_link_libraries(aotclib PUBLIC ${REQUIRED_LLVM_LIBS}) if(NOT IN_OSS_FUZZ) message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment") - target_compile_options(aotclib PUBLIC + target_compile_options(aotclib PUBLIC -fprofile-instr-generate -fcoverage-mapping -fno-sanitize-recover=all -fsanitize=address,undefined diff --git a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc index e758cd974..89b4bad0a 100644 --- a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc +++ b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc @@ -35,6 +35,12 @@ LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) /* libfuzzer don't allow to modify the given Data, so make a copy here */ std::vector myData(Data, Data + Size); + if (Size >= 4 + && get_package_type(myData.data(), Size) != Wasm_Module_Bytecode) { + printf("Invalid wasm file: magic header not detected\n"); + return 0; + } + wasm_runtime_init(); module = wasm_runtime_load((uint8_t *)myData.data(), Size, error_buf, 120); From 477d66d00f7e0b5c88a83241742acdac942547b2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 13 May 2025 13:40:24 +0900 Subject: [PATCH 151/198] product-mini/platforms/windows: set C++17 explicitly (#4269) The recent LLVM uses std::optional, which is C++17. --- product-mini/platforms/windows/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index 9ec5d3415..e0a4e255b 100644 --- a/product-mini/platforms/windows/CMakeLists.txt +++ b/product-mini/platforms/windows/CMakeLists.txt @@ -14,6 +14,8 @@ set (WAMR_BUILD_PLATFORM "windows") set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") +set(CMAKE_CXX_STANDARD 17) + add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) # Set WAMR_BUILD_TARGET, currently values supported: From 26aa4830e9db000c8117321f3c40e25d7474d518 Mon Sep 17 00:00:00 2001 From: Su Yihan Date: Wed, 14 May 2025 06:35:32 +0800 Subject: [PATCH 152/198] fix buf checking in load_table_section (#4276) Signed-off-by: Su Yihan --- core/iwasm/interpreter/wasm_loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 8fbfea36b..a83de4a48 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3833,11 +3833,11 @@ load_table_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, uint8 flag; bool has_init = false; - CHECK_BUF(buf, buf_end, 1); + CHECK_BUF(p, p_end, 1); flag = read_uint8(p); if (flag == TABLE_INIT_EXPR_FLAG) { - CHECK_BUF(buf, buf_end, 1); + CHECK_BUF(p, p_end, 1); flag = read_uint8(p); if (flag != 0x00) { From f0a8286863c192fc56829c085923621ac55bfccb Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 10:38:30 +0800 Subject: [PATCH 153/198] Refactor fast-interpreter SIMD compilation flags (#4261) - enable SIMD flag by default unless hardware limitation - use SIMDE flag to control fast-interpreter behavior --- build-scripts/config_common.cmake | 5 +---- build-scripts/runtime_lib.cmake | 22 ++++++++++++---------- core/iwasm/common/wasm_loader_common.c | 9 +++++---- core/iwasm/interpreter/wasm_interp_fast.c | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 7ded52fd9..82d59ba2a 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -377,10 +377,7 @@ else () message (" Wakeup of blocking operations enabled") endif () if (WAMR_BUILD_SIMD EQUAL 1) - if (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0) - set(SIMD_ENABLED 0) - message(" SIMD disabled for fast-interp as simde is not being built") - elseif (WAMR_BUILD_TARGET MATCHES "RISCV64.*") + if (WAMR_BUILD_TARGET MATCHES "RISCV64.*") set(SIMD_ENABLED 0) message (" SIMD disabled due to not supported on target RISCV64") else() diff --git a/build-scripts/runtime_lib.cmake b/build-scripts/runtime_lib.cmake index 994414ffa..d9459838e 100644 --- a/build-scripts/runtime_lib.cmake +++ b/build-scripts/runtime_lib.cmake @@ -155,16 +155,6 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1) include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake) endif () -if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1) - if (WAMR_BUILD_PLATFORM STREQUAL "windows") - message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM}) - set(WAMR_BUILD_SIMDE 0) - else() - include (${IWASM_DIR}/libraries/simde/simde.cmake) - set (WAMR_BUILD_SIMDE 1) - endif() -endif () - if (WAMR_BUILD_WASM_CACHE EQUAL 1) include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake) endif () @@ -178,6 +168,18 @@ endif () # include the build config template file include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake) +if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1) + if (WAMR_BUILD_PLATFORM STREQUAL "windows") + message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM}) + set(WAMR_BUILD_SIMDE 0) + else() + include (${IWASM_DIR}/libraries/simde/simde.cmake) + set (WAMR_BUILD_SIMDE 1) + endif() +else() + set(WAMR_BUILD_SIMDE 0) +endif () + include_directories (${IWASM_DIR}/include) file (GLOB header diff --git a/core/iwasm/common/wasm_loader_common.c b/core/iwasm/common/wasm_loader_common.c index 6018f90a6..dc8009205 100644 --- a/core/iwasm/common/wasm_loader_common.c +++ b/core/iwasm/common/wasm_loader_common.c @@ -152,11 +152,12 @@ bool is_valid_value_type_for_interpreter(uint8 value_type) { #if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \ - && (WASM_ENABLE_FAST_INTERP == 0) + && (WASM_ENABLE_SIMDE == 0) /* - * Note: regardless of WASM_ENABLE_SIMD, our interpreters don't have - * SIMD implemented. It's safer to reject v128, especially for the - * fast interpreter. + * Note: regardless of WASM_ENABLE_SIMD, our classic interpreters don't + * have SIMD implemented. + * + * WASM_ENABLE_SIMDE is used to control SIMD feaure in fast interpreter */ if (value_type == VALUE_TYPE_V128) return false; diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index f33ad60e3..78b2f609e 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -3565,7 +3565,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } -#if WASM_ENABLE_SIMD != 0 +#if WASM_ENABLE_SIMDE != 0 HANDLE_OP(EXT_OP_SET_LOCAL_FAST_V128) HANDLE_OP(EXT_OP_TEE_LOCAL_FAST_V128) { @@ -3619,7 +3619,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, GET_I64_FROM_ADDR((uint32 *)global_addr)); HANDLE_OP_END(); } -#if WASM_ENABLE_SIMD != 0 +#if WASM_ENABLE_SIMDE != 0 HANDLE_OP(WASM_OP_GET_GLOBAL_V128) { global_idx = read_uint32(frame_ip); @@ -4956,7 +4956,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP_END(); } -#if WASM_ENABLE_SIMD != 0 +#if WASM_ENABLE_SIMDE != 0 HANDLE_OP(EXT_OP_COPY_STACK_TOP_V128) { addr1 = GET_OFFSET(); From 065cc72350eaed9958afa7794c839be7a334ba73 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 10:38:49 +0800 Subject: [PATCH 154/198] Bypass wamr_ide-related components from the release process. (#4268) Mostly because of some observations: - There is no actual usage reported. - Both ide-ext and ide-docker-image have not been maintained for quite a while. - At the very least, there is no need to recompile it every time when there are no modifications. --- .github/workflows/release_process.yml | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release_process.yml b/.github/workflows/release_process.yml index ad751f870..91f081fd2 100644 --- a/.github/workflows/release_process.yml +++ b/.github/workflows/release_process.yml @@ -113,7 +113,7 @@ jobs: runner: macos-13 upload_url: ${{ needs.create_release.outputs.upload_url }} ver_num: ${{ needs.create_tag.outputs.new_ver }} - + release_wamrc_on_windows: permissions: contents: write # upload release artifact @@ -192,28 +192,30 @@ jobs: wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git + # Let's disable it for now and reopen it when the actual requirement arises. + # Please ensure all dependencies have been updated before reopening. # - # vscode extension cross-platform - release_wamr_ide_vscode_ext: - permissions: - contents: write # upload release artifact - needs: [create_tag, create_release] - uses: ./.github/workflows/build_wamr_vscode_ext.yml - secrets: inherit - with: - upload_url: ${{ needs.create_release.outputs.upload_url }} - ver_num: ${{ needs.create_tag.outputs.new_ver }} + # # vscode extension cross-platform + # release_wamr_ide_vscode_ext: + # permissions: + # contents: write # upload release artifact + # needs: [create_tag, create_release] + # uses: ./.github/workflows/build_wamr_vscode_ext.yml + # secrets: inherit + # with: + # upload_url: ${{ needs.create_release.outputs.upload_url }} + # ver_num: ${{ needs.create_tag.outputs.new_ver }} - # - # vscode extension docker images package - release_wamr_ide_docker_images_package: - permissions: - contents: write # upload release artifact - needs: [create_tag, create_release] - uses: ./.github/workflows/build_docker_images.yml - with: - upload_url: ${{ needs.create_release.outputs.upload_url }} - ver_num: ${{ needs.create_tag.outputs.new_ver }} + # # + # # vscode extension docker images package + # release_wamr_ide_docker_images_package: + # permissions: + # contents: write # upload release artifact + # needs: [create_tag, create_release] + # uses: ./.github/workflows/build_docker_images.yml + # with: + # upload_url: ${{ needs.create_release.outputs.upload_url }} + # ver_num: ${{ needs.create_tag.outputs.new_ver }} # # WAMR_LLDB From 5c7f64bcc0825e3f1f2cfcd9c07ebe5d9218d73f Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 10:39:06 +0800 Subject: [PATCH 155/198] Set CMAKE_OSX_SYSROOT when building lldb (#4274) CMake 4 no longer sets the CMAKE_OSX_SYSROOT variable by default, causing the lldb build to fail after all GitHub-hosted runners have been upgraded to CMake 4. As a workaround, the variable is set using CMake command line options. There is a PR to fix this issue in the llvm-project: https://github.com/llvm/llvm-project/pull/138020. We might want to remove this workaround after that PR has been merged. --- .github/workflows/build_wamr_lldb.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_wamr_lldb.yml b/.github/workflows/build_wamr_lldb.yml index b5cf53a4c..297328cc5 100644 --- a/.github/workflows/build_wamr_lldb.yml +++ b/.github/workflows/build_wamr_lldb.yml @@ -172,6 +172,12 @@ jobs: python3 ci/validate_lldb.py --port 1239 --lldb core/deps/wamr-lldb/bin/lldb --wamr wamr-debug/iwasm --verbose working-directory: . + # Define CMAKE_OSX_SYSROOT to avoid the error: + # no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excServer.c' + # no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excUser.c' + # + # This workaround should be removed when the issue is fixed in llvm-project: + # - https://github.com/llvm/llvm-project/pull/138020/ - name: build lldb macos if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos') run: | @@ -179,6 +185,7 @@ jobs: mkdir -p wamr-lldb cmake -S ./llvm -B build \ -G Ninja \ + -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \ -DCMAKE_INSTALL_PREFIX=../wamr-lldb \ -DCMAKE_BUILD_TYPE:STRING="Release" \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ From 70b35f9e604b7cc7e8043e9c7dfa3a2944127242 Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 13 May 2025 19:58:19 -0700 Subject: [PATCH 156/198] Check for WASM_ENABLE_SIMDE in a couple more places (#4266) For WAMR users who don't use cmake, it's possible that WASM_ENABLE_SIMD is set when WASM_ENABLE_SIMDE isn't. This was causing build failures. --- core/iwasm/interpreter/wasm_opcode.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/iwasm/interpreter/wasm_opcode.h b/core/iwasm/interpreter/wasm_opcode.h index 9660bb123..bb04d56f1 100644 --- a/core/iwasm/interpreter/wasm_opcode.h +++ b/core/iwasm/interpreter/wasm_opcode.h @@ -790,15 +790,14 @@ typedef enum WASMAtomicEXTOpcode { #endif #define SET_GOTO_TABLE_ELEM(opcode) [opcode] = HANDLE_OPCODE(opcode) -#if (WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0) \ - && WASM_ENABLE_SIMD != 0 +#if WASM_ENABLE_SIMDE != 0 #define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() \ SET_GOTO_TABLE_ELEM(WASM_OP_SIMD_PREFIX), #else #define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() #endif -#if (WASM_ENABLE_FAST_INTERP != 0) && WASM_ENABLE_SIMD != 0 +#if WASM_ENABLE_SIMD != 0 && WASM_ENABLE_SIMDE != 0 #define DEF_EXT_V128_HANDLE() \ SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \ SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \ From 8ad47897d1f5579a3c9d75e4d7d234474fc54bbd Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 11:09:08 +0800 Subject: [PATCH 157/198] Add error handling for sgx ci (#4222) > Process completed with exit code 143. It will attempt to run spec test scripts three times if they end with code 143. It is a known issue with GitHub-hosted runners. Usually, increasing the swap file can help avoid it. However, sometimes error 143 still occurs. To prevent confusion, let's capture error 143 and allow the CI to pass. --- .github/workflows/compilation_on_sgx.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index 541f7a284..e6cc29108 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -290,6 +290,28 @@ jobs: - name: run spec tests run: | + set +e source /opt/intel/sgxsdk/environment - ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} + attempts=0 + max_attempts=3 + + while [ $attempts -lt $max_attempts ]; do + ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} + exitcode="$?" + + if [ $exitcode -eq 0 ]; then + echo "Spec test passed" + exit 0 + elif [ $exitcode -ne 143 ]; then + echo "Spec test failed with error code $exitcode" + exit 1 + fi + + echo "$exitcode is a known GitHub-hosted runner issue" + echo "::notice::Re-running the spec test due to error code 143" + attempts=$((attempts + 1)) + done + + echo "::notice::Report an error with code 143 in SGX CI after $max_attempts attempts" + exit 143 working-directory: ./tests/wamr-test-suites From 129dc3a30f21ee4624fab46c410438d0b6366333 Mon Sep 17 00:00:00 2001 From: Maks Litskevich Date: Wed, 14 May 2025 05:35:56 +0100 Subject: [PATCH 158/198] Add select 128 (#4236) Add select 128 --- core/iwasm/compilation/aot_compiler.c | 7 +++ core/iwasm/interpreter/wasm_interp_fast.c | 21 +++++++++ core/iwasm/interpreter/wasm_loader.c | 53 ++++++++++++++++++----- core/iwasm/interpreter/wasm_opcode.h | 8 ++-- 4 files changed, 76 insertions(+), 13 deletions(-) diff --git a/core/iwasm/compilation/aot_compiler.c b/core/iwasm/compilation/aot_compiler.c index 82f70ca3d..5d9664ee8 100644 --- a/core/iwasm/compilation/aot_compiler.c +++ b/core/iwasm/compilation/aot_compiler.c @@ -1316,6 +1316,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) return false; break; +#if WASM_ENABLE_SIMD != 0 + case WASM_OP_SELECT_128: + if (!aot_compile_op_select(comp_ctx, func_ctx, true)) + return false; + break; +#endif + #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 case WASM_OP_SELECT_T: { diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 78b2f609e..78f53e694 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1888,6 +1888,27 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, } HANDLE_OP_END(); } +#if WASM_ENABLE_SIMD != 0 + HANDLE_OP(WASM_OP_SELECT_128) + { + cond = frame_lp[GET_OFFSET()]; + addr1 = GET_OFFSET(); + addr2 = GET_OFFSET(); + addr_ret = GET_OFFSET(); + + if (!cond) { + if (addr_ret != addr1) + PUT_V128_TO_ADDR(frame_lp + addr_ret, + GET_V128_FROM_ADDR(frame_lp + addr1)); + } + else { + if (addr_ret != addr2) + PUT_V128_TO_ADDR(frame_lp + addr_ret, + GET_V128_FROM_ADDR(frame_lp + addr2)); + } + HANDLE_OP_END(); + } +#endif #if WASM_ENABLE_GC != 0 HANDLE_OP(WASM_OP_SELECT_T) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index a83de4a48..db9afb0f2 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -7304,6 +7304,9 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, case WASM_OP_SELECT: case WASM_OP_DROP_64: case WASM_OP_SELECT_64: +#if WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0 + case WASM_OP_SELECT_128: +#endif break; #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 @@ -12788,8 +12791,7 @@ re_scan: case VALUE_TYPE_F64: #if WASM_ENABLE_FAST_INTERP == 0 *(p - 1) = WASM_OP_SELECT_64; -#endif -#if WASM_ENABLE_FAST_INTERP != 0 +#else if (loader_ctx->p_code_compiled) { uint8 opcode_tmp = WASM_OP_SELECT_64; #if WASM_ENABLE_LABELS_AS_VALUES != 0 @@ -12797,8 +12799,7 @@ re_scan: *(void **)(p_code_compiled_tmp - sizeof(void *)) = handle_table[opcode_tmp]; -#else -#if UINTPTR_MAX == UINT64_MAX +#elif UINTPTR_MAX == UINT64_MAX /* emit int32 relative offset in 64-bit target */ int32 offset = @@ -12811,7 +12812,6 @@ re_scan: *(uint32 *)(p_code_compiled_tmp - sizeof(uint32)) = (uint32)(uintptr_t)handle_table[opcode_tmp]; -#endif #endif /* end of WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS */ #else /* else of WASM_ENABLE_LABELS_AS_VALUES */ #if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 @@ -12827,6 +12827,39 @@ re_scan: #if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ || (WASM_ENABLE_FAST_INTERP != 0) case VALUE_TYPE_V128: +#if WASM_ENABLE_FAST_INTERP == 0 + *(p - 1) = WASM_OP_SELECT_128; +#else + if (loader_ctx->p_code_compiled) { + uint8 opcode_tmp = WASM_OP_SELECT_128; +#if WASM_ENABLE_LABELS_AS_VALUES != 0 +#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 + *(void **)(p_code_compiled_tmp + - sizeof(void *)) = + handle_table[opcode_tmp]; +#elif UINTPTR_MAX == UINT64_MAX + /* emit int32 relative offset in 64-bit target + */ + int32 offset = + (int32)((uint8 *)handle_table[opcode_tmp] + - (uint8 *)handle_table[0]); + *(int32 *)(p_code_compiled_tmp + - sizeof(int32)) = offset; +#else + /* emit uint32 label address in 32-bit target */ + *(uint32 *)(p_code_compiled_tmp + - sizeof(uint32)) = + (uint32)(uintptr_t)handle_table[opcode_tmp]; +#endif /* end of WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS */ +#else /* else of WASM_ENABLE_LABELS_AS_VALUES */ +#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 + *(p_code_compiled_tmp - 1) = opcode_tmp; +#else + *(p_code_compiled_tmp - 2) = opcode_tmp; +#endif /* end of WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS */ +#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */ + } +#endif /* end of WASM_ENABLE_FAST_INTERP */ break; #endif /* (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ (WASM_ENABLE_FAST_INTERP != 0) */ @@ -12924,12 +12957,12 @@ re_scan: uint8 opcode_tmp = WASM_OP_SELECT; if (type == VALUE_TYPE_V128) { -#if (WASM_ENABLE_SIMD == 0) \ - || ((WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \ - && (WASM_ENABLE_FAST_INTERP == 0)) +#if WASM_ENABLE_JIT != 0 \ + || WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0 + opcode_tmp = WASM_OP_SELECT_128; +#else set_error_buf(error_buf, error_buf_size, - "SIMD v128 type isn't supported"); - goto fail; + "v128 value type requires simd feature"); #endif } else { diff --git a/core/iwasm/interpreter/wasm_opcode.h b/core/iwasm/interpreter/wasm_opcode.h index bb04d56f1..37d32b122 100644 --- a/core/iwasm/interpreter/wasm_opcode.h +++ b/core/iwasm/interpreter/wasm_opcode.h @@ -278,13 +278,14 @@ typedef enum WASMOpcode { DEBUG_OP_BREAK = 0xdc, /* debug break point */ #endif -#if WASM_ENABLE_JIT != 0 \ - || WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0 +#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0 \ + || WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_SIMD != 0 EXT_OP_SET_LOCAL_FAST_V128 = 0xdd, EXT_OP_TEE_LOCAL_FAST_V128 = 0xde, EXT_OP_COPY_STACK_TOP_V128 = 0xdf, WASM_OP_GET_GLOBAL_V128 = 0xe0, WASM_OP_SET_GLOBAL_V128 = 0xe1, + WASM_OP_SELECT_128 = 0xe2, #endif /* Post-MVP extend op prefix */ @@ -803,7 +804,8 @@ typedef enum WASMAtomicEXTOpcode { SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \ SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), /* 0xdf */ \ SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), /* 0xe0 */ \ - SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128), /* 0xe1 */ + SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128), /* 0xe1 */ \ + SET_GOTO_TABLE_ELEM(WASM_OP_SELECT_128), /* 0xe2 */ #else #define DEF_EXT_V128_HANDLE() From 28702edaf739cdeee54e81efe5868bf00724c33c Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 14 May 2025 12:43:55 +0800 Subject: [PATCH 159/198] Merge commit from fork --- build-scripts/config_common.cmake | 7 ++++- .../libraries/libc-uvwasi/libc_uvwasi.cmake | 30 +++++++------------ .../libc-uvwasi/libc_uvwasi_wrapper.c | 18 +++++++++++ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 82d59ba2a..5f7746f6a 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -279,7 +279,12 @@ else () message (" Libc builtin disabled") endif () if (WAMR_BUILD_LIBC_UVWASI EQUAL 1) - message (" Libc WASI enabled with uvwasi implementation") + message (" Libc WASI enabled with uvwasi implementation\n" + " WANRING:: uvwasi does not currently provide the comprehensive\n" + " file system security properties provided by some WASI runtimes.\n" + " Full support for secure file system sandboxing may or may not\n" + " be implemented in future. In the mean time, DO NOT RELY ON IT\n" + " TO RUN UNTRUSTED CODE.") elseif (WAMR_BUILD_LIBC_WASI EQUAL 1) message (" Libc WASI enabled") else () diff --git a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake index fefe0fca2..6919efba2 100644 --- a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake +++ b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake @@ -10,7 +10,7 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE) set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR}) -set (LIBUV_VERSION v1.46.0) +set (LIBUV_VERSION v1.51.0) add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1) @@ -29,15 +29,10 @@ else() GIT_REPOSITORY https://github.com/libuv/libuv.git GIT_TAG ${LIBUV_VERSION} ) - FetchContent_GetProperties(libuv) - if (NOT libuv_POPULATED) - message("-- Fetching libuv ..") - FetchContent_Populate(libuv) - include_directories("${libuv_SOURCE_DIR}/include") - add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL) - set (LIBUV_LIBRARIES uv_a) - set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1) - endif() + FetchContent_MakeAvailable(libuv) + include_directories("${libuv_SOURCE_DIR}/include") + set (LIBUV_LIBRARIES uv_a) + set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1) endif() ## uvwasi @@ -48,17 +43,12 @@ else() FetchContent_Declare( uvwasi GIT_REPOSITORY https://github.com/nodejs/uvwasi.git - GIT_TAG main + GIT_TAG v0.0.21 ) - FetchContent_GetProperties(uvwasi) - if (NOT uvwasi_POPULATED) - message("-- Fetching uvwasi ..") - FetchContent_Populate(uvwasi) - include_directories("${uvwasi_SOURCE_DIR}/include") - add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL) - set (UVWASI_LIBRARIES uvwasi_a) - set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1) - endif() + FetchContent_MakeAvailable(uvwasi) + include_directories("${uvwasi_SOURCE_DIR}/include") + set (UVWASI_LIBRARIES uvwasi_a) + set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1) endif() set (UV_A_LIBS ${LIBUV_LIBRARIES} ${UVWASI_LIBRARIES}) diff --git a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c index 35d091e78..59616daf6 100644 --- a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c +++ b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c @@ -890,6 +890,24 @@ wasi_path_symlink(wasm_exec_env_t exec_env, const char *old_path, if (!uvwasi) return (wasi_errno_t)-1; + /* + * check if old_path is valid. + * if it is a symlink, follow it. + * + * this is a workaround for the fact that + * uvwasi_path_symlink does not check if the old_path is valid + * + * the goal is trigger uvwasi__resolve_path() to check + */ + { + uvwasi_filestat_t filestat = { 0 }; + wasi_errno_t err = + uvwasi_path_filestat_get(uvwasi, fd, UVWASI_LOOKUP_SYMLINK_FOLLOW, + old_path, old_path_len, &filestat); + if (err) + return err; + } + return uvwasi_path_symlink(uvwasi, old_path, old_path_len, fd, new_path, new_path_len); } From c7b2db18329f849b81568b94e72ddd0b20f431a5 Mon Sep 17 00:00:00 2001 From: jammar1 <108334558+jammar1@users.noreply.github.com> Date: Wed, 14 May 2025 10:32:00 +0100 Subject: [PATCH 160/198] Update version to 2.3.0 (#4171) - Update version to 2.3.0 - Update RELEASE_NOTES.md. Remove commits that forget to squash when PRs were merged, and some updates on commit messages --------- Co-authored-by: James Marsh Co-authored-by: liang.he@intel.com Co-authored-by: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> --- RELEASE_NOTES.md | 721 ++++++++++++++++++++++++------------ build-scripts/version.cmake | 2 +- core/version.h | 2 +- 3 files changed, 485 insertions(+), 240 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e0bb032cf..b39f55bae 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,45 +1,239 @@ -## WAMR-2.2.0 +## WAMR-2.3.0 -### Breaking changes +### Breaking changes -### New features -- Add support for multi-memory proposal in classic interpreter (#3742) -- wasi-nn: Add a new target for llama.cpp as a wasi-nn backend (#3709) -- Add memory instance support apis (#3786) -- Implement a first version of shared heap feature (#3789) -- Support dynamic aot debug (#3788) -- Implement shared heap for AOT (#3815) -- Support table64 extension in classic-interp and AOT running modes (#3811) - +### New features + +- simd for fast-interp (#4131) +- copy call-stack (#4033) ### Bug fixes -- Enable merged os_mmap for aot data sections (#3681) -- Fix arm64 issues on mac (#3688) + +- fix(ios): Remove `float-abi` flag (#3889) +- Fix out of bounds issues after memory.grow on non-aot non-threads builds (#3872) +- Fix out of bounds issue in is_native_addr_in_shared_heap function (#3886) +- Fix mmap flags for AOT loader on non-Linux SGX platforms (#3890) +- fix(uwp): Gate NTSTATUS definition behind WINAPI_PARTITION_DESKTOP for UWP builds (#3897) +- Fix linked global initialization in multimodule (#3905) +- Correct the table index calculation in aot_instantiation (#3903) +- Fix a leak in wasm_loader_emit_br_info (#3900) +- Check possible integer overflow in aot memory boundary check (#3920) +- Fix CI wamr-ide error (#3913) +- Fix WASI Path Mapping Processing (#3923) +- Use plain assignment rather than bh_memcpy_s (#3924) +- Fix loader small bug (#3928) +- don't return an uninitialized trap if argv_to_results fails (#3935) +- support WASM_FUNCREF return type in argv_to_results (#3936) +- Fix incorrect assignment in win_file.c (#3939) +- Fix aot table instantiate (#3946) +- set alignment 4 when loading multi return value (#3955) +- Only access Zephyr thread stats info when it's available (#3962) +- top-level cmakefile: fix macOS build (#3968) +- Handle a new scenario where an item is both exported and imported. (#3984) +- platform/nuttx: Flush icache/dcache properly (#4147) +- fix(runtest.py): A workaround to bypass errors that occur when deleting temporary files (#4093) +- Fix build issues when compiling WAMRC as a cross-compiler (#4112) +- include bh_platform.h (#4135) +- Fix iwasm build error when WAMR_BUILD_WASI_NN enabled (#4138) +- avoid Windows perform newline translation (#4128) +- fix: correct typos and improve comments across multiple files by codespell (#4116) +- fix: fix load aarch64 aot failed (#4114) +- wasm_loader allocates more spaces for elements (#4099) +- fix: add dispose of the debug information builder when destroying compilation context (#4105) +- prevent mmap size overflow on 32 bit platform for memory.grow (#4071) +- fix: when load aot init expr,no type_idx set. (#4094) +- fix(aot_emit_aot_file): prevent buffer emission for zero byte_count (#4095) +- fix(build_llvm_libraries.yml): Correct script path for build_llvm.py (#4089) +- fix(unit-test): libc_builtin_test issues (#4073) +- [gc] Subtyping fix (#4075) +- fix(build_llvm.py): clean up whitespace and formatting in build script (#4087) +- Unit test:type matching issue and code redundancy (#4079) +- fix(aot): ensure value_cmp does not exceed br_count in branch table compilation (#4065) +- In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064) +- Use wasm32-wasip1 instead of wasm32-wasi target for rust code (#4057) +- Update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in CI (#4050) +- Fix wasm loader check data segment count (#4039) +- Fix table index calculations in wasm_loader and wasm_mini_loader (#4004) +- Ensure **heap_base and **data_end global indices are validated against import count (#3996) +- fix format specifier warning on 32bit builds (#4177) +- Remove indirect-load for constants on Xtensa Target to improve performance (#4162) +- cmake: Enhance target selection for ARM architectures with FPU (#4185) +- Add import memory/table flag assert check for miniloader (#4179) +- Fix few integer overflowing (#4161) +- prevent frame_offset underflow in wasm_loader (#4165) +- fix: Remove unused variables in SIMD_v128_const case (#4197) +- fix false native stack overflow detections with HW_BOUND_CHECK (#4196) +- Keep fix the CMake compatibility issue (#4180) +- Fix the error of AOT mode on the "i386-windows-msvc" platform (#4183) +- debug-engine: fix a few type mismatches (#4189) +- Replace CMAKE_CURRENT_FUNCTION_LIST_DIR (#4200) +- fix potential memory leak (#4205) +- Add missing V128 handling in WASM_OP_BR (#4203) +- fix print_help when libc wasi is enabled (#4218) +- LLVM: don't verify instcombine fixpoint (#4219) +- LLVMCreateTargetMachineWithOpts: disable large data (#4220) +- set default value of `WAMR_BUILD_REF_TYPES` to 1 in standalone cases (#4227) +- platform/nuttx: Fix dcache operation in os_dcache_flush (#4225) +- fix return types of our 64-bit clz/ctz/popcount intrinsics (#4238) +- riscv: avoid llvm.cttz.i32/i64 for xip (#4248) +- Add overflow check for preserved local offset in preserve_referenced_local (#4211) +- aot_resolve_object_relocation_group: adapt to LLVM 16 (#4250) +- initialize WASI stdio handles to invalid for better error handling (#4092) +- Modifying build flags to ensure libiwasm.so is built (#4255) +- Stop pretending to support extended-const proposal (#4258) +- Improve readlinkat_dup() to handle symlink size correctly (#4229) +- fix: improve error handling of snprintf() in send_thread_stop_status() (#4234) +- Don't call os_thread_get_stack_boundary unless we actually use it (#4264) +- avoid access null pointer (#4262) +- disable compiler to prevent get_current_target() crash (#4251) +- product-mini/platforms/windows: set C++17 explicitly (#4269) +- fix buf checking in load_table_section (#4276) +- Set CMAKE_OSX_SYSROOT when building lldb (#4274) +- Add select 128 (#4236) + +### Enhancements + +- Refine looking up aot function with index (#3882) +- Wasm loader enhancement: check code size in code entry (#3892) +- Refactor AOT loader to support compatible versions (#3891) +- GlobalValueSet was moved to IRPartitionLayer recently, but we have a local definition anyway (#3899) +- Support external toolchain on Windows for aot compiler (#3911) +- Drop declarative elements on module instantiation (#3922) +- add testcases for shared heap and fix POP_MEM_OFFSET of memory64 (#3916) +- Enable ref types by default (#3894) +- Update README.md to clarify Windows toolchain support and ESP-IDF reference (#3917) +- add thread cpu time for zephyr (#3937) +- Improvements for platform thread APIs on Windows and Zephyr (#3941) +- Refactor SConscript and add file checks in iwasm.c (#3945) +- Consume the placeholders that were put when emitting table info (#3940) +- wasm_export.h: Use "default" visibility for gcc and clang (#3957) +- [fuzzing] Enable instantiation (#3958) +- use a random secret key (#3971) +- CMakeLists.txt: Do not require C++ (#3956) +- add reference type support by default for darwin to support WASI-SDK-25 (#3978) +- top-level cmake: link llvm libraries to our shared library (#3973) +- Set thread information earlier in exec_env creation (#3967) +- Break aot_create_comp_data into small functions (#3987) +- Optimize memory initialization handling in AOT loader (#3983) +- nuttx: remove the up_x API for kernel build (#4154) +- Expose WAMR_BUILD_GC_HEAP_SIZE_DEFAULT as a CMake option (#4124) +- Use log instead of using assertion in aot loader (#4119) +- feat: use C linkage in aot_comp_option.h for C++ embeding (#4106) +- Cmake improvements (#4076) +- feat: add support for EXTERNREF value type and enable AOT validator in fuzz tests (#4083) +- build_llvm.py: Allow to build xtensa target on non-xtensa host (#4086) +- Add a conditional check for the macro **STDC_VERSION** (#4080) +- [fuzzing] execute every exported function (#3959) +- Update memory allocation functions to use allocator user data (#4043) +- Add versioning support and update CMake configuration (#3933) +- Show wasm proposals status during compilation and execution (#3989) +- add a validator for aot module (#3995) +- Synchronize the GC spec tests to the commit from December 9. 2024. (#4022) +- Refine getting const offsets in wasm loader of fast-interp (#4012) +- fixes for compiling on windows (#4026) +- .github: Add shared lib builds (#3975) +- Error message improvement (#4000) +- Refine read leb int wasm loader of fast interpreter (#4017) +- Enable shrunk memory by default and add related configurations (#4008) +- Add documentation regarding security issues and the status of Wasm proposals (#3972) +- Improve stack consistency by ensuring sufficient space for dummy offsets (#4011) +- Check whether related table has funcref elem in opcode call_indirect (#3999) +- [fuzzing] Use software bound-check during fuzzing (#4003) +- Add an example of how to embed WAMR in Zephyr user mode (#3998) +- Update cmake min to 3.14 (#4175) +- aot: add new u64 intrinsics (#4168) +- Refactor Dockerfile and update .dockerignore for wasi-nn tests; adjust map-dir parameters in smoke test script (#4158) +- improve variable naming and code clarity in SIMD operations (#4157) +- Raise CI runner to ubuntu 22.04 (#4191) +- Remove the dlen to optimize it. (#4193) +- Add missing casts and improve error handling in performance map functions (#4202) +- Raise wasi-sdk to 25 and wabt to 1.0.37 (#4187) +- wamrc: add --disable-llvm-jump-tables option (#4224) +- feat(fuzz): add a new fuzzing target about aot compiler (#4121) +- bypass vptr santizier (#4231) +- use a selected llvm libs list to replace the full list (#4232) +- teach aot emitter/loader about .srodata and .srodata.cst\* sections (#4240) +- run_clang_format_diff: mention homebrew for clang-format installation (#4237) +- Use --target to pass a triple in wamrc (#4199) +- samples/wasm-c-api: skip aot compilation unless necessary (#4239) +- samples/wasm-c-api: remove unused valgrind detection (#4249) +- More detail to python setup, and fixed small typo (#4247) +- JIT: don't join worker threads twice (#4252) +- aot_resolve_object_relocation_group: adapt to LLVM 19 (#4254) +- build-scripts/build_llvm.py: bump to llvm 18 (#4259) +- CI: make macos' build_samples_wasm_c_api similar to ubuntu (#4253) +- Refactor fast-interpreter SIMD compilation flags (#4261) +- Bypass wamr_ide-related components from the release process. (#4268) +- Check for WASM_ENABLE_SIMDE in a couple more places (#4266) +- Add error handling for sgx ci (#4222) + +### Security Issues + +- Add validation for old_path in wasi_path_symlink (# CVE-2025-43853) + +### Others + +- Exclude fuzz test python and npm packages in scoreboard scan (#3871) +- Bump AOT_CURRENT_VERSION for WAMR 2.x (gc, memory64) (#3880) +- Add Tianlong into code owners (#3970) +- build(deps): Bump actions/upload-artifact from 4.4.3 to 4.5.0 (#3981) +- docs: Update build instructions suggestions for using Valgrind (#4164) +- test: temporarily skip 'skip-stack-guard-page' test case (#4163) +- build(deps): Bump actions/upload-artifact from 4.6.1 to 4.6.2 (#4159) +- Update NuttX and NuttX Apps references to releases/12.9 in workflow files (#4148) +- build(deps): Bump esbuild, @vitejs/plugin-react and vite (#4149) +- build(deps): Bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#4109) +- build(deps): bump github/codeql-action from 3.26.13 to 3.28.1 (#3888) (#3902) +- build(deps): Bump github/codeql-action from 3.28.10 to 3.28.11 (#4132) +- build(deps): Bump github/codeql-action from 3.28.9 to 3.28.10 (#4108) +- build(deps): Bump actions/upload-artifact from 4.6.0 to 4.6.1 (#4107) + +--- + +## WAMR-2.2.0 + +### Breaking changes + +### New features + +- Add support for multi-memory proposal in classic interpreter (#3742) +- wasi-nn: Add a new target for llama.cpp as a wasi-nn backend (#3709) +- Add memory instance support apis (#3786) +- Implement a first version of shared heap feature (#3789) +- Support dynamic aot debug (#3788) +- Implement shared heap for AOT (#3815) +- Support table64 extension in classic-interp and AOT running modes (#3811) + +### Bug fixes + +- Enable merged os_mmap for aot data sections (#3681) +- Fix arm64 issues on mac (#3688) - aot loader: Call os_mmap with MMAP_MAP_32BIT only when target is x86-64 or riscv64 (#3755) -- Fix building iwasm_shared and iwasm_static libs on win32 (#3762) +- Fix building iwasm_shared and iwasm_static libs on win32 (#3762) - Fix compile error when multi-module and tags are enabled (#3781) - Fix aot multi export memory support (#3791) - Fix Windows compile error when uvwasi is enabled (#3810) - Fix missing symbols when using aot mode on riscv platforms (#3812) - Fix mac build of libc_emcc_wrapper.c (#3836) - aot_comp_option.h: Add missing stdint.h header (#3834) -- Fix compilation error found in tflite test (#3820) -- Fix exec_env_tls assertion in module instantiation (#3844) +- Fix compilation error found in tflite test (#3820) +- Fix exec_env_tls assertion in module instantiation (#3844) - Fix issues of destroy_shared_heaps (#3847) ### Enhancements + - aot loader: Refine os_mmap related code (#3711) - Enable merged os_mmap for aot data sections and aot text (#3743) - Improve posix mmap retry logic (#3714) - Remove unnecessary code duplication in aot runtime (#3767) -- Add wamrc parameter to configure stack frame features (#3763) +- Add wamrc parameter to configure stack frame features (#3763) - refactoring: Re-use commit IP functionality between exception handling and other cases (#3768) -- AOT call stack optimizations (#3773) +- AOT call stack optimizations (#3773) - Appease GCC strict prototypes warning (#3775) - Appease GCC -Wformat (#3783) - Fix compiler warnings (#3784) - Implement option for skipping function index in the callstack (#3785) -- Fix a compile warning in aot_emit_function.c (#3793) +- Fix a compile warning in aot_emit_function.c (#3793) - Restore cmake hidden compile symbol visibility (#3796) - Refactor shared heap feature for interpreter mode (#3794) - Add no_resolve to LoadArgs and wasm_runtime_resolve_symbols (#3790) @@ -49,179 +243,189 @@ - Add scoreboard CI for supply-chain security (#3819) - Emit load_addr and load_size if WAMR_ENABLE_COMPILER is set (#3835) - libc-emcc: Use alternate method to check getrandom support (#3848) -- Enable libc-wasi for windows msvc build (#3852) -- Remove unused folder samples/gui and samples/littlevgl (#3853) +- Enable libc-wasi for windows msvc build (#3852) +- Remove unused folder samples/gui and samples/littlevgl (#3853) - Fix some compile warnings and typos (#3854) - Allow to set native stack boundary to exec_env (#3862) - Refine wasm/aot function instance lookup (#3865) - Fix quadratic runtime for duplicate export name detection (#3861) - ### Others -- Add a comment on AOT_SECTION_TYPE_SIGNATURE (#3746) + +- Add a comment on AOT_SECTION_TYPE_SIGNATURE (#3746) - CI: Freeze version of bloaty for NuttX compilation (#3756) - aot compiler: Allow to control stack boundary check when boundary check is enabled (#3754) - Update ref to the multi-memory tests (#3764) - compilation_on_nuttx.yml: Update checkout action to suppress warnings (#3765) - CI: Disable parallel test in spectest for NuttX (#3780) -- spec_test_on_nuttx.yml: Disable riscv32_ilp32f for now (#3777) +- spec_test_on_nuttx.yml: Disable riscv32_ilp32f for now (#3777) - Ignore temporary file from aider (#3787) - Add CODEOWNERS (#3822) - build(deps): bump github/codeql-action from 2.2.4 to 3.26.9 (#3826) - build(deps): bump actions/upload-artifact from 3.1.0 to 4.4.0 (#3827) - build(deps): bump ossf/scorecard-action from 2.3.1 to 2.4.0 (#3828) -- build(deps): bump github/codeql-action from 3.26.9 to 3.26.11 (#3843) +- build(deps): bump github/codeql-action from 3.26.9 to 3.26.11 (#3843) - build(deps): bump actions/upload-artifact from 4.4.0 to 4.4.3 (#3855) - build(deps): bump github/codeql-action from 3.26.11 to 3.26.12 (#3856) - Add Windows wamrc and iwasm build in release CI (#3857) - Fix syntax error in codeql_buildscript.sh (#3864) - release CI: Add another iwasm binary that supports Garbage Collection and Exception Handling (#3866) - Fix lookup function issue reported in nightly run (#3868) - + --- ## WAMR-2.1.2 ### Breaking Changes - - wasi-nn: Apply new architecture (#3692) + +- wasi-nn: Apply new architecture (#3692) ### New Features - - [wasi-nn] Add a new wasi-nn backend openvino (#3603) - - Add APIs into wasm_c_api.h to summary wasm function execution duration (#3639) - - Add support for RISCV32 ILP32F (#3708) + +- [wasi-nn] Add a new wasi-nn backend openvino (#3603) +- Add APIs into wasm_c_api.h to summary wasm function execution duration (#3639) +- Add support for RISCV32 ILP32F (#3708) ### Bug Fixes - - libc-builtin: Fix function prototype for wasm_runtime_module_realloc (#3702) - - Fix potential memory leak in insert_native_symbol (#3712) - - aot compiler: Fix NaN handling for opcode f32/f64.const in XIP mode (#3721) - - Fix table idx resolving in op call_indirect/return_call_indirect (#3726) + +- libc-builtin: Fix function prototype for wasm_runtime_module_realloc (#3702) +- Fix potential memory leak in insert_native_symbol (#3712) +- aot compiler: Fix NaN handling for opcode f32/f64.const in XIP mode (#3721) +- Fix table idx resolving in op call_indirect/return_call_indirect (#3726) ### Enhancements - - Remove a few hardcoded spec test knowledge from the core library (#3648) - - Change log of import function to be consistent (#3656) - - libc-builtin: Fix a printf format (#3652) - - Set compile symbol visibility to hidden in cmake (#3655) - - wamrc: Add --mllvm= option (#3658) - - wamr-compiler: Avoid size-level tweak if target is specified (#3659) - - aot runtime: Add missing arm/thumb relocations (#3660) - - aot compiler: Enlarge AOTNativeSymbol->symbol (#3662) - - aot compiler: Bail out on too long native symbol names (#3663) - - Support more features for rt-thread (#3661) - - Zephyr User Mode Support (#3650) - - Set posix thread name for debug build (#3657) - - Add emscripten_sleep() wrapper to libc-emcc (#3669) - - Fix a compilation warning (#3682) - - wamrc: Add some help text for --size-level (#3689) - - Restore linux iwasm default visibility (#3691) - - posix_thread.c: Restore old signal alternate stack before thread exit (#3693) - - libc-wasi: Make rights of STDIN/STDOUT/STDERR fixed and overlook their access modes (#3694) - - [refactoring] Extract read leb to a separate file, share the code between loader and mini loader (#3701) - - debug-interp: Only add lock when signal_flag is SIG_SINGSTEP (#3704) - - Fix compilation warnings (#3707) - - Add missing headers in bh_atomic.h and aot_llvm_extra.cpp (#3715) - - Update std atomic check and simd compatibility check for arc compiler (#3716) - - aot compiler: Track non-0x00 tableindex as ref types use (#3695) - - compilation: Use the dedicated stack-sizes section only for AOT (#3732) - - riscv: Add missing relocation intrinsics for __fixdfsi/__ltdf2 (#3733) + +- Remove a few hardcoded spec test knowledge from the core library (#3648) +- Change log of import function to be consistent (#3656) +- libc-builtin: Fix a printf format (#3652) +- Set compile symbol visibility to hidden in cmake (#3655) +- wamrc: Add --mllvm= option (#3658) +- wamr-compiler: Avoid size-level tweak if target is specified (#3659) +- aot runtime: Add missing arm/thumb relocations (#3660) +- aot compiler: Enlarge AOTNativeSymbol->symbol (#3662) +- aot compiler: Bail out on too long native symbol names (#3663) +- Support more features for rt-thread (#3661) +- Zephyr User Mode Support (#3650) +- Set posix thread name for debug build (#3657) +- Add emscripten_sleep() wrapper to libc-emcc (#3669) +- Fix a compilation warning (#3682) +- wamrc: Add some help text for --size-level (#3689) +- Restore linux iwasm default visibility (#3691) +- posix_thread.c: Restore old signal alternate stack before thread exit (#3693) +- libc-wasi: Make rights of STDIN/STDOUT/STDERR fixed and overlook their access modes (#3694) +- [refactoring] Extract read leb to a separate file, share the code between loader and mini loader (#3701) +- debug-interp: Only add lock when signal_flag is SIG_SINGSTEP (#3704) +- Fix compilation warnings (#3707) +- Add missing headers in bh_atomic.h and aot_llvm_extra.cpp (#3715) +- Update std atomic check and simd compatibility check for arc compiler (#3716) +- aot compiler: Track non-0x00 tableindex as ref types use (#3695) +- compilation: Use the dedicated stack-sizes section only for AOT (#3732) +- riscv: Add missing relocation intrinsics for **fixdfsi/**ltdf2 (#3733) ### Others - - Fix night run CI (#3640) - - spec-test-script/runtest.py: Don't assume the tmp dir path (#3632) - - wamr-test-suites: Remove dead code (wasi_test) (#3634) - - wamr-test-suites/test_wamr.sh: Add an option to specify wamrc binary (#3635) - - CI: Build llvm for xtensa (#3637) - - spec-test-script/runtest.py: Avoid specifying -v=0 unnecessarily (#3642) - - spec-test-script: Add xtensa case (#3643) - - spec-test-script/runtest.py: Move "--size-level=1" to common place for RISCV64 (#3644) - - spec-test-script/runtest.py: Use a shorter timeout when expected to fail (#3647) - - spec-test-script: Make case_last_words larger (#3651) - - spec-test-script/runtest.py: Reduce stack size for aot w/o gc (#3653) - - spec-test-script: Skip a few tests for xtensa qemu (#3664) - - spec-test-script: Use -mtext-section-literals for xtensa xip (#3666) - - spec_test_on_nuttx.yml: Add xtensa (#3665) - - spec_test_on_nuttx.yml: Enable xip (#3671) - - spec_test_on_nuttx.yml: Record more logs (#3670) - - spec_test_on_nuttx.yml: Replace sed with kconfig-tweak (#3672) - - spec_test_on_nuttx.yml: Retire CONFIG_EOL_IS_LF (#3676) - - spec-test-script/runtest.py: Use wamrc --xip option for xip (#3683) - - CI: Bump NuttX version to 12.6 (#3684) - - wamr-test-suites: Clean up generated tmp files after spec test (#3700) - - test_wamr.sh: Fix build wabt tool (#3703) - - NuttX: Retire CONFIG_ARCH_RV32IM and CONFIG_ARCH_RV64GC (#3717) - - runtest.py: Normallize option handling for XIP mode (#3722) - - CI: Enable XIP spectest for RISCV32 ILP32F (#3727) - - CI: Unify configuration stage for NuttX (#3725) + +- Fix night run CI (#3640) +- spec-test-script/runtest.py: Don't assume the tmp dir path (#3632) +- wamr-test-suites: Remove dead code (wasi_test) (#3634) +- wamr-test-suites/test_wamr.sh: Add an option to specify wamrc binary (#3635) +- CI: Build llvm for xtensa (#3637) +- spec-test-script/runtest.py: Avoid specifying -v=0 unnecessarily (#3642) +- spec-test-script: Add xtensa case (#3643) +- spec-test-script/runtest.py: Move "--size-level=1" to common place for RISCV64 (#3644) +- spec-test-script/runtest.py: Use a shorter timeout when expected to fail (#3647) +- spec-test-script: Make case_last_words larger (#3651) +- spec-test-script/runtest.py: Reduce stack size for aot w/o gc (#3653) +- spec-test-script: Skip a few tests for xtensa qemu (#3664) +- spec-test-script: Use -mtext-section-literals for xtensa xip (#3666) +- spec_test_on_nuttx.yml: Add xtensa (#3665) +- spec_test_on_nuttx.yml: Enable xip (#3671) +- spec_test_on_nuttx.yml: Record more logs (#3670) +- spec_test_on_nuttx.yml: Replace sed with kconfig-tweak (#3672) +- spec_test_on_nuttx.yml: Retire CONFIG_EOL_IS_LF (#3676) +- spec-test-script/runtest.py: Use wamrc --xip option for xip (#3683) +- CI: Bump NuttX version to 12.6 (#3684) +- wamr-test-suites: Clean up generated tmp files after spec test (#3700) +- test_wamr.sh: Fix build wabt tool (#3703) +- NuttX: Retire CONFIG_ARCH_RV32IM and CONFIG_ARCH_RV64GC (#3717) +- runtest.py: Normallize option handling for XIP mode (#3722) +- CI: Enable XIP spectest for RISCV32 ILP32F (#3727) +- CI: Unify configuration stage for NuttX (#3725) --- ## WAMR-2.1.1 ### Breaking Changes - - Sync up with latest wasi-nn spec (#3530) + +- Sync up with latest wasi-nn spec (#3530) ### New Features - - Add APIs to get package version (#3601) - - Export API wasm_runtime_enlarge_memory (#3569) - - Add table type API support (#3515) - - Add wasm_runtime_get_module_package_type() and wasm_runtime_get_file_package_type() (#3600) + +- Add APIs to get package version (#3601) +- Export API wasm_runtime_enlarge_memory (#3569) +- Add table type API support (#3515) +- Add wasm_runtime_get_module_package_type() and wasm_runtime_get_file_package_type() (#3600) ### Bug Fixes - - wasm_application.c: Avoid null pointer dereference (#3620) - - EH: Use the consistent type for EH handlers (#3619) - - wasm loader: Fix several issues in GC and exception handling (#3586) - - wasm loader: Fix push_frame_offset when pushing v128 type (#3588) - - Add integer overflow check for some indices in wasm/aot loader (#3579) - - aot-analyzer: Fix a few printf formats (#3590) - - aot-analyzer: Fix macos build (#3589) - - Fix compilation errors in aot-analyzer tool (#3584) - - interp debugger: Fix setting invalid value to step_count (#3583) - - aot loader: Check import global value type before using (#3571) - - Fix missing stack frame alloc/free in AOT multi-module invoke (#3562) - - aot loader: Verify global value type (#3560) - - aot loader: Add more checks in load_native_symbol_section() (#3559) - - core/shared/platform: Zero memory returned by os_mmap in some platforms (#3551) - - dwarf_extractor.cpp: Fix buffer overruns (#3541) - - aot loader: Prevent loading multiple native symbol sections (#3538) - - Validate func type in aot loader (#3535) - - wamrc: Fix truncated DW_AT_producer (#3537) - - wasm loader: Fix pop invalid offset count when stack top is ANY (#3516) - - Fix two fuzz issues (#3529) - - Fix several issues reported by oss-fuzz (#3526) + +- wasm_application.c: Avoid null pointer dereference (#3620) +- EH: Use the consistent type for EH handlers (#3619) +- wasm loader: Fix several issues in GC and exception handling (#3586) +- wasm loader: Fix push_frame_offset when pushing v128 type (#3588) +- Add integer overflow check for some indices in wasm/aot loader (#3579) +- aot-analyzer: Fix a few printf formats (#3590) +- aot-analyzer: Fix macos build (#3589) +- Fix compilation errors in aot-analyzer tool (#3584) +- interp debugger: Fix setting invalid value to step_count (#3583) +- aot loader: Check import global value type before using (#3571) +- Fix missing stack frame alloc/free in AOT multi-module invoke (#3562) +- aot loader: Verify global value type (#3560) +- aot loader: Add more checks in load_native_symbol_section() (#3559) +- core/shared/platform: Zero memory returned by os_mmap in some platforms (#3551) +- dwarf_extractor.cpp: Fix buffer overruns (#3541) +- aot loader: Prevent loading multiple native symbol sections (#3538) +- Validate func type in aot loader (#3535) +- wamrc: Fix truncated DW_AT_producer (#3537) +- wasm loader: Fix pop invalid offset count when stack top is ANY (#3516) +- Fix two fuzz issues (#3529) +- Fix several issues reported by oss-fuzz (#3526) ### Enhancements - - Fix compile warnings/error reported in Windows (#3616) - - wasm loader: Reject v128 for interpreters (#3611) - - Fix typos in wamrc and wasm_export.h (#3609) - - Bump ocaml/setup-ocaml from 2 to 3 (#3604) - - CMakeLists.txt: Fix Android pthread linkage (#3591) - - Add more arm AOT reloc entries (#3587) - - wasi-nn: Use numpy v1 in wasi-nn test requirements.txt (#3582) - - Optimize for multi-module support in AOT mode (#3563) - - aot compiler: Propagate const-ness by ourselves (#3567) - - aot_resolve_target_info: Avoid in-place modification of e_type (#3564) - - Allow missing imports in wasm loader and report error in wasm instantiation instead (#3539) - - aot compiler: Use larger alignment for load/store when possible (#3552) - - Consistent const keyword position in wasm_export.h (#3558) - - wasm_memory.c: Fix typo: hasn't been initialize -> `hasn't been initialized` (#3547) - - dwarf_extractor.cpp: Try to preserve link name (#3542) - - dwarf_extractor.cpp: Enable limited support for C++ (#3540) - - Sync up with latest wasi-nn spec (#3530) - - Expose more functions related to emitting AOT files (#3520) - - Make wasi-nn backends as separated shared libraries (#3509) - - build_llvm.py: Speed up llvm build with multi procs on windows (#3512) - - Fix compilation warnings of wasi-nn (#3497) - - Add missing functions to make RIOT work with the 2.x.x version (#3508) + +- Fix compile warnings/error reported in Windows (#3616) +- wasm loader: Reject v128 for interpreters (#3611) +- Fix typos in wamrc and wasm_export.h (#3609) +- Bump ocaml/setup-ocaml from 2 to 3 (#3604) +- CMakeLists.txt: Fix Android pthread linkage (#3591) +- Add more arm AOT reloc entries (#3587) +- wasi-nn: Use numpy v1 in wasi-nn test requirements.txt (#3582) +- Optimize for multi-module support in AOT mode (#3563) +- aot compiler: Propagate const-ness by ourselves (#3567) +- aot_resolve_target_info: Avoid in-place modification of e_type (#3564) +- Allow missing imports in wasm loader and report error in wasm instantiation instead (#3539) +- aot compiler: Use larger alignment for load/store when possible (#3552) +- Consistent const keyword position in wasm_export.h (#3558) +- wasm_memory.c: Fix typo: hasn't been initialize -> `hasn't been initialized` (#3547) +- dwarf_extractor.cpp: Try to preserve link name (#3542) +- dwarf_extractor.cpp: Enable limited support for C++ (#3540) +- Sync up with latest wasi-nn spec (#3530) +- Expose more functions related to emitting AOT files (#3520) +- Make wasi-nn backends as separated shared libraries (#3509) +- build_llvm.py: Speed up llvm build with multi procs on windows (#3512) +- Fix compilation warnings of wasi-nn (#3497) +- Add missing functions to make RIOT work with the 2.x.x version (#3508) ### Others - - Update devcontainer.md (#3628) - - Fix compile errors on workload bwa and benchmark jetstream (#3617) - - wasm-mutator-fuzz: Set compilers earlier (#3585) - - wasm-mutator-fuzz: Make compilers overridable (#3578) - - wasi-nn: Add wasmedge-wasinn-example as smoke test (#3554) - - Add standalone cases (#3536) - - wasm-mutator-fuzz: Fix build errors and warnings for macOS (#3519) - - wasm-mutator-fuzz: Use another variable to check if in oss-fuzz environment (#3518) - - Add wasi-nn example as smoke test case (#3501) + +- Update devcontainer.md (#3628) +- Fix compile errors on workload bwa and benchmark jetstream (#3617) +- wasm-mutator-fuzz: Set compilers earlier (#3585) +- wasm-mutator-fuzz: Make compilers overridable (#3578) +- wasi-nn: Add wasmedge-wasinn-example as smoke test (#3554) +- Add standalone cases (#3536) +- wasm-mutator-fuzz: Fix build errors and warnings for macOS (#3519) +- wasm-mutator-fuzz: Use another variable to check if in oss-fuzz environment (#3518) +- Add wasi-nn example as smoke test case (#3501) --- @@ -230,102 +434,107 @@ ### Breaking Changes ### New Features - - Add wasm_export.h APIs to expose memory type (#3496) - - Add api to get export global instance (#3452) - - Add wasm-mutator-fuzz test (#3420) - - Implement Memory64 support for AOT (#3362) - - Add wasm module global type information APIs (#3406) - - Add aot binary analysis tool aot-analyzer (#3379) - - Expose API to get import/export function's param/result valkind (#3363) - - Add WASI support for esp-idf platform (#3348) + +- Add wasm_export.h APIs to expose memory type (#3496) +- Add api to get export global instance (#3452) +- Add wasm-mutator-fuzz test (#3420) +- Implement Memory64 support for AOT (#3362) +- Add wasm module global type information APIs (#3406) +- Add aot binary analysis tool aot-analyzer (#3379) +- Expose API to get import/export function's param/result valkind (#3363) +- Add WASI support for esp-idf platform (#3348) ### Bug Fixes - - Fix posix build when libc wasi is disabled and debug interp is enabled (#3503) - - Fix wasm_mini_loader.c build when jit or multi-module is enabled (#3502) - - Fix wasm loader check data segment count (#3492) - - Fix loader parse block type and calculate dynamic offset for loop args (#3482) - - Fix memory64 handling find_block_addr and execute_main (#3480) - - Fix two issues to make fuzzing test quit earlier (#3471) - - Fix test-wamr-ide CI failure (#3485) - - NuttX: Fix a dbus-related crash on esp32s3 (#3470) - - Clone data segments when specified with load args (#3463) - - Fix codeql compilation error (#3461) - - Fix several typos and fix bh_log calculate mills (#3441) - - ssp_config.h: Fix ifdef for android random api (#3444) - - libc-wasi: Fix a locking botch (#3437) - - Fix fast interp RECOVER_BR_INFO and local set/tee (#3434) - - aot compiler: Fix a type mismatch in compile_op_float_min_max (#3423) - - Correct Exception Handling tag type when GC is enabled (#3413) - - wasm loader: Fix handling if block without op else (#3404) - - ref-types: Correct default value for function local variables (#3397) - - aot compiler: Fix the length type passed to aot_memmove/aot_memset (#3378) - - Fix loader and mini-loader select potiential error (#3374) - - Fix aot debugger compilation error on windows (#3370) - - A few native stack detection fixes for macOS/arm64 (#3368) - - Fix ESP32-S3 compiling error (#3359) - - Fix a few native stack address calculations (#3351) + +- Fix posix build when libc wasi is disabled and debug interp is enabled (#3503) +- Fix wasm_mini_loader.c build when jit or multi-module is enabled (#3502) +- Fix wasm loader check data segment count (#3492) +- Fix loader parse block type and calculate dynamic offset for loop args (#3482) +- Fix memory64 handling find_block_addr and execute_main (#3480) +- Fix two issues to make fuzzing test quit earlier (#3471) +- Fix test-wamr-ide CI failure (#3485) +- NuttX: Fix a dbus-related crash on esp32s3 (#3470) +- Clone data segments when specified with load args (#3463) +- Fix codeql compilation error (#3461) +- Fix several typos and fix bh_log calculate mills (#3441) +- ssp_config.h: Fix ifdef for android random api (#3444) +- libc-wasi: Fix a locking botch (#3437) +- Fix fast interp RECOVER_BR_INFO and local set/tee (#3434) +- aot compiler: Fix a type mismatch in compile_op_float_min_max (#3423) +- Correct Exception Handling tag type when GC is enabled (#3413) +- wasm loader: Fix handling if block without op else (#3404) +- ref-types: Correct default value for function local variables (#3397) +- aot compiler: Fix the length type passed to aot_memmove/aot_memset (#3378) +- Fix loader and mini-loader select potiential error (#3374) +- Fix aot debugger compilation error on windows (#3370) +- A few native stack detection fixes for macOS/arm64 (#3368) +- Fix ESP32-S3 compiling error (#3359) +- Fix a few native stack address calculations (#3351) ### Enhancements - - Modify logging for windows exception handler and remove unused function (#3489) - - posix iwasm: Make the timeout logic a bit more robust (#3478) - - libc-builtin: Enhance buffered print for printf_wrapper (#3460) - - Enhance GC const initializer expression to support nested struct/array new (#3447) - - wasi: Tweak the configuration for nuttx and explain why (#3451) - - NuttX: Replace esp32s3 bits with the OS-provided APIs (#3439) - - Allow not copying the wasm binary in wasm-c-api and not referring to the binary in wasm/aot loader (#3389) - - aot: Make precheck functions use short-call for xtensa (#3418) - - Add wasm_runtime_detect_native_stack_overflow_size (#3355) - - Enhance wasm loader checks for opcode br_table (#3352) + +- Modify logging for windows exception handler and remove unused function (#3489) +- posix iwasm: Make the timeout logic a bit more robust (#3478) +- libc-builtin: Enhance buffered print for printf_wrapper (#3460) +- Enhance GC const initializer expression to support nested struct/array new (#3447) +- wasi: Tweak the configuration for nuttx and explain why (#3451) +- NuttX: Replace esp32s3 bits with the OS-provided APIs (#3439) +- Allow not copying the wasm binary in wasm-c-api and not referring to the binary in wasm/aot loader (#3389) +- aot: Make precheck functions use short-call for xtensa (#3418) +- Add wasm_runtime_detect_native_stack_overflow_size (#3355) +- Enhance wasm loader checks for opcode br_table (#3352) ### Others - - Bump requests from 2.32.2 to 2.32.3 in /build-scripts (#3494) - - Enable building static library on Android platform (#3488) - - wasm-mutator-fuzz: Generate more kinds of corpus (#3487) - - Correct nuttx repo names (#3484) - - Bump requests from 2.31.0 to 2.32.2 in /build-scripts (#3474) - - wasm-mutator-fuzz: Adapt to oss-fuzz compilation (#3464) - - Add regression tests of BA issue cases (#3462) - - Add malformed test cases (#3459) - - NuttX: Rename a few recently-added nuttx options (#3449) - - wamr-test-suites: Enable AOT multi-module spec tests (#3450) - - Remove install_wasi_sdk from workload preparation script (#3445) - - Add cmake static/shared library build settings (#3443) - - Update spec test to latest commit (#3293) - - Fix typo of WAMR_CONFIGUABLE_BOUNDS_CHECKS (#3424) - - ci/coding_guidelines_check.py: Allow some well-known file names to contain '-' (#3428) - - product-mini/platforms/posix/main.c: Adapt to WASM_MEM_DUAL_BUS_MIRROR (#3427) - - Add comments to global type function declarations (#3431) - - nuttx/esp32s3: Apply ibus/dbus adjustment to internal ram 1 as well (#3421) - - Change WASM_ANYREF to WASM_EXTERNREF (#3426) - - Remove unused macros which were moved to wamr-app-framework (#3425) - - Add WASM_V128 in wasm_valkind_enum (#3412) - - Fix basic example, parameter missmatch between host and wasm (#3415) - - Fix workspaces path in build_wamr.sh (#3414) - - core/iwasm/compilation: Remove stale function prototypes (#3408) - - Add test cases for the requirements of "gc-aot" feature (#3399) - - append_aot_to_wasm.py: Add --ver-str option to emit more info in custom section name (#3398) - - Fix clang compile warnings (#3396) - - Fix some more spelling issues (#3393) - - Fix some spelling issues (#3385) - - samples/native-stack-overflow: Examine native functions with signature (#3382) - - Add some more comments on WASM_STACK_GUARD_SIZE (#3380) - - Fix typo for 'native' in wasm_export.h (#3376) - - CI: Use macos-13 instead of macos-latest (#3366) - - Test more samples in nightly-run CI (#3358) - - Random improvements to samples/native-stack-overflow (#3353) - - Reduce WASM_STACK_GUARD_SIZE a bit for posix-like platforms (#3350) - - doc: Add ADOPTERS.md (#3324) - - Update binary size info in README.md (#3030) - - core/config.h: Bump the default WASM_STACK_GUARD_SIZE (#3344) - - Add unit test suites (#3490) - - Fix internal global getter types (#3495) - - Fix CI build and run unit tests (#3499) + +- Bump requests from 2.32.2 to 2.32.3 in /build-scripts (#3494) +- Enable building static library on Android platform (#3488) +- wasm-mutator-fuzz: Generate more kinds of corpus (#3487) +- Correct nuttx repo names (#3484) +- Bump requests from 2.31.0 to 2.32.2 in /build-scripts (#3474) +- wasm-mutator-fuzz: Adapt to oss-fuzz compilation (#3464) +- Add regression tests of BA issue cases (#3462) +- Add malformed test cases (#3459) +- NuttX: Rename a few recently-added nuttx options (#3449) +- wamr-test-suites: Enable AOT multi-module spec tests (#3450) +- Remove install_wasi_sdk from workload preparation script (#3445) +- Add cmake static/shared library build settings (#3443) +- Update spec test to latest commit (#3293) +- Fix typo of WAMR_CONFIGUABLE_BOUNDS_CHECKS (#3424) +- ci/coding_guidelines_check.py: Allow some well-known file names to contain '-' (#3428) +- product-mini/platforms/posix/main.c: Adapt to WASM_MEM_DUAL_BUS_MIRROR (#3427) +- Add comments to global type function declarations (#3431) +- nuttx/esp32s3: Apply ibus/dbus adjustment to internal ram 1 as well (#3421) +- Change WASM_ANYREF to WASM_EXTERNREF (#3426) +- Remove unused macros which were moved to wamr-app-framework (#3425) +- Add WASM_V128 in wasm_valkind_enum (#3412) +- Fix basic example, parameter missmatch between host and wasm (#3415) +- Fix workspaces path in build_wamr.sh (#3414) +- core/iwasm/compilation: Remove stale function prototypes (#3408) +- Add test cases for the requirements of "gc-aot" feature (#3399) +- append_aot_to_wasm.py: Add --ver-str option to emit more info in custom section name (#3398) +- Fix clang compile warnings (#3396) +- Fix some more spelling issues (#3393) +- Fix some spelling issues (#3385) +- samples/native-stack-overflow: Examine native functions with signature (#3382) +- Add some more comments on WASM_STACK_GUARD_SIZE (#3380) +- Fix typo for 'native' in wasm_export.h (#3376) +- CI: Use macos-13 instead of macos-latest (#3366) +- Test more samples in nightly-run CI (#3358) +- Random improvements to samples/native-stack-overflow (#3353) +- Reduce WASM_STACK_GUARD_SIZE a bit for posix-like platforms (#3350) +- doc: Add ADOPTERS.md (#3324) +- Update binary size info in README.md (#3030) +- core/config.h: Bump the default WASM_STACK_GUARD_SIZE (#3344) +- Add unit test suites (#3490) +- Fix internal global getter types (#3495) +- Fix CI build and run unit tests (#3499) --- ## WAMR-2.0.0 ### Breaking Changes + - The AOT ABI was changed after GC and memory64 features were introduced: - Implement GC feature for interpreter, AOT and LLVM-JIT (#3125) - Implement memory64 for classic interpreter (#3266) @@ -335,11 +544,13 @@ - Separate app-manager and app-framework from WAMR (#3129) ### New Features + - Implement GC feature for interpreter, AOT and LLVM-JIT (#3125) - Implement memory64 for classic interpreter (#3266) - Add wasi_ephemeral_nn module support (#3241) ### Bug Fixes + - EH: Fix broken stack usage calculation (#3121) - Fix loader check_wasi_abi_compatibility (#3126) - Fix possible integer overflow in loader target block check (#3133) @@ -366,6 +577,7 @@ - Fix windows relocation string parsing issue (#3333) ### Enhancements + - Zero the memory mapped from os_mmap in NuttX (#3132) - Use logger for runtime error/debug prints (#3097) - aot_compile_op_call: Stop setting calling convention explicitly (#3140) @@ -409,6 +621,7 @@ - Add functions to expose module import/export info (#3330) ### Others + - Add ARM MacOS to the CI (#3120) - Download jetstream src from github instead of browserbench.org (#3196) - Update document to add wamr-rust-sdk introduction (#3204) @@ -427,12 +640,14 @@ ### Breaking Changes ### New Features + - Implement Exception Handling for classic interpreter (#3096) - Use `cmake -DWAMR_BUILD_EXCE_HANDLING=1/0` option to enable/disable the feature, and by default it is disabled - It is still in highly experimental stage ### Bug Fixes + - Fix build errors when initializing wasm_val_t values with macros (#3007) - fix(wasm-c-api): Do not clone stack frames if there's no trap (#3008) - classic-interp: Handle SIMD opcode when JIT is enabled (#3046) @@ -451,6 +666,7 @@ - Fix read and validation of misc/simd/atomic sub opcodes (#3115) ### Enhancements + - Clear compilation warning and dead code (#3002) - aot debug: Try to use a bit more appropriate file names (#3000) - Increase default app thread stack size (#3010) @@ -459,7 +675,7 @@ - Allow using mmap for shared memory if hw bound check is disabled (#3029) - Don't redefine D_INO if already defined (#3036) - Enhancements on wasm function execution time statistic (#2985) -- wamr-compiler: Fix non-x86{_64} host builds (#3037) +- wamr-compiler: Fix non-x86{\_64} host builds (#3037) - Disable quick aot entry for interp and fast-jit (#3039) - nuttx: Add option to enable quick aot entry (#3040) - Set CONFIG_HAS_CAP_ENTER to support posix file api for freertos (#3041) @@ -481,6 +697,7 @@ - Fix windows build error and compilation warnings (#3095) ### Others + - Fix nightly-run CI failure (#3014) - Build samples in debug mode (#3019) - Remove deprecated tests in language-bindings python (#3018) @@ -501,6 +718,7 @@ ## WAMR-1.3.1 ### Breaking Changes + - In multi-threading, when an exception was thrown in wasm_func_call(), the trap returned contains the stack frames of the thread where the exception occurs, but not the stack frames of the main thread. @@ -509,9 +727,11 @@ `wamrc --emit-custom-sections=name` to emit it and make it clear. ### New Features + - Enable AOT linux perf support (#2930) ### Bug Fixes + - Corrects Zephyr include files for current versions of Zephyr (#2881) - Fix possible dead lock in wasm_cluster_spawn_exec_env (#2882) - Handle ambiguous fstflags on fd_filestat_set_times (#2892) @@ -530,7 +750,8 @@ - Fix linux-sgx build error when libc-wasi is disabled (#2997) ### Enhancements -- fix command-reactor: Look for _initialize only if _start not found (#2891) + +- fix command-reactor: Look for \_initialize only if \_start not found (#2891) - Refactor reloc symbols for riscv (#2894) - Avoid memory import failure when wasi-threads is enabled (#2893) - interpreter: Simplify memory.grow a bit (#2899) @@ -542,7 +763,7 @@ - Enable wasm_runtime_terminate for single-threading (#2924) - nuttx: Add CONFIG_INTERPRETERS_WAMR_DEBUG_AOT (#2929) - Allow to control built-in libraries for wamrc from command line options (#2928) -- Fix a bug that appends '_precheck' to aot_func (#2936) +- Fix a bug that appends '\_precheck' to aot_func (#2936) - freertos: Add os_cond_broadcast for pthread wrapper (#2937) - Append .aot to .wasm as a custom section named "aot" (#2933) - fix(sgx-ra): Fix building when enclave is built without librats ahead (#2968) @@ -557,6 +778,7 @@ - Refine AOT/JIT code call wasm-c-api import process (#2982) ### Others + - compilation_on_nuttx.yml: Use docker image to simplify env setup (#2878) - samples/spawn-thread: Disable libc and pthread (#2883) - Add arm64 to nuttx compilation test (#2886) @@ -571,6 +793,7 @@ ## WAMR-1.3.0 ### Breaking Changes + - Abstract POSIX filesystem functions (#2585) - Change API wasm_runtime_set_wasi_args_ex's arguments `int stdinfd/stdoutfd/stderrfd` to `int64_t stdinfd/stdoutfd/stderrfd` @@ -585,6 +808,7 @@ - libc-wasi: Conditionally support SYNC flags (#2581) ### New Features + - Support muti-module for AOT mode (#2482) - Implement libc-wasi for Windows platform (#2740) - Implement module instance context APIs (#2436) @@ -593,8 +817,9 @@ - Add Cosmopolitan Libc Platform (#2598) ### Bug Fixes + - sgx-ra: Disable the building of samples (#2507) -- Handle a return from wasi _start function correctly (#2529) +- Handle a return from wasi \_start function correctly (#2529) - fd_object_release: Preserve errno (#2535) - Fix build error with ancient GCC (4.8) (#2553) - Fix compiling error for RT-Thread (#2569) @@ -645,6 +870,7 @@ - Fix sample basic intToStr was called with wrong length (#2876) ### Enhancements + - Implement strict validation of thread IDs according to the specification (#2521) - Stop abusing shared memory lock to protect exception (#2509) - Implement os_usleep for posix (#2517) @@ -660,7 +886,7 @@ - Add user to enlarge memory error callback (#2546) - runtest.py: Show accurate case amount in summary (#2549) - Allow using custom signal handler from non-main thread (#2551) -- Return __WASI_EINVAL from fd_prestat_dir_name (#2580) +- Return \_\_WASI_EINVAL from fd_prestat_dir_name (#2580) - Support AOT compiler with LLVM 17 (#2567) - Add support for closing/renumbering preopen fds (#2578) - Enable AOT usage on M1 mac (#2618) @@ -703,6 +929,7 @@ - Fix compilation warnings on Windows (#2868) ### Others + - Add mutex stress test (#2472) - Add unit tests for the tid allocator (#2519) - Add support for running tests on apple M1 macs (#2554) @@ -740,15 +967,18 @@ ## WAMR-1.2.3 ### Breaking Changes + - Increase default native stack size (#2332) ### New Features + - Implement the segue optimization for LLVM AOT/JIT (#2230) - Implement AOT static PGO (#2243) - Enable static PGO for Linux SGX (#2270) - Add Rust Formatters to Debugger (Vector, Map etc.) (#2219) ### Bug Fixes + - The Python language-binding needs python>=3.9 (#2228) - aot_compile_op_call: Remove a wrong optimization (#2233) - Fix typo in samples/ref-types (#2236) @@ -791,6 +1021,7 @@ - Fix typo in aot_emit_aot_file.c (#2478) ### Enhancements + - A few changes related to WAMRC_LLC_COMPILER (#2218) - Enhance linux-sgx CI (#2102) - Add asan and ubsan to WAMR CI (#2161) @@ -799,7 +1030,7 @@ - Add cmake variable to disable writing gs register (#2284) - Make hmu_tree_node 4 byte aligned to reduce compiler warning (#2268) - Appease unused warning on min_uint64 (#2277) -- Fix format warning by PRIu32 in [wasm|aot] dump call stack (#2251) +- Fix format warning by PRIu32 in [wasm|aot] dump call stack (#2251) - Fix a compile warning due to missing include (#2293) - Fix dockerfile linter warnings (#2291) - Enable windows x86-32 AOT relocations (#2285) @@ -812,7 +1043,7 @@ - aot: Implement a few more relocation types for riscv (#2318) - wasi-nn: Add support of wasi-nn as shared lib (#2310) - Add a few more assertions on structures to which aot abi is sensitive (#2326) -- Fix sanitizer errors in posix socket (#2331) +- Fix sanitizer errors in posix socket (#2331) - Add "--xip" option for wamrc (#2336) - Add "--enable-llvm-passes=" option to wamrc (#2335) - Make memory access boundary check behavior configurable (#2289) @@ -856,6 +1087,7 @@ - Clone the input binary during wasm_module_validate (#2483) ### Others + - Nuttx CI: Ignore the expired certificate for riscv gcc toolchain (#2222) - core/iwasm/compilation: constify a bit (#2223) - Bump requests from 2.28.2 to 2.31.0 in /build-scripts (#2229) @@ -878,9 +1110,11 @@ ### Breaking Changes ### New Features + - Implement Fast JIT multi-threading feature (#2134) ### Bug Fixes + - Update request.ts wasm_response_send signature (#2122) - Fix ems allocator unaligned memory access on riscv64 (#2140) - libc_wasi_wrapper.c: Fix min func issue for size_t < 8 bytes on some platforms (#2152) @@ -889,6 +1123,7 @@ - Fix wamr-ide debugger ignoring launch config (#2155) ### Enhancements + - Add test for validating linear memory size updates (#2078) - Update Zephyr docs to remove unsupported west subcommand (#2128) - Update messages/comments to refer the new place of the version definition (#2133) @@ -907,6 +1142,7 @@ - Fix compile warnings on windows platform (#2208) ### Others + - CI: Add ubsan checks to samples/wasm-c-api (#2147) - CI: More precise trigger paths for github actions (#2157) @@ -919,6 +1155,7 @@ ### New Features ### Bug Fixes + - libc-wasi/posix.c: Fix POLL{RD,WR}NORM in uClibc (#2069) - Fix bh_assert for 64-bit platforms (#2071) - wamr-ide: Modify Dockerfile to update base image version and fix build issue (#2068) @@ -932,6 +1169,7 @@ - Fix interpreter read linear memory size for multi-threading (#2088) ### Enhancements + - Limit the minimal size of bh_hashmap (#2073) - Bump tensorflow to 2.11.1 in /core/iwasm/libraries/wasi-nn/test (#2061) - Bump tensorflow to 2.11.1 in install_tensorflow.sh (#2076) @@ -939,6 +1177,7 @@ - Update documents (#2100) ### Others + - spectest/nuttx: Increase stack size of iwasm task (#2082) - ci: Refactor windows build definition (#2087) - ci: Enable WASI threads in CI (#2086) @@ -950,8 +1189,8 @@ ### Breaking Changes - ### New Features + - Implement two-level Multi-tier JIT engine: tier-up from Fast JIT to LLVM JIT to get quick cold startup and better performance - Enable running mode control for runtime, wasm module instance and iwasm - Implement wasi-threads feature @@ -964,6 +1203,7 @@ - Add libsodium benchmark ### Bug Fixes + - Fix wasm-c-api import func link issue in wasm_instance_new - Fix watchpoint segfault when using debug interp without server - libc-wasi: Fix spurious poll timeout @@ -992,6 +1232,7 @@ - fix debugger: Set termination flags also when in debug mode ### Enhancements + - Add WAMR-IDE vscode extension to the Visual Studio Marketplace - Refine Windows thread waiting list operations - Improve wasm-c-api instantiation-time linking @@ -1032,6 +1273,7 @@ - Refine aot compiler check suspend_flags and fix issue of multi-tier jit ### Others + - Enable XIP in CI daily test - Integrate wasi test suite to wamr-test-suites and CI - Add CI for wasi-threads tests @@ -1046,6 +1288,7 @@ ## WAMR-1.1.2 ### Breaking Changes + - Remove the LLVM MCJIT mode, replace it with LLVM ORC JIT eager mode - Add option to pass user data to the allocator functions of RuntimeInitArgs - Change how iwasm returns: @@ -1055,6 +1298,7 @@ - Enable bulk memory by default ### New Features + - Add control for the native stack check with hardware trap - Add memory watchpoint support to debugger - Add wasm_module_obtain() to clone wasm_module_t @@ -1062,6 +1306,7 @@ - esp-idf: Add socket support for esp-idf platform ### Bug Fixes + - Fix XIP issue caused by rem_s on RISC-V - Fix XIP issues of fp to int cast and int rem/div - Fix missing float cmp for XIP @@ -1081,6 +1326,7 @@ - Fix XIP issue of handling 64-bit const in 32-bit target ### Enhancements + - Refactor the layout of interpreter and AOT module instance - Refactor LLVM JIT: remove mcjit and legacy pass manager, upgrade to ORCv2 JIT - Refine Fast JIT call indirect and call native process @@ -1097,7 +1343,7 @@ - Refine the stack frame size check in interpreter - Enlarge the default wasm operand stack size to 64KB - Use cmake POSITION_INDEPENDENT_CODE instead of hardcoding -pie -fPIE -- Implement R_ARM_THM_MOVT_[ABS|REPL] for thumb +- Implement R*ARM_THM_MOVT*[ABS|REPL] for thumb - Suppress the warnings when building with GCC11 - samples/native-lib: Add a bit more complicated example - Add mutex initializer for wasm-c-api engine operations @@ -1125,6 +1371,7 @@ - Enable wasm cache loading in wasm-c-api ### Others + - Add CIs to release new version and publish binary files - Add more compilation groups of fast jit into CI - Enable spec test on nuttx and daily run it @@ -1273,5 +1520,3 @@ ### Others --- - - diff --git a/build-scripts/version.cmake b/build-scripts/version.cmake index 21eaedca8..e34a11821 100644 --- a/build-scripts/version.cmake +++ b/build-scripts/version.cmake @@ -7,7 +7,7 @@ if(NOT WAMR_ROOT_DIR) endif() set(WAMR_VERSION_MAJOR 2) -set(WAMR_VERSION_MINOR 2) +set(WAMR_VERSION_MINOR 3) set(WAMR_VERSION_PATCH 0) message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}") diff --git a/core/version.h b/core/version.h index d1becac61..00d212c5b 100644 --- a/core/version.h +++ b/core/version.h @@ -17,7 +17,7 @@ /* clang-format off */ #define WAMR_VERSION_MAJOR 2 -#define WAMR_VERSION_MINOR 2 +#define WAMR_VERSION_MINOR 3 #define WAMR_VERSION_PATCH 0 /* clang-format on */ From e48367c044363ae2db06e7eeeb297e1f04d2634a Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 19 May 2025 10:31:17 +0800 Subject: [PATCH 161/198] Fix SIMD load lane to avoid incompatible pointer types (#4278) --- core/iwasm/interpreter/wasm_interp_fast.c | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 78f53e694..681612380 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -6101,8 +6101,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 #define SIMD_LANE_HANDLE_UNALIGNED_ACCESS() #else -#define SIMD_LANE_HANDLE_UNALIGNED_ACCESS() *frame_ip++; -#endif +#define SIMD_LANE_HANDLE_UNALIGNED_ACCESS() (void)*frame_ip++ +#endif /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */ + #define SIMD_EXTRACT_LANE_OP(register, return_type, push_elem) \ do { \ uint8 lane = *frame_ip++; \ @@ -6514,17 +6515,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, break; } -#define SIMD_LOAD_LANE_COMMON(vec, register, lane, width) \ - do { \ - addr_ret = GET_OFFSET(); \ - CHECK_MEMORY_OVERFLOW(width / 8); \ - if (width == 64) { \ - vec.register[lane] = GET_I64_FROM_ADDR(maddr); \ - } \ - else { \ - vec.register[lane] = *(uint##width *)(maddr); \ - } \ - PUT_V128_TO_ADDR(frame_lp + addr_ret, vec); \ +#define SIMD_LOAD_LANE_COMMON(vec, register, lane, width) \ + do { \ + addr_ret = GET_OFFSET(); \ + CHECK_MEMORY_OVERFLOW(width / 8); \ + if (width == 64) { \ + vec.register[lane] = GET_I64_FROM_ADDR((uint32 *)maddr); \ + } \ + else { \ + vec.register[lane] = *(uint##width *)(maddr); \ + } \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, vec); \ } while (0) #define SIMD_LOAD_LANE_OP(register, width) \ From 14d09bfb6617ce374f8a3d38d7bb8273a24a71ff Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Mon, 19 May 2025 10:32:07 +0800 Subject: [PATCH 162/198] Fixed unit tests on X86_32 (#4279) * fix unit tests on x86_32 * enbale wasm-c-api unit test on X86_32 * enable aot-stack-frame unit test on X86_32 * add ci: unit tests on X86_32 --- .../compilation_on_android_ubuntu.yml | 12 ++++- tests/unit/CMakeLists.txt | 23 ++++++--- .../aot-stack-frame/wasm-apps/CMakeLists.txt | 48 ++++++++++++------- tests/unit/wasm-c-api/CMakeLists.txt | 4 +- 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index dd6c096f1..521c2e08f 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -315,6 +315,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04] + build_target: [ + "X86_64", + "X86_32", + ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} @@ -351,10 +355,16 @@ jobs: cmake --build . --config Release --parallel 4 working-directory: wamr-compiler + - name: Install dependencies for X86_32 + if: matrix.build_target == 'X86_32' + run: | + sudo apt-get update + sudo apt-get install -y g++-multilib + - name: Build and run unit tests run: | mkdir build && cd build - cmake .. + cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }} cmake --build . --config Release --parallel 4 ctest working-directory: tests/unit diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index fa9b400fa..8c963cadd 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -32,6 +32,7 @@ include (FetchContent) FetchContent_Declare ( googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) FetchContent_MakeAvailable (googletest) @@ -42,19 +43,27 @@ enable_testing() add_subdirectory(wasm-vm) add_subdirectory(interpreter) -add_subdirectory(aot) add_subdirectory(wasm-c-api) add_subdirectory(libc-builtin) add_subdirectory(shared-utils) -add_subdirectory(running-modes) -add_subdirectory(runtime-common) -add_subdirectory(custom-section) -add_subdirectory(compilation) add_subdirectory(linear-memory-wasm) add_subdirectory(linear-memory-aot) add_subdirectory(aot-stack-frame) add_subdirectory(linux-perf) add_subdirectory(gc) -add_subdirectory(memory64) add_subdirectory(tid-allocator) -add_subdirectory(shared-heap) \ No newline at end of file + +if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32") + # should enable 32-bit llvm when X86_32 + add_subdirectory (aot) + add_subdirectory (custom-section) + add_subdirectory (compilation) + + # Fast-JIT or mem64 is not supported on X86_32 + add_subdirectory (running-modes) + add_subdirectory (memory64) + add_subdirectory (shared-heap) + + # HW_BOUND_CHECK is not supported on X86_32 + add_subdirectory (runtime-common) +endif () diff --git a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt index 6c43a4184..7d80bbfbf 100644 --- a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt @@ -5,23 +5,37 @@ cmake_minimum_required(VERSION 3.14) project(wasm-apps-aot-stack-frame) -add_custom_target(aot-stack-frame-test-wasm ALL - COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc - -S ${WAMR_ROOT_DIR}/wamr-compiler - && cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc - && /opt/wabt/bin/wat2wasm - -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm - ${CMAKE_CURRENT_LIST_DIR}/test.wast - && ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc - --enable-dump-call-stack --bounds-checks=1 --enable-gc - -o ${CMAKE_CURRENT_BINARY_DIR}/test.aot - ${CMAKE_CURRENT_BINARY_DIR}/test.wasm - && cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump - -S ${WAMR_ROOT_DIR}/test-tools/binarydump-tool - && cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump - && ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump/binarydump - -o ${CMAKE_CURRENT_LIST_DIR}/test_aot.h -n test_aot - ${CMAKE_CURRENT_BINARY_DIR}/test.aot +set (WAMRC_OPTION --enable-dump-call-stack --bounds-checks=1 --enable-gc) +if (WAMR_BUILD_TARGET STREQUAL "X86_32") + set (WAMRC_OPTION ${WAMRC_OPTION} --target=i386) +endif () + +add_custom_target( + aot-stack-frame-test-wasm ALL + + # Step 1: Build wamrc + COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc + -S ${WAMR_ROOT_DIR}/wamr-compiler + COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc + + # Step 2: Compile .wast to .wasm + COMMAND /opt/wabt/bin/wat2wasm + -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_LIST_DIR}/test.wast + + # Step 3: Compile .wasm to .aot using wamrc + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc ${WAMRC_OPTION} + -o ${CMAKE_CURRENT_BINARY_DIR}/test.aot ${CMAKE_CURRENT_BINARY_DIR}/test.wasm + + # Step 4: Build binarydump tool + COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump + -S ${WAMR_ROOT_DIR}/test-tools/binarydump-tool + COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump + + # Step 5: Generate .h file from .aot + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump/binarydump + -o ${CMAKE_CURRENT_LIST_DIR}/test_aot.h + -n test_aot + ${CMAKE_CURRENT_BINARY_DIR}/test.aot ) diff --git a/tests/unit/wasm-c-api/CMakeLists.txt b/tests/unit/wasm-c-api/CMakeLists.txt index 9448cd8c3..9556c600e 100644 --- a/tests/unit/wasm-c-api/CMakeLists.txt +++ b/tests/unit/wasm-c-api/CMakeLists.txt @@ -13,7 +13,9 @@ set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") # WAMR features switch -set(WAMR_BUILD_TARGET "X86_64") +if (NOT DEFINED WAMR_BUILD_TARGET) + set(WAMR_BUILD_TARGET "X86_64") +endif() set(WAMR_BUILD_INTERP 1) set(WAMR_BUILD_AOT 0) set(WAMR_BUILD_JIT 0) From f4f33b6a7634197efe40647842d66d32dbed646a Mon Sep 17 00:00:00 2001 From: ChenWen <63690793+cwespressif@users.noreply.github.com> Date: Mon, 19 May 2025 10:33:09 +0800 Subject: [PATCH 163/198] feat(yml): Add ESP32-P4 and ESP32-C5 support (#4270) - Add ESP32-P4 and ESP32-C5 support - Support for compiler options of different floating-point types in various RISC-V chips --- build-scripts/esp-idf/wamr/CMakeLists.txt | 30 +++--- idf_component.yml | 4 +- product-mini/platforms/esp-idf/README.md | 91 +++++++++++++++++++ .../platforms/esp-idf/build_and_run.sh | 14 ++- 4 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 product-mini/platforms/esp-idf/README.md diff --git a/build-scripts/esp-idf/wamr/CMakeLists.txt b/build-scripts/esp-idf/wamr/CMakeLists.txt index af0d8efc9..b47cd16ab 100644 --- a/build-scripts/esp-idf/wamr/CMakeLists.txt +++ b/build-scripts/esp-idf/wamr/CMakeLists.txt @@ -5,11 +5,15 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION) if (CONFIG_IDF_TARGET_ARCH_RISCV) - set (WAMR_BUILD_TARGET "RISCV32") + if (CONFIG_IDF_TARGET_ESP32P4) + set (WAMR_BUILD_TARGET "RISCV32_ILP32F") + else () + set (WAMR_BUILD_TARGET "RISCV32_ILP32") + endif () elseif (CONFIG_IDF_TARGET_ARCH_XTENSA) - set (WAMR_BUILD_TARGET "XTENSA") + set (WAMR_BUILD_TARGET "XTENSA") else () - message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported") + message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported") endif () set (WAMR_BUILD_PLATFORM "esp-idf") @@ -41,31 +45,31 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION) endif () if (CONFIG_WAMR_ENABLE_MULTI_MODULE) - set (WAMR_BUILD_MULTI_MODULE 1) + set (WAMR_BUILD_MULTI_MODULE 1) endif () if (CONFIG_WAMR_ENABLE_SHARED_MEMORY) - set (WAMR_BUILD_SHARED_MEMORY 1) + set (WAMR_BUILD_SHARED_MEMORY 1) endif () if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING) - set (WAMR_BUILD_MEMORY_PROFILING 1) + set (WAMR_BUILD_MEMORY_PROFILING 1) endif () if (CONFIG_WAMR_ENABLE_PERF_PROFILING) - set (WAMR_BUILD_PERF_PROFILING 1) + set (WAMR_BUILD_PERF_PROFILING 1) endif () if (CONFIG_WAMR_ENABLE_REF_TYPES) - set (WAMR_BUILD_REF_TYPES 1) + set (WAMR_BUILD_REF_TYPES 1) endif () if (CONFIG_WAMR_ENABLE_LIBC_WASI) - set (WAMR_BUILD_LIBC_WASI 1) + set (WAMR_BUILD_LIBC_WASI 1) endif () if (CONFIG_WAMR_ENABLE_LIB_PTHREAD) - set (WAMR_BUILD_LIB_PTHREAD 1) + set (WAMR_BUILD_LIB_PTHREAD 1) endif () set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) @@ -89,7 +93,11 @@ idf_component_register(SRCS ${srcs} target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") if (CONFIG_IDF_TARGET_ARCH_RISCV) - target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1) + if (CONFIG_IDF_TARGET_ESP32P4) + target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32F=1) + else () + target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1) + endif () elseif (CONFIG_IDF_TARGET_ARCH_XTENSA) target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1) endif () diff --git a/idf_component.yml b/idf_component.yml index ff25b32cb..a8083a742 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.0.0" +version: "2.2.0~3" description: WebAssembly Micro Runtime - A lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features url: https://bytecodealliance.org/ repository: https://github.com/bytecodealliance/wasm-micro-runtime.git @@ -11,5 +11,7 @@ targets: - esp32s3 - esp32c3 - esp32c6 + - esp32p4 + - esp32c5 examples: - path: product-mini/platforms/esp-idf \ No newline at end of file diff --git a/product-mini/platforms/esp-idf/README.md b/product-mini/platforms/esp-idf/README.md new file mode 100644 index 000000000..eb71f09cd --- /dev/null +++ b/product-mini/platforms/esp-idf/README.md @@ -0,0 +1,91 @@ +# How to Use WAMR with ESP-IDF + +ESP-IDF is the official development framework for Espressif SoCs, supporting Windows, Linux, and macOS. WAMR (WebAssembly Micro Runtime) can be integrated as a standard [ESP-IDF](https://github.com/espressif/esp-idf) component. + +## 1. Setup the ESP-IDF Development Environment + +This example demonstrates how to use WAMR with ESP-IDF. Before proceeding, ensure you have the ESP-IDF development environment installed. For the relevant process, please refer to ESP-IDF [documents](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html). + +### Prerequisites + +#### Software Requirements + +* ESP-IDF v4.4.0 and above. + +#### Hardware Requirements + +* A development board with one of the following SoCs: + + - ESP32 + + - ESP32-C3 + + - ESP32-S3 + + - ESP32-C6 + + - ESP32-P4 + + - ESP32-C5 + +* See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it. + +> Note: Different chips require different ESP-IDF versions, please check [ESP-IDF Release and SoC Compatibility](https://github.com/espressif/esp-idf?tab=readme-ov-file#esp-idf-release-and-soc-compatibility) before proceeding. + +### Installation Steps + +1. Navigate to the ESP-IDF root directory. + +2. Run the installation script based on your OS: + + - Linux/MacOS + + ``` + ./install.sh + ``` + + - Windows + + ``` + ./install.bat + ``` + +3. If successful, you should see: + + ``` + All done! You can now run: + + . ./export.sh + ``` + +## 2. Compiling and Running the Project + +### Set the Target Chip + +Switch to the project directory and specify the target chip: + +```bash +idf.py set-target +``` + +### Configure the project + +Open the configuration menu: + +```bash +idf.py menuconfig +``` + +To modify WAMR settings, navigate to: `Component config -> WASM Micro Runtime` + +### Build and Flash + +Run the following command to compile, flash, and monitor the application: + +```bash +idf.py -p PORT flash monitor +``` + +(To exit the serial monitor, type ``Ctrl-]``.) + +See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects. \ No newline at end of file diff --git a/product-mini/platforms/esp-idf/build_and_run.sh b/product-mini/platforms/esp-idf/build_and_run.sh index 7ce1b57a5..4b8d248cb 100755 --- a/product-mini/platforms/esp-idf/build_and_run.sh +++ b/product-mini/platforms/esp-idf/build_and_run.sh @@ -7,16 +7,20 @@ ESP32_TARGET="esp32" ESP32C3_TARGET="esp32c3" ESP32S3_TARGET="esp32s3" ESP32C6_TARGET="esp32c6" +ESP32P4_TARGET="esp32p4" +ESP32C5_TARGET="esp32c5" usage () { echo "USAGE:" - echo "$0 $ESP32_TARGET|$ESP32C3_TARGET|$ESP32S3_TARGET" + echo "$0 $ESP32_TARGET|$ESP32C3_TARGET|$ESP32S3_TARGET|$ESP32C6_TARGET|$ESP32P4_TARGET|$ESP32C5_TARGET" echo "Example:" echo " $0 $ESP32_TARGET" echo " $0 $ESP32C3_TARGET" echo " $0 $ESP32S3_TARGET" echo " $0 $ESP32C6_TARGET" + echo " $0 $ESP32P4_TARGET" + echo " $0 $ESP32C5_TARGET" exit 1 } @@ -26,12 +30,18 @@ fi TARGET=$1 +if [ "$TARGET" = "$ESP32C5_TARGET" ]; then + IDF_ST_CMD="idf.py --preview set-target $TARGET" +else + IDF_ST_CMD="idf.py set-target $TARGET" +fi + if [[ -z "${WAMR_PATH}" ]]; then export WAMR_PATH=$PWD/../../.. fi rm -rf build -idf.py set-target $TARGET +$IDF_ST_CMD idf.py build idf.py flash From 76caabede5604ea044d5502c009cfdaee6bdf5b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 08:24:15 +0800 Subject: [PATCH 164/198] build(deps): Bump github/codeql-action from 3.28.17 to 3.28.18 (#4285) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.17 to 3.28.18. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.17...v3.28.18) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.18 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7126e2d09..665c1588d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.17 + uses: github/codeql-action/init@v3.28.18 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.17 + uses: github/codeql-action/analyze@v3.28.18 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.17 + uses: github/codeql-action/upload-sarif@v3.28.18 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index acc123c77..2bc70f9bc 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@5eb3ed6614230b1931d5c08df9e096e4ba524f21 + uses: github/codeql-action/upload-sarif@57eebf61a2246ab60a0c2f5a85766db783ad3553 with: sarif_file: results.sarif From b7474b354f0a36c63c24fb3f6cf8b7c14684ceed Mon Sep 17 00:00:00 2001 From: Krisztian <34309983+kr-t@users.noreply.github.com> Date: Thu, 22 May 2025 02:24:41 +0200 Subject: [PATCH 165/198] Improve Embedding WAMR guideline (#4263) (#4284) * Fix CMakeList example by adding -lm * Add bh_read_file inclusion to CMakeList * replace non-existing read_binary_to_buffer() to existing bh_read_file_to_buffer() * add #include initialization Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> --- doc/embed_wamr.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/embed_wamr.md b/doc/embed_wamr.md index 9a6f685c7..7d9c46f9d 100644 --- a/doc/embed_wamr.md +++ b/doc/embed_wamr.md @@ -22,7 +22,12 @@ set (WAMR_ROOT_DIR path/to/wamr/root) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) -target_link_libraries (your_project vmlib) +# include bh_read_file.h +include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) + +add_executable (your_project main.c ${UNCOMMON_SHARED_SOURCE}) + +target_link_libraries (your_project vmlib -lm) ``` Examples can be found in [CMakeLists.txt of linux platform](../product-mini/platforms/linux/CMakeLists.txt) and [other platforms](../product-mini/platforms). The available features to configure can be found in [Build WAMR vmcore](./build_wamr.md#wamr-vmcore-cmake-building-configurations). @@ -31,6 +36,10 @@ Developer can also use Makefile to embed WAMR, by defining macros and including ## The runtime initialization ``` C + #include "bh_platform.h" + #include "bh_read_file.h" + #include "wasm_export.h" + char *buffer, error_buf[128]; wasm_module_t module; wasm_module_inst_t module_inst; @@ -42,7 +51,7 @@ Developer can also use Makefile to embed WAMR, by defining macros and including wasm_runtime_init(); /* read WASM file into a memory buffer */ - buffer = read_wasm_binary_to_buffer(…, &size); + buffer = bh_read_file_to_buffer(…, &size); /* add line below if we want to export native functions to WASM app */ wasm_runtime_register_natives(...); From 6659a312cf460ba9d54639af75b56775b9abea4c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 23 May 2025 17:56:21 +0900 Subject: [PATCH 166/198] add a sample to use cmake package (#4291) - add a sample to use cmake package --- .../compilation_on_android_ubuntu.yml | 5 ++++ .github/workflows/compilation_on_macos.yml | 5 ++++ samples/printversion/CMakeLists.txt | 10 ++++++++ samples/printversion/printversion.c | 21 ++++++++++++++++ samples/printversion/test.sh | 24 +++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 samples/printversion/CMakeLists.txt create mode 100644 samples/printversion/printversion.c create mode 100755 samples/printversion/test.sh diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 521c2e08f..db0200cac 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -437,6 +437,11 @@ jobs: ctest --test-dir build --output-on-failure working-directory: samples/wasm-c-api + - name: Build Sample [printversion] + run: | + ./test.sh + working-directory: samples/printversion + build_samples_others: needs: [ diff --git a/.github/workflows/compilation_on_macos.yml b/.github/workflows/compilation_on_macos.yml index b59f841c5..44c7973f1 100644 --- a/.github/workflows/compilation_on_macos.yml +++ b/.github/workflows/compilation_on_macos.yml @@ -282,6 +282,11 @@ jobs: ctest --test-dir build --output-on-failure working-directory: samples/wasm-c-api + - name: Build Sample [printversion] + run: | + ./test.sh + working-directory: samples/printversion + build_samples_others: needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos] runs-on: ${{ matrix.os }} diff --git a/samples/printversion/CMakeLists.txt b/samples/printversion/CMakeLists.txt new file mode 100644 index 000000000..6e97cb72c --- /dev/null +++ b/samples/printversion/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required(VERSION 3.16) + +project(printversion LANGUAGES C) + +add_executable(printversion printversion.c) +find_package(iwasm REQUIRED) +target_link_libraries(printversion iwasm::vmlib) diff --git a/samples/printversion/printversion.c b/samples/printversion/printversion.c new file mode 100644 index 000000000..91b244fe2 --- /dev/null +++ b/samples/printversion/printversion.c @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2025 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include +#include +#include + +#include + +int +main(int argc, char **argv) +{ + uint32_t major; + uint32_t minor; + uint32_t patch; + wasm_runtime_get_version(&major, &minor, &patch); + printf("wasm-micro-runtime %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, + minor, patch); +} diff --git a/samples/printversion/test.sh b/samples/printversion/test.sh new file mode 100755 index 000000000..a51c1849c --- /dev/null +++ b/samples/printversion/test.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +# Copyright (C) 2025 Midokura Japan KK. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +set -e + +DIST=$(mktemp -d) + +# WAMR_BUILD_SIMD=0 to avoid fetching simde, which is +# not relevant to this particular test. +cmake -B build-wamr \ +-D CMAKE_INSTALL_PREFIX=${DIST} \ +-D WAMR_BUILD_SIMD=0 \ +../.. +cmake --build build-wamr -t install + +cmake -B build-app \ +-D CMAKE_PREFIX_PATH=${DIST} \ +-D CMAKE_INSTALL_PREFIX=${DIST} \ +. +cmake --build build-app + +./build-app/printversion From c018b8ab987e28e1ed92c1dc7280a3a777bd8a6d Mon Sep 17 00:00:00 2001 From: Alix ANNERAUD Date: Mon, 26 May 2025 10:16:42 +0200 Subject: [PATCH 167/198] feat: Add instruction metering for interpreter (#4122) - add instruction metering support with execution limit - initialize instruction execution limit in exec_env - docs: add instruction metering section to build_wamr documentation --- build-scripts/config_common.cmake | 4 +++ core/config.h | 4 +++ core/iwasm/common/wasm_exec_env.c | 4 +++ core/iwasm/common/wasm_exec_env.h | 5 ++++ core/iwasm/common/wasm_runtime_common.c | 9 ++++++ core/iwasm/common/wasm_runtime_common.h | 10 ++++++- core/iwasm/include/wasm_export.h | 14 +++++++++ core/iwasm/interpreter/wasm_interp_classic.c | 30 ++++++++++++++++++-- core/iwasm/interpreter/wasm_interp_fast.c | 23 +++++++++++++++ doc/build_wamr.md | 4 +++ 10 files changed, 104 insertions(+), 3 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 5f7746f6a..1a77d4cac 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -671,6 +671,10 @@ if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1) message (" AOT validator enabled") add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1) endif () +if (WAMR_BUILD_INSTRUCTION_METERING EQUAL 1) + message (" Instruction metering enabled") + add_definitions (-DWASM_ENABLE_INSTRUCTION_METERING=1) +endif () ######################################## # Show Phase4 Wasm proposals status. diff --git a/core/config.h b/core/config.h index cb1189c96..a4e1499e3 100644 --- a/core/config.h +++ b/core/config.h @@ -716,4 +716,8 @@ unless used elsewhere */ #define WASM_ENABLE_AOT_VALIDATOR 0 #endif +#ifndef WASM_ENABLE_INSTRUCTION_METERING +#define WASM_ENABLE_INSTRUCTION_METERING 0 +#endif + #endif /* end of _CONFIG_H_ */ diff --git a/core/iwasm/common/wasm_exec_env.c b/core/iwasm/common/wasm_exec_env.c index 27484dfc5..47752950f 100644 --- a/core/iwasm/common/wasm_exec_env.c +++ b/core/iwasm/common/wasm_exec_env.c @@ -85,6 +85,10 @@ wasm_exec_env_create_internal(struct WASMModuleInstanceCommon *module_inst, wasm_runtime_dump_exec_env_mem_consumption(exec_env); #endif +#if WASM_ENABLE_INSTRUCTION_METERING != 0 + exec_env->instructions_to_execute = -1; +#endif + return exec_env; #ifdef OS_ENABLE_HW_BOUND_CHECK diff --git a/core/iwasm/common/wasm_exec_env.h b/core/iwasm/common/wasm_exec_env.h index ce0c1fa7f..5d80312fb 100644 --- a/core/iwasm/common/wasm_exec_env.h +++ b/core/iwasm/common/wasm_exec_env.h @@ -87,6 +87,11 @@ typedef struct WASMExecEnv { uint8 *bottom; } wasm_stack; +#if WASM_ENABLE_INSTRUCTION_METERING != 0 + /* instructions to execute */ + int instructions_to_execute; +#endif + #if WASM_ENABLE_FAST_JIT != 0 /** * Cache for diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index d33c02727..b316a6e30 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -2285,6 +2285,15 @@ wasm_runtime_access_exce_check_guard_page() } #endif +#if WASM_ENABLE_INSTRUCTION_METERING != 0 +void +wasm_runtime_set_instruction_count_limit(WASMExecEnv *exec_env, + int instructions_to_execute) +{ + exec_env->instructions_to_execute = instructions_to_execute; +} +#endif + WASMFuncType * wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function, uint32 module_type) diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 8ac032bf8..64a6cd793 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -791,9 +791,17 @@ WASM_RUNTIME_API_EXTERN void wasm_runtime_set_native_stack_boundary(WASMExecEnv *exec_env, uint8 *native_stack_boundary); -#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0 +#if WASM_ENABLE_INSTRUCTION_METERING != 0 /* See wasm_export.h for description */ WASM_RUNTIME_API_EXTERN void +wasm_runtime_set_instruction_count_limit(WASMExecEnv *exec_env, + int instructions_to_execute); +#endif + +#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0 +/* See wasm_export.h for description */ +WASM_RUNTIME_API_EXTERN +void wasm_runtime_set_bounds_checks(WASMModuleInstanceCommon *module_inst, bool enable); diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index b73a0364e..b4ab34bea 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -1821,6 +1821,20 @@ WASM_RUNTIME_API_EXTERN void wasm_runtime_set_native_stack_boundary(wasm_exec_env_t exec_env, uint8_t *native_stack_boundary); +/** + * Set the instruction count limit to the execution environment. + * By default the instruction count limit is -1, which means no limit. + * However, if the instruction count limit is set to a positive value, + * the execution will be terminated when the instruction count reaches + * the limit. + * + * @param exec_env the execution environment + * @param instruction_count the instruction count limit + */ +WASM_RUNTIME_API_EXTERN void +wasm_runtime_set_instruction_count_limit(wasm_exec_env_t exec_env, + int instruction_count); + /** * Dump runtime memory consumption, including: * Exec env memory consumption diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 41ac4c724..1e98b0fa9 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1516,10 +1516,13 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst, } \ os_mutex_unlock(&exec_env->wait_lock); \ } \ + CHECK_INSTRUCTION_LIMIT(); \ goto *handle_table[*frame_ip++]; \ } while (0) #else -#define HANDLE_OP_END() FETCH_OPCODE_AND_DISPATCH() +#define HANDLE_OP_END() \ + CHECK_INSTRUCTION_LIMIT(); \ + FETCH_OPCODE_AND_DISPATCH() #endif #else /* else of WASM_ENABLE_LABELS_AS_VALUES */ @@ -1542,9 +1545,12 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst, } \ os_mutex_unlock(&exec_env->wait_lock); \ } \ + CHECK_INSTRUCTION_LIMIT(); \ continue; #else -#define HANDLE_OP_END() continue +#define HANDLE_OP_END() \ + CHECK_INSTRUCTION_LIMIT(); \ + continue; #endif #endif /* end of WASM_ENABLE_LABELS_AS_VALUES */ @@ -1562,6 +1568,18 @@ get_global_addr(uint8 *global_data, WASMGlobalInstance *global) #endif } +#if WASM_ENABLE_INSTRUCTION_METERING != 0 +#define CHECK_INSTRUCTION_LIMIT() \ + if (instructions_left == 0) { \ + wasm_set_exception(module, "instruction limit exceeded"); \ + goto got_exception; \ + } \ + else if (instructions_left > 0) \ + instructions_left--; +#else +#define CHECK_INSTRUCTION_LIMIT() (void)0 +#endif + static void wasm_interp_call_func_bytecode(WASMModuleInstance *module, WASMExecEnv *exec_env, @@ -1605,6 +1623,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint32 local_idx, local_offset, global_idx; uint8 local_type, *global_addr; uint32 cache_index, type_index, param_cell_num, cell_num; + +#if WASM_ENABLE_INSTRUCTION_METERING != 0 + int instructions_left = -1; + if (exec_env) { + instructions_left = exec_env->instructions_to_execute; + } +#endif + #if WASM_ENABLE_EXCE_HANDLING != 0 int32_t exception_tag_index; #endif diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 681612380..4e5edf41b 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -105,6 +105,19 @@ typedef float64 CellType_F64; goto unaligned_atomic; \ } while (0) +#if WASM_ENABLE_INSTRUCTION_METERING != 0 +#define CHECK_INSTRUCTION_LIMIT() \ + if (instructions_left == 0) { \ + wasm_set_exception(module, "instruction limit exceeded"); \ + goto got_exception; \ + } \ + else if (instructions_left > 0) \ + instructions_left--; + +#else +#define CHECK_INSTRUCTION_LIMIT() (void)0 +#endif + static inline uint32 rotl32(uint32 n, uint32 c) { @@ -1441,6 +1454,7 @@ wasm_interp_dump_op_count() do { \ const void *p_label_addr = *(void **)frame_ip; \ frame_ip += sizeof(void *); \ + CHECK_INSTRUCTION_LIMIT(); \ goto *p_label_addr; \ } while (0) #else @@ -1452,6 +1466,7 @@ wasm_interp_dump_op_count() /* int32 relative offset was emitted in 64-bit target */ \ p_label_addr = label_base + (int32)LOAD_U32_WITH_2U16S(frame_ip); \ frame_ip += sizeof(int32); \ + CHECK_INSTRUCTION_LIMIT(); \ goto *p_label_addr; \ } while (0) #else @@ -1462,6 +1477,7 @@ wasm_interp_dump_op_count() /* uint32 label address was emitted in 32-bit target */ \ p_label_addr = (void *)(uintptr_t)LOAD_U32_WITH_2U16S(frame_ip); \ frame_ip += sizeof(int32); \ + CHECK_INSTRUCTION_LIMIT(); \ goto *p_label_addr; \ } while (0) #endif @@ -1538,6 +1554,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint8 *maddr = NULL; uint32 local_idx, local_offset, global_idx; uint8 opcode = 0, local_type, *global_addr; + +#if WASM_ENABLE_INSTRUCTION_METERING != 0 + int instructions_left = -1; + if (exec_env) { + instructions_left = exec_env->instructions_to_execute; + } +#endif #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0 diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 6425450bd..94dd96284 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -327,6 +327,10 @@ And the wasm app can calls below APIs to allocate/free memory from/to the shared - **WAMR_BUILD_SHRUNK_MEMORY**=1/0, default to enable if not set > Note: When enabled, this feature will reduce memory usage by decreasing the size of the linear memory, particularly when the `memory.grow` opcode is not used and memory usage is somewhat predictable. +## **Instruction metering** +- **WAMR_BUILD_INSTRUCTION_METERING**=1/0, default to disable if not set +> Note: Enabling this feature allows limiting the number of instructions a wasm module instance can execute. Use the `wasm_runtime_set_instruction_count_limit(...)` API before calling `wasm_runtime_call_*(...)` APIs to enforce this limit. + ## **Combination of configurations:** We can combine the configurations. For example, if we want to disable interpreter, enable AOT and WASI, we can run command: From 21bcf5c75ddfb1e5891acb5afd3d5c82b9b74a8e Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 28 May 2025 09:05:07 +0800 Subject: [PATCH 168/198] Fix Compiler Error C2491 (#4286) > Data, static data members, and functions can be declared as `dllimports` but not defined as `dllimports`. https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2491?view=msvc-170 --- core/iwasm/common/wasm_runtime_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index b316a6e30..1c1a20022 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -1504,7 +1504,7 @@ wasm_runtime_load_ex(uint8 *buf, uint32 size, const LoadArgs *args, error_buf_size); } -WASM_RUNTIME_API_EXTERN bool +bool wasm_runtime_resolve_symbols(WASMModuleCommon *module) { #if WASM_ENABLE_INTERP != 0 @@ -7845,7 +7845,7 @@ wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env, return true; } -WASM_RUNTIME_API_EXTERN bool +bool wasm_runtime_is_underlying_binary_freeable(WASMModuleCommon *const module) { #if WASM_ENABLE_INTERP != 0 From 782c69fe8a43294566a9b1482029a68b825b95bc Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 28 May 2025 10:05:29 +0900 Subject: [PATCH 169/198] Revert the location to install public headers (#4295) This partly reverts "Cmake improvements". (https://github.com/bytecodealliance/wasm-micro-runtime/pull/4076) Recently we changed the location to install public headers. For example, Old: include/wasm_export.h New: include/iwasm/wasm_export.h For cmake-based user applications using find_package(iwasm), the cmake package, namely target_include_directories(INSTALL_INTERFACE), is expected to add necessary compiler options like -isystem automatically. (See samples/printversion for an example of such user applications.) However, in reality, not every user application uses cmake. This commit reverts the location to install public headers for now, to avoid breakage for non-cmake user applications. In case we want to re-apply the location change in future, we should better communicate to the users. (eg. document migration proceduces in release notes.) Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4290 References: https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.html --- CMakeLists.txt | 4 ++-- product-mini/platforms/darwin/CMakeLists.txt | 4 ++-- product-mini/platforms/linux/CMakeLists.txt | 4 ++-- product-mini/platforms/windows/CMakeLists.txt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 551991f89..0a374b5d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,7 +160,7 @@ add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm) target_include_directories(vmlib INTERFACE $ - $ + $ ) target_link_libraries (vmlib PUBLIC ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT}) @@ -189,7 +189,7 @@ set_version_info (vmlib) install (TARGETS vmlib EXPORT iwasmTargets LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include/iwasm + PUBLIC_HEADER DESTINATION include ) install_iwasm_package () diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index 594110a44..cd7c8bc88 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -132,7 +132,7 @@ add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_version_info (vmlib) target_include_directories(vmlib INTERFACE - $ + $ ) set (WAMR_PUBLIC_HEADERS @@ -151,7 +151,7 @@ target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthr install (TARGETS vmlib EXPORT iwasmTargets DESTINATION lib - PUBLIC_HEADER DESTINATION include/iwasm + PUBLIC_HEADER DESTINATION include ) install_iwasm_package () diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt index be0c57ede..cef8329d7 100644 --- a/product-mini/platforms/linux/CMakeLists.txt +++ b/product-mini/platforms/linux/CMakeLists.txt @@ -177,7 +177,7 @@ add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_version_info (vmlib) target_include_directories(vmlib INTERFACE - $ + $ ) set (WAMR_PUBLIC_HEADERS @@ -197,7 +197,7 @@ target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthr install (TARGETS vmlib EXPORT iwasmTargets DESTINATION lib - PUBLIC_HEADER DESTINATION include/iwasm + PUBLIC_HEADER DESTINATION include ) install_iwasm_package () diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index e0a4e255b..1a1707f0c 100644 --- a/product-mini/platforms/windows/CMakeLists.txt +++ b/product-mini/platforms/windows/CMakeLists.txt @@ -147,7 +147,7 @@ add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_version_info (vmlib) target_include_directories(vmlib INTERFACE - $ + $ ) set (WAMR_PUBLIC_HEADERS @@ -174,7 +174,7 @@ endif() install (TARGETS vmlib EXPORT iwasmTargets DESTINATION lib - PUBLIC_HEADER DESTINATION include/iwasm + PUBLIC_HEADER DESTINATION include ) install_iwasm_package () From 7f9e49213e2dd1839cb85c04e5a1dbf6fc6b4475 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 28 May 2025 20:29:09 +0800 Subject: [PATCH 170/198] Enhance type checking for function types in loader and improve error handling (#4294) Especially when GC is enabled, a valid item of `module->types` needs additional checks before casting to WASMFuncType. Also, avoid overflowing if reftype_map_count is 0. Additionally, correctly set IN_OSS_FUZZ based on CFLAGS_ENV for sanitizer configuration. Update ASan and UBSan messages for clarity in non-oss-fuzz environments. --- core/iwasm/interpreter/wasm.h | 2 +- core/iwasm/interpreter/wasm_loader.c | 58 ++++++++++++++----- tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt | 7 ++- .../aot-compiler/CMakeLists.txt | 2 +- .../wasm-mutator/CMakeLists.txt | 2 +- wamr-compiler/CMakeLists.txt | 1 + 6 files changed, 52 insertions(+), 20 deletions(-) diff --git a/core/iwasm/interpreter/wasm.h b/core/iwasm/interpreter/wasm.h index 6023b0702..ddc0b15b4 100644 --- a/core/iwasm/interpreter/wasm.h +++ b/core/iwasm/interpreter/wasm.h @@ -1243,7 +1243,7 @@ wasm_value_type_size_internal(uint8 value_type, uint8 pointer_size) return sizeof(int16); #endif else { - bh_assert(0); + bh_assert(0 && "Unknown value type. It should be handled ahead."); } #if WASM_ENABLE_GC == 0 (void)pointer_size; diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index db9afb0f2..6ef1ff5bf 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -379,7 +379,6 @@ memory_realloc(void *mem_old, uint32 size_old, uint32 size_new, char *error_buf, mem = mem_new; \ } while (0) -#if WASM_ENABLE_GC != 0 static bool check_type_index(const WASMModule *module, uint32 type_count, uint32 type_index, char *error_buf, uint32 error_buf_size) @@ -392,6 +391,7 @@ check_type_index(const WASMModule *module, uint32 type_count, uint32 type_index, return true; } +#if WASM_ENABLE_GC != 0 static bool check_array_type(const WASMModule *module, uint32 type_index, char *error_buf, uint32 error_buf_size) @@ -409,6 +409,29 @@ check_array_type(const WASMModule *module, uint32 type_index, char *error_buf, } #endif +/* + * if no GC is enabled, an valid type is always a function type. + * but if GC is enabled, we need to check the type flag + */ +static bool +check_function_type(const WASMModule *module, uint32 type_index, + char *error_buf, uint32 error_buf_size) +{ + if (!check_type_index(module, module->type_count, type_index, error_buf, + error_buf_size)) { + return false; + } + +#if WASM_ENABLE_GC != 0 + if (module->types[type_index]->type_flag != WASM_TYPE_FUNC) { + set_error_buf(error_buf, error_buf_size, "unknown function type"); + return false; + } +#endif + + return true; +} + static bool check_function_index(const WASMModule *module, uint32 function_index, char *error_buf, uint32 error_buf_size) @@ -2479,8 +2502,8 @@ load_function_import(const uint8 **p_buf, const uint8 *buf_end, read_leb_uint32(p, p_end, declare_type_index); *p_buf = p; - if (declare_type_index >= parent_module->type_count) { - set_error_buf(error_buf, error_buf_size, "unknown type"); + if (!check_function_type(parent_module, declare_type_index, error_buf, + error_buf_size)) { return false; } @@ -2893,8 +2916,8 @@ load_tag_import(const uint8 **p_buf, const uint8 *buf_end, /* get type */ read_leb_uint32(p, p_end, declare_type_index); /* compare against module->types */ - if (declare_type_index >= parent_module->type_count) { - set_error_buf(error_buf, error_buf_size, "unknown tag type"); + if (!check_function_type(parent_module, declare_type_index, error_buf, + error_buf_size)) { goto fail; } @@ -3563,8 +3586,9 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, for (i = 0; i < func_count; i++) { /* Resolve function type */ read_leb_uint32(p, p_end, type_index); - if (type_index >= module->type_count) { - set_error_buf(error_buf, error_buf_size, "unknown type"); + + if (!check_function_type(module, type_index, error_buf, + error_buf_size)) { return false; } @@ -4970,8 +4994,8 @@ load_tag_section(const uint8 *buf, const uint8 *buf_end, const uint8 *buf_code, /* get type */ read_leb_uint32(p, p_end, tag_type); /* compare against module->types */ - if (tag_type >= module->type_count) { - set_error_buf(error_buf, error_buf_size, "unknown type"); + if (!check_function_type(module, tag_type, error_buf, + error_buf_size)) { return false; } @@ -10477,7 +10501,7 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, uint8 opcode, * match block type. */ if (cur_block->is_stack_polymorphic) { #if WASM_ENABLE_GC != 0 - int32 j = reftype_map_count - 1; + int32 j = (int32)reftype_map_count - 1; #endif for (i = (int32)arity - 1; i >= 0; i--) { #if WASM_ENABLE_GC != 0 @@ -10780,7 +10804,7 @@ check_block_stack(WASMLoaderContext *loader_ctx, BranchBlock *block, * match block type. */ if (block->is_stack_polymorphic) { #if WASM_ENABLE_GC != 0 - int32 j = return_reftype_map_count - 1; + int32 j = (int32)return_reftype_map_count - 1; #endif for (i = (int32)return_count - 1; i >= 0; i--) { #if WASM_ENABLE_GC != 0 @@ -11549,15 +11573,17 @@ re_scan: } else { int32 type_index; + /* Resolve the leb128 encoded type index as block type */ p--; p_org = p - 1; pb_read_leb_int32(p, p_end, type_index); - if ((uint32)type_index >= module->type_count) { - set_error_buf(error_buf, error_buf_size, - "unknown type"); + + if (!check_function_type(module, type_index, error_buf, + error_buf_size)) { goto fail; } + block_type.is_value_type = false; block_type.u.type = (WASMFuncType *)module->types[type_index]; @@ -12607,8 +12633,8 @@ re_scan: /* skip elem idx */ POP_TBL_ELEM_IDX(); - if (type_idx >= module->type_count) { - set_error_buf(error_buf, error_buf_size, "unknown type"); + if (!check_function_type(module, type_idx, error_buf, + error_buf_size)) { goto fail; } diff --git a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt index a6ff12d64..500ad8fe3 100644 --- a/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt @@ -181,7 +181,12 @@ add_link_options(-fsanitize=fuzzer -fno-sanitize=vptr) # Enable sanitizers if not in oss-fuzz environment set(CFLAGS_ENV $ENV{CFLAGS}) -string(FIND "${CFLAGS_ENV}" "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" IN_OSS_FUZZ) +string(FIND "${CFLAGS_ENV}" "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" FUZZ_POS) +if (FUZZ_POS GREATER -1) + set(IN_OSS_FUZZ 1) +else() + set(IN_OSS_FUZZ 0) +endif() add_subdirectory(aot-compiler) add_subdirectory(wasm-mutator) diff --git a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt index a613ea4e2..5ca33906a 100644 --- a/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/aot-compiler/CMakeLists.txt @@ -68,7 +68,7 @@ target_link_directories(aotclib PUBLIC ${LLVM_LIBRARY_DIR}) target_link_libraries(aotclib PUBLIC ${REQUIRED_LLVM_LIBS}) if(NOT IN_OSS_FUZZ) - message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment") + message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment for aotclib") target_compile_options(aotclib PUBLIC -fprofile-instr-generate -fcoverage-mapping -fno-sanitize-recover=all diff --git a/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt index 4d6ae0fa4..b501baecf 100644 --- a/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt +++ b/tests/fuzz/wasm-mutator-fuzz/wasm-mutator/CMakeLists.txt @@ -58,7 +58,7 @@ add_executable(wasm_mutator_fuzz wasm_mutator_fuzz.cc) target_link_libraries(wasm_mutator_fuzz PRIVATE vmlib m) if(NOT IN_OSS_FUZZ) - message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment") + message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment for vmlib") target_compile_options(vmlib PUBLIC -fprofile-instr-generate -fcoverage-mapping -fno-sanitize-recover=all diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index bbe83cc64..0ce647394 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -315,6 +315,7 @@ if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1) include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake) endif () +#TODO: sync up WAMR_BUILD_SANITIZER in config_common.cmake # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion") if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" OR MSVC)) From 3ab9f840265007335bf7728f52c90d9c77598977 Mon Sep 17 00:00:00 2001 From: hongxia <103626902+HongxiaWangSSSS@users.noreply.github.com> Date: Wed, 28 May 2025 20:29:41 +0800 Subject: [PATCH 171/198] Dockerfile.vx-delegate build error fix (#4273) - specify tensorflow version & bugfix --- .../wasi-nn/test/Dockerfile.vx-delegate | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate b/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate index e05b30119..fdeff3022 100644 --- a/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate +++ b/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate @@ -37,7 +37,10 @@ RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake- WORKDIR /tmp RUN git clone https://github.com/VeriSilicon/TIM-VX.git tim-vx \ && git clone https://github.com/VeriSilicon/tflite-vx-delegate.git \ - && git clone https://github.com/tensorflow/tensorflow.git + && git clone https://github.com/tensorflow/tensorflow.git --branch v2.12.0 + +WORKDIR /tmp/tensorflow +RUN git cherry-pick -n 5115fa96d7c5b41451674892317be43e30b7c389 # Build TIM-VX @@ -99,28 +102,24 @@ RUN cp --parents \ ENV VIVANTE_SDK_DIR=/tmp/tim-vx/prebuilt-sdk/x86_64_linux/ ENV VSIMULATOR_CONFIG=czl -ENV LD_LIBRARY_PATH=/tmp/tim-vx/prebuilt-sdk/x86_64_linux/lib:/usr/local/lib:/lib/x86_64-linux-gnu/:/lib64/:/usr/lib:$LD_LIBRARY_PATH - # Build WASI-NN WORKDIR /home/wamr COPY . . -WORKDIR /home/wamr/core/iwasm/libraries/wasi-nn/test/build +WORKDIR /home/wamr/product-mini/platforms/linux -# hadolint ignore=SC2086 -RUN cmake \ - -DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}:/usr/local/lib/ \ - -DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}:/usr/local/include/ \ +RUN rm -rf build \ + && cmake -S . -B build\ + -DCMAKE_LIBRARY_PATH="/usr/local/lib/" \ + -DCMAKE_INCLUDE_PATH="/usr/local/include/" \ -DWAMR_BUILD_WASI_NN=1 \ -DWAMR_BUILD_WASI_NN_TFLITE=1\ -DWAMR_BUILD_WASI_NN_ENABLE_EXT=1 \ -DWASI_NN_EXT_DELEGATE_PATH="/usr/lib/libvx_delegate.so" \ - .. + && cmake --build build -j "$(grep -c ^processor /proc/cpuinfo)" -RUN make -j "$(grep -c ^processor /proc/cpuinfo)" - -RUN cp /home/wamr/core/iwasm/libraries/wasi-nn/test/build/iwasm /run/iwasm \ +RUN cp /home/wamr/product-mini/platforms/linux/build/iwasm /run/iwasm \ && cp /home/wamr/product-mini/platforms/linux/build/lib*.so /usr/lib ENTRYPOINT [ "/run/iwasm" ] From 3580d1a386d25ef1e89df2a1919e0a179db50128 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 28 May 2025 20:30:05 +0800 Subject: [PATCH 172/198] Enable runtime API exposure for MSVC builds (#4287) --- CMakeLists.txt | 4 ---- build-scripts/runtime_lib.cmake | 7 +++++++ product-mini/platforms/windows/CMakeLists.txt | 2 -- samples/basic/src/free_buffer_early.c | 1 + wamr-compiler/CMakeLists.txt | 1 - 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a374b5d5..88a1642b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,10 +152,6 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) set (THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -if (MSVC) - add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) -endif () - add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE}) set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm) target_include_directories(vmlib INTERFACE diff --git a/build-scripts/runtime_lib.cmake b/build-scripts/runtime_lib.cmake index d9459838e..e538b5d91 100644 --- a/build-scripts/runtime_lib.cmake +++ b/build-scripts/runtime_lib.cmake @@ -193,6 +193,13 @@ else() enable_language (ASM) endif() +# it will expose the runtime APIs. +# you'll use the following command to check the exported APIs +# dumpbin.exe /EXPORTS xxx +if (MSVC) + add_compile_definitions(COMPILING_WASM_RUNTIME_API=1) +endif () + include (${SHARED_PLATFORM_CONFIG}) include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake) include (${IWASM_DIR}/common/iwasm_common.cmake) diff --git a/product-mini/platforms/windows/CMakeLists.txt b/product-mini/platforms/windows/CMakeLists.txt index 1a1707f0c..2a4017d68 100644 --- a/product-mini/platforms/windows/CMakeLists.txt +++ b/product-mini/platforms/windows/CMakeLists.txt @@ -16,8 +16,6 @@ set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") set(CMAKE_CXX_STANDARD 17) -add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) - # Set WAMR_BUILD_TARGET, currently values supported: # "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", "MIPS", "XTENSA" if (NOT DEFINED WAMR_BUILD_TARGET) diff --git a/samples/basic/src/free_buffer_early.c b/samples/basic/src/free_buffer_early.c index c4d71d18f..b55b6eb1d 100644 --- a/samples/basic/src/free_buffer_early.c +++ b/samples/basic/src/free_buffer_early.c @@ -5,6 +5,7 @@ #include "wasm_export.h" #include "bh_read_file.h" +#include "bh_getopt.h" void my_log(uint32 log_level, const char *file, int line, const char *fmt, ...) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index 0ce647394..da02ece00 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -18,7 +18,6 @@ if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows") else() project (aot-compiler C ASM CXX) enable_language (ASM_MASM) - add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) endif() set (CMAKE_CXX_STANDARD 17) From 207da7b22fc1704e67395890fe67253fdcb730c3 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 30 May 2025 07:42:39 +0800 Subject: [PATCH 173/198] updating WASI stdio handle initialization and build options for UVWASI (#4260) --- core/iwasm/aot/aot_loader.c | 8 +++++++- core/iwasm/common/wasm_runtime_common.c | 14 +++++++++----- core/iwasm/interpreter/wasm_loader.c | 8 +++++++- core/iwasm/interpreter/wasm_mini_loader.c | 8 +++++++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 13de3009d..b875ab93c 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -4128,10 +4128,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) #endif #if WASM_ENABLE_LIBC_WASI != 0 +#if WASM_ENABLE_UVWASI == 0 module->wasi_args.stdio[0] = os_invalid_raw_handle(); module->wasi_args.stdio[1] = os_invalid_raw_handle(); module->wasi_args.stdio[2] = os_invalid_raw_handle(); -#endif +#else + module->wasi_args.stdio[0] = os_get_invalid_handle(); + module->wasi_args.stdio[1] = os_get_invalid_handle(); + module->wasi_args.stdio[2] = os_get_invalid_handle(); +#endif /* WASM_ENABLE_UVWASI == 0 */ +#endif /* WASM_ENABLE_LIBC_WASI != 0 */ return module; #if WASM_ENABLE_GC != 0 diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 1c1a20022..dcee0aeaf 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -3886,11 +3886,15 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst, init_options.allocator = &uvwasi_allocator; init_options.argc = argc; init_options.argv = (const char **)argv; - init_options.in = (stdinfd != -1) ? (uvwasi_fd_t)stdinfd : init_options.in; - init_options.out = - (stdoutfd != -1) ? (uvwasi_fd_t)stdoutfd : init_options.out; - init_options.err = - (stderrfd != -1) ? (uvwasi_fd_t)stderrfd : init_options.err; + init_options.in = (stdinfd != os_get_invalid_handle()) + ? (uvwasi_fd_t)stdinfd + : init_options.in; + init_options.out = (stdoutfd != os_get_invalid_handle()) + ? (uvwasi_fd_t)stdoutfd + : init_options.out; + init_options.err = (stderrfd != os_get_invalid_handle()) + ? (uvwasi_fd_t)stderrfd + : init_options.err; if (dir_count > 0) { init_options.preopenc = dir_count; diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 6ef1ff5bf..40ea697a9 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -6404,10 +6404,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) #endif #if WASM_ENABLE_LIBC_WASI != 0 +#if WASM_ENABLE_UVWASI == 0 module->wasi_args.stdio[0] = os_invalid_raw_handle(); module->wasi_args.stdio[1] = os_invalid_raw_handle(); module->wasi_args.stdio[2] = os_invalid_raw_handle(); -#endif +#else + module->wasi_args.stdio[0] = os_get_invalid_handle(); + module->wasi_args.stdio[1] = os_get_invalid_handle(); + module->wasi_args.stdio[2] = os_get_invalid_handle(); +#endif /* WASM_ENABLE_UVWASI == 0 */ +#endif /* WASM_ENABLE_LIBC_WASI != 0 */ (void)ret; return module; diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 1ed91230f..e66c08bab 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -3140,10 +3140,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) #endif #if WASM_ENABLE_LIBC_WASI != 0 +#if WASM_ENABLE_LIBC_UVWASI == 0 module->wasi_args.stdio[0] = os_invalid_raw_handle(); module->wasi_args.stdio[1] = os_invalid_raw_handle(); module->wasi_args.stdio[2] = os_invalid_raw_handle(); -#endif +#else + module->wasi_args.stdio[0] = os_get_invalid_handle(); + module->wasi_args.stdio[1] = os_get_invalid_handle(); + module->wasi_args.stdio[2] = os_get_invalid_handle(); +#endif /* WASM_ENABLE_UVWASI == 0 */ +#endif /* WASM_ENABLE_LIBC_WASI != 0 */ (void)ret; return module; From 670aa839858ca73f644d74343aba68f1cb66c066 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 2 Jun 2025 10:45:50 +0800 Subject: [PATCH 174/198] Bump version to 2.3.1 and update release notes (#4303) --- RELEASE_NOTES.md | 32 ++++++++++++++++++++++++++++++++ build-scripts/version.cmake | 2 +- core/version.h | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b39f55bae..8b3cfec28 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,35 @@ +## WAMR-2.3.1 + +### Breaking Changes + +- Revert the location to install public headers (#4295). This restores compatibility (of installed headers) with WAMR-2.2.0 and earlier. + +### New Features + +- feat: Add instruction metering for interpreter (#4122) + +### Bug Fixes + +- updating WASI stdio handle initialization and build options for UVWASI (#4260) +- Fix SIMD load lane to avoid incompatible pointer types (#4278) +- Fixed unit tests on X86_32 (#4279) +- Improve Embedding WAMR guideline (#4284) +- Fix Compiler Error C2491 (#4286) +- Enhance type checking for function types in loader and improve error handling (#4294) +- Dockerfile.vx-delegate build error fix (#4273) +- Enable runtime API exposure for MSVC builds (#4287) + +### Enhancements + +- feat(yml): Add ESP32-P4 and ESP32-C5 support (#4270) +- add a sample to use cmake package (#4291) + +### Others + +- build(deps): Bump github/codeql-action from 3.28.17 to 3.28.18 (#4285) + +--- + ## WAMR-2.3.0 ### Breaking changes diff --git a/build-scripts/version.cmake b/build-scripts/version.cmake index e34a11821..c98b10f6f 100644 --- a/build-scripts/version.cmake +++ b/build-scripts/version.cmake @@ -8,7 +8,7 @@ endif() set(WAMR_VERSION_MAJOR 2) set(WAMR_VERSION_MINOR 3) -set(WAMR_VERSION_PATCH 0) +set(WAMR_VERSION_PATCH 1) message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}") diff --git a/core/version.h b/core/version.h index 00d212c5b..85e033390 100644 --- a/core/version.h +++ b/core/version.h @@ -18,7 +18,7 @@ /* clang-format off */ #define WAMR_VERSION_MAJOR 2 #define WAMR_VERSION_MINOR 3 -#define WAMR_VERSION_PATCH 0 +#define WAMR_VERSION_PATCH 1 /* clang-format on */ #endif From 2a303861cc916dc182b7fecaa0aacc1b797e7ac6 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 2 Jun 2025 16:30:51 +0800 Subject: [PATCH 175/198] Fix a linking error caused by commit #3580d1 (#4311) > **Fix a release-blocking issue** --- Like: ``` vmlib.lib(blocking_op.obj) : error LNK2019: unresolved external symbol __imp_wasm_runtime_begin_blocking_op referenced in function blocking_op_close [D:\a\wasm-micro-runtime\wasm-micro-runtime\wamr-compiler\build\wamrc.vcxproj] vmlib.lib(blocking_op.obj) : error LNK2019: unresolved external symbol __imp_wasm_runtime_end_blocking_op referenced in function blocking_op_close [D:\a\wasm-micro-runtime\wasm-micro-runtime\wamr-compiler\build\wamrc.vcxproj] ``` --- wamr-compiler/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index da02ece00..0ce647394 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -18,6 +18,7 @@ if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows") else() project (aot-compiler C ASM CXX) enable_language (ASM_MASM) + add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) endif() set (CMAKE_CXX_STANDARD 17) From aa1ff778b9cca546c0fdbd43d78beb1c45d38846 Mon Sep 17 00:00:00 2001 From: hongxia <103626902+HongxiaWangSSSS@users.noreply.github.com> Date: Tue, 3 Jun 2025 06:26:58 +0800 Subject: [PATCH 176/198] add load_by_name in wasi-nn (#4298) --- .../iwasm/libraries/wasi-nn/include/wasi_nn.h | 2 +- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 1 + .../wasi-nn/src/wasi_nn_tensorflowlite.cpp | 47 +++++++++---------- core/iwasm/libraries/wasi-nn/test/utils.c | 5 +- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index ad1f37deb..c8d1217a7 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h @@ -30,7 +30,7 @@ load(graph_builder_array *builder, graph_encoding encoding, __attribute__((import_module("wasi_nn"))); wasi_nn_error -load_by_name(const char *name, graph *g) +load_by_name(const char *name, uint32_t name_len, graph *g) __attribute__((import_module("wasi_nn"))); /** diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 4697e931b..75f362c76 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -697,6 +697,7 @@ static NativeSymbol native_symbols_wasi_nn[] = { REG_NATIVE_FUNC(get_output, "(ii*i*)i"), #else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */ REG_NATIVE_FUNC(load, "(*ii*)i"), + REG_NATIVE_FUNC(load_by_name, "(*i*)i"), REG_NATIVE_FUNC(init_execution_context, "(i*)i"), REG_NATIVE_FUNC(set_input, "(ii*)i"), REG_NATIVE_FUNC(compute, "(i)i"), diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp index f63d57e07..09e12f0d2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp @@ -85,12 +85,8 @@ is_valid_graph(TFLiteContext *tfl_ctx, graph g) NN_ERR_PRINTF("Invalid graph: %d >= %d.", g, MAX_GRAPHS_PER_INST); return runtime_error; } - if (tfl_ctx->models[g].model_pointer == NULL) { - NN_ERR_PRINTF("Context (model) non-initialized."); - return runtime_error; - } if (tfl_ctx->models[g].model == NULL) { - NN_ERR_PRINTF("Context (tflite model) non-initialized."); + NN_ERR_PRINTF("Context (model) non-initialized."); return runtime_error; } return success; @@ -472,32 +468,31 @@ deinit_backend(void *tflite_ctx) NN_DBG_PRINTF("Freeing memory."); for (int i = 0; i < MAX_GRAPHS_PER_INST; ++i) { tfl_ctx->models[i].model.reset(); - if (tfl_ctx->models[i].model_pointer) { - if (tfl_ctx->delegate) { - switch (tfl_ctx->models[i].target) { - case gpu: - { + if (tfl_ctx->delegate) { + switch (tfl_ctx->models[i].target) { + case gpu: + { #if WASM_ENABLE_WASI_NN_GPU != 0 - TfLiteGpuDelegateV2Delete(tfl_ctx->delegate); + TfLiteGpuDelegateV2Delete(tfl_ctx->delegate); #else - NN_ERR_PRINTF("GPU delegate delete but not enabled."); + NN_ERR_PRINTF("GPU delegate delete but not enabled."); #endif - break; - } - case tpu: - { -#if WASM_ENABLE_WASI_NN_EXTERNAL_DELEGATE != 0 - TfLiteExternalDelegateDelete(tfl_ctx->delegate); -#else - NN_ERR_PRINTF( - "External delegate delete but not enabled."); -#endif - break; - } - default: - break; + break; } + case tpu: + { +#if WASM_ENABLE_WASI_NN_EXTERNAL_DELEGATE != 0 + TfLiteExternalDelegateDelete(tfl_ctx->delegate); +#else + NN_ERR_PRINTF("External delegate delete but not enabled."); +#endif + break; + } + default: + break; } + } + if (tfl_ctx->models[i].model_pointer) { wasm_runtime_free(tfl_ctx->models[i].model_pointer); } tfl_ctx->models[i].model_pointer = NULL; diff --git a/core/iwasm/libraries/wasi-nn/test/utils.c b/core/iwasm/libraries/wasi-nn/test/utils.c index 9e43ec985..690c37f0e 100644 --- a/core/iwasm/libraries/wasi-nn/test/utils.c +++ b/core/iwasm/libraries/wasi-nn/test/utils.c @@ -58,7 +58,7 @@ wasm_load(char *model_name, graph *g, execution_target target) wasi_nn_error wasm_load_by_name(const char *model_name, graph *g) { - wasi_nn_error res = load_by_name(model_name, g); + wasi_nn_error res = load_by_name(model_name, strlen(model_name), g); return res; } @@ -108,7 +108,8 @@ run_inference(execution_target target, float *input, uint32_t *input_size, uint32_t num_output_tensors) { graph graph; - if (wasm_load(model_name, &graph, target) != success) { + + if (wasm_load_by_name(model_name, &graph) != success) { NN_ERR_PRINTF("Error when loading model."); exit(1); } From 62bb6e8158a4200fa1489be2677b052830a488bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 13:21:05 +0800 Subject: [PATCH 177/198] build(deps): Bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#4315) Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.1 to 2.4.2. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits](https://github.com/ossf/scorecard-action/compare/f49aabe0b5af0936a0987cfb85d86b75731b0186...05b42c624433fc40578a4040d5cf5e36ddca8cde) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-version: 2.4.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/supply_chain.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index 2bc70f9bc..d9e10a71c 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -39,7 +39,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 + uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2 with: results_file: results.sarif results_format: sarif From 938503af38d61e3fc4484ac9b44e8b78f1d8c435 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Tue, 3 Jun 2025 13:21:17 +0800 Subject: [PATCH 178/198] Bump uvwasi to latest commit #392e1f1 (#4312) --- .../libraries/libc-uvwasi/libc_uvwasi.cmake | 2 +- .../libc-uvwasi/libc_uvwasi_wrapper.c | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake index 6919efba2..f197b21d6 100644 --- a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake +++ b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake @@ -43,7 +43,7 @@ else() FetchContent_Declare( uvwasi GIT_REPOSITORY https://github.com/nodejs/uvwasi.git - GIT_TAG v0.0.21 + GIT_TAG 392e1f1c1c8a2d2102c9f2e0b9f35959a149d133 ) FetchContent_MakeAvailable(uvwasi) include_directories("${uvwasi_SOURCE_DIR}/include") diff --git a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c index 59616daf6..35d091e78 100644 --- a/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c +++ b/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c @@ -890,24 +890,6 @@ wasi_path_symlink(wasm_exec_env_t exec_env, const char *old_path, if (!uvwasi) return (wasi_errno_t)-1; - /* - * check if old_path is valid. - * if it is a symlink, follow it. - * - * this is a workaround for the fact that - * uvwasi_path_symlink does not check if the old_path is valid - * - * the goal is trigger uvwasi__resolve_path() to check - */ - { - uvwasi_filestat_t filestat = { 0 }; - wasi_errno_t err = - uvwasi_path_filestat_get(uvwasi, fd, UVWASI_LOOKUP_SYMLINK_FOLLOW, - old_path, old_path_len, &filestat); - if (err) - return err; - } - return uvwasi_path_symlink(uvwasi, old_path, old_path_len, fd, new_path, new_path_len); } From 1c12a3206681cde68c7d0f34251d5ad1ae234a70 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:21:32 +0900 Subject: [PATCH 179/198] wasi_nn_openvino.c: fix a few printf formats (#4310) --- core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c index db2f91db0..f8221d8d2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -58,7 +58,7 @@ dump_ov_shape_t(const ov_shape_t *shape, int32_t output_len, char *output) { int ret = 0; - ret = snprintf(output, output_len, "%ld,[", shape->rank); + ret = snprintf(output, output_len, "%" PRId64 ",[", shape->rank); if (!ret) return; @@ -66,7 +66,7 @@ dump_ov_shape_t(const ov_shape_t *shape, int32_t output_len, char *output) output += ret; for (unsigned i = 0; i < shape->rank && output_len; i++) { - ret = snprintf(output, output_len, " %ld", shape->dims[i]); + ret = snprintf(output, output_len, " %" PRId64, shape->dims[i]); if (!ret) return; From 16c46751acc49db1e005f13ba1d5b0810b207aee Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:22:27 +0900 Subject: [PATCH 180/198] wasi-nn: remove "backends" argument from detect_and_load_backend() (#4309) it seems meaningless and quite confusing to access a table with two aliases ("lookup" and "backends") within a function. no functional changes are intended. --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 75f362c76..f3c92eff2 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -342,7 +342,6 @@ graph_encoding_to_backend_lib_name(graph_encoding encoding) static bool detect_and_load_backend(graph_encoding backend_hint, - struct backends_api_functions *backends, graph_encoding *loaded_backend) { if (backend_hint > autodetect) @@ -365,7 +364,7 @@ detect_and_load_backend(graph_encoding backend_hint, if (!backend_lib_name) return false; - return prepare_backend(backend_lib_name, backends + backend_hint); + return prepare_backend(backend_lib_name, lookup + backend_hint); } /* WASI-NN implementation */ @@ -410,7 +409,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder, } graph_encoding loaded_backend = autodetect; - if (!detect_and_load_backend(encoding, lookup, &loaded_backend)) { + if (!detect_and_load_backend(encoding, &loaded_backend)) { res = invalid_encoding; NN_ERR_PRINTF("load backend failed"); goto fail; @@ -468,7 +467,7 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len, NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", name); graph_encoding loaded_backend = autodetect; - if (!detect_and_load_backend(autodetect, lookup, &loaded_backend)) { + if (!detect_and_load_backend(autodetect, &loaded_backend)) { NN_ERR_PRINTF("load backend failed"); return invalid_encoding; } @@ -527,7 +526,7 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name, NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...", name, config); graph_encoding loaded_backend = autodetect; - if (!detect_and_load_backend(autodetect, lookup, &loaded_backend)) { + if (!detect_and_load_backend(autodetect, &loaded_backend)) { NN_ERR_PRINTF("load backend failed"); return invalid_encoding; } From ae6e490ad5b976bebd012c7efe1ce077d31b63e5 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:22:48 +0900 Subject: [PATCH 181/198] fix wasi-nn abi definitions (#4307) sync with a more appropriate version of the definitions. as we use the "wasi_ephemeral_nn", which is p1-based, it seems more appropriate to use definitions from witx, not wit. it's a bit unfortunate p2-based wasi-nn made gratuitous changes like this from p1. note: this is an ABI change. --- core/iwasm/libraries/wasi-nn/README.md | 2 +- .../libraries/wasi-nn/include/wasi_nn_types.h | 25 ++++++------------- .../libraries/wasi-nn/src/wasi_nn_openvino.c | 2 -- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/README.md b/core/iwasm/libraries/wasi-nn/README.md index 99a766467..2e926a032 100644 --- a/core/iwasm/libraries/wasi-nn/README.md +++ b/core/iwasm/libraries/wasi-nn/README.md @@ -37,7 +37,7 @@ There is a big difference between the two sets of functions, `tensor_type`. ```c #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 -typedef enum { fp16 = 0, fp32, fp64, bf16, u8, i32, i64 } tensor_type; +typedef enum { fp16 = 0, fp32, fp64, u8, i32, i64 } tensor_type; #else typedef enum { fp16 = 0, fp32, up8, ip32 } tensor_type; #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h index 3ac694fc9..787cc6a5c 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -19,30 +19,19 @@ extern "C" { */ // sync up with -// https://github.com/WebAssembly/wasi-nn/blob/main/wit/wasi-nn.wit#L136 Error -// codes returned by functions in this API. +// https://github.com/WebAssembly/wasi-nn/blob/71320d95b8c6d43f9af7f44e18b1839db85d89b4/wasi-nn.witx#L5-L17 +// Error codes returned by functions in this API. typedef enum { - // No error occurred. success = 0, - // Caller module passed an invalid argument. invalid_argument, - // Invalid encoding. invalid_encoding, - // The operation timed out. - timeout, - // Runtime Error. + missing_memory, + busy, runtime_error, - // Unsupported operation. unsupported_operation, - // Graph is too large. too_large, - // Graph not found. not_found, - // The operation is insecure or has insufficient privilege to be performed. - // e.g., cannot access a hardware feature requested - security, - // The operation failed for an unspecified reason. - unknown, + // for WasmEdge-wasi-nn end_of_sequence = 100, // End of Sequence Found. context_full = 101, // Context Full. @@ -66,9 +55,9 @@ typedef struct { #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 // sync up with -// https://github.com/WebAssembly/wasi-nn/blob/main/wit/wasi-nn.wit#L27 +// https://github.com/WebAssembly/wasi-nn/blob/71320d95b8c6d43f9af7f44e18b1839db85d89b4/wasi-nn.witx#L19-L28 // The type of the elements in a tensor. -typedef enum { fp16 = 0, fp32, fp64, bf16, u8, i32, i64 } tensor_type; +typedef enum { fp16 = 0, fp32, fp64, u8, i32, i64 } tensor_type; #else typedef enum { fp16 = 0, fp32, up8, ip32 } tensor_type; #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c index f8221d8d2..4bd9b9ede 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -161,8 +161,6 @@ wasi_nn_tensor_type_to_openvino_element_type(tensor_type wasi_nn_type) #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 case fp64: return F64; - case bf16: - return BF16; case i64: return I64; case u8: From 61cb97221eccc2fa00a06f1397a0bc8765af0e56 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:23:19 +0900 Subject: [PATCH 182/198] wasi-nn: fix shared library filenames for macOS (#4306) tested with openvino --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index f3c92eff2..15f5fb550 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -21,9 +21,14 @@ #include "wasm_export.h" #define HASHMAP_INITIAL_SIZE 20 -#define TFLITE_BACKEND_LIB "libwasi_nn_tflite.so" -#define OPENVINO_BACKEND_LIB "libwasi_nn_openvino.so" -#define LLAMACPP_BACKEND_LIB "libwasi_nn_llamacpp.so" +#if defined(__APPLE__) +#define LIB_EXTENTION ".dylib" +#else +#define LIB_EXTENTION ".so" +#endif +#define TFLITE_BACKEND_LIB "libwasi_nn_tflite" LIB_EXTENTION +#define OPENVINO_BACKEND_LIB "libwasi_nn_openvino" LIB_EXTENTION +#define LLAMACPP_BACKEND_LIB "libwasi_nn_llamacpp" LIB_EXTENTION /* Global variables */ struct backends_api_functions { From 6a00874f2fb02ef9db358845a9dc175ef9579cae Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Jun 2025 14:28:13 +0900 Subject: [PATCH 183/198] wasi_nn_openvino.c: make this buildable (#4305) --- core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c index 4bd9b9ede..dcfec1ccb 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c @@ -509,7 +509,7 @@ init_backend(void **ctx) *ctx = (void *)ov_ctx; return success; fail: - openvino_destroy((void *)ov_ctx); + os_free(ov_ctx); return ret; } From 93ef19b0cab66009a08c407ec21eb2afdbcca1a5 Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Tue, 3 Jun 2025 13:28:26 +0800 Subject: [PATCH 184/198] handle nullable heap reference types in import section (#4302) --- core/iwasm/interpreter/wasm_loader.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 40ea697a9..6317badc5 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3282,6 +3282,13 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, CHECK_BUF(p, p_end, 1); /* 0x70 */ u8 = read_uint8(p); +#if WASM_ENABLE_GC != 0 + if (wasm_is_reftype_htref_nullable(u8)) { + int32 heap_type; + read_leb_int32(p, p_end, heap_type); + (void)heap_type; + } +#endif read_leb_uint32(p, p_end, flags); read_leb_uint32(p, p_end, u32); if (flags & 1) @@ -3329,7 +3336,7 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, /* valtype */ CHECK_BUF(p, p_end, 1); global_type = read_uint8(p); - if (wasm_is_type_multi_byte_type(global_type)) { + if (wasm_is_reftype_htref_nullable(global_type)) { int32 heap_type; read_leb_int32(p, p_end, heap_type); (void)heap_type; From 85efe0843140713eb36e83d3785068487a607e33 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 5 Jun 2025 10:19:46 +0900 Subject: [PATCH 185/198] wasi-nn: protect the backend lookup table with a lock (#4319) this would avoid potential issues when multiple instances happen to make an attempt to load a backend at the same time. Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4314 --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 15f5fb550..724485449 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -31,6 +31,14 @@ #define LLAMACPP_BACKEND_LIB "libwasi_nn_llamacpp" LIB_EXTENTION /* Global variables */ +static korp_mutex wasi_nn_lock; +/* + * the "lookup" table is protected by wasi_nn_lock. + * + * an exception: during wasm_runtime_destroy, wasi_nn_destroy tears down + * the table without acquiring the lock. it's ok because there should be + * no other threads using the runtime at this point. + */ struct backends_api_functions { void *backend_handle; api_function functions; @@ -109,12 +117,18 @@ wasi_nn_initialize() { NN_DBG_PRINTF("[WASI NN General] Initializing wasi-nn"); + if (os_mutex_init(&wasi_nn_lock)) { + NN_ERR_PRINTF("Error while initializing global lock"); + return false; + } + // hashmap { instance: wasi_nn_ctx } hashmap = bh_hash_map_create(HASHMAP_INITIAL_SIZE, true, hash_func, key_equal_func, key_destroy_func, value_destroy_func); if (hashmap == NULL) { NN_ERR_PRINTF("Error while initializing hashmap"); + os_mutex_destroy(&wasi_nn_lock); return false; } @@ -175,6 +189,8 @@ wasi_nn_destroy() memset(&lookup[i].functions, 0, sizeof(api_function)); } + + os_mutex_destroy(&wasi_nn_lock); } /* Utils */ @@ -349,6 +365,8 @@ static bool detect_and_load_backend(graph_encoding backend_hint, graph_encoding *loaded_backend) { + bool ret; + if (backend_hint > autodetect) return false; @@ -360,16 +378,23 @@ detect_and_load_backend(graph_encoding backend_hint, *loaded_backend = backend_hint; + os_mutex_lock(&wasi_nn_lock); /* if already loaded */ - if (lookup[backend_hint].backend_handle) + if (lookup[backend_hint].backend_handle) { + os_mutex_unlock(&wasi_nn_lock); return true; + } const char *backend_lib_name = graph_encoding_to_backend_lib_name(backend_hint); - if (!backend_lib_name) + if (!backend_lib_name) { + os_mutex_unlock(&wasi_nn_lock); return false; + } - return prepare_backend(backend_lib_name, lookup + backend_hint); + ret = prepare_backend(backend_lib_name, lookup + backend_hint); + os_mutex_unlock(&wasi_nn_lock); + return ret; } /* WASI-NN implementation */ From b20ebc2724d7ef363999fa33ba902e3db6d07cc7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 5 Jun 2025 10:48:00 +0900 Subject: [PATCH 186/198] wasi_nn.h: add import_name attribute (#4328) this would fix undefined symbol errors by making it clear these functions are imported. references: https://github.com/llvm/llvm-project/blob/e2c698c7e836306f1a25c67597ae9e25a1fcc575/llvm/lib/MC/WasmObjectWriter.cpp#L1798-L1799 https://github.com/llvm/llvm-project/blob/e2c698c7e836306f1a25c67597ae9e25a1fcc575/llvm/lib/Object/WasmObjectFile.cpp#L749-L752 https://github.com/llvm/llvm-project/blob/e2c698c7e836306f1a25c67597ae9e25a1fcc575/lld/wasm/Symbols.cpp#L203 https://github.com/llvm/llvm-project/blob/e2c698c7e836306f1a25c67597ae9e25a1fcc575/lld/wasm/Relocations.cpp#L36-L40 --- core/iwasm/libraries/wasi-nn/include/wasi_nn.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index c8d1217a7..4a238e65e 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h @@ -15,6 +15,9 @@ #include #include "wasi_nn_types.h" +#define WASI_NN_IMPORT(name) \ + __attribute__((import_module("wasi_nn"), import_name(name))) + /** * @brief Load an opaque sequence of bytes to use for inference. * @@ -26,12 +29,11 @@ */ wasi_nn_error load(graph_builder_array *builder, graph_encoding encoding, - execution_target target, graph *g) - __attribute__((import_module("wasi_nn"))); + execution_target target, graph *g) WASI_NN_IMPORT("load"); wasi_nn_error load_by_name(const char *name, uint32_t name_len, graph *g) - __attribute__((import_module("wasi_nn"))); + WASI_NN_IMPORT("load_by_name"); /** * INFERENCE @@ -47,7 +49,7 @@ load_by_name(const char *name, uint32_t name_len, graph *g) */ wasi_nn_error init_execution_context(graph g, graph_execution_context *ctx) - __attribute__((import_module("wasi_nn"))); + WASI_NN_IMPORT("init_execution_context"); /** * @brief Define the inputs to use for inference. @@ -59,7 +61,7 @@ init_execution_context(graph g, graph_execution_context *ctx) */ wasi_nn_error set_input(graph_execution_context ctx, uint32_t index, tensor *tensor) - __attribute__((import_module("wasi_nn"))); + WASI_NN_IMPORT("set_input"); /** * @brief Compute the inference on the given inputs. @@ -68,7 +70,7 @@ set_input(graph_execution_context ctx, uint32_t index, tensor *tensor) * @return wasi_nn_error Execution status. */ wasi_nn_error -compute(graph_execution_context ctx) __attribute__((import_module("wasi_nn"))); +compute(graph_execution_context ctx) WASI_NN_IMPORT("compute"); /** * @brief Extract the outputs after inference. @@ -85,6 +87,6 @@ compute(graph_execution_context ctx) __attribute__((import_module("wasi_nn"))); wasi_nn_error get_output(graph_execution_context ctx, uint32_t index, tensor_data output_tensor, uint32_t *output_tensor_size) - __attribute__((import_module("wasi_nn"))); + WASI_NN_IMPORT("get_output"); #endif From 79cb4366ae5187fb68440c23a3e2470ac0c5ae3c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 5 Jun 2025 10:48:28 +0900 Subject: [PATCH 187/198] wasi-nn: remove unused wasi_nn_dump_tensor_dimension prototype (#4325) --- core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h index 787cc6a5c..5a8136ca9 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -160,10 +160,6 @@ typedef struct { BACKEND_DEINITIALIZE deinit; } api_function; -void -wasi_nn_dump_tensor_dimension(tensor_dimensions *dim, int32_t output_len, - char *output); - #ifdef __cplusplus } #endif From 602e86adc35cd6fcdc3c985887dc2aa96c6a92cd Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Thu, 5 Jun 2025 11:57:29 +0800 Subject: [PATCH 188/198] Add wamrc compilation into Windows CI workflow (#4327) +formatting --- .github/workflows/compilation_on_windows.yml | 82 +++++++++++++++----- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/.github/workflows/compilation_on_windows.yml b/.github/workflows/compilation_on_windows.yml index 369980ba9..21f961cb9 100644 --- a/.github/workflows/compilation_on_windows.yml +++ b/.github/workflows/compilation_on_windows.yml @@ -57,23 +57,33 @@ permissions: contents: read jobs: - build: + build_llvm_libraries_on_windows: + permissions: + contents: read + actions: write + uses: ./.github/workflows/build_llvm_libraries.yml + with: + os: "windows-latest" + arch: "AArch64 ARM Mips RISCV X86" + + build_iwasm: runs-on: windows-latest strategy: matrix: - build_options: [ - "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0", - "-DWAMR_BUILD_AOT=0", - "-DWAMR_BUILD_TAIL_CALL=1", - "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1", - "-DWAMR_DISABLE_HW_BOUND_CHECK=1", - "-DWAMR_BUILD_REF_TYPES=1", - "-DWAMR_BUILD_SIMD=1", - "-DWAMR_BUILD_DEBUG_INTERP=1", - "-DWAMR_BUILD_LIB_PTHREAD=1", - "-DWAMR_BUILD_LIB_WASI_THREADS=1", - "-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1" - ] + build_options: + [ + "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0", + "-DWAMR_BUILD_AOT=0", + "-DWAMR_BUILD_TAIL_CALL=1", + "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1", + "-DWAMR_DISABLE_HW_BOUND_CHECK=1", + "-DWAMR_BUILD_REF_TYPES=1", + "-DWAMR_BUILD_SIMD=1", + "-DWAMR_BUILD_DEBUG_INTERP=1", + "-DWAMR_BUILD_LIB_PTHREAD=1", + "-DWAMR_BUILD_LIB_WASI_THREADS=1", + "-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1", + ] steps: - uses: actions/checkout@v4 @@ -89,17 +99,49 @@ jobs: cmake .. ${{ matrix.build_options }} cmake --build . --config Release --parallel 4 + build_wamrc: + needs: [build_llvm_libraries_on_windows] + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: windows-latest + llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }} + steps: + - name: checkout + uses: actions/checkout@v4 + + # since jobs.id can't contain the dot character + # it is hard to use `format` to assemble the cache key + - name: Get LLVM libraries + id: retrieve_llvm_libs + uses: actions/cache@v4 + with: + path: | + ./core/deps/llvm/build/bin + ./core/deps/llvm/build/include + ./core/deps/llvm/build/lib + ./core/deps/llvm/build/libexec + ./core/deps/llvm/build/share + key: ${{ matrix.llvm_cache_key }} + + - name: Quit if cache miss + if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' + run: echo "::error::can not get prebuilt llvm libraries" && exit 1 + + - name: Build wamrc + run: | + cmake -S . -B build + cmake --build build --config Release --parallel 4 + working-directory: wamr-compiler + test: runs-on: windows-latest - needs: [build] + needs: [build_iwasm, build_wamrc] strategy: fail-fast: false matrix: - running_mode: - [ - "classic-interp", - "fast-interp", - ] + running_mode: ["classic-interp", "fast-interp"] test_option: [ $DEFAULT_TEST_OPTIONS, From 48a97736b3c12fb1a2abba3932415814474e60a6 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 6 Jun 2025 15:05:04 +0800 Subject: [PATCH 189/198] Update binary compression steps to follow symlinks for actual files (#4321) By default, zip follows symbolic links and includes the actual files or directories they point to in the archive. --- .github/workflows/build_iwasm_release.yml | 3 ++- .github/workflows/build_wamrc.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_iwasm_release.yml b/.github/workflows/build_iwasm_release.yml index 74c2340af..a975d5807 100644 --- a/.github/workflows/build_iwasm_release.yml +++ b/.github/workflows/build_iwasm_release.yml @@ -137,7 +137,8 @@ jobs: - name: compress the binary on non-Windows if: inputs.runner != 'windows-latest' run: | - tar czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm + # Follow the symlink to the actual binary file + tar --dereference -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm zip iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm working-directory: ${{ inputs.cwd }}/build diff --git a/.github/workflows/build_wamrc.yml b/.github/workflows/build_wamrc.yml index 6b687c749..55d63f13b 100644 --- a/.github/workflows/build_wamrc.yml +++ b/.github/workflows/build_wamrc.yml @@ -73,7 +73,8 @@ jobs: - name: compress the binary on non-Windows if: inputs.runner != 'windows-latest' && inputs.release run: | - tar czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc + # Follow the symlink to the actual binary file + tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc working-directory: wamr-compiler/build From 97e9502bb3034c160dd2e93d605262c9effad379 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 6 Jun 2025 15:05:44 +0800 Subject: [PATCH 190/198] Update Dockerfile for Zephyr SDK and Zephyr-project versioning (#4335) Use a minimum manifest to reduce time consumption --- .../platforms/zephyr/simple/Dockerfile | 42 ++++++++++++------- .../platforms/zephyr/simple/README.md | 6 +++ .../platforms/zephyr/simple/west_lite.yml | 15 +++++++ 3 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 product-mini/platforms/zephyr/simple/west_lite.yml diff --git a/product-mini/platforms/zephyr/simple/Dockerfile b/product-mini/platforms/zephyr/simple/Dockerfile index a4c69a8ff..c3fb1325d 100644 --- a/product-mini/platforms/zephyr/simple/Dockerfile +++ b/product-mini/platforms/zephyr/simple/Dockerfile @@ -1,9 +1,15 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html +# for more information on how to set up the Zephyr development environment. FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive ENV TZ=Asian/Shanghai +ARG ZEPHYR_SDK_VERSION=0.16.9 +# In west_lite.yml, the Zephyr version is set to v3.7.0 +#ARG ZEPHYR_VERSION=3.7.0 # Install dependencies for Zephyr # hadolint ignore=DL3008 @@ -16,28 +22,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends git cmake ninja # Install the Zephyr Software Development Kit (SDK) WORKDIR /opt # hadolint ignore=DL4006 -RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/zephyr-sdk-0.16.3_linux-x86_64.tar.xz \ - && wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/sha256.sum | shasum --check --ignore-missing \ - && tar xvf zephyr-sdk-0.16.3_linux-x86_64.tar.xz && rm zephyr-sdk-0.16.3_linux-x86_64.tar.xz +RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz \ + && wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \ + && tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz -WORKDIR /opt/zephyr-sdk-0.16.3 +WORKDIR /opt/zephyr-sdk-${ZEPHYR_SDK_VERSION} # hadolint ignore=DL4006 -RUN yes | ./setup.sh +# Install host tools and Register Zephyr SDK CMake package +RUN ./setup.sh -h -c # Get Zephyr +WORKDIR /root/zephyrproject/smoke-test + # hadolint ignore=DL3013 -RUN pip3 install --no-cache-dir west && west init -m https://github.com/zephyrproject-rtos/zephyr --mr v3.5.0 /root/zephyrproject +RUN pip3 install --no-cache-dir west +COPY ./west_lite.yml ./west.yml + +# init the west workspace with a minimal manifest +RUN west init -l WORKDIR /root/zephyrproject -RUN west update +RUN west update --stats -WORKDIR /root/zephyrproject/zephyr -RUN west zephyr-export && pip install --no-cache-dir -r ~/zephyrproject/zephyr/scripts/requirements.txt +WORKDIR /root/zephyrproject/modules/zephyr +RUN west zephyr-export && pip install --no-cache-dir -r ./scripts/requirements.txt + +ENV ZEPHYR_BASE="/root/zephyrproject/modules/zephyr" # Git clone wamr -WORKDIR /root -RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git - -WORKDIR /root/wasm-micro-runtime/product-mini/platforms/zephyr/simple - -ENV ZEPHYR_BASE="/root/zephyrproject/zephyr" +WORKDIR /root/zephyrproject/modules/ +RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git wasm-micro-runtime +WORKDIR /root/zephyrproject/modules/wasm-micro-runtime/product-mini/platforms/zephyr diff --git a/product-mini/platforms/zephyr/simple/README.md b/product-mini/platforms/zephyr/simple/README.md index aab096b8c..3f1a74c6b 100644 --- a/product-mini/platforms/zephyr/simple/README.md +++ b/product-mini/platforms/zephyr/simple/README.md @@ -87,6 +87,12 @@ is a 64-bit ARM target for emulating the Cortex-A53 platform. west build . -b qemu_cortex_a53 -p always -- -DWAMR_BUILD_TARGET=AARCH64 ``` +[ARC QEMU](https://docs.zephyrproject.org/latest/boards/qemu/arc/doc/index.html) +is a 32-bit ARC target for emulating the ARC platform. + +```shell +west build . -b qemu_arc/qemu_arc_em -p always -- -DWAMR_BUILD_TARGET=ARC +``` ## Flashing or Running Image diff --git a/product-mini/platforms/zephyr/simple/west_lite.yml b/product-mini/platforms/zephyr/simple/west_lite.yml new file mode 100644 index 000000000..447affdb4 --- /dev/null +++ b/product-mini/platforms/zephyr/simple/west_lite.yml @@ -0,0 +1,15 @@ +# The west manifest file for WAMR on Zephyr smoke test. +# +manifest: + # + # Please add items below based on alphabetical order + projects: + - name: zephyr + url: https://github.com/zephyrproject-rtos/zephyr + revision: v3.7.0 + clone-depth: 1 + path: modules/zephyr + west-commands: scripts/west-commands.yml + + self: + path: smoke-test From 350af77b03d34328d44295f4b845f6d769c9d3ea Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:06:57 +0800 Subject: [PATCH 191/198] Collective fix: fix some typos (#4337) --- README.md | 2 +- doc/ref_types.md | 2 +- language-bindings/python/src/wamr/wasmcapi/ffi.py | 8 ++++---- samples/socket-api/sample_test_run.py | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 05368b929..39ce5fd03 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm) ### Key features - Full compliant to the W3C Wasm MVP -- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memroy/shared memroy support, text size from bloaty) +- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memory/shared memory support, text size from bloaty) * ~58.9K for fast interpreter * ~56.3K for classic interpreter * ~29.4K for aot runtime diff --git a/doc/ref_types.md b/doc/ref_types.md index 7fefa999d..2cd300497 100644 --- a/doc/ref_types.md +++ b/doc/ref_types.md @@ -4,6 +4,6 @@ WebAssembly [reference-types](https://github.com/WebAssembly/reference-types) pr WAMR has implemented the reference-types proposal. WAMR allows a native method to pass a host object to a WASM application as an `externref` parameter or receives a host object from a WASM application as an `externref` result. Internally, WAMR won't try to parse or dereference `externref`. It is an opaque type. -The restriction of using `externref` in a native method is the host object has to be the value of a `unintptr_t` variable. In other words, it takes **8 bytes** on 64-bit machine and **4 bytes** on 32-bit machines. Please keep that in mind especially when calling `wasm_runtime_call_wasm`. +The restriction of using `externref` in a native method is the host object has to be the value of a `uintptr_t` variable. In other words, it takes **8 bytes** on 64-bit machine and **4 bytes** on 32-bit machines. Please keep that in mind especially when calling `wasm_runtime_call_wasm`. Please ref to the [sample](../samples/ref-types) for more details. diff --git a/language-bindings/python/src/wamr/wasmcapi/ffi.py b/language-bindings/python/src/wamr/wasmcapi/ffi.py index 82292335b..e8a084c14 100644 --- a/language-bindings/python/src/wamr/wasmcapi/ffi.py +++ b/language-bindings/python/src/wamr/wasmcapi/ffi.py @@ -112,12 +112,12 @@ def wasm_vec_to_list(vec): wasm_frame_vec_t, wasm_extern_vec_t, ] - known_vec_pointer_type = [POINTER(type) for type in known_vec_type] + known_vec_pointer_type = [POINTER(vec_type) for vec_type in known_vec_type] - if any([isinstance(vec, type) for type in known_vec_pointer_type]): + if any([isinstance(vec, pointer_type) for pointer_type in known_vec_pointer_type]): vec = dereference(vec) return [vec.data[i] for i in range(vec.num_elems)] - elif any([isinstance(vec, type) for type in known_vec_type]): + elif any([isinstance(vec, vec_type) for vec_type in known_vec_type]): return [vec.data[i] for i in range(vec.num_elems)] else: raise RuntimeError("not a known vector type") @@ -405,7 +405,7 @@ def __compare_wasm_val_t(self, other): elif WASM_F32 == self.kind: return self.of.f32 == other.of.f32 elif WASM_F64 == self.kind: - return self.of.f64 == other.of.f63 + return self.of.f64 == other.of.f64 elif WASM_EXTERNREF == self.kind: raise RuntimeError("FIXME") else: diff --git a/samples/socket-api/sample_test_run.py b/samples/socket-api/sample_test_run.py index ec0060281..6e9153b24 100755 --- a/samples/socket-api/sample_test_run.py +++ b/samples/socket-api/sample_test_run.py @@ -121,7 +121,6 @@ def main(): print("\n================================") print("Test address resolving") cmd = "./iwasm --allow-resolve=*.com addr_resolve.wasm github.com" - cmd = "./multicast_server FF02:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2" run_cmd(cmd, args.working_directory) # wait for a second From 769d16eaab27e4cababc500d6e31a5b45d5e7396 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 6 Jun 2025 16:07:29 +0900 Subject: [PATCH 192/198] wasi-nn: move some host-only things out of wasi_nn_types.h (#4334) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4324 --- .../libraries/wasi-nn/include/wasi_nn_types.h | 29 ------------------- .../libraries/wasi-nn/src/wasi_nn_private.h | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h index 5a8136ca9..7e25428fc 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -131,35 +131,6 @@ typedef uint32_t graph_execution_context; /* Definition of 'wasi_nn.h' structs in WASM app format (using offset) */ -typedef wasi_nn_error (*LOAD)(void *, graph_builder_array *, graph_encoding, - execution_target, graph *); -typedef wasi_nn_error (*LOAD_BY_NAME)(void *, const char *, uint32_t, graph *); -typedef wasi_nn_error (*LOAD_BY_NAME_WITH_CONFIG)(void *, const char *, - uint32_t, void *, uint32_t, - graph *); -typedef wasi_nn_error (*INIT_EXECUTION_CONTEXT)(void *, graph, - graph_execution_context *); -typedef wasi_nn_error (*SET_INPUT)(void *, graph_execution_context, uint32_t, - tensor *); -typedef wasi_nn_error (*COMPUTE)(void *, graph_execution_context); -typedef wasi_nn_error (*GET_OUTPUT)(void *, graph_execution_context, uint32_t, - tensor_data, uint32_t *); -/* wasi-nn general APIs */ -typedef wasi_nn_error (*BACKEND_INITIALIZE)(void **); -typedef wasi_nn_error (*BACKEND_DEINITIALIZE)(void *); - -typedef struct { - LOAD load; - LOAD_BY_NAME load_by_name; - LOAD_BY_NAME_WITH_CONFIG load_by_name_with_config; - INIT_EXECUTION_CONTEXT init_execution_context; - SET_INPUT set_input; - COMPUTE compute; - GET_OUTPUT get_output; - BACKEND_INITIALIZE init; - BACKEND_DEINITIALIZE deinit; -} api_function; - #ifdef __cplusplus } #endif diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h b/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h index bacae99ad..bb56f72fb 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h @@ -15,4 +15,33 @@ typedef struct { void *backend_ctx; } WASINNContext; +typedef wasi_nn_error (*LOAD)(void *, graph_builder_array *, graph_encoding, + execution_target, graph *); +typedef wasi_nn_error (*LOAD_BY_NAME)(void *, const char *, uint32_t, graph *); +typedef wasi_nn_error (*LOAD_BY_NAME_WITH_CONFIG)(void *, const char *, + uint32_t, void *, uint32_t, + graph *); +typedef wasi_nn_error (*INIT_EXECUTION_CONTEXT)(void *, graph, + graph_execution_context *); +typedef wasi_nn_error (*SET_INPUT)(void *, graph_execution_context, uint32_t, + tensor *); +typedef wasi_nn_error (*COMPUTE)(void *, graph_execution_context); +typedef wasi_nn_error (*GET_OUTPUT)(void *, graph_execution_context, uint32_t, + tensor_data, uint32_t *); +/* wasi-nn general APIs */ +typedef wasi_nn_error (*BACKEND_INITIALIZE)(void **); +typedef wasi_nn_error (*BACKEND_DEINITIALIZE)(void *); + +typedef struct { + LOAD load; + LOAD_BY_NAME load_by_name; + LOAD_BY_NAME_WITH_CONFIG load_by_name_with_config; + INIT_EXECUTION_CONTEXT init_execution_context; + SET_INPUT set_input; + COMPUTE compute; + GET_OUTPUT get_output; + BACKEND_INITIALIZE init; + BACKEND_DEINITIALIZE deinit; +} api_function; + #endif From 933f8124b003d23ad2cb4054c7d376f9bb8bd7b1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 6 Jun 2025 16:08:18 +0900 Subject: [PATCH 193/198] wasi-nn: fix the size of tensor->type (#4333) * this enum is (@witx tag u8) in witx * it seems that some wasm modules actually use non-zero padding and cause errors * it's a bad practice to use C enum for ABI description anyway --- core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h index 7e25428fc..0d62ce80d 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -79,7 +79,8 @@ typedef struct { // dimensions. tensor_dimensions *dimensions; // Describe the type of element in the tensor (e.g., f32). - tensor_type type; + uint8_t type; + uint8_t _pad[3]; // Contains the tensor data. tensor_data data; } tensor; From 99c75b53db7ccc9f04e729befc3bac56bfde12a5 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Mon, 9 Jun 2025 11:35:24 +0800 Subject: [PATCH 194/198] remove temporary wasi-libc build steps from CI workflows (#4343) Ref: https://github.com/bytecodealliance/wasm-micro-runtime/pull/2465 --- .../workflows/compilation_on_android_ubuntu.yml | 11 +---------- .github/workflows/nightly_run.yml | 14 +++----------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index db0200cac..44c8d5168 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -682,15 +682,6 @@ jobs: with: os: ${{ matrix.os }} - # It is a temporary solution until new wasi-sdk that includes bug fixes is released - - name: build wasi-libc from source - if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: | - git clone https://github.com/WebAssembly/wasi-libc - cd wasi-libc - make -j AR=/opt/wasi-sdk/bin/llvm-ar NM=/opt/wasi-sdk/bin/llvm-nm CC=/opt/wasi-sdk/bin/clang THREAD_MODEL=posix - echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV - - name: set env variable(if llvm are used) if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit' run: echo "USE_LLVM=true" >> $GITHUB_ENV @@ -727,7 +718,7 @@ jobs: - name: Build WASI thread tests if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: bash build.sh --sysroot "$SYSROOT_PATH" + run: bash build.sh working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/ - name: build socket api tests diff --git a/.github/workflows/nightly_run.yml b/.github/workflows/nightly_run.yml index 92b8f5519..d9841a2b3 100644 --- a/.github/workflows/nightly_run.yml +++ b/.github/workflows/nightly_run.yml @@ -640,19 +640,11 @@ jobs: uses: actions/checkout@v4 - name: install-wasi-sdk-wabt + if: matrix.test_option == '$WASI_TEST_OPTIONS' uses: ./.github/actions/install-wasi-sdk-wabt with: os: ${{ matrix.os }} - # It is a temporary solution until new wasi-sdk that includes bug fixes is released - - name: build wasi-libc from source - if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: | - git clone https://github.com/WebAssembly/wasi-libc - cd wasi-libc - make -j AR=/opt/wasi-sdk/bin/llvm-ar NM=/opt/wasi-sdk/bin/llvm-nm CC=/opt/wasi-sdk/bin/clang THREAD_MODEL=posix - echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV - - name: set env variable(if llvm are used) if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit' run: echo "USE_LLVM=true" >> $GITHUB_ENV @@ -697,12 +689,12 @@ jobs: - name: Build WASI thread tests if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: bash build.sh --sysroot "$SYSROOT_PATH" + run: bash build.sh working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/ - name: Build WASI thread stress tests if: matrix.test_option == '$WASI_TEST_OPTIONS' - run: bash build.sh --sysroot "$SYSROOT_PATH" + run: bash build.sh working-directory: ./core/iwasm/libraries/lib-wasi-threads/stress-test/ - name: build socket api tests From 4d6b8dcd5d670195967f9f5b9b213934cd6c382a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 9 Jun 2025 12:36:05 +0900 Subject: [PATCH 195/198] wasi_nn.h: make this compatible with wasi_ephemeral_nn (#4330) - wasi_nn.h: make this compatible with wasi_ephemeral_nn cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4323 - fix WASM_ENABLE_WASI_EPHEMERAL_NN build this structure is used by host logic as well. ideally definitions for wasm and host should be separated. until it happens, check __wasm__ to avoid the breakage. --- .../iwasm/libraries/wasi-nn/include/wasi_nn.h | 19 +++++++++++++++++++ .../libraries/wasi-nn/include/wasi_nn_types.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h index 4a238e65e..35b2d9bf0 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn.h @@ -15,21 +15,33 @@ #include #include "wasi_nn_types.h" +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 +#define WASI_NN_IMPORT(name) \ + __attribute__((import_module("wasi_ephemeral_nn"), import_name(name))) +#else #define WASI_NN_IMPORT(name) \ __attribute__((import_module("wasi_nn"), import_name(name))) +#endif /** * @brief Load an opaque sequence of bytes to use for inference. * * @param builder Model builder. + * @param builder_len The size of model builder. * @param encoding Model encoding. * @param target Execution target. * @param g Graph. * @return wasi_nn_error Execution status. */ +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 +wasi_nn_error +load(graph_builder *builder, uint32_t builder_len, graph_encoding encoding, + execution_target target, graph *g) WASI_NN_IMPORT("load"); +#else wasi_nn_error load(graph_builder_array *builder, graph_encoding encoding, execution_target target, graph *g) WASI_NN_IMPORT("load"); +#endif wasi_nn_error load_by_name(const char *name, uint32_t name_len, graph *g) @@ -84,9 +96,16 @@ compute(graph_execution_context ctx) WASI_NN_IMPORT("compute"); * copied number of bytes. * @return wasi_nn_error Execution status. */ +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 +wasi_nn_error +get_output(graph_execution_context ctx, uint32_t index, + tensor_data output_tensor, uint32_t output_tensor_max_size, + uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output"); +#else wasi_nn_error get_output(graph_execution_context ctx, uint32_t index, tensor_data output_tensor, uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output"); +#endif #endif diff --git a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h index 0d62ce80d..dd6b8f14a 100644 --- a/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h +++ b/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h @@ -77,7 +77,11 @@ typedef struct { // Describe the size of the tensor (e.g., 2x2x2x2 -> [2, 2, 2, 2]). To // represent a tensor containing a single value, use `[1]` for the tensor // dimensions. +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 && defined(__wasm__) + tensor_dimensions dimensions; +#else tensor_dimensions *dimensions; +#endif // Describe the type of element in the tensor (e.g., f32). uint8_t type; uint8_t _pad[3]; From ea5757f1d71ec52eb27a1692c42083789aad8276 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 9 Jun 2025 12:36:31 +0900 Subject: [PATCH 196/198] wasi-nn: do not assign wasi_nn_ctx->backend multiple times (#4329) --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index 724485449..1a8ad03c6 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -517,7 +517,6 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len, if (res != success) return res; - wasi_nn_ctx->backend = loaded_backend; wasi_nn_ctx->is_model_loaded = true; return success; } @@ -577,7 +576,6 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name, if (res != success) return res; - wasi_nn_ctx->backend = loaded_backend; wasi_nn_ctx->is_model_loaded = true; return success; } From 07c23cb98e8c9719781050e1c08cc98e80ec9675 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 07:35:56 +0800 Subject: [PATCH 197/198] build(deps): Bump github/codeql-action from 3.28.18 to 3.28.19 (#4346) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.18...v3.28.19) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.19 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 6 +++--- .github/workflows/supply_chain.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 665c1588d..37d331189 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3.28.18 + uses: github/codeql-action/init@v3.28.19 with: languages: ${{ matrix.language }} @@ -70,7 +70,7 @@ jobs: - run: | ./.github/scripts/codeql_buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3.28.18 + uses: github/codeql-action/analyze@v3.28.19 with: category: "/language:${{matrix.language}}" upload: false @@ -99,7 +99,7 @@ jobs: output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning - uses: github/codeql-action/upload-sarif@v3.28.18 + uses: github/codeql-action/upload-sarif@v3.28.19 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" diff --git a/.github/workflows/supply_chain.yml b/.github/workflows/supply_chain.yml index d9e10a71c..fe105b246 100644 --- a/.github/workflows/supply_chain.yml +++ b/.github/workflows/supply_chain.yml @@ -60,6 +60,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@57eebf61a2246ab60a0c2f5a85766db783ad3553 + uses: github/codeql-action/upload-sarif@b1e4dc3db58c9601794e22a9f6d28d45461b9dbf with: sarif_file: results.sarif From 7f968f59260c1a5198b07e3a2f56106e33902836 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 11 Jun 2025 08:46:35 +0900 Subject: [PATCH 198/198] wasi_socket_ext.c: avoid tls to make this library-friendly (#4338) --- .../lib-socket/src/wasi/wasi_socket_ext.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c b/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c index 1172d0a77..f573d35b8 100644 --- a/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c +++ b/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c @@ -12,6 +12,26 @@ #include #include +/* + * Avoid direct TLS access to allow a single library to be + * linked to both of threaded and non-threaded applications. + * + * wasi-libc's errno is a TLS variable, exposed directly via + * errno.h. if we use it here, LLVM may lower it differently, + * depending on enabled features like atomcs and bulk-memory. + * we tweak the way to access errno here in order to make us + * compatible with both of threaded and non-threaded applications. + * __errno_location() should be reasonably stable because + * it was introduced as an alternative ABI for non-C software. + * https://github.com/WebAssembly/wasi-libc/pull/347 + */ +#if defined(errno) +#undef errno +#endif +int * +__errno_location(void); +#define errno (*__errno_location()) + #define HANDLE_ERROR(error) \ if (error != __WASI_ERRNO_SUCCESS) { \ errno = error; \